CCL_QMS检验
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.

6120 lines
268 KiB

2 months ago
3 months ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 weeks ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 weeks ago
3 weeks ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 weeks ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 months ago
3 months ago
2 months ago
3 weeks ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 weeks ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
3 weeks ago
3 weeks ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 weeks ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
3 weeks ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
3 months ago
1 month ago
1 month ago
4 weeks ago
3 months ago
4 weeks ago
4 weeks ago
4 weeks ago
3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 weeks ago
3 weeks ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 weeks ago
2 months ago
4 weeks ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
4 weeks ago
2 months ago
2 months ago
3 weeks ago
3 weeks ago
4 weeks ago
3 weeks ago
2 months ago
3 weeks ago
3 weeks ago
3 weeks ago
4 weeks ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 weeks ago
3 months ago
3 months ago
3 months ago
3 months ago
4 weeks ago
3 months ago
3 months ago
3 months ago
4 weeks ago
4 weeks ago
4 weeks ago
1 month 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.gaotao.modules.pms.mapper.QcMapper">
  4. <!-- ================================================= FAI检验维护 ================================================= -->
  5. <!-- 查询FAI基础数据 -->
  6. <select id="selectFAIBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  7. SELECT
  8. top 1
  9. a.orderno as orderNo,
  10. j.partNo,
  11. j.PartDescription as part_desc,
  12. c.operationDesc,
  13. b.approve_qty as rollQty,
  14. a.s_resourceid as resourceId,
  15. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  16. a.itemno as itemNo,
  17. a.id as ssrId
  18. FROM soscheduledrouting as a
  19. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  20. LEFT JOIN sfdc as b
  21. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  22. select min(sfdc.id)
  23. from sfdc
  24. group by sfdc.assjob_seq_no, site
  25. )
  26. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  27. LEFT JOIN part j ON so.site = j.site and so.PartNo = j.partNo
  28. WHERE a.itemno = '10'
  29. AND a.id not in (select ssr_id from qc_fai_record)
  30. AND b.approve_qty is not null
  31. ORDER BY a.id desc
  32. </select>
  33. <!-- 获取该物料属性下维护的iqc -->
  34. <select id="selectPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  35. SELECT
  36. qat.site,
  37. qat.bu_no,
  38. qat.attribute_no,
  39. qat.template_id,
  40. qat.sampling_level_no,
  41. qsil.sampling_level_desc,
  42. qat.inspection_cycle,
  43. qat.sampling_programme_no,
  44. qsip.sampling_programme_desc,
  45. qat.AQL,
  46. qat.AC,
  47. qat.RE,
  48. qt.default_sampling_quantity,
  49. qt.default_sampling_proportion
  50. FROM qc_attribute_template as qat
  51. LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
  52. LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
  53. LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
  54. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  55. AND qat.attribute_no = #{partNo}
  56. AND qat.attribute_type = #{attributeType}
  57. AND qt.inspection_type_no = #{inspectionTypeNo}
  58. AND qat.manufacturer_id = #{supplierNo}
  59. </select>
  60. <!-- 获取该物料属性下维护的ipqc -->
  61. <select id="selectPartAttributeByOperationAndResource" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  62. SELECT
  63. qat.site,
  64. qat.bu_no,
  65. qat.attribute_no,
  66. qat.template_id,
  67. qat.sampling_level_no,
  68. qsil.sampling_level_desc,
  69. qat.inspection_cycle,
  70. qat.sampling_programme_no,
  71. qsip.sampling_programme_desc,
  72. qat.AQL,
  73. qat.AC,
  74. qat.RE,
  75. qt.default_sampling_quantity,
  76. qt.default_sampling_proportion
  77. FROM qc_attribute_template as qat
  78. LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
  79. LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
  80. LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
  81. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  82. AND qat.attribute_no = #{partNo}
  83. AND qat.attribute_type = #{attributeType1}
  84. AND qt.inspection_type_no = #{inspectionTypeNo}
  85. AND qat.operation = #{operationDesc}
  86. AND qat.resource_id = #{resourceId}
  87. </select>
  88. <!-- 获取模板详情 -->
  89. <select id="selectTemplate" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  90. SELECT
  91. qt.site,
  92. qt.bu_no,
  93. qt.template_id,
  94. qt.sampling_level_no,
  95. qsil.sampling_level_desc,
  96. qt.inspection_cycle,
  97. qt.sampling_programme_no,
  98. qsip.sampling_programme_desc,
  99. qt.AQL,
  100. qt.AC,
  101. qt.RE,
  102. qt.default_sampling_quantity,
  103. qt.default_sampling_proportion
  104. FROM qc_template as qt
  105. LEFT JOIN qc_sampling_inspection_level as qsil ON qt.sampling_level_no = qsil.sampling_level_no and qt.site = qsil.site and qt.bu_no = qsil.bu_no
  106. LEFT JOIN qc_sampling_inspection_programme as qsip ON qt.sampling_programme_no = qsip.sampling_programme_no and qt.site = qsip.site and qt.bu_no = qsip.bu_no
  107. WHERE qt.site = #{site} and qt.template_id = #{templateId} and qt.bu_no = #{buNo}
  108. </select>
  109. <!-- 新增FAI主记录信息 -->
  110. <insert id="saveFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  111. INSERT INTO qc_fai_record (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id, part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  112. VALUES(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId}, #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  113. </insert>
  114. <insert id="saveFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  115. INSERT INTO qc_fai_detailed_record
  116. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  117. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  118. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  119. VALUES
  120. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  121. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  122. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  123. </insert>
  124. <!-- 新增FAI明细记录信息 -->
  125. <insert id="saveFAIDetailedRecords">
  126. INSERT INTO qc_fai_detailed_record
  127. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  128. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  129. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  130. VALUES
  131. <foreach collection="list" item="item" separator=",">
  132. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  133. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  134. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  135. </foreach>
  136. </insert>
  137. <!-- 查询FAI主记录信息 -->
  138. <select id="qcFAIInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  139. SELECT
  140. a.inspection_no,
  141. a.site,
  142. a.bu_no,
  143. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  144. a.state,
  145. a.inspection_result,
  146. a.task_date,
  147. a.inspection_type_no,
  148. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  149. a.inspection_cycle,
  150. a.order_no,
  151. a.operation_desc,
  152. a.resource_id,
  153. r.resourceDesc,
  154. a.part_no,
  155. d.PartDescription as part_desc,
  156. d.cinv_source_code as cinvSourceCode,
  157. d.sku as sku,
  158. d.PartType as invdefinetype,
  159. a.inspection_remark,
  160. a.roll_qty,
  161. a.sampling_qty,
  162. a.disposal_measures,
  163. a.disposal_remark,
  164. a.inspector_date as inspectorDate,
  165. a.inspector_no,
  166. u.user_display as inspectorName,
  167. a.ssr_id,
  168. a.unqualified_qty,
  169. a.submit_flag,
  170. a.seq_no,
  171. a.batch_roll_no,
  172. a.special_requirements,
  173. a.work_center_no,
  174. a.roll_no,
  175. a.um_id,
  176. um.UMName as umName,
  177. a.action_date,
  178. a.action_by,
  179. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  180. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  181. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  182. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  183. a.pass_qty,
  184. a.not_pass_qty,
  185. a.batch_qualified_qty
  186. FROM qc_fai_record as a
  187. inner join part as d on a.site = d.site and a.part_no = d.partNo
  188. left join sys_user as u on a.inspector_no = u.username
  189. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  190. left join UM as um on a.site = um.site and a.um_id = um.UMID
  191. <where>
  192. a.site in (select site from AccessSite where userID = #{query.userName})
  193. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  194. <if test="query.buNo != null and query.buNo != ''">
  195. AND a.bu_no = #{query.buNo}
  196. </if>
  197. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  198. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  199. </if>
  200. <if test = "query.partNo != null and query.partNo != ''">
  201. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  202. </if>
  203. <if test = "query.partDesc != null and query.partDesc != ''">
  204. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  205. </if>
  206. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  207. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  208. </if>
  209. <if test = "query.sku != null and query.sku != ''">
  210. AND d.sku LIKE '%' + #{query.sku} + '%'
  211. </if>
  212. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  213. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  214. </if>
  215. <if test = "query.states != null and query.states.size > 0">
  216. AND a.state in
  217. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  218. #{item}
  219. </foreach>
  220. </if>
  221. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  222. AND a.inspection_result = #{query.inspectionResult}
  223. </if>
  224. <if test = "query.orderNo != null and query.orderNo != ''">
  225. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  226. </if>
  227. <if test = "query.seqNo != null and query.seqNo != ''">
  228. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  229. </if>
  230. <if test = "query.operationDesc != null and query.operationDesc != ''">
  231. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  232. </if>
  233. <if test="query.startDate != null">
  234. AND a.inspector_date >= #{query.startDate}
  235. </if>
  236. <if test="query.endDate != null">
  237. AND #{query.endDate} >= a.inspector_date
  238. </if>
  239. <if test="query.startDate2 != null">
  240. AND a.task_date >= #{query.startDate2}
  241. </if>
  242. <if test="query.endDate2 != null">
  243. AND #{query.endDate2} >= a.task_date
  244. </if>
  245. </where>
  246. ORDER BY
  247. CASE WHEN a.state = '待检验' THEN 1
  248. WHEN a.state = '待审核' THEN 2
  249. WHEN a.state = '已完成' THEN 3
  250. END, a.task_date desc
  251. </select>
  252. <!-- 获取物料的类别编码 -->
  253. <select id="selectFamilyIdByPartNo" parameterType="string" resultType="string">
  254. SELECT FamilyID
  255. FROM part
  256. WHERE partNo = #{partNo} AND site = #{site}
  257. </select>
  258. <!-- FAI明细记录查询 -->
  259. <select id="faiDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  260. SELECT
  261. a.site,
  262. a.bu_no,
  263. a.inspection_no,
  264. a.order_no,
  265. a.template_id,
  266. a.sampling_level_no,
  267. a.sampling_level_desc,
  268. a.sampling_programme_no,
  269. a.sampling_programme_desc,
  270. a.AQL,
  271. a.AC,
  272. a.RE,
  273. a.item_no,
  274. a.item_desc,
  275. a.object_id,
  276. a.object_desc,
  277. a.default_value,
  278. a.min_value,
  279. a.max_value,
  280. a.text_value,
  281. a.number_value,
  282. a.value_type_db,
  283. a.value_type,
  284. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  285. a.is_submit,
  286. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  287. a.sampling_qty,
  288. dbo.qc_get_fai_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  289. c.method_no,
  290. c.method_name,
  291. c.method_remark,
  292. sw.color_code as qcSpecWarningColorCode,
  293. sw.threshold_value as qcSpecWarningThresholdValue
  294. FROM qc_fai_detailed_record as a
  295. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  296. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  297. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  298. order by a.order_id
  299. </select>
  300. <!-- 修改FAI主记录信息 -->
  301. <update id="updateFAIMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  302. UPDATE qc_fai_record
  303. SET disposal_measures = #{disposalMeasures},
  304. disposal_remark = #{disposalRemark},
  305. inspection_result = #{inspectionResult},
  306. inspector_no = #{inspectorNo},
  307. state = #{state},
  308. inspection_remark = #{inspectionRemark},
  309. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  310. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  311. roll_qty = #{rollQty,jdbcType=DECIMAL},
  312. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  313. pass_qty = #{passQty,jdbcType=DECIMAL},
  314. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  315. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  316. WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
  317. </update>
  318. <!-- 修改FAI明细记录信息 -->
  319. <update id="updateFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  320. UPDATE qc_fai_detailed_record
  321. SET item_result = #{itemResult},
  322. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  323. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  324. text_value = #{textValue},
  325. number_value = #{numberValue,jdbcType=DECIMAL}
  326. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  327. </update>
  328. <!-- 修改子明细提交标识 -->
  329. <update id="updateSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  330. UPDATE qc_fai_sub_detail_record
  331. SET is_submit = 'Y'
  332. WHERE inspection_no = #{inspectionNo}
  333. </update>
  334. <!-- 删除FAI检验记录 -->
  335. <delete id="deleteFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  336. DELETE FROM qc_fai_record
  337. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  338. </delete>
  339. <!-- 删除FAI明细记录信息 -->
  340. <delete id="deleteFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  341. DELETE FROM qc_fai_detailed_record
  342. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  343. </delete>
  344. <!-- 删除FAI子明细记录信息 -->
  345. <delete id="deleteFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  346. DELETE FROM qc_fai_sub_detail_record
  347. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  348. </delete>
  349. <!-- 修改FAI主记录标识为已提交 -->
  350. <update id="updateFAIMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  351. UPDATE qc_fai_record
  352. SET submit_flag = 'Y',
  353. state = '已完成',
  354. submit_date = getDate()
  355. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  356. </update>
  357. <!-- 修改FAI明细记录标识为已提交 -->
  358. <update id="updateFAIDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  359. UPDATE qc_fai_detailed_record
  360. SET is_submit = 'Y'
  361. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  362. </update>
  363. <!-- 修改子明细记录标识为已提交 -->
  364. <update id="updateFAISubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  365. UPDATE qc_fai_sub_detail_record
  366. SET is_submit = 'Y'
  367. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  368. </update>
  369. <!-- 查询FAI检验记录是否已提交 -->
  370. <select id="checkFAIIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  371. SELECT submit_flag
  372. FROM qc_fai_record
  373. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  374. </select>
  375. <!-- 查询FAI检验记录状态(用于保存前校验) -->
  376. <select id="getFAIRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  377. SELECT submit_flag, state
  378. FROM qc_fai_record
  379. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  380. </select>
  381. <!-- 删除子明细的老数据 -->
  382. <delete id="delFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  383. DELETE FROM qc_fai_sub_detail_record
  384. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  385. </delete>
  386. <!-- 新增FAI子明细信息 -->
  387. <insert id="saveFAISubDetailed">
  388. INSERT INTO qc_fai_sub_detail_record
  389. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
  390. VALUES
  391. <foreach collection="list" item="item" separator=",">
  392. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  393. </foreach>
  394. </insert>
  395. <!-- 查询FAI的子明细 -->
  396. <select id="selectFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  397. SELECT
  398. site,
  399. bu_no,
  400. sub_detail_value,
  401. sampling_location,
  402. is_submit,
  403. sampling_location_b,
  404. num,
  405. sub_detail_value_b,
  406. sub_detail_value_c,
  407. sub_detail_value_d,
  408. sub_detail_value_e
  409. FROM qc_fai_sub_detail_record
  410. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  411. <if test = "collectionDataContent != null and collectionDataContent != ''">
  412. AND sub_detail_value ${collectionDataContent}
  413. </if>
  414. </select>
  415. <!-- 获取该项目的子明细值 -->
  416. <select id="selectFAISubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  417. SELECT sub_detail_value,
  418. sampling_location,
  419. is_submit
  420. FROM qc_fai_sub_detail_record
  421. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  422. </select>
  423. <!-- ================================================= IPQC检验维护 ================================================= -->
  424. <!-- 查询IPQC基础数据 -->
  425. <select id="selectIPQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  426. SELECT
  427. top 1
  428. a.orderno as orderNo,
  429. j.partNo,
  430. j.PartDescription as partDesc,
  431. c.operationDesc,
  432. b.approve_qty as rollQty,
  433. a.s_resourceid as resourceId,
  434. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  435. a.itemno as itemNo,
  436. a.id as ssrId
  437. FROM soscheduledrouting as a
  438. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  439. LEFT JOIN sfdc as b
  440. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  441. select max(sfdc.id)
  442. from sfdc
  443. group by sfdc.assjob_seq_no, site
  444. )
  445. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  446. LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
  447. LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
  448. ON a.id = temp.ssr_id
  449. WHERE b.approve_qty is not null and temp.ssr_id is null
  450. ORDER BY a.id desc
  451. </select>
  452. <select id="qcExec" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="string" statementType="CALLABLE">
  453. {CALL
  454. getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
  455. }
  456. </select>
  457. <insert id="saveIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  458. INSERT INTO qc_ipqc_detailed_record
  459. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  460. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  461. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
  462. VALUES
  463. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  464. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  465. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  466. </insert>
  467. <!-- 新增IPQC明细记录信息 -->
  468. <insert id="saveIPQCDetailedRecords">
  469. INSERT INTO qc_ipqc_detailed_record
  470. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  471. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  472. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  473. VALUES
  474. <foreach collection="list" item="item" separator=",">
  475. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  476. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  477. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId}, #{item.custom1}, #{item.custom2}, #{item.custom3})
  478. </foreach>
  479. </insert>
  480. <!-- 新增IPQC主记录信息 -->
  481. <insert id="saveIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  482. INSERT INTO qc_ipqc_record
  483. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  484. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, create_by, inspector_by)
  485. VALUES
  486. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  487. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
  488. #{createBy}, #{inspectorBy})
  489. </insert>
  490. <!-- 查询IPQC主记录信息 -->
  491. <select id="qcIPQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  492. SELECT
  493. a.inspection_no,
  494. a.site,
  495. a.bu_no,
  496. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  497. a.state,
  498. a.inspection_result,
  499. a.task_date,
  500. a.create_date,
  501. a.inspection_type_no,
  502. a.inspection_cycle,
  503. a.order_no,
  504. a.operation_desc,
  505. a.resource_id,
  506. r.resourceDesc,
  507. a.part_no,
  508. d.PartDescription as part_desc,
  509. d.cinv_source_code as cinvSourceCode,
  510. d.sku as sku,
  511. d.PartType as invdefinetype,
  512. d.spec,
  513. a.inspection_remark,
  514. a.roll_qty,
  515. a.sampling_qty,
  516. a.disposal_measures,
  517. a.disposal_remark,
  518. a.inspector_date as inspectorDate,
  519. a.submit_date,
  520. isnull(sub.user_display, a.submit_by) as submitBy,
  521. a.inspector_no,
  522. u.user_display as inspectorName,
  523. a.ssr_id,
  524. a.unqualified_qty,
  525. a.submit_flag,
  526. a.seq_no,
  527. a.batch_roll_no,
  528. a.special_requirements,
  529. a.work_center_no,
  530. a.roll_no,
  531. a.um_id,
  532. um.UMName as umName,
  533. a.action_date,
  534. isnull(ab.user_display, a.action_by) as actionBy,
  535. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  536. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  537. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  538. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  539. a.pass_qty,
  540. a.not_pass_qty,
  541. a.batch_qualified_qty,
  542. w.WorkCenterDesc,
  543. a.release_no as releaseNo,
  544. a.line_no,
  545. isnull(a.inspector_by, a.create_by) as inspectorBy,
  546. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
  547. FROM qc_ipqc_record as a
  548. inner join part as d on a.site = d.site and a.part_no = d.partNo
  549. left join sys_user as u on a.inspector_no = u.username
  550. left join sys_user as ab on a.action_by = ab.username
  551. left join sys_user as sub on a.submit_by = sub.username
  552. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  553. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  554. left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
  555. left join UM as um on a.um_id = um.UMID
  556. <where>
  557. a.site in (select site from AccessSite where userID = #{query.userName})
  558. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  559. <if test="query.buNo != null and query.buNo != ''">
  560. AND a.bu_no = #{query.buNo}
  561. </if>
  562. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  563. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  564. </if>
  565. <if test = "query.partNo != null and query.partNo != ''">
  566. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  567. </if>
  568. <if test = "query.partDesc != null and query.partDesc != ''">
  569. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  570. </if>
  571. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  572. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  573. </if>
  574. <if test = "query.sku != null and query.sku != ''">
  575. AND d.sku LIKE '%' + #{query.sku} + '%'
  576. </if>
  577. <if test = "query.states != null and query.states.size > 0">
  578. AND a.state in
  579. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  580. #{item}
  581. </foreach>
  582. </if>
  583. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  584. AND a.inspection_type_no = #{query.inspectionTypeNo}
  585. </if>
  586. <if test = "query.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
  587. AND a.inspection_type_no in
  588. <foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
  589. #{item}
  590. </foreach>
  591. </if>
  592. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  593. AND a.inspection_result = #{query.inspectionResult}
  594. </if>
  595. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  596. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  597. </if>
  598. <if test = "query.orderNo != null and query.orderNo != ''">
  599. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  600. </if>
  601. <if test = "query.seqNo != null and query.seqNo != ''">
  602. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  603. </if>
  604. <if test = "query.operationDesc != null and query.operationDesc != ''">
  605. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  606. </if>
  607. <if test = "query.resourceId != null and query.resourceId != ''">
  608. AND a.resource_id = #{query.resourceId}
  609. </if>
  610. <if test = "query.workCenterNo != null and query.workCenterNo != ''">
  611. AND a.work_center_no = #{query.workCenterNo}
  612. </if>
  613. <if test="query.startDate != null">
  614. AND a.inspector_date >= #{query.startDate}
  615. </if>
  616. <if test="query.endDate != null">
  617. AND #{query.endDate} >= a.inspector_date
  618. </if>
  619. <if test="query.startDate2 != null">
  620. AND a.task_date >= #{query.startDate2}
  621. </if>
  622. <if test="query.endDate2 != null">
  623. AND #{query.endDate2} >= a.task_date
  624. </if>
  625. <if test = "query.spec != null and query.spec != ''">
  626. AND d.spec LIKE '%' + #{query.spec} + '%'
  627. </if>
  628. </where>
  629. ORDER BY a.inspection_no desc,
  630. CASE WHEN a.state = '未开始' THEN 1
  631. WHEN a.state = '待检验' THEN 2
  632. END, a.action_date,a.task_date,a.inspector_date desc
  633. </select>
  634. <!-- IPQC明细记录查询 -->
  635. <select id="ipqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  636. SELECT
  637. a.site,
  638. a.bu_no,
  639. a.inspection_no,
  640. a.order_no,
  641. a.template_id,
  642. a.sampling_level_no,
  643. a.sampling_level_desc,
  644. a.sampling_programme_no,
  645. a.sampling_programme_desc,
  646. a.AQL,
  647. a.AC,
  648. a.RE,
  649. a.item_no,
  650. a.item_desc,
  651. a.object_id,
  652. a.object_desc,
  653. a.default_value,
  654. a.min_value,
  655. a.max_value,
  656. a.text_value,
  657. a.number_value,
  658. a.value_type_db,
  659. a.value_type,
  660. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  661. a.item_remark as itemRemark,
  662. a.custom1,
  663. a.custom2,
  664. a.custom3,
  665. a.is_submit,
  666. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  667. a.sampling_qty,
  668. dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  669. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  670. c.method_no,
  671. c.method_name,
  672. c.method_remark,
  673. sw.color_code as qcSpecWarningColorCode,
  674. sw.threshold_value as qcSpecWarningThresholdValue,
  675. (SELECT TOP 1 epi.collection_flag
  676. FROM eam_properties_item epi
  677. WHERE epi.site = a.site
  678. AND epi.bu_no = a.bu_no
  679. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  680. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  681. epi.inspection_type_no) AS collectionFlag,
  682. (SELECT TOP 1 epi.image_flag
  683. FROM eam_properties_item epi
  684. WHERE epi.site = a.site
  685. AND epi.bu_no = a.bu_no
  686. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  687. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  688. epi.inspection_type_no) AS imageFlag,
  689. (SELECT TOP 1 epi.data_flag
  690. FROM eam_properties_item epi
  691. WHERE epi.site = a.site
  692. AND epi.bu_no = a.bu_no
  693. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  694. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  695. epi.inspection_type_no) AS dataFlag
  696. FROM qc_ipqc_detailed_record as a
  697. LEFT JOIN qc_ipqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  698. OUTER APPLY (
  699. SELECT TOP 1
  700. w.color_code,
  701. w.threshold_value
  702. FROM qc_spec_warning w
  703. WHERE w.site = a.site
  704. AND w.bu_no = a.bu_no
  705. AND w.part_no = r.part_no
  706. AND w.item_no = a.item_no
  707. AND w.inspection_type_no = r.inspection_type_no
  708. ORDER BY w.threshold_value
  709. ) sw
  710. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  711. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  712. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  713. order by a.order_id
  714. </select>
  715. <!-- 删除IPQC检验记录 -->
  716. <delete id="deleteIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  717. DELETE FROM qc_ipqc_record
  718. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  719. </delete>
  720. <!-- 删除IPQC明细记录信息 -->
  721. <delete id="deleteIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  722. DELETE FROM qc_ipqc_detailed_record
  723. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  724. </delete>
  725. <!-- 删除IPQC子明细记录信息 -->
  726. <delete id="deleteIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  727. DELETE FROM qc_ipqc_sub_detail_record
  728. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  729. </delete>
  730. <!-- 任务重载:修改IPQC检验记录 -->
  731. <update id="updateIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  732. UPDATE qc_ipqc_record
  733. SET inspection_type_no = #{inspectionTypeNo},
  734. sampling_qty = #{samplingQty},
  735. inspection_cycle = #{inspectionCycle},
  736. state = '未开始',
  737. inspection_result = null,
  738. disposal_measures = null,
  739. disposal_remark = null,
  740. inspection_remark = null,
  741. inspector_no = null,
  742. inspector_date = null,
  743. submit_flag = 'N',
  744. action_date = null,
  745. action_by = null,
  746. pass_qty = null,
  747. not_pass_qty = null,
  748. unqualified_qty = null,
  749. batch_qualified_qty = null
  750. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  751. </update>
  752. <!-- 修改IPQC主记录信息 -->
  753. <update id="updateIPQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  754. UPDATE qc_ipqc_record
  755. SET disposal_measures = #{disposalMeasures},
  756. disposal_remark = #{disposalRemark},
  757. inspection_result = #{inspectionResult},
  758. inspector_no = #{inspectorNo},
  759. state = #{state},
  760. inspection_remark = #{inspectionRemark},
  761. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  762. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  763. roll_qty = #{rollQty,jdbcType=DECIMAL},
  764. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  765. pass_qty = #{passQty,jdbcType=DECIMAL},
  766. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  767. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  768. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  769. </update>
  770. <!-- 修改IPQC明细记录信息 -->
  771. <update id="updateIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  772. UPDATE qc_ipqc_detailed_record
  773. SET item_result = #{itemResult},
  774. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  775. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  776. text_value = #{textValue},
  777. number_value = #{numberValue,jdbcType=DECIMAL},
  778. default_value = #{defaultValue},
  779. min_value = #{minValue,jdbcType=DECIMAL},
  780. max_value = #{maxValue,jdbcType=DECIMAL},
  781. item_remark = #{itemRemark},
  782. custom1 = #{custom1},
  783. custom2 = #{custom2},
  784. custom3 = #{custom3}
  785. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  786. </update>
  787. <update id="patchIPQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  788. UPDATE qc_ipqc_detailed_record
  789. <set>
  790. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  791. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  792. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  793. <if test="textValue != null">text_value = #{textValue},</if>
  794. </set>
  795. WHERE inspection_no = #{inspectionNo}
  796. and RTRIM(item_no) = RTRIM(#{itemNo})
  797. and site = #{site}
  798. and bu_no = #{buNo}
  799. </update>
  800. <!-- 修改IPQC主记录标识为已提交 -->
  801. <update id="updateIPQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  802. UPDATE qc_ipqc_record
  803. SET submit_flag = 'Y',
  804. state = '已完成',
  805. submit_date = getDate(),
  806. submit_by = #{updateBy}
  807. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  808. </update>
  809. <!-- 修改IPQC明细记录标识为已提交 -->
  810. <update id="updateIPQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  811. UPDATE qc_ipqc_detailed_record
  812. SET is_submit = 'Y'
  813. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  814. </update>
  815. <!-- 修改IPQC子明细记录标识为已提交 -->
  816. <update id="updateIPQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  817. UPDATE qc_ipqc_sub_detail_record
  818. SET is_submit = 'Y'
  819. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  820. </update>
  821. <!-- 删除IPQC子明细的老数据 -->
  822. <delete id="delIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  823. DELETE FROM qc_ipqc_sub_detail_record
  824. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  825. </delete>
  826. <!-- 新增IPQC子明细信息 -->
  827. <insert id="saveIPQCSubDetailed">
  828. INSERT INTO qc_ipqc_sub_detail_record
  829. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
  830. VALUES
  831. <foreach collection="list" item="item" separator=",">
  832. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
  833. </foreach>
  834. </insert>
  835. <!-- 查询IPQC的子明细 -->
  836. <select id="selectIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  837. SELECT
  838. site,
  839. bu_no,
  840. sub_detail_value,
  841. sampling_location,
  842. is_submit,
  843. sampling_location_b,
  844. num,
  845. sub_detail_value_b,
  846. sub_detail_value_c,
  847. sub_detail_value_d,
  848. sub_detail_value_e,
  849. file_name,
  850. is_transfer,
  851. is_qualified,
  852. defect_qty,
  853. roll_no,
  854. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  855. FROM qc_ipqc_sub_detail_record
  856. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  857. <if test = "collectionDataContent != null and collectionDataContent != ''">
  858. AND sub_detail_value ${collectionDataContent}
  859. </if>
  860. </select>
  861. <!-- 查询IPQC检验记录是否已提交 -->
  862. <select id="checkIPQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  863. SELECT submit_flag
  864. FROM qc_ipqc_record
  865. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  866. </select>
  867. <!-- 查询IPQC检验记录状态(用于保存前校验) -->
  868. <select id="getIPQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  869. SELECT submit_flag, state
  870. FROM qc_ipqc_record
  871. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  872. </select>
  873. <!-- 获取该项目的子明细值 -->
  874. <select id="selectIPQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  875. SELECT sub_detail_value,
  876. sampling_location,
  877. is_submit
  878. FROM qc_ipqc_sub_detail_record
  879. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  880. </select>
  881. <!-- ================================================= SQC库存复检 ================================================= -->
  882. <select id="selectSQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  883. SELECT
  884. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  885. FROM qc_sqc_record
  886. WHERE site = #{site} and bu_no = #{buNo}
  887. </select>
  888. <insert id="saveSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  889. INSERT INTO qc_sqc_detailed_record
  890. (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  891. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  892. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  893. VALUES
  894. (#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  895. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  896. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo}, #{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  897. </insert>
  898. <insert id="saveSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  899. INSERT INTO qc_sqc_record
  900. (inspection_no, site, bu_no, state, create_date, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  901. part_no, part_desc, roll_qty, sampling_qty, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id,
  902. batch_no, receipt_no, receipt_item_no, [po_orderNo], po_itemNo, supplier_no, create_by, inspector_by)
  903. VALUES
  904. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  905. #{partNo}, #{partDesc}, #{rollQty,jdbcType=DECIMAL}, #{samplingQty,jdbcType=DECIMAL}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
  906. #{batchNo}, #{receiptNo}, #{receiptItemNo}, #{poOrderNo}, #{poItemNo}, #{supplierNo}, #{createBy}, #{inspectorBy})
  907. </insert>
  908. <sql id="qcSQCInspectionSearchWhere">
  909. <where>
  910. a.site in (select site from AccessSite where userID = #{query.userName})
  911. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  912. <if test="query.buNo != null and query.buNo != ''">
  913. AND a.bu_no = #{query.buNo}
  914. </if>
  915. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  916. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  917. </if>
  918. <if test = "query.partNo != null and query.partNo != ''">
  919. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  920. </if>
  921. <if test = "query.partDesc != null and query.partDesc != ''">
  922. AND (d.PartDescription LIKE '%' + #{query.partDesc} + '%' OR a.part_desc LIKE '%' + #{query.partDesc} + '%')
  923. </if>
  924. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  925. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  926. </if>
  927. <if test = "query.sku != null and query.sku != ''">
  928. AND d.sku LIKE '%' + #{query.sku} + '%'
  929. </if>
  930. <if test = "query.states != null and query.states.size > 0">
  931. AND a.state in
  932. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  933. #{item}
  934. </foreach>
  935. </if>
  936. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  937. AND a.inspection_type_no = #{query.inspectionTypeNo}
  938. </if>
  939. <if test = "query.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
  940. AND a.inspection_type_no in
  941. <foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
  942. #{item}
  943. </foreach>
  944. </if>
  945. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  946. AND a.inspection_result = #{query.inspectionResult}
  947. </if>
  948. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  949. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  950. </if>
  951. <if test = "query.orderNo != null and query.orderNo != ''">
  952. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  953. </if>
  954. <if test = "query.seqNo != null and query.seqNo != ''">
  955. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  956. </if>
  957. <if test = "query.batchNo != null and query.batchNo != ''">
  958. AND a.batch_no LIKE '%' + #{query.batchNo} + '%'
  959. </if>
  960. <if test = "query.receiptNo != null and query.receiptNo != ''">
  961. AND a.receipt_no LIKE '%' + #{query.receiptNo} + '%'
  962. </if>
  963. <if test = "query.operationDesc != null and query.operationDesc != ''">
  964. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  965. </if>
  966. <if test = "query.resourceId != null and query.resourceId != ''">
  967. AND a.resource_id = #{query.resourceId}
  968. </if>
  969. <if test = "query.workCenterNo != null and query.workCenterNo != ''">
  970. AND a.work_center_no = #{query.workCenterNo}
  971. </if>
  972. <if test="query.startDate != null">
  973. AND a.inspector_date >= #{query.startDate}
  974. </if>
  975. <if test="query.endDate != null">
  976. AND #{query.endDate} >= a.inspector_date
  977. </if>
  978. <if test="query.startDate2 != null">
  979. AND a.task_date >= #{query.startDate2}
  980. </if>
  981. <if test="query.endDate2 != null">
  982. AND #{query.endDate2} >= a.task_date
  983. </if>
  984. <if test = "query.spec != null and query.spec != ''">
  985. AND d.spec LIKE '%' + #{query.spec} + '%'
  986. </if>
  987. </where>
  988. </sql>
  989. <select id="qcSQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  990. SELECT
  991. a.inspection_no,
  992. a.site,
  993. a.bu_no,
  994. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  995. a.state,
  996. a.inspection_result,
  997. a.task_date,
  998. a.create_date,
  999. a.inspection_type_no,
  1000. a.inspection_cycle,
  1001. a.order_no,
  1002. a.operation_desc,
  1003. a.resource_id,
  1004. r.resourceDesc,
  1005. a.part_no,
  1006. COALESCE(d.PartDescription, a.part_desc) as part_desc,
  1007. d.cinv_source_code as cinvSourceCode,
  1008. d.sku as sku,
  1009. d.PartType as invdefinetype,
  1010. d.spec,
  1011. a.inspection_remark,
  1012. a.roll_qty,
  1013. a.sampling_qty,
  1014. a.disposal_measures,
  1015. a.disposal_remark,
  1016. a.inspector_date as inspectorDate,
  1017. a.submit_date,
  1018. isnull(sub.user_display, a.submit_by) as submitBy,
  1019. a.inspector_no,
  1020. u.user_display as inspectorName,
  1021. a.unqualified_qty,
  1022. a.submit_flag,
  1023. a.seq_no,
  1024. a.batch_roll_no,
  1025. a.special_requirements,
  1026. a.work_center_no,
  1027. a.roll_no,
  1028. a.um_id,
  1029. um.UMName as umName,
  1030. a.action_date,
  1031. isnull(ab.user_display, a.action_by) as actionBy,
  1032. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1033. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1034. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1035. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1036. a.pass_qty,
  1037. a.not_pass_qty,
  1038. a.batch_qualified_qty,
  1039. w.WorkCenterDesc,
  1040. a.batch_no,
  1041. a.receipt_no,
  1042. a.receipt_item_no,
  1043. a.[po_orderNo] as poOrderNo,
  1044. a.po_itemNo as poItemNo,
  1045. a.release_no as releaseNo,
  1046. a.line_no,
  1047. isnull(a.inspector_by, a.create_by) as inspectorBy,
  1048. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
  1049. FROM qc_sqc_record as a
  1050. inner join part as d on a.site = d.site and a.part_no = d.partNo
  1051. left join sys_user as u on a.inspector_no = u.username
  1052. left join sys_user as ab on a.action_by = ab.username
  1053. left join sys_user as sub on a.submit_by = sub.username
  1054. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  1055. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  1056. left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
  1057. left join UM as um on a.site = um.site and a.um_id = um.UMID
  1058. <include refid="qcSQCInspectionSearchWhere"/>
  1059. ORDER BY a.inspection_no desc,
  1060. CASE WHEN a.state = '未开始' THEN 1
  1061. WHEN a.state = '待检验' THEN 2
  1062. END, a.action_date,a.task_date,a.inspector_date desc
  1063. </select>
  1064. <select id="qcSQCInspectionSearchCount" resultType="java.lang.Long">
  1065. SELECT COUNT(1)
  1066. FROM qc_sqc_record as a
  1067. inner join part as d on a.site = d.site and a.part_no = d.partNo
  1068. <include refid="qcSQCInspectionSearchWhere"/>
  1069. </select>
  1070. <select id="sqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1071. SELECT
  1072. a.site,
  1073. a.bu_no,
  1074. a.inspection_no,
  1075. a.template_id,
  1076. a.sampling_level_no,
  1077. a.sampling_level_desc,
  1078. a.sampling_programme_no,
  1079. a.sampling_programme_desc,
  1080. a.AQL,
  1081. a.AC,
  1082. a.RE,
  1083. a.item_no,
  1084. a.item_desc,
  1085. a.object_id,
  1086. a.object_desc,
  1087. a.default_value,
  1088. a.min_value,
  1089. a.max_value,
  1090. a.text_value,
  1091. a.number_value,
  1092. a.value_type_db,
  1093. a.value_type,
  1094. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1095. a.item_remark as itemRemark,
  1096. a.custom1,
  1097. a.custom2,
  1098. a.custom3,
  1099. a.is_submit,
  1100. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1101. a.sampling_qty,
  1102. (SELECT COUNT(1) FROM qc_sqc_sub_detail_record s WHERE s.site = a.site AND s.bu_no = a.bu_no AND s.inspection_no = a.inspection_no AND s.item_no = a.item_no) as subDetailRecordNum,
  1103. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  1104. c.method_no,
  1105. c.method_name,
  1106. c.method_remark,
  1107. sw.color_code as qcSpecWarningColorCode,
  1108. sw.threshold_value as qcSpecWarningThresholdValue,
  1109. (SELECT TOP 1 epi.collection_flag
  1110. FROM eam_properties_item epi
  1111. WHERE epi.site = a.site
  1112. AND epi.bu_no = a.bu_no
  1113. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1114. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1115. epi.inspection_type_no) AS collectionFlag,
  1116. (SELECT TOP 1 epi.image_flag
  1117. FROM eam_properties_item epi
  1118. WHERE epi.site = a.site
  1119. AND epi.bu_no = a.bu_no
  1120. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1121. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1122. epi.inspection_type_no) AS imageFlag,
  1123. (SELECT TOP 1 epi.data_flag
  1124. FROM eam_properties_item epi
  1125. WHERE epi.site = a.site
  1126. AND epi.bu_no = a.bu_no
  1127. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1128. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1129. epi.inspection_type_no) AS dataFlag
  1130. FROM qc_sqc_detailed_record as a
  1131. LEFT JOIN qc_sqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  1132. OUTER APPLY (
  1133. SELECT TOP 1
  1134. w.color_code,
  1135. w.threshold_value
  1136. FROM qc_spec_warning w
  1137. WHERE w.site = a.site
  1138. AND w.bu_no = a.bu_no
  1139. AND w.part_no = r.part_no
  1140. AND w.item_no = a.item_no
  1141. AND w.inspection_type_no = r.inspection_type_no
  1142. ORDER BY w.threshold_value
  1143. ) sw
  1144. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  1145. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  1146. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1147. order by a.order_id
  1148. </select>
  1149. <delete id="deleteSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1150. DELETE FROM qc_sqc_record
  1151. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1152. </delete>
  1153. <delete id="deleteSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1154. DELETE FROM qc_sqc_detailed_record
  1155. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1156. </delete>
  1157. <delete id="deleteSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1158. DELETE FROM qc_sqc_sub_detail_record
  1159. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1160. </delete>
  1161. <!-- 任务重载:修改SQC检验记录 -->
  1162. <update id="updateSQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1163. UPDATE qc_sqc_record
  1164. SET inspection_type_no = #{inspectionTypeNo},
  1165. sampling_qty = #{samplingQty},
  1166. inspection_cycle = #{inspectionCycle},
  1167. part_desc = #{partDesc},
  1168. state = '未开始',
  1169. inspection_result = null,
  1170. disposal_measures = null,
  1171. disposal_remark = null,
  1172. inspection_remark = null,
  1173. inspector_no = null,
  1174. inspector_date = null,
  1175. submit_flag = 'N',
  1176. action_date = null,
  1177. action_by = null,
  1178. pass_qty = null,
  1179. not_pass_qty = null,
  1180. unqualified_qty = null,
  1181. batch_qualified_qty = null
  1182. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1183. </update>
  1184. <update id="updateSQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1185. UPDATE qc_sqc_record
  1186. SET disposal_measures = #{disposalMeasures},
  1187. disposal_remark = #{disposalRemark},
  1188. inspection_result = #{inspectionResult},
  1189. inspector_no = #{inspectorNo},
  1190. state = #{state},
  1191. inspection_remark = #{inspectionRemark},
  1192. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  1193. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1194. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1195. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1196. pass_qty = #{passQty,jdbcType=DECIMAL},
  1197. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1198. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  1199. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1200. </update>
  1201. <update id="updateSQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1202. UPDATE qc_sqc_detailed_record
  1203. SET item_result = #{itemResult},
  1204. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1205. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1206. text_value = #{textValue},
  1207. number_value = #{numberValue,jdbcType=DECIMAL},
  1208. default_value = #{defaultValue},
  1209. min_value = #{minValue,jdbcType=DECIMAL},
  1210. max_value = #{maxValue,jdbcType=DECIMAL},
  1211. item_remark = #{itemRemark},
  1212. custom1 = #{custom1},
  1213. custom2 = #{custom2},
  1214. custom3 = #{custom3}
  1215. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1216. </update>
  1217. <update id="patchSQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1218. UPDATE qc_sqc_detailed_record
  1219. <set>
  1220. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  1221. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  1222. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  1223. <if test="textValue != null">text_value = #{textValue},</if>
  1224. </set>
  1225. WHERE inspection_no = #{inspectionNo}
  1226. and RTRIM(item_no) = RTRIM(#{itemNo})
  1227. and site = #{site}
  1228. and bu_no = #{buNo}
  1229. </update>
  1230. <update id="updateSQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1231. UPDATE qc_sqc_record
  1232. SET submit_flag = 'Y',
  1233. state = '已完成',
  1234. submit_date = getDate(),
  1235. submit_by = #{updateBy}
  1236. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1237. </update>
  1238. <update id="updateSQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1239. UPDATE qc_sqc_detailed_record
  1240. SET is_submit = 'Y'
  1241. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1242. </update>
  1243. <update id="updateSQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1244. UPDATE qc_sqc_sub_detail_record
  1245. SET is_submit = 'Y'
  1246. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1247. </update>
  1248. <delete id="delSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  1249. DELETE FROM qc_sqc_sub_detail_record
  1250. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1251. </delete>
  1252. <insert id="saveSQCSubDetailed">
  1253. INSERT INTO qc_sqc_sub_detail_record
  1254. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
  1255. VALUES
  1256. <foreach collection="list" item="item" separator=",">
  1257. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
  1258. </foreach>
  1259. </insert>
  1260. <select id="selectSQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1261. SELECT
  1262. site,
  1263. bu_no,
  1264. sub_detail_value,
  1265. sampling_location,
  1266. is_submit,
  1267. sampling_location_b,
  1268. num,
  1269. sub_detail_value_b,
  1270. sub_detail_value_c,
  1271. sub_detail_value_d,
  1272. sub_detail_value_e,
  1273. file_name,
  1274. is_transfer,
  1275. is_qualified,
  1276. defect_qty,
  1277. roll_no,
  1278. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  1279. FROM qc_sqc_sub_detail_record
  1280. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1281. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1282. AND sub_detail_value ${collectionDataContent}
  1283. </if>
  1284. </select>
  1285. <select id="checkSQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1286. SELECT submit_flag
  1287. FROM qc_sqc_record
  1288. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1289. </select>
  1290. <select id="getSQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1291. SELECT submit_flag, state
  1292. FROM qc_sqc_record
  1293. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1294. </select>
  1295. <select id="selectSQCSubDetailValue" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1296. SELECT sub_detail_value,
  1297. sampling_location,
  1298. is_submit
  1299. FROM qc_sqc_sub_detail_record
  1300. WHERE inspection_no = #{param1} and item_no = #{param2} and site = #{param3}
  1301. </select>
  1302. <update id="actionSQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  1303. update qc_sqc_record
  1304. set action_date = getDate(),
  1305. action_by = #{actionBy},
  1306. state = #{state}
  1307. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1308. </update>
  1309. <select id="getSQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  1310. select
  1311. a.site,
  1312. a.bu_no,
  1313. a.inspection_no,
  1314. a.item_no,
  1315. a.item_desc,
  1316. b.collection_source,
  1317. b.collection_method,
  1318. b.equipment_classification
  1319. from qc_sqc_detailed_record as a
  1320. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  1321. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  1322. order by a.order_id
  1323. </select>
  1324. <select id="getSQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  1325. SELECT
  1326. ItemNo as itemNo,
  1327. ItemDesc as itemDesc,
  1328. DefaultValue as defaultValue,
  1329. MaxValue as maxValue,
  1330. MinValue as minValue,
  1331. ValueType as valueType,
  1332. ValueType_DB as valueTypeDb
  1333. FROM eam_properties_item
  1334. WHERE site = #{site}
  1335. AND bu_no = #{buNo}
  1336. AND inspection_type_no = #{inspectionTypeNo}
  1337. <if test="itemNo != null and itemNo != ''">
  1338. AND ItemNo LIKE '%' + #{itemNo} + '%'
  1339. </if>
  1340. <if test="itemDesc != null and itemDesc != ''">
  1341. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  1342. </if>
  1343. AND ItemNo NOT IN (
  1344. SELECT item_no
  1345. FROM qc_sqc_detailed_record
  1346. WHERE site = #{site}
  1347. AND bu_no = #{buNo}
  1348. AND inspection_no = #{inspectionNo}
  1349. )
  1350. ORDER BY ItemNo
  1351. </select>
  1352. <select id="getSQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  1353. SELECT
  1354. d.item_no as itemNo,
  1355. d.item_desc as itemDesc
  1356. FROM qc_sqc_detailed_record d
  1357. WHERE d.site = #{site}
  1358. AND d.bu_no = #{buNo}
  1359. AND d.inspection_no = #{inspectionNo}
  1360. ORDER BY d.item_no
  1361. </select>
  1362. <select id="getExistingSQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  1363. SELECT TOP 1
  1364. template_id as templateId,
  1365. item_no as itemNo,
  1366. item_desc as itemDesc
  1367. FROM qc_sqc_detailed_record
  1368. WHERE site = #{site}
  1369. AND bu_no = #{buNo}
  1370. AND inspection_no = #{inspectionNo}
  1371. ORDER BY item_no
  1372. </select>
  1373. <insert id="insertSQCItemDetail" parameterType="java.util.Map">
  1374. INSERT INTO qc_sqc_detailed_record (
  1375. inspection_no,
  1376. template_id,
  1377. item_no,
  1378. item_desc,
  1379. default_value,
  1380. min_value,
  1381. max_value,
  1382. value_type_db,
  1383. value_type,
  1384. site,
  1385. bu_no,
  1386. order_id
  1387. ) VALUES (
  1388. #{inspectionNo},
  1389. #{templateId},
  1390. #{itemNo},
  1391. #{itemDesc},
  1392. #{defaultValue},
  1393. #{minValue},
  1394. #{maxValue},
  1395. #{valueTypeDb},
  1396. #{valueType},
  1397. #{site},
  1398. #{buNo},
  1399. #{orderId}
  1400. )
  1401. </insert>
  1402. <select id="getMaxOrderIdForSQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  1403. SELECT ISNULL(MAX(order_id), 0)
  1404. FROM qc_sqc_detailed_record
  1405. WHERE site = #{site}
  1406. AND bu_no = #{buNo}
  1407. AND inspection_no = #{inspectionNo}
  1408. </select>
  1409. <delete id="deleteSQCItemDetail" parameterType="java.util.Map">
  1410. DELETE FROM qc_sqc_detailed_record
  1411. WHERE site = #{site}
  1412. AND bu_no = #{buNo}
  1413. AND inspection_no = #{inspectionNo}
  1414. AND item_no = #{itemNo}
  1415. </delete>
  1416. <delete id="deleteSQCSubDetailByItem" parameterType="java.util.Map">
  1417. DELETE FROM qc_sqc_sub_detail_record
  1418. WHERE site = #{site}
  1419. AND bu_no = #{buNo}
  1420. AND inspection_no = #{inspectionNo}
  1421. AND item_no = #{itemNo}
  1422. </delete>
  1423. <select id="getSQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  1424. SELECT
  1425. t.template_id as templateId,
  1426. t.template_name as templateName,
  1427. t.template_remark as remark,
  1428. (SELECT COUNT(*) FROM qc_template_detailed d
  1429. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  1430. FROM qc_template t
  1431. WHERE t.site = #{site}
  1432. AND t.bu_no = #{buNo}
  1433. AND t.inspection_type_no = #{inspectionTypeNo}
  1434. <if test="templateId != null and templateId != ''">
  1435. AND t.template_id LIKE '%' + #{templateId} + '%'
  1436. </if>
  1437. <if test="templateDesc != null and templateDesc != ''">
  1438. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  1439. </if>
  1440. ORDER BY t.template_id
  1441. </select>
  1442. <select id="getExistingSQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  1443. SELECT item_no
  1444. FROM qc_sqc_detailed_record
  1445. WHERE site = #{site}
  1446. AND bu_no = #{buNo}
  1447. AND inspection_no = #{inspectionNo}
  1448. </select>
  1449. <select id="getSQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  1450. select
  1451. a.site,
  1452. a.bu_no,
  1453. b.collection_condition as equipmentNo,
  1454. #{inspectionNo} as inspectionNo,
  1455. a.item_no,
  1456. b.collection_source,
  1457. #{actionBy} as actionBy,
  1458. b.collection_method
  1459. from qc_sqc_detailed_record as a
  1460. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  1461. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  1462. order by a.order_id
  1463. </select>
  1464. <!-- 查询工序列表 -->
  1465. <select id="getOperationList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1466. SELECT DISTINCT
  1467. operation_description as operationDesc
  1468. FROM View_IFS_Shop_Order_Operation
  1469. WHERE site = #{site}
  1470. AND order_no = #{orderNo}
  1471. AND release_no = #{releaseNo}
  1472. AND sequence_no = #{lineNo}
  1473. <!--<choose>
  1474. <when test="orderNo != null and orderNo != '' and releaseNo != null and releaseNo != '' and lineNo != null and lineNo != ''">
  1475. SELECT DISTINCT
  1476. operation_description as operationDesc
  1477. FROM View_IFS_Shop_Order_Operation
  1478. WHERE site = #{site}
  1479. AND order_no = #{orderNo}
  1480. AND release_no = #{releaseNo}
  1481. AND sequence_no = #{lineNo}
  1482. </when>
  1483. <otherwise>
  1484. SELECT
  1485. DISTINCT
  1486. a.seqno as seqNo,
  1487. a.orderno as orderNo,
  1488. j.partNo,
  1489. j.PartDescription as partDesc,
  1490. j.PartType as invdefinetype,
  1491. j.sku,
  1492. c.operationDesc as operationDesc,
  1493. a.itemno as operationNo,
  1494. a.s_resourceid as resourceId,
  1495. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1496. c.WorkCenterNo
  1497. FROM soscheduledrouting as a
  1498. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  1499. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  1500. LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
  1501. WHERE a.site = #{site} and a.seqno = #{seqNo}
  1502. </otherwise>
  1503. </choose>-->
  1504. </select>
  1505. <!-- 根据工单号和工序号查出所有数据 -->
  1506. <select id="getResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1507. SELECT
  1508. a.s_resourceid as resourceId,
  1509. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1510. c.workCenterNo
  1511. FROM soscheduledrouting as a
  1512. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  1513. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  1514. <!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
  1515. WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
  1516. ORDER BY a.id desc
  1517. </select>
  1518. <!-- 查询机台名称 -->
  1519. <select id="selectResourceDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1520. SELECT distinct
  1521. resourceDesc
  1522. FROM WorkCenterResource
  1523. WHERE site = #{site} and resourceId = #{resourceId}
  1524. </select>
  1525. <!-- 查询物料名称 -->
  1526. <select id="selectPartDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1527. SELECT distinct
  1528. PartDescription as part_desc
  1529. FROM part
  1530. WHERE site = #{site} and partNo = #{partNo}
  1531. </select>
  1532. <!-- ================================================= IQC检验维护 ================================================= -->
  1533. <!-- 查询IQC基础数据 -->
  1534. <select id="selectIQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1535. SELECT
  1536. qir.inspection_no,
  1537. qir.state,
  1538. qir.defect_tracking_flag as defectTrackingFlag,
  1539. qir.create_date as taskDate,
  1540. qir.roll_no,
  1541. qir.part_no,
  1542. p.PartDescription as part_desc,
  1543. p.cinv_source_code,
  1544. p.sku as sku,
  1545. qir.roll_qty,
  1546. qir.print_flag,
  1547. qir.inspector_by,
  1548. qir.supplier_no,
  1549. qir.site,
  1550. qir.bu_no,
  1551. qir.po_orderNo,
  1552. qir.po_itemNo,
  1553. qir.roll_count,
  1554. qir.document_no
  1555. FROM qc_iqc_record as qir
  1556. LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
  1557. WHERE qir.site in (select site from AccessSite where userID = #{userName})
  1558. and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
  1559. and qir.detail_flag = 'N'
  1560. </select>
  1561. <!-- 新增IQC明细记录信息 -->
  1562. <insert id="saveIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1563. INSERT INTO qc_iqc_detailed_record (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value, max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
  1564. VALUES(#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  1565. </insert>
  1566. <!-- 生成IQC检验单号:格式 IQC + YYYYMMDD + 3位流水(与 GetAutogenerateinspectiontasks 一致) -->
  1567. <select id="selectIQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1568. SELECT
  1569. CONVERT(VARCHAR(8), GETDATE(), 112)
  1570. + RIGHT('000' + CONVERT(VARCHAR(3), ISNULL(MAX(CONVERT(INT, RIGHT(inspection_no, 3))), 0) + 1), 3)
  1571. FROM qc_iqc_record
  1572. WHERE site = #{site}
  1573. AND bu_no = #{buNo}
  1574. AND inspection_no LIKE 'IQC' + CONVERT(VARCHAR(8), GETDATE(), 112) + '%'
  1575. AND LEN(inspection_no) >= 14
  1576. </select>
  1577. <!-- 新增IQC主记录信息(刀模新增等直接保存场景) -->
  1578. <insert id="saveIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1579. INSERT INTO qc_iqc_record
  1580. (inspection_no, site, bu_no, state, create_date, inspection_type_no, part_no, part_desc,
  1581. roll_qty, roll_count, roll_no, supplier_no, create_by, inspector_by, detail_flag, submission_type,
  1582. tool_instance_id, qualified_supplier_flag, supplier_avl_no, die_mold_type, special_requirements)
  1583. VALUES
  1584. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{partNo}, #{partDesc,jdbcType=VARCHAR},
  1585. #{rollQty,jdbcType=DECIMAL}, #{rollCount,jdbcType=DECIMAL}, #{rollNo,jdbcType=VARCHAR}, #{supplierNo,jdbcType=VARCHAR}, #{createBy}, #{inspectorBy},
  1586. 'N', #{taskSource,jdbcType=VARCHAR},
  1587. #{toolInstanceId,jdbcType=VARCHAR}, #{qualifiedSupplierFlag,jdbcType=CHAR}, #{supplierAvlNo,jdbcType=VARCHAR}, #{dieMoldType,jdbcType=NVARCHAR}, #{specialRequirements,jdbcType=VARCHAR})
  1588. </insert>
  1589. <!-- 修改IQC检验记录 -->
  1590. <update id="updateIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1591. UPDATE qc_iqc_record
  1592. SET inspection_type_no = #{inspectionTypeNo},
  1593. sampling_qty = #{samplingQty},
  1594. inspection_cycle = #{inspectionCycle},
  1595. part_desc = #{partDesc},
  1596. detail_flag = 'Y',
  1597. state = '未开始',
  1598. action_date = null,
  1599. action_by = null
  1600. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1601. </update>
  1602. <!-- 新增IQC记录后更新送检卷数 -->
  1603. <update id="updateIQCRecordRollCountOnAdd" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1604. UPDATE qc_iqc_record
  1605. SET roll_count = #{rollCount,jdbcType=DECIMAL}
  1606. WHERE site = #{site}
  1607. AND bu_no = #{buNo}
  1608. AND po_orderNo = #{poOrderNo}
  1609. AND po_itemNo = #{poItemNo}
  1610. AND part_no = #{partNo}
  1611. AND inspection_no = (
  1612. SELECT TOP 1 inspection_no
  1613. FROM qc_iqc_record
  1614. WHERE site = #{site}
  1615. AND bu_no = #{buNo}
  1616. AND po_orderNo = #{poOrderNo}
  1617. AND po_itemNo = #{poItemNo}
  1618. AND part_no = #{partNo}
  1619. ORDER BY create_date DESC
  1620. )
  1621. </update>
  1622. <!-- 刀模新增后更新扩展字段 -->
  1623. <update id="updateIQCRecordDieMoldOnAdd" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1624. UPDATE qc_iqc_record
  1625. SET roll_count = #{rollCount,jdbcType=DECIMAL},
  1626. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1627. supplier_no = #{supplierNo,jdbcType=VARCHAR},
  1628. tool_instance_id = #{toolInstanceId,jdbcType=VARCHAR},
  1629. qualified_supplier_flag = #{qualifiedSupplierFlag,jdbcType=CHAR},
  1630. supplier_avl_no = #{supplierAvlNo,jdbcType=VARCHAR},
  1631. die_mold_type = #{dieMoldType,jdbcType=NVARCHAR}
  1632. WHERE site = #{site}
  1633. AND bu_no = #{buNo}
  1634. AND part_no = #{partNo}
  1635. AND inspection_no = (
  1636. SELECT TOP 1 inspection_no
  1637. FROM qc_iqc_record
  1638. WHERE site = #{site}
  1639. AND bu_no = #{buNo}
  1640. AND part_no = #{partNo}
  1641. ORDER BY create_date DESC
  1642. )
  1643. </update>
  1644. <!-- 新增检验记录后更新下达号、行号 -->
  1645. <update id="updateRecordReleaseNoLineNoOnAdd">
  1646. UPDATE
  1647. <choose>
  1648. <when test="recordType == 'IQC'">qc_iqc_record</when>
  1649. <when test="recordType == 'IPQC'">qc_ipqc_record</when>
  1650. <when test="recordType == 'FQC'">qc_fqc_record</when>
  1651. <when test="recordType == 'OQC'">qc_oqc_record</when>
  1652. <when test="recordType == 'SQC'">qc_sqc_record</when>
  1653. </choose>
  1654. SET release_no = #{data.releaseNo,jdbcType=VARCHAR},
  1655. line_no = #{data.lineNo,jdbcType=VARCHAR}
  1656. WHERE site = #{data.site}
  1657. AND bu_no = #{data.buNo}
  1658. <choose>
  1659. <when test="data.inspectionNo != null and data.inspectionNo != ''">
  1660. AND inspection_no = #{data.inspectionNo}
  1661. </when>
  1662. <when test="recordType == 'IQC'">
  1663. AND po_orderNo = #{data.poOrderNo}
  1664. AND po_itemNo = #{data.poItemNo}
  1665. AND part_no = #{data.partNo}
  1666. AND inspection_no = (
  1667. SELECT TOP 1 inspection_no
  1668. FROM qc_iqc_record
  1669. WHERE site = #{data.site}
  1670. AND bu_no = #{data.buNo}
  1671. AND po_orderNo = #{data.poOrderNo}
  1672. AND po_itemNo = #{data.poItemNo}
  1673. AND part_no = #{data.partNo}
  1674. ORDER BY create_date DESC
  1675. )
  1676. </when>
  1677. <when test="recordType == 'OQC'">
  1678. AND part_no = #{data.partNo}
  1679. AND inspector_by = #{data.inspectorBy}
  1680. AND inspection_no = (
  1681. SELECT TOP 1 inspection_no
  1682. FROM qc_oqc_record
  1683. WHERE site = #{data.site}
  1684. AND bu_no = #{data.buNo}
  1685. AND part_no = #{data.partNo}
  1686. AND inspector_by = #{data.inspectorBy}
  1687. ORDER BY create_date DESC
  1688. )
  1689. </when>
  1690. <otherwise>
  1691. AND order_no = #{data.orderNo}
  1692. AND seq_no = #{data.seqNo}
  1693. AND part_no = #{data.partNo}
  1694. AND inspection_no = (
  1695. SELECT TOP 1 inspection_no
  1696. FROM
  1697. <choose>
  1698. <when test="recordType == 'IPQC'">qc_ipqc_record</when>
  1699. <when test="recordType == 'FQC'">qc_fqc_record</when>
  1700. <when test="recordType == 'SQC'">qc_sqc_record</when>
  1701. </choose>
  1702. WHERE site = #{data.site}
  1703. AND bu_no = #{data.buNo}
  1704. AND order_no = #{data.orderNo}
  1705. AND seq_no = #{data.seqNo}
  1706. AND part_no = #{data.partNo}
  1707. ORDER BY create_date DESC
  1708. )
  1709. </otherwise>
  1710. </choose>
  1711. </update>
  1712. <!-- 查询IQC主记录信息 -->
  1713. <select id="qcIQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1714. SELECT
  1715. a.inspection_no,
  1716. a.site,
  1717. a.bu_no,
  1718. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1719. a.state,
  1720. a.defect_tracking_flag as defectTrackingFlag,
  1721. a.inspection_result,
  1722. a.create_date as taskDate,
  1723. a.create_date,
  1724. a.inspection_type_no,
  1725. a.inspection_cycle,
  1726. a.part_no,
  1727. d.PartDescription as partDesc,
  1728. d.cinv_source_code as cinvSourceCode,
  1729. d.sku,
  1730. d.umid as umId,
  1731. um.UMName as umName,
  1732. d.PartType as invdefinetype,
  1733. d.spec,
  1734. a.inspection_remark,
  1735. a.roll_qty,
  1736. a.sampling_qty,
  1737. a.disposal_measures,
  1738. a.disposal_remark,
  1739. a.inspector_date as inspectorDate,
  1740. a.submit_date,
  1741. isnull(sub.user_display, a.submit_by) as submitBy,
  1742. a.inspector_no,
  1743. u.user_display as inspectorName,
  1744. a.unqualified_quantity,
  1745. a.submit_flag,
  1746. a.roll_no,
  1747. a.supplier_no,
  1748. s.SupplierName as supplierDesc,
  1749. a.po_orderNo,
  1750. a.po_itemNo,
  1751. a.roll_count,
  1752. a.roll_count as dhjs,
  1753. dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) as orderType,
  1754. a.action_date,
  1755. isnull(ab.user_display, a.action_by) as actionBy,
  1756. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1757. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1758. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1759. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1760. a.submission_remark,
  1761. a.submission_type as submissionType,
  1762. a.tool_instance_id as toolInstanceId,
  1763. a.qualified_supplier_flag as qualifiedSupplierFlag,
  1764. a.supplier_avl_no as supplierAvlNo,
  1765. a.die_mold_type as dieMoldType,
  1766. a.batch_no,
  1767. a.production_date,
  1768. a.expiration_warning_date,
  1769. a.expiration_date,
  1770. a.pass_qty,
  1771. a.not_pass_qty,
  1772. a.batch_qualified_qty,
  1773. a.release_no as releaseNo,
  1774. a.line_no,
  1775. a.document_no,
  1776. isnull(a.inspector_by, a.create_by) as inspectorBy,
  1777. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
  1778. FROM qc_iqc_record as a
  1779. inner join part as d on a.site = d.site and a.part_no = d.partNo
  1780. left join view_Supplier as s on a.site = s.site and a.supplier_no = s.SupplierID
  1781. left join sys_user as u on a.inspector_no = u.username
  1782. left join sys_user as ab on a.action_by = ab.username
  1783. left join sys_user as sub on a.submit_by = sub.username
  1784. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  1785. left join um as um on d.umid = um.UMID
  1786. <where>
  1787. a.site in (select site from AccessSite where userID = #{query.userName})
  1788. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  1789. <if test="query.buNo != null and query.buNo != ''">
  1790. AND a.bu_no = #{query.buNo}
  1791. </if>
  1792. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1793. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1794. </if>
  1795. <if test = "query.states != null and query.states.size > 0">
  1796. AND a.state in
  1797. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  1798. #{item}
  1799. </foreach>
  1800. </if>
  1801. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1802. AND a.inspection_result = #{query.inspectionResult}
  1803. </if>
  1804. <if test = "query.partNo != null and query.partNo != ''">
  1805. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  1806. </if>
  1807. <if test = "query.partDesc != null and query.partDesc != ''">
  1808. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  1809. </if>
  1810. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1811. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1812. </if>
  1813. <if test = "query.sku != null and query.sku != ''">
  1814. AND d.sku LIKE '%' + #{query.sku} + '%'
  1815. </if>
  1816. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  1817. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  1818. </if>
  1819. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1820. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1821. </if>
  1822. <if test = "query.inspectorName != null and query.inspectorName != ''">
  1823. u.user_display LIKE '%' + #{query.inspectorName} + '%'
  1824. </if>
  1825. <if test="query.startDate != null">
  1826. AND a.inspector_date >= #{query.startDate}
  1827. </if>
  1828. <if test="query.endDate != null">
  1829. AND #{query.endDate} >= a.inspector_date
  1830. </if>
  1831. <if test="query.startDate2 != null">
  1832. AND a.create_date >= #{query.startDate2}
  1833. </if>
  1834. <if test="query.endDate2 != null">
  1835. AND #{query.endDate2} >= a.create_date
  1836. </if>
  1837. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  1838. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  1839. </if>
  1840. <if test = "query.poItemNo != null and query.poItemNo != ''">
  1841. AND a.po_itemNo LIKE '%' + #{query.poItemNo} + '%'
  1842. </if>
  1843. <if test = "query.orderType != null and query.orderType != ''">
  1844. AND dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) = #{query.orderType}
  1845. </if>
  1846. <if test = "query.submissionType != null and query.submissionType != ''">
  1847. AND a.submission_type = #{query.submissionType}
  1848. </if>
  1849. <if test = "query.invdefinetype != null and query.invdefinetype != ''">
  1850. AND d.PartType LIKE '%' + #{query.invdefinetype} + '%'
  1851. </if>
  1852. <if test = "query.spec != null and query.spec != ''">
  1853. AND d.spec LIKE '%' + #{query.spec} + '%'
  1854. </if>
  1855. <if test = "query.documentNo != null and query.documentNo != ''">
  1856. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  1857. </if>
  1858. </where>
  1859. ORDER BY a.inspection_no desc,
  1860. CASE WHEN a.state = '待检验' THEN 1
  1861. WHEN a.state = '待审核' THEN 2
  1862. WHEN a.state = '已完成' THEN 3
  1863. END, a.create_date desc
  1864. </select>
  1865. <!-- IQC明细记录查询 -->
  1866. <select id="iqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1867. SELECT
  1868. a.site,
  1869. a.bu_no,
  1870. a.inspection_no,
  1871. a.template_id,
  1872. a.sampling_level_no,
  1873. a.sampling_level_desc,
  1874. a.sampling_programme_no,
  1875. a.sampling_programme_desc,
  1876. a.AQL,
  1877. a.AC,
  1878. a.RE,
  1879. a.item_no,
  1880. a.item_desc,
  1881. a.object_id,
  1882. a.object_desc,
  1883. a.default_value,
  1884. a.min_value,
  1885. a.max_value,
  1886. a.text_value,
  1887. a.number_value,
  1888. a.value_type_db,
  1889. a.value_type,
  1890. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1891. a.item_remark as itemRemark,
  1892. a.custom1,
  1893. a.custom2,
  1894. a.custom3,
  1895. a.is_submit,
  1896. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1897. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1898. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  1899. c.method_no,
  1900. c.method_name,
  1901. c.method_remark,
  1902. sw.color_code as qcSpecWarningColorCode,
  1903. sw.threshold_value as qcSpecWarningThresholdValue,
  1904. a.sampling_qty,
  1905. (SELECT TOP 1 epi.collection_flag
  1906. FROM eam_properties_item epi
  1907. WHERE epi.site = a.site
  1908. AND epi.bu_no = a.bu_no
  1909. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1910. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1911. epi.inspection_type_no) AS collectionFlag,
  1912. (SELECT TOP 1 epi.image_flag
  1913. FROM eam_properties_item epi
  1914. WHERE epi.site = a.site
  1915. AND epi.bu_no = a.bu_no
  1916. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1917. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1918. epi.inspection_type_no) AS imageFlag,
  1919. (SELECT TOP 1 epi.data_flag
  1920. FROM eam_properties_item epi
  1921. WHERE epi.site = a.site
  1922. AND epi.bu_no = a.bu_no
  1923. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  1924. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  1925. epi.inspection_type_no) AS dataFlag
  1926. FROM qc_iqc_detailed_record as a
  1927. LEFT JOIN qc_iqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  1928. OUTER APPLY (
  1929. SELECT TOP 1
  1930. w.color_code,
  1931. w.threshold_value
  1932. FROM qc_spec_warning w
  1933. WHERE w.site = a.site
  1934. AND w.bu_no = a.bu_no
  1935. AND w.part_no = r.part_no
  1936. AND w.item_no = a.item_no
  1937. AND w.inspection_type_no = r.inspection_type_no
  1938. ORDER BY w.threshold_value
  1939. ) sw
  1940. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  1941. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  1942. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1943. order by a.order_id
  1944. </select>
  1945. <!-- 查询IQC的子明细 -->
  1946. <select id="selectIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1947. SELECT
  1948. site,
  1949. bu_no,
  1950. sub_detail_value,
  1951. sampling_location,
  1952. is_submit,
  1953. sampling_location_b,
  1954. num,
  1955. sub_detail_value_b,
  1956. sub_detail_value_c,
  1957. sub_detail_value_d,
  1958. sub_detail_value_e,
  1959. file_name,
  1960. is_transfer,
  1961. is_qualified,
  1962. defect_qty,
  1963. roll_no,
  1964. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  1965. FROM qc_iqc_sub_detail_record
  1966. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1967. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1968. AND sub_detail_value ${collectionDataContent}
  1969. </if>
  1970. </select>
  1971. <!-- 获取该项目的子明细值 -->
  1972. <select id="selectIQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1973. SELECT sub_detail_value,
  1974. sampling_location,
  1975. is_submit
  1976. FROM qc_iqc_sub_detail_record
  1977. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1978. </select>
  1979. <!-- 修改IQC主记录信息 -->
  1980. <update id="updateIQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1981. UPDATE qc_iqc_record
  1982. SET disposal_measures = #{disposalMeasures},
  1983. disposal_remark = #{disposalRemark},
  1984. inspection_result = #{inspectionResult},
  1985. inspector_no = #{inspectorNo},
  1986. state = #{state},
  1987. inspection_remark = #{inspectionRemark},
  1988. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  1989. roll_count = #{rollCount,jdbcType=DECIMAL},
  1990. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1991. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1992. pass_qty = #{passQty,jdbcType=DECIMAL},
  1993. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1994. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  1995. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1996. </update>
  1997. <!-- 修改IQC明细记录信息 -->
  1998. <update id="updateIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1999. UPDATE qc_iqc_detailed_record
  2000. SET item_result = #{itemResult},
  2001. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2002. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2003. text_value = #{textValue},
  2004. number_value = #{numberValue,jdbcType=DECIMAL},
  2005. default_value = #{defaultValue},
  2006. min_value = #{minValue,jdbcType=DECIMAL},
  2007. max_value = #{maxValue,jdbcType=DECIMAL},
  2008. item_remark = #{itemRemark},
  2009. custom1 = #{custom1},
  2010. custom2 = #{custom2},
  2011. custom3 = #{custom3}
  2012. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2013. </update>
  2014. <!-- 部分更新IQC明细(实测值/结论即时落库,避免 null 覆盖其他字段) -->
  2015. <update id="patchIQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2016. UPDATE qc_iqc_detailed_record
  2017. <set>
  2018. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  2019. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  2020. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  2021. <if test="textValue != null">text_value = #{textValue},</if>
  2022. </set>
  2023. WHERE inspection_no = #{inspectionNo}
  2024. and RTRIM(item_no) = RTRIM(#{itemNo})
  2025. and site = #{site}
  2026. and bu_no = #{buNo}
  2027. </update>
  2028. <!-- 查询该记录明细是否已存在 -->
  2029. <select id="checkIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2030. SELECT inspection_no,
  2031. template_id
  2032. FROM qc_iqc_detailed_record
  2033. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2034. </select>
  2035. <!-- 查询IQC检验记录是否已提交 -->
  2036. <select id="checkIQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2037. SELECT submit_flag
  2038. FROM qc_iqc_record
  2039. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2040. </select>
  2041. <!-- 查询IQC检验记录状态(用于保存前校验) -->
  2042. <select id="getIQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2043. SELECT submit_flag, state
  2044. FROM qc_iqc_record
  2045. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2046. </select>
  2047. <!-- 删除IQC子明细的老数据 -->
  2048. <delete id="delIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  2049. DELETE FROM qc_iqc_sub_detail_record
  2050. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2051. </delete>
  2052. <!-- 新增IQC子明细信息 -->
  2053. <insert id="saveIQCSubDetailed">
  2054. INSERT INTO qc_iqc_sub_detail_record
  2055. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
  2056. VALUES
  2057. <foreach collection="list" item="item" separator=",">
  2058. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
  2059. </foreach>
  2060. </insert>
  2061. <!-- 修改IQC主记录标识为已提交 -->
  2062. <update id="updateIQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2063. UPDATE qc_iqc_record
  2064. SET submit_flag = 'Y',
  2065. state = '已完成',
  2066. submit_date = getDate(),
  2067. submit_by = #{updateBy}
  2068. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2069. </update>
  2070. <!-- 修改IQC明细记录标识为已提交 -->
  2071. <update id="updateIQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2072. UPDATE qc_iqc_detailed_record
  2073. SET is_submit = 'Y'
  2074. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2075. </update>
  2076. <!-- 修改IQC子明细记录标识为已提交 -->
  2077. <update id="updateIQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2078. UPDATE qc_iqc_sub_detail_record
  2079. SET is_submit = 'Y'
  2080. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2081. </update>
  2082. <!-- 删除IQC检验记录 -->
  2083. <delete id="deleteIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2084. DELETE FROM qc_iqc_record
  2085. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2086. </delete>
  2087. <!-- 删除IQC明细记录信息 -->
  2088. <delete id="deleteIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2089. DELETE FROM qc_iqc_detailed_record
  2090. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2091. </delete>
  2092. <!-- 删除IQC子明细记录信息 -->
  2093. <delete id="deleteIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2094. DELETE FROM qc_iqc_sub_detail_record
  2095. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2096. </delete>
  2097. <!-- 查询文件ID -->
  2098. <select id="queryFileId" parameterType="com.gaotao.modules.oss.entity.SysOssEntity" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  2099. SELECT id, file_name
  2100. FROM sys_oss
  2101. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  2102. </select>
  2103. <!-- 获取工序列表 -->
  2104. <select id="getOperationDescList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
  2105. SELECT distinct
  2106. operationDesc
  2107. FROM view_SO_Routing
  2108. <where>
  2109. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2110. AND operationDesc LIKE '%' + #{query.operationDesc} + '%'
  2111. </if>
  2112. <if test="query.site != null and query.site != ''">
  2113. AND site = #{query.site}
  2114. </if>
  2115. </where>
  2116. </select>
  2117. <!-- 获取供应商列表 -->
  2118. <select id="getManufacturerList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
  2119. SELECT
  2120. supplierID as manufacturerID,
  2121. supplierName as manufacturerName
  2122. FROM view_Supplier
  2123. <where>
  2124. <if test = "query.manufacturerID != null and query.manufacturerID != ''">
  2125. AND supplierID LIKE '%' + #{query.manufacturerID} + '%'
  2126. </if>
  2127. <if test = "query.manufacturerName != null and query.manufacturerName != ''">
  2128. AND supplierName LIKE '%' + #{query.manufacturerName} + '%'
  2129. </if>
  2130. </where>
  2131. </select>
  2132. <!-- 获取机台列表 -->
  2133. <select id="getAllResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2134. SELECT distinct
  2135. resourceId,
  2136. resourceDesc
  2137. FROM WorkCenterResource
  2138. <where>
  2139. site = #{site}
  2140. <if test = "resourceId != null and resourceId != ''">
  2141. AND resourceId LIKE '%' + #{resourceId} + '%'
  2142. </if>
  2143. <if test = "resourceDesc != null and resourceDesc != ''">
  2144. AND resourceDesc LIKE '%' + #{resourceDesc} + '%'
  2145. </if>
  2146. </where>
  2147. </select>
  2148. <!-- 获取工单列表 -->
  2149. <select id="getOrderNoList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2150. SELECT DISTINCT
  2151. a.orderno as orderNo
  2152. FROM soscheduledrouting as a
  2153. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2154. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  2155. <!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
  2156. <where>
  2157. a.site = #{site}
  2158. AND b.approve_qty is not null
  2159. <if test = "orderNo != null and orderNo != ''">
  2160. AND a.orderno LIKE '%' + #{orderNo} + '%'
  2161. </if>
  2162. </where>
  2163. order by a.orderno DESC
  2164. </select>
  2165. <!-- 查询FQC主记录信息 -->
  2166. <select id="qcFQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2167. SELECT
  2168. a.inspection_no,
  2169. a.site,
  2170. a.bu_no,
  2171. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2172. a.state,
  2173. a.inspection_result,
  2174. a.task_date,
  2175. a.create_date,
  2176. a.inspection_type_no,
  2177. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  2178. a.inspection_cycle,
  2179. a.order_no,
  2180. a.operation_desc,
  2181. a.resource_id,
  2182. r.resourceDesc,
  2183. a.part_no,
  2184. d.PartDescription as part_desc,
  2185. d.cinv_source_code as cinvSourceCode,
  2186. d.sku as sku,
  2187. d.PartType as invdefinetype,
  2188. d.spec,
  2189. a.inspection_remark,
  2190. a.roll_qty,
  2191. a.sampling_qty,
  2192. a.disposal_measures,
  2193. a.disposal_remark,
  2194. a.inspector_date as inspectorDate,
  2195. a.submit_date,
  2196. isnull(su.user_display, a.submit_by) as submitBy,
  2197. a.inspector_no,
  2198. u.user_display as inspectorName,
  2199. a.ssr_id,
  2200. a.unqualified_qty,
  2201. a.submit_flag,
  2202. a.seq_no,
  2203. a.batch_roll_no,
  2204. a.special_requirements,
  2205. a.work_center_no,
  2206. a.roll_no,
  2207. a.um_id,
  2208. um.UMName as umName,
  2209. a.action_date,
  2210. isnull(ab.user_display, a.action_by) as actionBy,
  2211. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2212. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2213. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2214. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2215. a.pass_qty,
  2216. a.not_pass_qty,
  2217. a.batch_qualified_qty,
  2218. a.document_no,
  2219. a.release_no as releaseNo,
  2220. a.line_no,
  2221. isnull(a.inspector_by, a.create_by) as inspectorBy,
  2222. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
  2223. FROM qc_fqc_record as a
  2224. inner join part as d on a.site = d.site and a.part_no = d.partNo
  2225. left join sys_user as u on a.inspector_no = u.username
  2226. left join sys_user as ab on a.action_by = ab.username
  2227. left join sys_user as su on a.submit_by = su.username
  2228. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  2229. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  2230. left join UM as um on a.site = um.site and a.um_id = um.UMID
  2231. <where>
  2232. a.site in (select site from AccessSite where userID = #{query.userName})
  2233. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  2234. <if test="query.buNo != null and query.buNo != ''">
  2235. AND a.bu_no = #{query.buNo}
  2236. </if>
  2237. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2238. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2239. </if>
  2240. <if test = "query.partNo != null and query.partNo != ''">
  2241. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2242. </if>
  2243. <if test = "query.partDesc != null and query.partDesc != ''">
  2244. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  2245. </if>
  2246. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2247. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2248. </if>
  2249. <if test = "query.sku != null and query.sku != ''">
  2250. AND d.sku LIKE '%' + #{query.sku} + '%'
  2251. </if>
  2252. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2253. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2254. </if>
  2255. <if test = "query.states != null and query.states.size > 0">
  2256. AND a.state in
  2257. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2258. #{item}
  2259. </foreach>
  2260. </if>
  2261. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2262. AND a.inspection_result = #{query.inspectionResult}
  2263. </if>
  2264. <if test = "query.orderNo != null and query.orderNo != ''">
  2265. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2266. </if>
  2267. <if test = "query.seqNo != null and query.seqNo != ''">
  2268. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  2269. </if>
  2270. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2271. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2272. </if>
  2273. <if test="query.startDate != null">
  2274. AND a.inspector_date >= #{query.startDate}
  2275. </if>
  2276. <if test="query.endDate != null">
  2277. AND #{query.endDate} >= a.inspector_date
  2278. </if>
  2279. <if test="query.startDate2 != null">
  2280. AND a.task_date >= #{query.startDate2}
  2281. </if>
  2282. <if test="query.endDate2 != null">
  2283. AND #{query.endDate2} >= a.task_date
  2284. </if>
  2285. <if test = "query.spec != null and query.spec != ''">
  2286. AND d.spec LIKE '%' + #{query.spec} + '%'
  2287. </if>
  2288. <if test = "query.documentNo != null and query.documentNo != ''">
  2289. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  2290. </if>
  2291. </where>
  2292. ORDER BY a.inspection_no desc,
  2293. CASE WHEN a.state = '待检验' THEN 1
  2294. WHEN a.state = '待审核' THEN 2
  2295. WHEN a.state = '已完成' THEN 3
  2296. END, a.task_date desc
  2297. </select>
  2298. <insert id="saveFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2299. INSERT INTO qc_fqc_detailed_record
  2300. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2301. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2302. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id, custom1, custom2, custom3)
  2303. VALUES
  2304. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  2305. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  2306. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER}, #{custom1}, #{custom2}, #{custom3})
  2307. </insert>
  2308. <!-- 新增FQC明细记录信息 -->
  2309. <insert id="saveFQCDetailedRecords">
  2310. INSERT INTO qc_fqc_detailed_record
  2311. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2312. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2313. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  2314. VALUES
  2315. <foreach collection="list" item="item" separator=",">
  2316. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  2317. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  2318. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId}, #{item.custom1}, #{item.custom2}, #{item.custom3})
  2319. </foreach>
  2320. </insert>
  2321. <!-- 新增FQC主记录信息 -->
  2322. <insert id="saveFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2323. INSERT INTO qc_fqc_record
  2324. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  2325. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, create_by, inspector_by)
  2326. VALUES
  2327. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  2328. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId},
  2329. #{createBy}, #{inspectorBy})
  2330. </insert>
  2331. <!-- FQC明细记录查询 -->
  2332. <select id="fqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2333. SELECT
  2334. a.site,
  2335. a.bu_no,
  2336. a.inspection_no,
  2337. a.order_no,
  2338. a.template_id,
  2339. a.sampling_level_no,
  2340. a.sampling_level_desc,
  2341. a.sampling_programme_no,
  2342. a.sampling_programme_desc,
  2343. a.AQL,
  2344. a.AC,
  2345. a.RE,
  2346. a.item_no,
  2347. a.item_desc,
  2348. a.object_id,
  2349. a.object_desc,
  2350. a.default_value,
  2351. a.min_value,
  2352. a.max_value,
  2353. a.text_value,
  2354. a.number_value,
  2355. a.value_type_db,
  2356. a.value_type,
  2357. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2358. a.item_remark as itemRemark,
  2359. a.custom1,
  2360. a.custom2,
  2361. a.custom3,
  2362. a.is_submit,
  2363. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2364. a.sampling_qty,
  2365. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2366. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  2367. c.method_no,
  2368. c.method_name,
  2369. c.method_remark,
  2370. sw.color_code as qcSpecWarningColorCode,
  2371. sw.threshold_value as qcSpecWarningThresholdValue,
  2372. (SELECT TOP 1 epi.collection_flag
  2373. FROM eam_properties_item epi
  2374. WHERE epi.site = a.site
  2375. AND epi.bu_no = a.bu_no
  2376. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2377. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2378. epi.inspection_type_no) AS collectionFlag,
  2379. (SELECT TOP 1 epi.image_flag
  2380. FROM eam_properties_item epi
  2381. WHERE epi.site = a.site
  2382. AND epi.bu_no = a.bu_no
  2383. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2384. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2385. epi.inspection_type_no) AS imageFlag,
  2386. (SELECT TOP 1 epi.data_flag
  2387. FROM eam_properties_item epi
  2388. WHERE epi.site = a.site
  2389. AND epi.bu_no = a.bu_no
  2390. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  2391. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  2392. epi.inspection_type_no) AS dataFlag
  2393. FROM qc_fqc_detailed_record as a
  2394. LEFT JOIN qc_fqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  2395. OUTER APPLY (
  2396. SELECT TOP 1
  2397. w.color_code,
  2398. w.threshold_value
  2399. FROM qc_spec_warning w
  2400. WHERE w.site = a.site
  2401. AND w.bu_no = a.bu_no
  2402. AND w.part_no = r.part_no
  2403. AND w.item_no = a.item_no
  2404. AND w.inspection_type_no = r.inspection_type_no
  2405. ORDER BY w.threshold_value
  2406. ) sw
  2407. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  2408. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  2409. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2410. order by a.order_id
  2411. </select>
  2412. <!-- 删除FQC检验记录 -->
  2413. <delete id="deleteFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2414. DELETE FROM qc_fqc_record
  2415. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2416. </delete>
  2417. <!-- 删除FQC明细记录信息 -->
  2418. <delete id="deleteFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2419. DELETE FROM qc_fqc_detailed_record
  2420. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2421. </delete>
  2422. <!-- 删除FQC子明细记录信息 -->
  2423. <delete id="deleteFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2424. DELETE FROM qc_fqc_sub_detail_record
  2425. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2426. </delete>
  2427. <!-- 任务重载:修改FQC检验记录 -->
  2428. <update id="updateFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2429. UPDATE qc_fqc_record
  2430. SET inspection_type_no = #{inspectionTypeNo},
  2431. sampling_qty = #{samplingQty},
  2432. inspection_cycle = #{inspectionCycle},
  2433. state = '未开始',
  2434. inspection_result = null,
  2435. disposal_measures = null,
  2436. disposal_remark = null,
  2437. inspection_remark = null,
  2438. inspector_no = null,
  2439. inspector_date = null,
  2440. submit_flag = 'N',
  2441. action_date = null,
  2442. action_by = null,
  2443. pass_qty = null,
  2444. not_pass_qty = null,
  2445. unqualified_qty = null,
  2446. batch_qualified_qty = null
  2447. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2448. </update>
  2449. <!-- 修改FQC主记录信息 -->
  2450. <update id="updateFQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2451. UPDATE qc_fqc_record
  2452. SET disposal_measures = #{disposalMeasures},
  2453. disposal_remark = #{disposalRemark},
  2454. inspection_result = #{inspectionResult},
  2455. inspector_no = #{inspectorNo},
  2456. state = #{state},
  2457. inspection_remark = #{inspectionRemark},
  2458. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  2459. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2460. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2461. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2462. pass_qty = #{passQty,jdbcType=DECIMAL},
  2463. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2464. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  2465. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2466. </update>
  2467. <!-- 修改FQC明细记录信息 -->
  2468. <update id="updateFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2469. UPDATE qc_fqc_detailed_record
  2470. SET item_result = #{itemResult},
  2471. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2472. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2473. text_value = #{textValue},
  2474. number_value = #{numberValue,jdbcType=DECIMAL},
  2475. default_value = #{defaultValue},
  2476. min_value = #{minValue,jdbcType=DECIMAL},
  2477. max_value = #{maxValue,jdbcType=DECIMAL},
  2478. item_remark = #{itemRemark},
  2479. custom1 = #{custom1},
  2480. custom2 = #{custom2},
  2481. custom3 = #{custom3}
  2482. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2483. </update>
  2484. <update id="patchFQCDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2485. UPDATE qc_fqc_detailed_record
  2486. <set>
  2487. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  2488. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  2489. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  2490. <if test="textValue != null">text_value = #{textValue},</if>
  2491. </set>
  2492. WHERE inspection_no = #{inspectionNo}
  2493. and RTRIM(item_no) = RTRIM(#{itemNo})
  2494. and site = #{site}
  2495. and bu_no = #{buNo}
  2496. </update>
  2497. <!-- 修改FQC主记录标识为已提交 -->
  2498. <update id="updateFQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2499. UPDATE qc_fqc_record
  2500. SET submit_flag = 'Y',
  2501. state = '已完成',
  2502. submit_date = getDate(),
  2503. submit_by = #{updateBy}
  2504. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2505. </update>
  2506. <!-- 修改FAI明细记录标识为已提交 -->
  2507. <update id="updateFQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2508. UPDATE qc_fqc_detailed_record
  2509. SET is_submit = 'Y'
  2510. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2511. </update>
  2512. <!-- 修改子明细记录标识为已提交 -->
  2513. <update id="updateFQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2514. UPDATE qc_fqc_sub_detail_record
  2515. SET is_submit = 'Y'
  2516. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2517. </update>
  2518. <!-- 删除子明细的老数据 -->
  2519. <delete id="delFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  2520. DELETE FROM qc_fqc_sub_detail_record
  2521. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2522. </delete>
  2523. <!-- 新增子明细信息 -->
  2524. <insert id="saveFQCSubDetailed">
  2525. INSERT INTO qc_fqc_sub_detail_record
  2526. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
  2527. VALUES
  2528. <foreach collection="list" item="item" separator=",">
  2529. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
  2530. </foreach>
  2531. </insert>
  2532. <!-- 查询FQC的子明细 -->
  2533. <select id="selectFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2534. SELECT
  2535. site,
  2536. bu_no,
  2537. sub_detail_value,
  2538. sampling_location,
  2539. is_submit,
  2540. sampling_location_b,
  2541. num,
  2542. sub_detail_value_b,
  2543. sub_detail_value_c,
  2544. sub_detail_value_d,
  2545. sub_detail_value_e,
  2546. file_name,
  2547. is_transfer,
  2548. is_qualified,
  2549. defect_qty,
  2550. roll_no,
  2551. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  2552. FROM qc_fqc_sub_detail_record
  2553. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2554. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2555. AND sub_detail_value ${collectionDataContent}
  2556. </if>
  2557. </select>
  2558. <!-- 查询FQC检验记录是否已提交 -->
  2559. <select id="checkFQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2560. SELECT submit_flag
  2561. FROM qc_fqc_record
  2562. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2563. </select>
  2564. <!-- 查询FQC检验记录状态(用于保存前校验) -->
  2565. <select id="getFQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2566. SELECT submit_flag, state
  2567. FROM qc_fqc_record
  2568. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2569. </select>
  2570. <!-- 获取该项目的子明细值 -->
  2571. <select id="selectFQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2572. SELECT sub_detail_value,
  2573. sampling_location,
  2574. is_submit
  2575. FROM qc_fqc_sub_detail_record
  2576. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2577. </select>
  2578. <!-- 生成FQC检验单号 -->
  2579. <select id="selectFQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2580. SELECT
  2581. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2582. FROM qc_fqc_record
  2583. WHERE site = #{site} and bu_no = #{buNo}
  2584. </select>
  2585. <!-- 生成IPQC检验单号 -->
  2586. <select id="selectIPQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2587. SELECT
  2588. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  2589. FROM qc_ipqc_record
  2590. WHERE site = #{site} and bu_no = #{buNo}
  2591. </select>
  2592. <!-- 生成FAI检验单号 -->
  2593. <select id="selectFAIInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2594. SELECT
  2595. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2596. FROM qc_fai_record
  2597. WHERE site = #{site} and bu_no = #{buNo}
  2598. </select>
  2599. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  2600. <select id="queryDataFromViewPoOrder" resultType="com.gaotao.modules.pms.data.PoOrderData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2601. SELECT
  2602. site,
  2603. order_no,
  2604. item_no,
  2605. part_no,
  2606. part_desc,
  2607. spec,
  2608. supplier_id,
  2609. supplier_name,
  2610. order_qty,
  2611. created_date,
  2612. status,
  2613. citem_code,
  2614. citem_class,
  2615. sendto_address,
  2616. order_type
  2617. FROM view_po_order
  2618. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  2619. </select>
  2620. <!-- 向收货任务表里添加数据 -->
  2621. <insert id="saveReceivingTask" parameterType="com.gaotao.modules.pms.data.PoOrderData">
  2622. INSERT INTO receiving_task (site, order_no, item_no, part_no, part_desc, spec, supplier_id, supplier_name, order_qty, created_date, status, citem_code, citem_class, sendto_address, order_type, inspection_no, batch_no, production_date, expiration_warning_date, expiration_date)
  2623. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}, #{batchNo}, #{productionDate}, #{expirationWarningDate}, #{expirationDate})
  2624. </insert>
  2625. <!-- 检查动控是否开启 -->
  2626. <select id="queryController" parameterType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity" resultType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity">
  2627. SELECT
  2628. type,
  2629. base_data,
  2630. base_desc,
  2631. status,
  2632. remark,
  2633. third_type,
  2634. second_type,
  2635. page_control,
  2636. control_style
  2637. FROM sys_scene_dynamic_control_model
  2638. where site = #{site} and control_no = #{controlNo}
  2639. </select>
  2640. <!-- 查询检验模板列表 -->
  2641. <select id="queryTemplateList" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
  2642. SELECT
  2643. site,
  2644. bu_no,
  2645. template_id as templateId,
  2646. template_name as templateName,
  2647. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2648. FROM qc_template
  2649. <where>
  2650. site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  2651. <if test = "templateId != null and templateId != ''">
  2652. AND template_id LIKE '%' + #{templateId}+'%'
  2653. </if>
  2654. <if test = "templateName != null and templateName != ''">
  2655. AND template_name LIKE '%' + #{templateName}+'%'
  2656. </if>
  2657. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2658. AND inspection_type_no = #{inspectionTypeNo}
  2659. </if>
  2660. </where>
  2661. </select>
  2662. <!-- 查询检验模板列表 -->
  2663. <select id="getPartInformation" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2664. select
  2665. partNo,
  2666. PartDescription as partDesc,
  2667. spec,
  2668. sku,
  2669. DefaultWarehouseID as defaultWarehouseId
  2670. from part
  2671. where site = #{site} and partNo = #{partNo}
  2672. </select>
  2673. <!-- 获取特殊工序列表 -->
  2674. <select id="getSpecialOperationList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2675. select
  2676. site,
  2677. operation_no,
  2678. operation_desc
  2679. from qc_special_task_operation
  2680. where site = #{site}
  2681. </select>
  2682. <!-- 获取处置措施列表 -->
  2683. <select id="disposalMeasuresSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2684. SELECT
  2685. id,
  2686. disposal_measures
  2687. FROM qc_disposal_measures
  2688. <where>
  2689. <if test = "inspectionTypeNo != '101'">
  2690. inspection_type != 'IPQC'
  2691. </if>
  2692. </where>
  2693. </select>
  2694. <!-- 查询文件路径 -->
  2695. <select id="searchItemFileUrl" resultType="com.gaotao.modules.oss.entity.SysOssEntity" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2696. SELECT
  2697. id,
  2698. url,
  2699. file_name
  2700. FROM sys_oss
  2701. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2702. </select>
  2703. <!-- 删除图片-->
  2704. <delete id="imageDelete" parameterType="com.gaotao.modules.oss.entity.SysOssEntity">
  2705. DELETE FROM sys_oss
  2706. WHERE id = #{id}
  2707. </delete>
  2708. <!-- 模糊查询标签号 -->
  2709. <select id="getRollNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2710. SELECT DISTINCT top 3
  2711. a.seqno,
  2712. a.orderno,
  2713. b.RollNo
  2714. FROM soscheduledrouting AS a
  2715. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
  2716. WHERE a.site = #{site} and b.RollNo like '%' + #{rollNo} + '%'
  2717. </select>
  2718. <!-- 标签号回车事件 -->
  2719. <select id="rollNoEnter" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2720. SELECT
  2721. a.site,
  2722. a.seqno as seqNo,
  2723. a.orderno as orderNo,
  2724. b.RollNo,
  2725. #{inspectionTypeNo} as inspectionTypeNo
  2726. FROM soscheduledrouting AS a
  2727. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
  2728. WHERE a.site = #{site} and b.RollNo = #{rollNo}
  2729. </select>
  2730. <!-- 查询物料列表 -->
  2731. <select id="queryPartList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2732. SELECT
  2733. site,
  2734. partNo,
  2735. PartDescription as partDesc,
  2736. PartType as invdefinetype,
  2737. sku,
  2738. spec,
  2739. cinv_source_code as cinvSourceCode
  2740. FROM part
  2741. <where>
  2742. site = #{site}
  2743. <if test = "partNo != null and partNo != ''">
  2744. AND partNo LIKE '%' + #{partNo} + '%'
  2745. </if>
  2746. <if test = "partDesc != null and partDesc != ''">
  2747. AND PartDescription LIKE '%' + #{partDesc} + '%'
  2748. </if>
  2749. <if test = "sku != null and sku != ''">
  2750. AND sku LIKE '%' + #{sku} + '%'
  2751. </if>
  2752. <if test = "cinvSourceCode != null and cinvSourceCode != ''">
  2753. AND cinv_source_code LIKE '%' + #{cinvSourceCode} + '%'
  2754. </if>
  2755. </where>
  2756. order by partNo
  2757. </select>
  2758. <!-- 查询物料列表(分页) -->
  2759. <select id="queryPartListPage" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2760. SELECT
  2761. site,
  2762. partNo,
  2763. PartDescription as partDesc,
  2764. PartType as invdefinetype,
  2765. sku,
  2766. spec,
  2767. cinv_source_code as cinvSourceCode
  2768. FROM part
  2769. <where>
  2770. site = #{query.site}
  2771. <if test = "query.partNo != null and query.partNo != ''">
  2772. AND partNo LIKE '%' + #{query.partNo} + '%'
  2773. </if>
  2774. <if test = "query.partDesc != null and query.partDesc != ''">
  2775. AND PartDescription LIKE '%' + #{query.partDesc} + '%'
  2776. </if>
  2777. <if test = "query.sku != null and query.sku != ''">
  2778. AND sku LIKE '%' + #{query.sku} + '%'
  2779. </if>
  2780. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2781. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2782. </if>
  2783. </where>
  2784. order by partNo
  2785. </select>
  2786. <!-- 查询单位列表 -->
  2787. <select id="umSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2788. SELECT
  2789. site,
  2790. UMID as umId,
  2791. UMName as umName
  2792. FROM UM
  2793. WHERE active = #{active}
  2794. </select>
  2795. <!-- 查询单位列表 -->
  2796. <select id="checkItem" resultType="com.gaotao.modules.pms.data.SubDetailValues" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
  2797. SELECT
  2798. site,
  2799. bu_no,
  2800. inspection_no,
  2801. item_no,
  2802. value_type_db,
  2803. min_value,
  2804. max_value
  2805. FROM
  2806. <choose>
  2807. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  2808. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  2809. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  2810. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  2811. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  2812. <when test="flag == 'pqc'">qc_pqc_detailed_record</when>
  2813. <otherwise>qc_iqc_detailed_record</otherwise>
  2814. </choose>
  2815. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  2816. order by order_id
  2817. </select>
  2818. <!-- 修改detailFlag字段为N -->
  2819. <update id="updateIQCDetailFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2820. UPDATE qc_iqc_record
  2821. SET detail_flag = 'N'
  2822. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2823. </update>
  2824. <select id="searchSeqInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2825. SELECT
  2826. a.site,
  2827. a.order_no as orderNo,
  2828. a.release_no as releaseNo,
  2829. a.sequence_no as [lineNo],
  2830. a.part_no as partNo,
  2831. a.part_description as partDesc,
  2832. a.lot_size as lotsize,
  2833. a.planner,
  2834. a.status
  2835. FROM View_IFS_Shop_Order a
  2836. WHERE a.site = #{query.site}
  2837. <if test="query.userName != null and query.userName != ''">
  2838. AND a.site in (Select Site from AccessSite where upper(UserID) = #{query.userName})
  2839. </if>
  2840. <if test="query.status != null and query.status != ''">
  2841. AND a.status = #{query.status}
  2842. </if>
  2843. <if test="query.orderNo != null and query.orderNo != ''">
  2844. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2845. </if>
  2846. <if test="query.releaseNo != null and query.releaseNo != ''">
  2847. AND a.release_no LIKE '%' + #{query.releaseNo} + '%'
  2848. </if>
  2849. <if test="query.lineNo != null and query.lineNo != ''">
  2850. AND a.sequence_no LIKE '%' + #{query.lineNo} + '%'
  2851. </if>
  2852. <if test="query.partNo != null and query.partNo != ''">
  2853. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2854. </if>
  2855. <if test="query.partDesc != null and query.partDesc != ''">
  2856. AND a.part_description LIKE '%' + #{query.partDesc} + '%'
  2857. </if>
  2858. </select>
  2859. <!-- 查询采购订单信息(IQC新增) -->
  2860. <select id="searchPoOrderInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2861. SELECT
  2862. v.site,
  2863. v.poOrderNo,
  2864. v.poOrderItemNo as poItemNo,
  2865. CAST(v.poOrderLineNo AS VARCHAR(20)) as releaseNo,
  2866. CAST(v.receiptNo AS VARCHAR(20)) as receiptItemNo,
  2867. CAST(v.receiptNo AS VARCHAR(20)) as receiptNo,
  2868. v.partNo,
  2869. p.PartDescription as partDesc,
  2870. p.spec,
  2871. v.supplierNo,
  2872. s.SupplierName as supplierDesc,
  2873. v.orderQty as lotsize,
  2874. p.PartType as invdefinetype,
  2875. v.receivedQty as currentArrivalQty,
  2876. ISNULL(v.qtyInspected, 0) as allowInQty,
  2877. ISNULL(v.qtyToInspected, 0) as pendingInspectQty,
  2878. ISNULL(v.qtyInspected, 0) as inspectedQty,
  2879. v.umId,
  2880. um.UMName as umName
  2881. FROM View_Purchase_Order_List v
  2882. LEFT JOIN part p ON v.site = p.site AND v.partNo = p.PartNo
  2883. LEFT JOIN Supplier s ON v.supplierNo = s.SupplierID
  2884. LEFT JOIN UM um ON v.site = um.site AND v.umId = um.UMID
  2885. WHERE v.site = #{query.site}
  2886. AND CAST(v.poOrderNo AS VARCHAR(50)) LIKE '%' + #{query.poOrderNo} + '%'
  2887. <if test="query.poItemNo != null and query.poItemNo != ''">
  2888. AND CAST(v.poOrderItemNo AS VARCHAR(20)) LIKE '%' + #{query.poItemNo} + '%'
  2889. </if>
  2890. <if test="query.releaseNo != null and query.releaseNo != ''">
  2891. AND CAST(v.poOrderLineNo AS VARCHAR(20)) LIKE '%' + #{query.releaseNo} + '%'
  2892. </if>
  2893. <if test="query.receiptNo != null and query.receiptNo != ''">
  2894. AND CAST(v.receiptNo AS VARCHAR(20)) LIKE '%' + #{query.receiptNo} + '%'
  2895. </if>
  2896. <if test="query.partNo != null and query.partNo != ''">
  2897. AND v.partNo LIKE '%' + #{query.partNo} + '%'
  2898. </if>
  2899. <if test="query.partDesc != null and query.partDesc != ''">
  2900. AND p.PartDescription LIKE '%' + #{query.partDesc} + '%'
  2901. </if>
  2902. <if test="query.supplierNo != null and query.supplierNo != ''">
  2903. AND v.supplierNo LIKE '%' + #{query.supplierNo} + '%'
  2904. </if>
  2905. <if test="query.supplierDesc != null and query.supplierDesc != ''">
  2906. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  2907. </if>
  2908. </select>
  2909. <!--
  2910. IQC批量新增:采购接收单查询(可不填PO;支持供应商、接收日期)
  2911. 依赖 View_Purchase_Order_List 提供:receivedDate(接收日期)、batchNo(供应商批次)
  2912. 若视图暂无这两列,请先执行 db/view_purchase_order_list_batch_fields.sql 说明让 Mingo 补齐
  2913. -->
  2914. <select id="searchPoOrderInfoForBatch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2915. SELECT
  2916. v.site,
  2917. v.poOrderNo,
  2918. v.poOrderItemNo as poItemNo,
  2919. CAST(v.poOrderLineNo AS VARCHAR(20)) as releaseNo,
  2920. CAST(v.receiptNo AS VARCHAR(20)) as receiptItemNo,
  2921. CAST(v.receiptNo AS VARCHAR(20)) as receiptNo,
  2922. v.partNo,
  2923. p.PartDescription as partDesc,
  2924. p.spec,
  2925. v.supplierNo,
  2926. s.SupplierName as supplierDesc,
  2927. v.orderQty as lotsize,
  2928. p.PartType as invdefinetype,
  2929. v.receivedQty as currentArrivalQty,
  2930. ISNULL(v.qtyInspected, 0) as allowInQty,
  2931. ISNULL(v.qtyToInspected, 0) as pendingInspectQty,
  2932. ISNULL(v.qtyInspected, 0) as inspectedQty,
  2933. v.umId,
  2934. um.UMName as umName<!--,
  2935. v.batchNo as batchNo,
  2936. v.receivedDate as arrivalDate-->
  2937. FROM View_Purchase_Order_List v
  2938. LEFT JOIN part p ON v.site = p.site AND v.partNo = p.PartNo
  2939. LEFT JOIN Supplier s ON v.supplierNo = s.SupplierID
  2940. LEFT JOIN UM um ON v.site = um.site AND v.umId = um.UMID
  2941. WHERE v.site = #{query.site}
  2942. <if test="query.poOrderNo != null and query.poOrderNo != ''">
  2943. AND CAST(v.poOrderNo AS VARCHAR(50)) LIKE '%' + #{query.poOrderNo} + '%'
  2944. </if>
  2945. <if test="query.poItemNo != null and query.poItemNo != ''">
  2946. AND CAST(v.poOrderItemNo AS VARCHAR(20)) LIKE '%' + #{query.poItemNo} + '%'
  2947. </if>
  2948. <if test="query.releaseNo != null and query.releaseNo != ''">
  2949. AND CAST(v.poOrderLineNo AS VARCHAR(20)) LIKE '%' + #{query.releaseNo} + '%'
  2950. </if>
  2951. <if test="query.receiptNo != null and query.receiptNo != ''">
  2952. AND CAST(v.receiptNo AS VARCHAR(20)) LIKE '%' + #{query.receiptNo} + '%'
  2953. </if>
  2954. <if test="query.partNo != null and query.partNo != ''">
  2955. AND v.partNo LIKE '%' + #{query.partNo} + '%'
  2956. </if>
  2957. <if test="query.partDesc != null and query.partDesc != ''">
  2958. AND p.PartDescription LIKE '%' + #{query.partDesc} + '%'
  2959. </if>
  2960. <if test="query.supplierNo != null and query.supplierNo != ''">
  2961. AND v.supplierNo LIKE '%' + #{query.supplierNo} + '%'
  2962. </if>
  2963. <if test="query.supplierDesc != null and query.supplierDesc != ''">
  2964. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  2965. </if>
  2966. <if test="query.startDate != null">
  2967. AND v.receivedDate &gt;= #{query.startDate}
  2968. </if>
  2969. <if test="query.endDate != null">
  2970. AND v.receivedDate &lt;= #{query.endDate}
  2971. </if>
  2972. ORDER BY v.poOrderNo, v.poOrderItemNo
  2973. </select>
  2974. <select id="searchPartInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2975. select
  2976. partNo,
  2977. PartDescription as partDesc,
  2978. PartType as invdefinetype,
  2979. sku,
  2980. bu_no
  2981. from
  2982. part
  2983. where
  2984. bu_no = #{query.buNo}
  2985. <if test="query.site != null and query.site != ''">
  2986. AND site = #{query.site}
  2987. </if>
  2988. <if test="query.type != null and query.type != ''">
  2989. AND PartType = #{query.type}
  2990. </if>
  2991. <if test="query.handle != null and query.handle != ''">
  2992. AND handle = #{query.handle}
  2993. </if>
  2994. <if test="query.partNo != null and query.partNo != ''">
  2995. AND partNo LIKE '%' + #{query.partNo} + '%'
  2996. </if>
  2997. <if test="query.partDesc != null and query.partDesc != ''">
  2998. AND PartDescription LIKE '%' + #{query.partDesc} + '%'
  2999. </if>
  3000. <if test="query.sku != null and query.sku != ''">
  3001. AND sku LIKE '%' + #{query.sku} + '%'
  3002. </if>
  3003. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  3004. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  3005. </if>
  3006. order by partNo
  3007. </select>
  3008. <select id="getInterfaceTimeData" parameterType="String" resultType="com.gaotao.modules.pms.data.InterfaceTimeData">
  3009. SELECT
  3010. id,
  3011. start_time,
  3012. end_time,
  3013. del_flag
  3014. FROM interface_time
  3015. WHERE del_flag = 'N' and site = #{site}
  3016. </select>
  3017. <update id="updateInterfaceTimeData" parameterType="com.gaotao.modules.pms.data.InterfaceTimeData">
  3018. UPDATE interface_time
  3019. set
  3020. updated_by = #{updatedBy},
  3021. updated_date = #{updatedDate},
  3022. del_flag = #{delFlag}
  3023. </update>
  3024. <select id="getInterfaceRdStyleData" parameterType="String" resultType="com.gaotao.modules.pms.data.RdStyleData">
  3025. SELECT
  3026. crdcode,
  3027. crdname,
  3028. iRdGrade,
  3029. rdtype,
  3030. brdend
  3031. FROM view_custdev_mes_rdstyle
  3032. WHERE crdname = #{crdName}
  3033. </select>
  3034. <insert id="insertHardtagPurchaseInStorageData" parameterType="com.gaotao.modules.pms.data.HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
  3035. INSERT INTO purchase_in_storage_count
  3036. (site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
  3037. cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
  3038. values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
  3039. #{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
  3040. </insert>
  3041. <insert id="batchSaveHrdtagTransHeader" parameterType="com.gaotao.modules.pms.data.HardtagTransHeaderData">
  3042. insert into TransHeader
  3043. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
  3044. TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
  3045. department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
  3046. values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
  3047. #{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
  3048. #{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
  3049. </insert>
  3050. <insert id="batchSaveHardtagTransDetail" parameterType="com.gaotao.modules.pms.data.HardtagTransDetailData">
  3051. INSERT INTO TransDetail
  3052. (TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
  3053. values
  3054. (#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
  3055. </insert>
  3056. <select id="getSendMailAddress" parameterType="String" resultType="com.gaotao.modules.pms.data.MailAddressData">
  3057. SELECT
  3058. id,
  3059. site,
  3060. bu_no,
  3061. mail_address,
  3062. send_type,
  3063. del_flag,
  3064. created_by,
  3065. created_date,
  3066. orderref1
  3067. FROM mailAddress
  3068. WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
  3069. <if test="buNo != null and buNo != ''">
  3070. AND bu_no = #{buNo}
  3071. </if>
  3072. </select>
  3073. <select id="getSendMailFromAddress" resultType="com.gaotao.modules.pms.data.MailSendAddressData">
  3074. SELECT
  3075. port,
  3076. host,
  3077. username,
  3078. password,
  3079. emailForm,
  3080. timeout,
  3081. personal,
  3082. id
  3083. FROM mailSendAddress
  3084. where delFlag = 'N'
  3085. </select>
  3086. <!-- 新增发送邮件记录 -->
  3087. <insert id="saveSendMailRecord" parameterType="com.gaotao.modules.pms.data.SendMailRecord">
  3088. insert into send_mail_record
  3089. (site, bu_no, document_no, sender, recipient, send_date, type)
  3090. values
  3091. (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate(), #{type})
  3092. </insert>
  3093. <select id="orderTypeSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3094. SELECT distinct
  3095. order_type
  3096. FROM view_po_order
  3097. </select>
  3098. <update id="actionIQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3099. update qc_iqc_record
  3100. set action_date = getDate(),
  3101. action_by = #{actionBy},
  3102. state = #{state}
  3103. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3104. </update>
  3105. <update id="actionFAIInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3106. update qc_fai_record
  3107. set action_date = getDate(),
  3108. action_by = #{actionBy},
  3109. state = #{state}
  3110. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3111. </update>
  3112. <update id="actionIPQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3113. update qc_ipqc_record
  3114. set action_date = getDate(),
  3115. action_by = #{actionBy},
  3116. state = #{state}
  3117. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3118. </update>
  3119. <update id="actionFQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3120. update qc_fqc_record
  3121. set action_date = getDate(),
  3122. action_by = #{actionBy},
  3123. state = #{state}
  3124. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3125. </update>
  3126. <insert id="addEquipmentDataAcquisition">
  3127. insert into Equipment_data_acquisition
  3128. (site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
  3129. values
  3130. <foreach collection="list" item="item" separator=",">
  3131. (#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
  3132. </foreach>
  3133. </insert>
  3134. <!-- 新增人员信息 -->
  3135. <insert id="saveOperator" >
  3136. INSERT INTO eam_actual_operator
  3137. (site, order_no, function_type, operator, bu_no)
  3138. VALUES
  3139. <foreach collection="list" item="item" separator=",">
  3140. (#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
  3141. </foreach>
  3142. </insert>
  3143. <!-- 删除之前的人员-->
  3144. <delete id="delOperator" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3145. DELETE FROM eam_actual_operator
  3146. WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
  3147. </delete>
  3148. <select id="getInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3149. select distinct
  3150. site,
  3151. bu_no,
  3152. equipment_no,
  3153. inspection_no,
  3154. item_no,
  3155. collection_source,
  3156. collection_method,
  3157. batch_no,
  3158. accumulate_collect,
  3159. delete_after_collect
  3160. from Equipment_data_acquisition
  3161. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3162. </select>
  3163. <select id="getInspectionNoByItem" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3164. select distinct
  3165. site,
  3166. bu_no,
  3167. equipment_no,
  3168. inspection_no,
  3169. item_no,
  3170. collection_source,
  3171. collection_method,
  3172. batch_no,
  3173. accumulate_collect,
  3174. delete_after_collect
  3175. from Equipment_data_acquisition
  3176. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  3177. </select>
  3178. <select id="dataAcquisition" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  3179. select
  3180. id,
  3181. site,
  3182. bu_no,
  3183. #{inspectionNo} as inspectionNo,
  3184. #{itemNo} as itemNo,
  3185. <if test='subDetailValueType == 0'>
  3186. ${collectionSource} as subDetailValue,
  3187. </if>
  3188. <if test='subDetailValueType == 1'>
  3189. ${collectionSource} as subDetailValueB,
  3190. </if>
  3191. <if test='subDetailValueType == 2'>
  3192. ${collectionSource} as subDetailValueC,
  3193. </if>
  3194. <if test='subDetailValueType == 3'>
  3195. ${collectionSource} as subDetailValueD,
  3196. </if>
  3197. <if test='subDetailValueType == 4'>
  3198. ${collectionSource} as subDetailValueE,
  3199. </if>
  3200. num,
  3201. #{collectionSource} as collectionSource,
  3202. #{collectionMethod} as collectionMethod
  3203. from Equipment_data_detail
  3204. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  3205. <if test='collectionMethod == "plc"'>
  3206. AND inspection_no = #{inspectionNo}
  3207. </if>
  3208. <if test='collectionMethod == "RS232"'>
  3209. AND (inspection_no is null or inspection_no = '')
  3210. </if>
  3211. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3212. AND ${collectionSource} ${collectionDataContent}
  3213. </if>
  3214. <if test='standardMode != null and standardMode'>
  3215. AND source_column_no IS NULL
  3216. AND (serial_no IS NULL OR serial_no = '')
  3217. </if>
  3218. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3219. </select>
  3220. <select id="dataAcquisitionB" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  3221. select
  3222. id,
  3223. site,
  3224. bu_no,
  3225. #{inspectionNo} as inspectionNo,
  3226. #{itemNo} as itemNo,
  3227. ${collectionSource} as subDetailValueB,
  3228. num,
  3229. #{collectionSource} as collectionSource
  3230. from Equipment_data_detail
  3231. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  3232. <if test='collectionMethod == "plc"'>
  3233. AND inspection_no = #{inspectionNo}
  3234. </if>
  3235. <if test='collectionMethod == "RS232"'>
  3236. AND (inspection_no is null or inspection_no = '')
  3237. </if>
  3238. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3239. AND ${collectionSource} ${collectionDataContent}
  3240. </if>
  3241. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3242. </select>
  3243. <select id="dataAcquisition2" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  3244. select
  3245. site as orderRef1,
  3246. bu_no as orderRef4,
  3247. #{inspectionNo} as orderRef2,
  3248. #{itemNo} as orderRef3,
  3249. ${collectionSource} as url
  3250. from Equipment_data_detail
  3251. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  3252. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3253. AND ${collectionSource} ${collectionDataContent}
  3254. </if>
  3255. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3256. </select>
  3257. <select id="getIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3258. select
  3259. a.site,
  3260. a.bu_no,
  3261. b.collection_condition as equipmentNo,
  3262. #{inspectionNo} as inspectionNo,
  3263. a.item_no,
  3264. b.collection_source,
  3265. #{actionBy} as actionBy,
  3266. b.collection_method
  3267. from qc_iqc_detailed_record as a
  3268. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3269. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
  3270. order by a.order_id
  3271. </select>
  3272. <select id="getFAIDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3273. select
  3274. a.site,
  3275. a.bu_no,
  3276. b.collection_condition as equipmentNo,
  3277. #{inspectionNo} as inspectionNo,
  3278. a.item_no,
  3279. b.collection_source,
  3280. #{actionBy} as actionBy,
  3281. b.collection_method
  3282. from qc_fai_detailed_record as a
  3283. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3284. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
  3285. order by order_id
  3286. </select>
  3287. <select id="getIPQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3288. select
  3289. a.site,
  3290. a.bu_no,
  3291. b.collection_condition as equipmentNo,
  3292. #{inspectionNo} as inspectionNo,
  3293. a.item_no,
  3294. b.collection_source,
  3295. #{actionBy} as actionBy,
  3296. b.collection_method
  3297. from qc_ipqc_detailed_record as a
  3298. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3299. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  3300. order by a.order_id
  3301. </select>
  3302. <select id="getFQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  3303. select
  3304. a.site,
  3305. a.bu_no,
  3306. b.collection_condition as equipmentNo,
  3307. #{inspectionNo} as inspectionNo,
  3308. a.item_no,
  3309. b.collection_source,
  3310. #{actionBy} as actionBy,
  3311. b.collection_method
  3312. from qc_fqc_detailed_record as a
  3313. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3314. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
  3315. order by a.order_id
  3316. </select>
  3317. <select id="querySubDetails" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  3318. select
  3319. b.site,
  3320. b.bu_no,
  3321. b.inspection_no,
  3322. b.item_no,
  3323. b.default_value,
  3324. b.min_value,
  3325. b.max_value,
  3326. b.value_type_db,
  3327. a.sub_detail_value
  3328. <if test="flag == 'iqc'">
  3329. from qc_iqc_sub_detail_record as a
  3330. left join qc_iqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3331. </if>
  3332. <if test="flag == 'ipqc'">
  3333. from qc_ipqc_sub_detail_record as a
  3334. left join qc_ipqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3335. </if>
  3336. <if test="flag == 'sqc'">
  3337. from qc_sqc_sub_detail_record as a
  3338. left join qc_sqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3339. </if>
  3340. <if test="flag == 'fqc'">
  3341. from qc_fqc_sub_detail_record as a
  3342. left join qc_fqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3343. </if>
  3344. <if test="flag == 'fai'">
  3345. from qc_fai_sub_detail_record as a
  3346. left join qc_fai_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3347. </if>
  3348. <if test="flag == 'fqas' or flag == 'oqc'">
  3349. from qc_oqc_sub_detail_record as a
  3350. left join qc_oqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3351. </if>
  3352. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
  3353. order by b.order_id
  3354. </select>
  3355. <insert id="saveFileList">
  3356. INSERT INTO sys_oss
  3357. (url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
  3358. VALUES
  3359. <foreach collection="list" item="item" separator=",">
  3360. (#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
  3361. </foreach>
  3362. </insert>
  3363. <select id="getEquipmentNoList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
  3364. select
  3365. equipment_no
  3366. from Equipment_folder_location
  3367. where site = #{site} and bu_no = #{buNo}
  3368. </select>
  3369. <select id="getEquipmentClassificationList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
  3370. select distinct
  3371. equipment_classification
  3372. from Equipment_folder_location
  3373. where site = #{site} and bu_no = #{buNo}
  3374. and equipment_classification is not null
  3375. and equipment_classification != ''
  3376. order by equipment_classification
  3377. </select>
  3378. <!-- 获取责任人员列表 -->
  3379. <select id="getResponsibleOperatorList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  3380. SELECT
  3381. DISTINCT
  3382. OperatorID as adminID,
  3383. OperatorName as adminName
  3384. FROM operator
  3385. <where>
  3386. site in (select site from AccessSite where userID = #{userName})
  3387. <if test = "adminID != null and adminID != ''">
  3388. AND OperatorID LIKE '%' + #{adminID} + '%'
  3389. </if>
  3390. <if test = "adminName != null and adminName != ''">
  3391. AND OperatorName LIKE '%' + #{adminName} + '%'
  3392. </if>
  3393. </where>
  3394. </select>
  3395. <select id="getDataContentList" parameterType="com.gaotao.modules.pms.data.QcCollectionDataContentData" resultType="com.gaotao.modules.pms.data.QcCollectionDataContentData">
  3396. select
  3397. content_desc
  3398. from qc_collection_data_content
  3399. where site = #{site} and bu_no = #{buNo} and active = 'Y'
  3400. </select>
  3401. <select id="getItemCollectionDataContent" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="string">
  3402. select
  3403. collection_data_content
  3404. from eam_properties_item
  3405. where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
  3406. </select>
  3407. <!-- 获取当前项目不包含的设备 -->
  3408. <select id="getObjectList1" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3409. SELECT
  3410. a.site,
  3411. a.bu_no,
  3412. a.equipment_no as ObjectID,
  3413. a.equipment_desc as ObjectDesc
  3414. FROM Equipment_folder_location as a
  3415. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.equipment_no = b.ObjectID and b.ItemNo = #{itemNo}
  3416. where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null
  3417. </select>
  3418. <!-- 获取当前项目所包含的设备 -->
  3419. <select id="getObjectList2" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3420. SELECT
  3421. a.site,
  3422. a.bu_no,
  3423. a.ObjectID,
  3424. b.equipment_desc as ObjectDesc,
  3425. a.default_flag
  3426. FROM qc_item_object a
  3427. LEFT JOIN Equipment_folder_location b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.equipment_no
  3428. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
  3429. </select>
  3430. <!-- 获取当前项目不包含的设备 -->
  3431. <select id="getObjectListBy" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  3432. SELECT
  3433. a.site,
  3434. a.bu_no,
  3435. a.equipment_no as ObjectID,
  3436. a.equipment_desc as ObjectDesc
  3437. FROM Equipment_folder_location as a
  3438. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.equipment_no = b.ObjectID and b.ItemNo = #{itemNo}
  3439. <where>
  3440. a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null
  3441. <if test = "objectID != null and objectID != ''">
  3442. AND a.equipment_no LIKE '%' + #{objectID} + '%'
  3443. </if>
  3444. <if test = "objectDesc != null and objectDesc != ''">
  3445. AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
  3446. </if>
  3447. </where>
  3448. order by a.equipment_no
  3449. </select>
  3450. <!-- 新增项目设备 -->
  3451. <insert id="addItemObject">
  3452. INSERT INTO qc_item_object
  3453. (site, bu_no, ItemNo, ObjectID, default_flag)
  3454. VALUES
  3455. <foreach collection="list" item="item" separator=",">
  3456. (#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
  3457. </foreach>
  3458. </insert>
  3459. <delete id="deleteItemObject">
  3460. DELETE FROM qc_item_object
  3461. WHERE
  3462. <foreach collection="list" item="item" separator=" or " index="index">
  3463. (site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
  3464. </foreach>
  3465. </delete>
  3466. <update id="updateItemObject">
  3467. UPDATE qc_item_object
  3468. SET default_flag = #{defaultFlag}
  3469. WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
  3470. </update>
  3471. <select id="getIQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3472. select
  3473. a.site,
  3474. a.bu_no,
  3475. a.inspection_no,
  3476. a.item_no,
  3477. a.item_desc,
  3478. b.collection_source,
  3479. b.collection_method,
  3480. b.equipment_classification
  3481. from qc_iqc_detailed_record as a
  3482. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3483. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
  3484. order by a.order_id
  3485. </select>
  3486. <select id="getFAIInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3487. select
  3488. a.site,
  3489. a.bu_no,
  3490. a.inspection_no,
  3491. a.item_no,
  3492. a.item_desc,
  3493. b.collection_source,
  3494. b.collection_method,
  3495. b.equipment_classification
  3496. from qc_fai_detailed_record as a
  3497. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3498. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
  3499. order by a.order_id
  3500. </select>
  3501. <select id="getFQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3502. select
  3503. a.site,
  3504. a.bu_no,
  3505. a.inspection_no,
  3506. a.item_no,
  3507. a.item_desc,
  3508. b.collection_source,
  3509. b.collection_method,
  3510. b.equipment_classification
  3511. from qc_fqc_detailed_record as a
  3512. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3513. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
  3514. order by a.order_id
  3515. </select>
  3516. <select id="getIPQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  3517. select
  3518. a.site,
  3519. a.bu_no,
  3520. a.inspection_no,
  3521. a.item_no,
  3522. a.item_desc,
  3523. b.collection_source,
  3524. b.collection_method,
  3525. b.equipment_classification
  3526. from qc_ipqc_detailed_record as a
  3527. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3528. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  3529. order by a.order_id
  3530. </select>
  3531. <delete id="deleteEquipmentDataAcquisition" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3532. delete from Equipment_data_acquisition
  3533. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3534. </delete>
  3535. <!-- IPQC检验项目操作相关SQL -->
  3536. <!-- 查询可选的IPQC检验项目(未添加到当前检验单的) -->
  3537. <select id="getIPQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3538. SELECT
  3539. ItemNo as itemNo,
  3540. ItemDesc as itemDesc,
  3541. DefaultValue as defaultValue,
  3542. MaxValue as maxValue,
  3543. MinValue as minValue,
  3544. ValueType as valueType,
  3545. ValueType_DB as valueTypeDb
  3546. FROM eam_properties_item
  3547. WHERE site = #{site}
  3548. AND bu_no = #{buNo}
  3549. AND inspection_type_no = '101'
  3550. <if test="itemNo != null and itemNo != ''">
  3551. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3552. </if>
  3553. <if test="itemDesc != null and itemDesc != ''">
  3554. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3555. </if>
  3556. AND ItemNo NOT IN (
  3557. SELECT item_no
  3558. FROM qc_ipqc_detailed_record
  3559. WHERE site = #{site}
  3560. AND bu_no = #{buNo}
  3561. AND inspection_no = #{inspectionNo}
  3562. )
  3563. ORDER BY ItemNo
  3564. </select>
  3565. <!-- 查询已有的IPQC检验项目(当前检验单已添加的) -->
  3566. <select id="getIPQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3567. SELECT
  3568. d.item_no as itemNo,
  3569. d.item_desc as itemDesc
  3570. FROM qc_ipqc_detailed_record d
  3571. WHERE d.site = #{site}
  3572. AND d.bu_no = #{buNo}
  3573. AND d.inspection_no = #{inspectionNo}
  3574. ORDER BY d.item_no
  3575. </select>
  3576. <!-- 查询当前检验单已有的项目(用于获取template_id) -->
  3577. <select id="getExistingIPQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3578. SELECT TOP 1
  3579. template_id as templateId,
  3580. item_no as itemNo,
  3581. item_desc as itemDesc
  3582. FROM qc_ipqc_detailed_record
  3583. WHERE site = #{site}
  3584. AND bu_no = #{buNo}
  3585. AND inspection_no = #{inspectionNo}
  3586. ORDER BY item_no
  3587. </select>
  3588. <!-- 插入IPQC检验项目明细 -->
  3589. <insert id="insertIPQCItemDetail" parameterType="java.util.Map">
  3590. INSERT INTO qc_ipqc_detailed_record (
  3591. inspection_no,
  3592. order_no,
  3593. template_id,
  3594. item_no,
  3595. item_desc,
  3596. default_value,
  3597. min_value,
  3598. max_value,
  3599. value_type_db,
  3600. value_type,
  3601. site,
  3602. bu_no,
  3603. foreign_flag,
  3604. order_id
  3605. ) VALUES (
  3606. #{inspectionNo},
  3607. #{orderNo},
  3608. #{templateId},
  3609. #{itemNo},
  3610. #{itemDesc},
  3611. #{defaultValue},
  3612. #{minValue},
  3613. #{maxValue},
  3614. #{valueTypeDb},
  3615. #{valueType},
  3616. #{site},
  3617. #{buNo},
  3618. #{foreignFlag},
  3619. #{orderId}
  3620. )
  3621. </insert>
  3622. <!-- 获取检验单中最大的order_id -->
  3623. <select id="getMaxOrderIdForIPQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  3624. SELECT ISNULL(MAX(order_id), 0)
  3625. FROM qc_ipqc_detailed_record
  3626. WHERE site = #{site}
  3627. AND bu_no = #{buNo}
  3628. AND inspection_no = #{inspectionNo}
  3629. </select>
  3630. <!-- 删除IPQC检验项目明细 -->
  3631. <delete id="deleteIPQCItemDetail" parameterType="java.util.Map">
  3632. DELETE FROM qc_ipqc_detailed_record
  3633. WHERE site = #{site}
  3634. AND bu_no = #{buNo}
  3635. AND inspection_no = #{inspectionNo}
  3636. AND item_no = #{itemNo}
  3637. </delete>
  3638. <!-- 删除IPQC检验项目的子明细 -->
  3639. <delete id="deleteIPQCSubDetailByItem" parameterType="java.util.Map">
  3640. DELETE FROM qc_ipqc_sub_detail_record
  3641. WHERE site = #{site}
  3642. AND bu_no = #{buNo}
  3643. AND inspection_no = #{inspectionNo}
  3644. AND item_no = #{itemNo}
  3645. </delete>
  3646. <!-- IPQC模板导入相关SQL -->
  3647. <!-- 查询IPQC模板列表 -->
  3648. <select id="getIPQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  3649. SELECT
  3650. t.template_id as templateId,
  3651. t.template_name as templateName,
  3652. t.template_remark as remark,
  3653. (SELECT COUNT(*) FROM qc_template_detailed d
  3654. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  3655. FROM qc_template t
  3656. WHERE t.site = #{site}
  3657. AND t.bu_no = #{buNo}
  3658. AND t.inspection_type_no = '101'
  3659. <if test="templateId != null and templateId != ''">
  3660. AND t.template_id LIKE '%' + #{templateId} + '%'
  3661. </if>
  3662. <if test="templateDesc != null and templateDesc != ''">
  3663. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  3664. </if>
  3665. ORDER BY t.template_id
  3666. </select>
  3667. <!-- 查询模板的所有检验项目(按order_id排序) -->
  3668. <select id="getTemplateItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3669. SELECT
  3670. d.ItemNo as itemNo,
  3671. p.ItemDesc as itemDesc,
  3672. d.default_value as defaultValue,
  3673. d.max_value as maxValue,
  3674. d.min_value as minValue,
  3675. p.ValueType as valueType,
  3676. p.ValueType_DB as valueTypeDb,
  3677. d.order_id as orderId
  3678. FROM qc_template_detailed d
  3679. LEFT JOIN eam_properties_item p
  3680. ON d.site = p.site
  3681. AND d.bu_no = p.bu_no
  3682. AND d.ItemNo = p.ItemNo
  3683. WHERE d.site = #{site}
  3684. AND d.bu_no = #{buNo}
  3685. AND d.template_id = #{templateId}
  3686. ORDER BY COALESCE(d.order_id, 99999) ASC, d.ItemNo ASC
  3687. </select>
  3688. <!-- 查询检验单已有的项目编码列表 -->
  3689. <select id="getExistingItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  3690. SELECT item_no
  3691. FROM qc_ipqc_detailed_record
  3692. WHERE site = #{site}
  3693. AND bu_no = #{buNo}
  3694. AND inspection_no = #{inspectionNo}
  3695. </select>
  3696. <!-- ======================== IQC检验项目操作和模板导入 ======================== -->
  3697. <!-- 查询IQC可选的检验项目 -->
  3698. <select id="getIQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3699. SELECT
  3700. ItemNo as itemNo,
  3701. ItemDesc as itemDesc,
  3702. DefaultValue as defaultValue,
  3703. MaxValue as maxValue,
  3704. MinValue as minValue,
  3705. ValueType as valueType,
  3706. ValueType_DB as valueTypeDb
  3707. FROM eam_properties_item
  3708. WHERE site = #{site}
  3709. AND bu_no = #{buNo}
  3710. AND inspection_type_no = '105'
  3711. <if test="itemNo != null and itemNo != ''">
  3712. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3713. </if>
  3714. <if test="itemDesc != null and itemDesc != ''">
  3715. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3716. </if>
  3717. AND ItemNo NOT IN (
  3718. SELECT item_no
  3719. FROM qc_iqc_detailed_record
  3720. WHERE site = #{site}
  3721. AND bu_no = #{buNo}
  3722. AND inspection_no = #{inspectionNo}
  3723. )
  3724. ORDER BY ItemNo
  3725. </select>
  3726. <!-- 查询IQC已选的检验项目 -->
  3727. <select id="getIQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3728. SELECT
  3729. d.item_no as itemNo,
  3730. d.item_desc as itemDesc
  3731. FROM qc_iqc_detailed_record d
  3732. WHERE d.site = #{site}
  3733. AND d.bu_no = #{buNo}
  3734. AND d.inspection_no = #{inspectionNo}
  3735. ORDER BY d.item_no
  3736. </select>
  3737. <!-- 查询当前IQC检验单已有的项目 -->
  3738. <select id="getExistingIQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3739. SELECT TOP 1
  3740. template_id as templateId,
  3741. item_no as itemNo,
  3742. foreign_flag as foreignFlag
  3743. FROM qc_iqc_detailed_record
  3744. WHERE site = #{site}
  3745. AND bu_no = #{buNo}
  3746. AND inspection_no = #{inspectionNo}
  3747. </select>
  3748. <!-- 插入IQC检验项目 -->
  3749. <insert id="insertIQCItemDetail" parameterType="java.util.Map">
  3750. INSERT INTO qc_iqc_detailed_record (
  3751. inspection_no,
  3752. template_id,
  3753. item_no,
  3754. item_desc,
  3755. default_value,
  3756. min_value,
  3757. max_value,
  3758. value_type_db,
  3759. value_type,
  3760. site,
  3761. bu_no,
  3762. foreign_flag,
  3763. order_id
  3764. ) VALUES (
  3765. #{inspectionNo},
  3766. #{templateId},
  3767. #{itemNo},
  3768. #{itemDesc},
  3769. #{defaultValue},
  3770. #{minValue},
  3771. #{maxValue},
  3772. #{valueTypeDb},
  3773. #{valueType},
  3774. #{site},
  3775. #{buNo},
  3776. #{foreignFlag},
  3777. #{orderId}
  3778. )
  3779. </insert>
  3780. <!-- 获取IQC检验单中最大的order_id -->
  3781. <select id="getMaxOrderIdForIQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  3782. SELECT ISNULL(MAX(order_id), 0)
  3783. FROM qc_iqc_detailed_record
  3784. WHERE site = #{site}
  3785. AND bu_no = #{buNo}
  3786. AND inspection_no = #{inspectionNo}
  3787. </select>
  3788. <!-- 删除IQC检验项目 -->
  3789. <delete id="deleteIQCItemDetail" parameterType="java.util.Map">
  3790. DELETE FROM qc_iqc_detailed_record
  3791. WHERE site = #{site}
  3792. AND bu_no = #{buNo}
  3793. AND inspection_no = #{inspectionNo}
  3794. AND item_no = #{itemNo}
  3795. </delete>
  3796. <!-- 删除IQC检验项目的子明细 -->
  3797. <delete id="deleteIQCSubDetailByItem" parameterType="java.util.Map">
  3798. DELETE FROM qc_iqc_sub_detail_record
  3799. WHERE site = #{site}
  3800. AND bu_no = #{buNo}
  3801. AND inspection_no = #{inspectionNo}
  3802. AND item_no = #{itemNo}
  3803. </delete>
  3804. <!-- 查询IQC模板列表 -->
  3805. <select id="getIQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  3806. SELECT
  3807. t.template_id as templateId,
  3808. t.template_name as templateName,
  3809. t.template_remark as remark,
  3810. (SELECT COUNT(*) FROM qc_template_detailed d
  3811. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  3812. FROM qc_template t
  3813. WHERE t.site = #{site}
  3814. AND t.bu_no = #{buNo}
  3815. AND t.inspection_type_no = '105'
  3816. <if test="templateId != null and templateId != ''">
  3817. AND t.template_id LIKE '%' + #{templateId} + '%'
  3818. </if>
  3819. <if test="templateDesc != null and templateDesc != ''">
  3820. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  3821. </if>
  3822. ORDER BY t.template_id
  3823. </select>
  3824. <!-- 查询IQC检验单已有的项目编码 -->
  3825. <select id="getExistingIQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  3826. SELECT item_no
  3827. FROM qc_iqc_detailed_record
  3828. WHERE site = #{site}
  3829. AND bu_no = #{buNo}
  3830. AND inspection_no = #{inspectionNo}
  3831. </select>
  3832. <!-- ======================== FQC检验项目操作和模板导入 ======================== -->
  3833. <!-- 查询FQC可选的检验项目 -->
  3834. <select id="getFQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3835. SELECT
  3836. ItemNo as itemNo,
  3837. ItemDesc as itemDesc,
  3838. DefaultValue as defaultValue,
  3839. MaxValue as maxValue,
  3840. MinValue as minValue,
  3841. ValueType as valueType,
  3842. ValueType_DB as valueTypeDb
  3843. FROM eam_properties_item
  3844. WHERE site = #{site}
  3845. AND bu_no = #{buNo}
  3846. AND inspection_type_no = '107'
  3847. <if test="itemNo != null and itemNo != ''">
  3848. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3849. </if>
  3850. <if test="itemDesc != null and itemDesc != ''">
  3851. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3852. </if>
  3853. AND ItemNo NOT IN (
  3854. SELECT item_no
  3855. FROM qc_fqc_detailed_record
  3856. WHERE site = #{site}
  3857. AND bu_no = #{buNo}
  3858. AND inspection_no = #{inspectionNo}
  3859. )
  3860. ORDER BY ItemNo
  3861. </select>
  3862. <!-- 查询FQC已选的检验项目 -->
  3863. <select id="getFQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3864. SELECT
  3865. d.item_no as itemNo,
  3866. d.item_desc as itemDesc
  3867. FROM qc_fqc_detailed_record d
  3868. WHERE d.site = #{site}
  3869. AND d.bu_no = #{buNo}
  3870. AND d.inspection_no = #{inspectionNo}
  3871. ORDER BY d.item_no
  3872. </select>
  3873. <!-- 查询当前FQC检验单已有的项目 -->
  3874. <select id="getExistingFQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3875. SELECT TOP 1
  3876. template_id as templateId,
  3877. item_no as itemNo,
  3878. foreign_flag as foreignFlag
  3879. FROM qc_fqc_detailed_record
  3880. WHERE site = #{site}
  3881. AND bu_no = #{buNo}
  3882. AND inspection_no = #{inspectionNo}
  3883. </select>
  3884. <!-- 插入FQC检验项目 -->
  3885. <insert id="insertFQCItemDetail" parameterType="java.util.Map">
  3886. INSERT INTO qc_fqc_detailed_record (
  3887. inspection_no,
  3888. template_id,
  3889. item_no,
  3890. item_desc,
  3891. default_value,
  3892. min_value,
  3893. max_value,
  3894. value_type_db,
  3895. value_type,
  3896. site,
  3897. bu_no,
  3898. foreign_flag,
  3899. order_id
  3900. ) VALUES (
  3901. #{inspectionNo},
  3902. #{templateId},
  3903. #{itemNo},
  3904. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  3905. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  3906. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  3907. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  3908. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  3909. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  3910. #{site},
  3911. #{buNo},
  3912. #{foreignFlag},
  3913. #{orderId}
  3914. )
  3915. </insert>
  3916. <!-- 获取FQC检验单中最大的order_id -->
  3917. <select id="getMaxOrderIdForFQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  3918. SELECT ISNULL(MAX(order_id), 0)
  3919. FROM qc_fqc_detailed_record
  3920. WHERE site = #{site}
  3921. AND bu_no = #{buNo}
  3922. AND inspection_no = #{inspectionNo}
  3923. </select>
  3924. <!-- 删除FQC检验项目 -->
  3925. <delete id="deleteFQCItemDetail" parameterType="java.util.Map">
  3926. DELETE FROM qc_fqc_detailed_record
  3927. WHERE site = #{site}
  3928. AND bu_no = #{buNo}
  3929. AND inspection_no = #{inspectionNo}
  3930. AND item_no = #{itemNo}
  3931. </delete>
  3932. <!-- 删除FQC检验项目的子明细 -->
  3933. <delete id="deleteFQCSubDetailByItem" parameterType="java.util.Map">
  3934. DELETE FROM qc_fqc_sub_detail_record
  3935. WHERE site = #{site}
  3936. AND bu_no = #{buNo}
  3937. AND inspection_no = #{inspectionNo}
  3938. AND item_no = #{itemNo}
  3939. </delete>
  3940. <!-- 查询FQC模板列表 -->
  3941. <select id="getFQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  3942. SELECT
  3943. t.template_id as templateId,
  3944. t.template_name as templateName,
  3945. t.template_remark as remark,
  3946. (SELECT COUNT(*) FROM qc_template_detailed d
  3947. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  3948. FROM qc_template t
  3949. WHERE t.site = #{site}
  3950. AND t.bu_no = #{buNo}
  3951. AND t.inspection_type_no = '107'
  3952. <if test="templateId != null and templateId != ''">
  3953. AND t.template_id LIKE '%' + #{templateId} + '%'
  3954. </if>
  3955. <if test="templateDesc != null and templateDesc != ''">
  3956. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  3957. </if>
  3958. ORDER BY t.template_id
  3959. </select>
  3960. <!-- 查询FQC检验单已有的项目编码 -->
  3961. <select id="getExistingFQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  3962. SELECT item_no
  3963. FROM qc_fqc_detailed_record
  3964. WHERE site = #{site}
  3965. AND bu_no = #{buNo}
  3966. AND inspection_no = #{inspectionNo}
  3967. </select>
  3968. <!-- ======================== OQC检验项目操作和模板导入 ======================== -->
  3969. <!-- 查询OQC可选的检验项目 -->
  3970. <select id="getOQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  3971. SELECT
  3972. ItemNo as itemNo,
  3973. ItemDesc as itemDesc,
  3974. DefaultValue as defaultValue,
  3975. MaxValue as maxValue,
  3976. MinValue as minValue,
  3977. ValueType as valueType,
  3978. ValueType_DB as valueTypeDb
  3979. FROM eam_properties_item
  3980. WHERE site = #{site}
  3981. AND bu_no = #{buNo}
  3982. AND inspection_type_no = '109'
  3983. <if test="itemNo != null and itemNo != ''">
  3984. AND ItemNo LIKE '%' + #{itemNo} + '%'
  3985. </if>
  3986. <if test="itemDesc != null and itemDesc != ''">
  3987. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  3988. </if>
  3989. AND ItemNo NOT IN (
  3990. SELECT item_no
  3991. FROM qc_oqc_detailed_record
  3992. WHERE site = #{site}
  3993. AND bu_no = #{buNo}
  3994. AND inspection_no = #{inspectionNo}
  3995. )
  3996. ORDER BY ItemNo
  3997. </select>
  3998. <!-- 查询OQC已选的检验项目 -->
  3999. <select id="getOQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  4000. SELECT
  4001. d.item_no as itemNo,
  4002. d.item_desc as itemDesc
  4003. FROM qc_oqc_detailed_record d
  4004. WHERE d.site = #{site}
  4005. AND d.bu_no = #{buNo}
  4006. AND d.inspection_no = #{inspectionNo}
  4007. ORDER BY d.item_no
  4008. </select>
  4009. <!-- 查询当前OQC检验单已有的项目 -->
  4010. <select id="getExistingOQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  4011. SELECT TOP 1
  4012. template_id as templateId,
  4013. item_no as itemNo,
  4014. foreign_flag as foreignFlag
  4015. FROM qc_oqc_detailed_record
  4016. WHERE site = #{site}
  4017. AND bu_no = #{buNo}
  4018. AND inspection_no = #{inspectionNo}
  4019. </select>
  4020. <!-- 插入OQC检验项目 -->
  4021. <insert id="insertOQCItemDetail" parameterType="java.util.Map">
  4022. INSERT INTO qc_oqc_detailed_record (
  4023. inspection_no,
  4024. template_id,
  4025. item_no,
  4026. item_desc,
  4027. default_value,
  4028. min_value,
  4029. max_value,
  4030. value_type_db,
  4031. value_type,
  4032. site,
  4033. bu_no,
  4034. foreign_flag,
  4035. order_id
  4036. ) VALUES (
  4037. #{inspectionNo},
  4038. #{templateId},
  4039. #{itemNo},
  4040. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4041. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4042. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4043. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4044. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4045. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  4046. #{site},
  4047. #{buNo},
  4048. #{foreignFlag},
  4049. #{orderId}
  4050. )
  4051. </insert>
  4052. <!-- 获取OQC检验单中最大的order_id -->
  4053. <select id="getMaxOrderIdForOQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  4054. SELECT ISNULL(MAX(order_id), 0)
  4055. FROM qc_oqc_detailed_record
  4056. WHERE site = #{site}
  4057. AND bu_no = #{buNo}
  4058. AND inspection_no = #{inspectionNo}
  4059. </select>
  4060. <!-- 删除OQC检验项目 -->
  4061. <delete id="deleteOQCItemDetail" parameterType="java.util.Map">
  4062. DELETE FROM qc_oqc_detailed_record
  4063. WHERE site = #{site}
  4064. AND bu_no = #{buNo}
  4065. AND inspection_no = #{inspectionNo}
  4066. AND item_no = #{itemNo}
  4067. </delete>
  4068. <!-- 删除OQC检验项目的子明细 -->
  4069. <delete id="deleteOQCSubDetailByItem" parameterType="java.util.Map">
  4070. DELETE FROM qc_oqc_sub_detail_record
  4071. WHERE site = #{site}
  4072. AND bu_no = #{buNo}
  4073. AND inspection_no = #{inspectionNo}
  4074. AND item_no = #{itemNo}
  4075. </delete>
  4076. <!-- 查询OQC模板列表 -->
  4077. <select id="getOQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  4078. SELECT
  4079. t.template_id as templateId,
  4080. t.template_name as templateName,
  4081. t.template_remark as remark,
  4082. (SELECT COUNT(*) FROM qc_template_detailed d
  4083. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  4084. FROM qc_template t
  4085. WHERE t.site = #{site}
  4086. AND t.bu_no = #{buNo}
  4087. AND t.inspection_type_no = '109'
  4088. <if test="templateId != null and templateId != ''">
  4089. AND t.template_id LIKE '%' + #{templateId} + '%'
  4090. </if>
  4091. <if test="templateDesc != null and templateDesc != ''">
  4092. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  4093. </if>
  4094. ORDER BY t.template_id
  4095. </select>
  4096. <!-- 查询OQC检验单已有的项目编码 -->
  4097. <select id="getExistingOQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  4098. SELECT item_no
  4099. FROM qc_oqc_detailed_record
  4100. WHERE site = #{site}
  4101. AND bu_no = #{buNo}
  4102. AND inspection_no = #{inspectionNo}
  4103. </select>
  4104. <select id="getInspectionStandards" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  4105. select
  4106. site,
  4107. bu_no,
  4108. template_id,
  4109. item_no,
  4110. default_value,
  4111. min_value,
  4112. max_value,
  4113. condition,
  4114. collection_source,
  4115. seq_no
  4116. from qc_inspection_standards
  4117. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4118. </select>
  4119. <delete id="deleteInspectionStandard" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  4120. delete from qc_inspection_standards
  4121. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4122. </delete>
  4123. <insert id="saveInspectionStandard">
  4124. INSERT INTO qc_inspection_standards
  4125. (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
  4126. VALUES
  4127. <foreach collection="list" item="item" separator=",">
  4128. (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
  4129. </foreach>
  4130. </insert>
  4131. <select id="getInspectionTemplateDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  4132. select
  4133. site,
  4134. bu_no,
  4135. template_id,
  4136. item_no
  4137. <if test="flag == 'iqc'">
  4138. from qc_iqc_detailed_record
  4139. </if>
  4140. <if test="flag == 'ipqc'">
  4141. from qc_ipqc_detailed_record
  4142. </if>
  4143. <if test="flag == 'sqc'">
  4144. from qc_sqc_detailed_record
  4145. </if>
  4146. <if test="flag == 'fqc'">
  4147. from qc_fqc_detailed_record
  4148. </if>
  4149. <if test="flag == 'fai'">
  4150. from qc_fai_detailed_record
  4151. </if>
  4152. <if test="flag == 'fqas' or flag == 'oqc'">
  4153. from qc_oqc_detailed_record
  4154. </if>
  4155. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4156. order by order_id
  4157. </select>
  4158. <update id="updateEquipmentDataDetailInspectionNo" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
  4159. update Equipment_data_detail
  4160. set inspection_no = #{inspectionNo}
  4161. where id = #{id}
  4162. </update>
  4163. <delete id="deleteInspectionFiles" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4164. delete sys_oss
  4165. where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo}
  4166. </delete>
  4167. <select id="getUpItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
  4168. select
  4169. top 1
  4170. site,
  4171. bu_no,
  4172. template_id,
  4173. ItemNo,
  4174. order_id
  4175. from qc_template_detailed
  4176. where #{orderId} > order_id
  4177. and site = #{site}
  4178. and bu_no= #{buNo}
  4179. and template_id = #{templateId}
  4180. order by order_id desc
  4181. </select>
  4182. <select id="getDownItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
  4183. select
  4184. top 1
  4185. site,
  4186. bu_no,
  4187. template_id,
  4188. ItemNo,
  4189. order_id
  4190. from qc_template_detailed
  4191. where order_id > #{orderId}
  4192. and site = #{site}
  4193. and bu_no= #{buNo}
  4194. and template_id = #{templateId}
  4195. order by order_id
  4196. </select>
  4197. <update id="updateQcItemOrder">
  4198. update qc_template_detailed
  4199. set order_id=#{orderId}
  4200. where site = #{site}
  4201. and bu_no= #{buNo}
  4202. and template_id = #{templateId}
  4203. and ItemNo = #{itemNo}
  4204. </update>
  4205. <select id="selectInfoByInspectionNo" resultType="com.gaotao.modules.pms.data.PoOrderRollNoData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4206. select
  4207. site,
  4208. bu_no,
  4209. inspection_no
  4210. from po_order_roll_no
  4211. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4212. </select>
  4213. <update id="updateIQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4214. UPDATE qc_iqc_record
  4215. SET submit_flag = 'N',
  4216. state = '待检验',
  4217. cancel_check_by = #{updateBy},
  4218. cancel_check_date = getDate(),
  4219. submit_by = NULL
  4220. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4221. </update>
  4222. <update id="updateIQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4223. UPDATE qc_iqc_detailed_record
  4224. SET is_submit = 'N'
  4225. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4226. </update>
  4227. <update id="updateIQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4228. UPDATE qc_iqc_sub_detail_record
  4229. SET is_submit = 'N'
  4230. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4231. </update>
  4232. <update id="updatePartDefectTracking" statementType="CALLABLE">
  4233. {CALL UspUpdatePartDefectTracking(
  4234. #{site,mode=IN,jdbcType=VARCHAR},
  4235. #{buNo,mode=IN,jdbcType=VARCHAR},
  4236. #{partNo,mode=IN,jdbcType=VARCHAR},
  4237. #{supplierId,mode=IN,jdbcType=VARCHAR},
  4238. #{passFlag,mode=IN,jdbcType=BIT}
  4239. )}
  4240. </update>
  4241. <update id="updateFAIMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4242. UPDATE qc_fai_record
  4243. SET submit_flag = 'N',
  4244. state = '待检验',
  4245. cancel_check_by = #{updateBy},
  4246. cancel_check_date = getDate()
  4247. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4248. </update>
  4249. <update id="updateFAIDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4250. UPDATE qc_fai_detailed_record
  4251. SET is_submit = 'N'
  4252. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4253. </update>
  4254. <update id="updateFAISubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4255. UPDATE qc_fai_sub_detail_record
  4256. SET is_submit = 'N'
  4257. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4258. </update>
  4259. <update id="updateIPQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4260. UPDATE qc_ipqc_record
  4261. SET submit_flag = 'N',
  4262. state = '待检验',
  4263. cancel_check_by = #{updateBy},
  4264. cancel_check_date = getDate(),
  4265. submit_by = NULL
  4266. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4267. </update>
  4268. <update id="updateIPQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4269. UPDATE qc_ipqc_detailed_record
  4270. SET is_submit = 'N'
  4271. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4272. </update>
  4273. <update id="updateIPQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4274. UPDATE qc_ipqc_sub_detail_record
  4275. SET is_submit = 'N'
  4276. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4277. </update>
  4278. <update id="updateSQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4279. UPDATE qc_sqc_record
  4280. SET submit_flag = 'N',
  4281. state = '待检验',
  4282. cancel_check_by = #{updateBy},
  4283. cancel_check_date = getDate(),
  4284. submit_by = NULL
  4285. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4286. </update>
  4287. <update id="updateSQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4288. UPDATE qc_sqc_detailed_record
  4289. SET is_submit = 'N'
  4290. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4291. </update>
  4292. <update id="updateSQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4293. UPDATE qc_sqc_sub_detail_record
  4294. SET is_submit = 'N'
  4295. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4296. </update>
  4297. <update id="updateFQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4298. UPDATE qc_fqc_record
  4299. SET submit_flag = 'N',
  4300. state = '待检验',
  4301. cancel_check_by = #{updateBy},
  4302. cancel_check_date = getDate(),
  4303. submit_by = NULL
  4304. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4305. </update>
  4306. <update id="updateFQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4307. UPDATE qc_fqc_detailed_record
  4308. SET is_submit = 'N'
  4309. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4310. </update>
  4311. <update id="updateFQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4312. UPDATE qc_fqc_sub_detail_record
  4313. SET is_submit = 'N'
  4314. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4315. </update>
  4316. <update id="updateFQASMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4317. UPDATE qc_oqc_record
  4318. SET submit_flag = 'N',
  4319. state = '待检验',
  4320. cancel_check_by = #{updateBy},
  4321. cancel_check_date = getDate(),
  4322. submit_by = NULL
  4323. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4324. </update>
  4325. <update id="updateFQASDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4326. UPDATE qc_oqc_detailed_record
  4327. SET is_submit = 'N'
  4328. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4329. </update>
  4330. <update id="updateFQASSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4331. UPDATE qc_oqc_sub_detail_record
  4332. SET is_submit = 'N'
  4333. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4334. </update>
  4335. <delete id="deleteReceivingTaskByInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4336. delete receiving_task
  4337. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  4338. </delete>
  4339. <delete id="deleteObjectFile">
  4340. delete from sys_oss where id = #{id}
  4341. </delete>
  4342. <!-- 获取用户角色列表 -->
  4343. <select id="getUserRoleList" resultType="com.gaotao.modules.sys.entity.SysRoleEntity">
  4344. SELECT
  4345. role_id,
  4346. role_name
  4347. FROM sys_role
  4348. </select>
  4349. <select id="getOperatorListByOrder" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  4350. SELECT
  4351. a.user_id, a.username AS adminID, a.email, a.mobile AS phone, a.user_display AS adminName,
  4352. d.role_id, e.role_name, c.site, c.bu_no,
  4353. -- 获取计划工单数
  4354. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) AS planOrderCount,
  4355. -- 获取实际工单数
  4356. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) AS actualOrderCount,
  4357. -- 负荷率(%)
  4358. CASE
  4359. WHEN dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) = 0 THEN 0
  4360. ELSE
  4361. CAST(
  4362. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) * 100.0 /
  4363. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username)
  4364. AS DECIMAL(5,2))
  4365. END AS load_rate
  4366. FROM
  4367. sys_user AS a
  4368. LEFT JOIN AccessSite AS b ON a.username = b.userID
  4369. LEFT JOIN AccessBu AS c ON b.userID = c.username AND b.site = c.site
  4370. LEFT JOIN sys_user_role AS d ON a.user_id = d.user_id
  4371. LEFT JOIN sys_role AS e ON d.role_id = e.role_id
  4372. <where>
  4373. b.site = #{site} and c.bu_no = #{buNo}
  4374. <if test = "adminID != null and adminID != ''">
  4375. AND a.username LIKE '%' + #{adminID} + '%'
  4376. </if>
  4377. <if test = "adminName != null and adminName != ''">
  4378. AND a.user_display LIKE '%' + #{adminName} + '%'
  4379. </if>
  4380. <if test = "roleId != null and roleId != ''">
  4381. AND d.role_id = #{roleId}
  4382. </if>
  4383. <if test = "date != null and classesCode != null and classesCode != ''">
  4384. AND a.username IN (
  4385. SELECT tpm_scheduling_record.admin_id
  4386. FROM tpm_scheduling
  4387. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  4388. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  4389. )
  4390. </if>
  4391. <if test = "date != null and (classesCode == null or classesCode == '')">
  4392. AND a.username IN (
  4393. SELECT tpm_scheduling_record.admin_id
  4394. FROM tpm_scheduling
  4395. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  4396. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling_record.isHoliday = 'N'
  4397. )
  4398. </if>
  4399. <if test = "classesCode != null and classesCode != '' and date == null">
  4400. AND a.username IN (
  4401. SELECT tpm_scheduling_record.admin_id
  4402. FROM tpm_scheduling
  4403. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  4404. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  4405. )
  4406. </if>
  4407. </where>
  4408. order by load_rate desc
  4409. </select>
  4410. <!-- 查询OQC基础数据 -->
  4411. <select id="selectOQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4412. SELECT
  4413. qir.inspection_no,
  4414. qir.state,
  4415. qir.create_date as taskDate,
  4416. qir.roll_no,
  4417. qir.part_no,
  4418. dbo.Get_Part_DescSpec(qir.site, qir.part_no) as part_desc,
  4419. qir.roll_qty,
  4420. qir.print_flag,
  4421. qir.inspector_by,
  4422. qir.site,
  4423. qir.bu_no,
  4424. qir.roll_count
  4425. FROM qc_oqc_record as qir
  4426. LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
  4427. WHERE qir.site in (select site from AccessSite where userID = #{userName})
  4428. and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
  4429. and qir.detail_flag = 'N'
  4430. </select>
  4431. <select id="selectFQASPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4432. SELECT
  4433. qat.site,
  4434. qat.bu_no,
  4435. qat.attribute_no,
  4436. qat.template_id,
  4437. qat.sampling_level_no,
  4438. qsil.sampling_level_desc,
  4439. qat.inspection_cycle,
  4440. qat.sampling_programme_no,
  4441. qsip.sampling_programme_desc,
  4442. qat.AQL,
  4443. qat.AC,
  4444. qat.RE,
  4445. qt.default_sampling_quantity,
  4446. qt.default_sampling_proportion
  4447. FROM qc_attribute_template as qat
  4448. LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
  4449. LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
  4450. LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
  4451. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  4452. AND qat.attribute_no = #{partNo}
  4453. AND qat.attribute_type = #{attributeType}
  4454. AND qt.inspection_type_no = #{inspectionTypeNo}
  4455. </select>
  4456. <!-- 新增OQC明细记录信息 -->
  4457. <insert id="saveFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4458. INSERT INTO qc_oqc_detailed_record
  4459. (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE,
  4460. item_no, item_desc, object_id, object_desc, default_value, min_value, max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id, custom1, custom2, custom3)
  4461. VALUES
  4462. (#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL},
  4463. #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo}, #{orderId}, #{custom1}, #{custom2}, #{custom3})
  4464. </insert>
  4465. <!-- 修改OQC检验记录 -->
  4466. <update id="updateFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4467. UPDATE qc_oqc_record
  4468. SET inspection_type_no = #{inspectionTypeNo},
  4469. sampling_qty = #{samplingQty},
  4470. inspection_cycle = #{inspectionCycle},
  4471. part_desc = #{partDesc},
  4472. detail_flag = 'Y',
  4473. pass_qty = #{samplingQty},
  4474. not_pass_qty = 0
  4475. <if test="inspectorBy != null and inspectorBy != ''">
  4476. , inspector_by = #{inspectorBy}
  4477. </if>
  4478. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4479. </update>
  4480. <!-- 查询OQC主记录信息 -->
  4481. <select id="qcOQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4482. SELECT
  4483. a.inspection_no,
  4484. a.site,
  4485. a.bu_no,
  4486. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  4487. a.state,
  4488. a.inspection_result,
  4489. a.create_date as taskDate,
  4490. a.create_date,
  4491. a.inspection_type_no,
  4492. a.inspection_cycle,
  4493. a.part_no,
  4494. d.PartDescription as partDesc,
  4495. d.umid as umId,
  4496. um.UMName as umName,
  4497. d.spec,
  4498. a.inspection_remark,
  4499. a.roll_qty,
  4500. a.sampling_qty,
  4501. a.disposal_measures,
  4502. a.disposal_remark,
  4503. a.inspector_date as inspectorDate,
  4504. a.submit_date,
  4505. isnull(sub.user_display, a.submit_by) as submitBy,
  4506. a.inspector_no,
  4507. u.user_display as inspectorName,
  4508. a.submit_flag,
  4509. a.roll_no,
  4510. a.roll_count,
  4511. a.action_date,
  4512. isnull(ab.user_display, a.action_by) as actionBy,
  4513. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  4514. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  4515. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  4516. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  4517. a.pass_qty,
  4518. a.not_pass_qty,
  4519. a.batch_qualified_qty,
  4520. a.create_by as createBy,
  4521. isnull(u2.user_display, a.create_by) as createByName,
  4522. a.customer_no,
  4523. dbo.Get_CustomerDesc(a.site, a.customer_no) as customerName,
  4524. a.po_orderNo,
  4525. a.po_itemNo,
  4526. a.document_no,
  4527. a.release_no as releaseNo,
  4528. a.line_no,
  4529. a.operation_desc,
  4530. isnull(a.inspector_by, a.create_by) as inspectorBy,
  4531. isnull(u_ins.user_display, isnull(a.inspector_by, a.create_by)) as inspectorByName
  4532. FROM qc_oqc_record as a
  4533. left join sys_user as u on a.inspector_no = u.username
  4534. left join sys_user as ab on a.action_by = ab.username
  4535. left join sys_user as sub on a.submit_by = sub.username
  4536. inner join part as d on a.site = d.site and a.part_no = d.partNo
  4537. left join um as um on d.umid = um.UMID
  4538. left join sys_user as u2 on a.create_by = u2.username
  4539. left join sys_user as u_ins on isnull(a.inspector_by, a.create_by) = u_ins.username
  4540. <where>
  4541. a.site in (select site from AccessSite where userID = #{query.userName})
  4542. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  4543. <if test="query.buNo != null and query.buNo != ''">
  4544. AND a.bu_no = #{query.buNo}
  4545. </if>
  4546. <if test="query.buDesc != null and query.buDesc != ''">
  4547. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  4548. </if>
  4549. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  4550. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  4551. </if>
  4552. <if test = "query.states != null and query.states.size > 0">
  4553. AND a.state in
  4554. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  4555. #{item}
  4556. </foreach>
  4557. </if>
  4558. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  4559. AND a.inspection_result = #{query.inspectionResult}
  4560. </if>
  4561. <if test = "query.partNo != null and query.partNo != ''">
  4562. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  4563. </if>
  4564. <if test = "query.partDesc != null and query.partDesc != ''">
  4565. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  4566. </if>
  4567. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  4568. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  4569. </if>
  4570. <if test="query.startDate != null">
  4571. AND a.inspector_date >= #{query.startDate}
  4572. </if>
  4573. <if test="query.endDate != null">
  4574. AND #{query.endDate} >= a.inspector_date
  4575. </if>
  4576. <if test="query.startDate2 != null">
  4577. AND a.create_date >= #{query.startDate2}
  4578. </if>
  4579. <if test="query.endDate2 != null">
  4580. AND #{query.endDate2} >= a.create_date
  4581. </if>
  4582. <if test = "query.customerNo != null and query.customerNo != ''">
  4583. AND a.customer_no LIKE '%' + #{query.customerNo} + '%'
  4584. </if>
  4585. <if test = "query.customerName != null and query.customerName != ''">
  4586. AND dbo.Get_CustomerDesc(a.site, a.customer_no) LIKE '%' + #{query.customerName} + '%'
  4587. </if>
  4588. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  4589. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  4590. </if>
  4591. <if test = "query.spec != null and query.spec != ''">
  4592. AND d.spec LIKE '%' + #{query.spec} + '%'
  4593. </if>
  4594. <if test = "query.operationDesc != null and query.operationDesc != ''">
  4595. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  4596. </if>
  4597. </where>
  4598. ORDER BY a.inspection_no desc,
  4599. CASE WHEN a.state = '待检验' THEN 1
  4600. WHEN a.state = '待审核' THEN 2
  4601. WHEN a.state = '已完成' THEN 3
  4602. END, a.create_date desc
  4603. </select>
  4604. <!-- IQC明细记录查询 -->
  4605. <select id="fqasDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4606. SELECT
  4607. a.site,
  4608. a.bu_no,
  4609. a.inspection_no,
  4610. a.template_id,
  4611. a.sampling_level_no,
  4612. a.sampling_level_desc,
  4613. a.sampling_programme_no,
  4614. a.sampling_programme_desc,
  4615. a.AQL,
  4616. a.AC,
  4617. a.RE,
  4618. a.item_no,
  4619. a.item_desc,
  4620. a.object_id,
  4621. a.object_desc,
  4622. a.default_value,
  4623. a.min_value,
  4624. a.max_value,
  4625. a.text_value,
  4626. a.number_value,
  4627. a.value_type_db,
  4628. a.value_type,
  4629. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  4630. a.item_remark as itemRemark,
  4631. a.custom1,
  4632. a.custom2,
  4633. a.custom3,
  4634. a.is_submit,
  4635. a.unqualified_quantity,
  4636. dbo.qc_get_fqas_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  4637. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  4638. c.method_no,
  4639. c.method_name,
  4640. c.method_remark,
  4641. sw.color_code as qcSpecWarningColorCode,
  4642. sw.threshold_value as qcSpecWarningThresholdValue,
  4643. a.sampling_qty,
  4644. (SELECT TOP 1 epi.collection_flag
  4645. FROM eam_properties_item epi
  4646. WHERE epi.site = a.site
  4647. AND epi.bu_no = a.bu_no
  4648. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  4649. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  4650. epi.inspection_type_no) AS collectionFlag,
  4651. (SELECT TOP 1 epi.image_flag
  4652. FROM eam_properties_item epi
  4653. WHERE epi.site = a.site
  4654. AND epi.bu_no = a.bu_no
  4655. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  4656. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  4657. epi.inspection_type_no) AS imageFlag,
  4658. (SELECT TOP 1 epi.data_flag
  4659. FROM eam_properties_item epi
  4660. WHERE epi.site = a.site
  4661. AND epi.bu_no = a.bu_no
  4662. AND RTRIM(epi.ItemNo) = RTRIM(a.item_no)
  4663. ORDER BY CASE WHEN RTRIM(ISNULL(epi.inspection_type_no, '')) = RTRIM(ISNULL(r.inspection_type_no, '')) THEN 0 ELSE 1 END,
  4664. epi.inspection_type_no) AS dataFlag
  4665. FROM qc_oqc_detailed_record as a
  4666. LEFT JOIN qc_oqc_record as r on a.site = r.site and a.bu_no = r.bu_no and a.inspection_no = r.inspection_no
  4667. OUTER APPLY (
  4668. SELECT TOP 1
  4669. w.color_code,
  4670. w.threshold_value
  4671. FROM qc_spec_warning w
  4672. WHERE w.site = a.site
  4673. AND w.bu_no = a.bu_no
  4674. AND w.part_no = r.part_no
  4675. AND w.item_no = a.item_no
  4676. AND w.inspection_type_no = r.inspection_type_no
  4677. ORDER BY w.threshold_value
  4678. ) sw
  4679. LEFT JOIN qc_method_item as b on a.site = b.site and a.item_no = b.ItemNo and a.bu_no = b.bu_no
  4680. LEFT JOIN qc_method as c on b.site = c.site and b.method_no = c.method_no and b.bu_no = c.bu_no
  4681. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  4682. ORDER BY COALESCE(a.order_id, 99999) ASC
  4683. </select>
  4684. <!-- 查询FQAS的子明细 -->
  4685. <select id="selectFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  4686. SELECT
  4687. site,
  4688. bu_no,
  4689. sub_detail_value,
  4690. sampling_location,
  4691. is_submit,
  4692. sampling_location_b,
  4693. num,
  4694. sub_detail_value_b,
  4695. sub_detail_value_c,
  4696. sub_detail_value_d,
  4697. sub_detail_value_e,
  4698. file_name,
  4699. is_transfer,
  4700. is_qualified,
  4701. defect_qty,
  4702. roll_no,
  4703. CONVERT(VARCHAR(19), create_time, 120) AS createTime
  4704. FROM qc_oqc_sub_detail_record
  4705. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  4706. </select>
  4707. <select id="getSupplier" parameterType="java.lang.String" resultType="com.gaotao.modules.base.entity.SupplierData">
  4708. SELECT
  4709. site,
  4710. SupplierID,
  4711. SupplierName
  4712. FROM Supplier
  4713. WHERE site = #{site} and SupplierID = #{supplierID} and Active = #{active}
  4714. </select>
  4715. <!-- 修改FQAS主记录信息 -->
  4716. <update id="updateFQASMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4717. UPDATE qc_oqc_record
  4718. SET disposal_measures = #{disposalMeasures},
  4719. disposal_remark = #{disposalRemark},
  4720. inspection_result = #{inspectionResult},
  4721. inspector_no = #{inspectorNo},
  4722. state = #{state},
  4723. inspection_remark = #{inspectionRemark},
  4724. inspector_date = #{inspectorDate,jdbcType=TIMESTAMP},
  4725. roll_count = #{rollCount,jdbcType=DECIMAL},
  4726. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  4727. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  4728. pass_qty = #{passQty,jdbcType=DECIMAL},
  4729. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  4730. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL}
  4731. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  4732. </update>
  4733. <!-- 修改FQAS明细记录信息 -->
  4734. <update id="updateFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4735. UPDATE qc_oqc_detailed_record
  4736. SET item_result = #{itemResult},
  4737. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  4738. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  4739. text_value = #{textValue},
  4740. number_value = #{numberValue,jdbcType=DECIMAL},
  4741. default_value = #{defaultValue},
  4742. min_value = #{minValue,jdbcType=DECIMAL},
  4743. max_value = #{maxValue,jdbcType=DECIMAL},
  4744. item_remark = #{itemRemark},
  4745. custom1 = #{custom1},
  4746. custom2 = #{custom2},
  4747. custom3 = #{custom3}
  4748. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  4749. </update>
  4750. <update id="patchFQASDetailedItemResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4751. UPDATE qc_oqc_detailed_record
  4752. <set>
  4753. <if test="itemResult != null and itemResult != ''">item_result = #{itemResult},</if>
  4754. <if test="unqualifiedQuantity != null">unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},</if>
  4755. <if test="numberValue != null">number_value = #{numberValue,jdbcType=DECIMAL},</if>
  4756. <if test="textValue != null">text_value = #{textValue},</if>
  4757. </set>
  4758. WHERE inspection_no = #{inspectionNo}
  4759. and RTRIM(item_no) = RTRIM(#{itemNo})
  4760. and site = #{site}
  4761. and bu_no = #{buNo}
  4762. </update>
  4763. <!-- 查询FQAS主记录信息 -->
  4764. <select id="getFQASInspectionRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4765. SELECT
  4766. site,
  4767. bu_no,
  4768. inspection_no,
  4769. not_pass_qty,
  4770. roll_count,
  4771. inspection_result,
  4772. disposal_measures,
  4773. part_no
  4774. FROM qc_oqc_record
  4775. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4776. </select>
  4777. <!-- 修改FQAS主记录标识为已提交 -->
  4778. <update id="updateFQASMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4779. UPDATE qc_oqc_record
  4780. SET submit_flag = 'Y',
  4781. state = '已完成',
  4782. submit_date = getDate(),
  4783. submit_by = #{updateBy}
  4784. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4785. </update>
  4786. <!-- 修改FQAS明细记录标识为已提交 -->
  4787. <update id="updateFQASDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4788. UPDATE qc_oqc_detailed_record
  4789. SET is_submit = 'Y'
  4790. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4791. </update>
  4792. <!-- 修改FQAS子明细记录标识为已提交 -->
  4793. <update id="updateFQASSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4794. UPDATE qc_oqc_sub_detail_record
  4795. SET is_submit = 'Y'
  4796. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4797. </update>
  4798. <!-- 查询FQAS检验记录是否已提交 -->
  4799. <select id="checkFQASIsSubmit" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4800. SELECT submit_flag
  4801. FROM qc_oqc_record
  4802. WHERE inspection_no = #{inspectionNo} and site = #{site}
  4803. </select>
  4804. <!-- 删除FQAS子明细的老数据 -->
  4805. <delete id="delFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  4806. DELETE FROM qc_oqc_sub_detail_record
  4807. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  4808. </delete>
  4809. <!-- 新增FQAS子明细信息 -->
  4810. <insert id="saveFQASSubDetailed">
  4811. INSERT INTO qc_oqc_sub_detail_record
  4812. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e, file_name, is_transfer, is_qualified, defect_qty, roll_no, create_time)
  4813. VALUES
  4814. <foreach collection="list" item="item" separator=",">
  4815. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE}, #{item.fileName}, #{item.isTransfer}, #{item.isQualified}, #{item.defectQty}, #{item.rollNo}, getDate())
  4816. </foreach>
  4817. </insert>
  4818. <!-- 删除FQAS检验记录 -->
  4819. <delete id="deleteFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4820. DELETE FROM qc_oqc_record
  4821. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4822. </delete>
  4823. <!-- 删除FQAS明细记录信息 -->
  4824. <delete id="deleteFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4825. DELETE FROM qc_oqc_detailed_record
  4826. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4827. </delete>
  4828. <!-- 删除FQAS子明细记录信息 -->
  4829. <delete id="deleteFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4830. DELETE FROM qc_oqc_sub_detail_record
  4831. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4832. </delete>
  4833. <!-- 查询FQAS(OQC)检验单当前状态 -->
  4834. <select id="getFQASRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4835. SELECT submit_flag, state
  4836. FROM qc_oqc_record
  4837. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4838. </select>
  4839. <update id="actionFQASInspection" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4840. update qc_oqc_record
  4841. set action_date = getDate(),
  4842. action_by = #{actionBy},
  4843. state = #{state}
  4844. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4845. </update>
  4846. <update id="updateSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4847. update
  4848. <if test = "inspectionTypeNo == '105'">
  4849. qc_iqc_record
  4850. </if>
  4851. <if test = "inspectionTypeNo == '108'">
  4852. qc_oqc_record
  4853. </if>
  4854. set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
  4855. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4856. </update>
  4857. <update id="updateDetailSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  4858. update
  4859. <if test = "inspectionTypeNo == '105'">
  4860. qc_iqc_detailed_record
  4861. </if>
  4862. <if test = "inspectionTypeNo == '108'">
  4863. qc_oqc_detailed_record
  4864. </if>
  4865. set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
  4866. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4867. </update>
  4868. <!-- 获取审核人员列表 -->
  4869. <select id="getCheckerList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  4870. SELECT
  4871. a.user_id,
  4872. a.username as adminID,
  4873. a.email,
  4874. a.mobile as phone,
  4875. a.user_display as adminName,
  4876. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  4877. d.role_id,
  4878. e.role_name
  4879. FROM sys_user as a
  4880. LEFT JOIN AccessSite as b on a.username = b.userID
  4881. LEFT JOIN AccessBu as c on b.userID = c.username and b.site = c.site
  4882. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  4883. LEFT JOIN sys_role as e on d.role_id = e.role_id
  4884. <where>
  4885. b.site = #{site} and c.bu_no = #{buNo}
  4886. <if test = "adminID != null and adminID != ''">
  4887. AND a.username LIKE '%' + #{adminID}+'%'
  4888. </if>
  4889. <if test = "adminName != null and adminName != ''">
  4890. AND a.user_display LIKE '%' + #{adminName}+'%'
  4891. </if>
  4892. <if test = "buDesc != null and buDesc != ''">
  4893. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  4894. </if>
  4895. <if test = "roleId != null and roleId != ''">
  4896. AND d.role_id = #{roleId}
  4897. </if>
  4898. </where>
  4899. </select>
  4900. <!-- ================================================= SOP清单相关SQL ================================================= -->
  4901. <!-- SOP清单查询 -->
  4902. <select id="sopListSearch" resultType="map">
  4903. <!-- SELECT-->
  4904. <!-- ps.site,-->
  4905. <!-- ps.bu_no as buNo,-->
  4906. <!-- ps.part_no as partNo,-->
  4907. <!-- ps.sop_no as sopNo,-->
  4908. <!-- ps.sop_name as sopName,-->
  4909. <!-- ps.sop_url as sopUrl,-->
  4910. <!-- ps.version,-->
  4911. <!-- ps.sop_status as sopStatus,-->
  4912. <!-- ps.phase_in_date as phaseInDate,-->
  4913. <!-- ps.phase_out_date as phaseOutDate,-->
  4914. <!-- ps.created_by as createdBy,-->
  4915. <!-- ps.creation_date as creationDate,-->
  4916. <!-- ps.sop_type as sopType,-->
  4917. <!-- ps.operation_desc as operationDesc-->
  4918. <!-- FROM part_sop ps-->
  4919. <!-- <where>-->
  4920. <!-- <if test="params.site != null and params.site != ''">-->
  4921. <!-- AND ps.site = #{params.site}-->
  4922. <!-- </if>-->
  4923. <!-- <if test="params.partNo != null and params.partNo != ''">-->
  4924. <!-- AND ps.part_no = #{params.partNo}-->
  4925. <!-- </if>-->
  4926. <!-- </where>-->
  4927. <!-- ORDER BY ps.creation_date DESC-->
  4928. SELECT DISTINCT
  4929. site,
  4930. buNo,
  4931. partNo,
  4932. sopNo,
  4933. sopName,
  4934. sopUrl,
  4935. [version],
  4936. sopStatus,
  4937. phaseInDate,
  4938. phaseOutDate,
  4939. createdBy,
  4940. creationDate,
  4941. sopType,
  4942. operationDesc
  4943. FROM (
  4944. -- 来源1: part_sop(零件SOP)
  4945. SELECT
  4946. ps.site,
  4947. ps.bu_no AS buNo,
  4948. ps.part_no AS partNo,
  4949. ps.sop_no AS sopNo,
  4950. ps.sop_name AS sopName,
  4951. ps.sop_url AS sopUrl,
  4952. ps.[version ] AS [version],
  4953. ps.sop_status AS sopStatus,
  4954. ps.phase_in_date AS phaseInDate,
  4955. ps.phase_out_date AS phaseOutDate,
  4956. ps.created_by AS createdBy,
  4957. ps.creation_date AS creationDate,
  4958. ps.sop_type AS sopType,
  4959. ps.operation_desc AS operationDesc
  4960. FROM part_sop ps
  4961. WHERE ps.site = #{params.site}
  4962. AND ps.part_no = #{params.partNo}
  4963. UNION ALL
  4964. -- 来源2: file_management(公共生产文件 或 订单关联文件)
  4965. SELECT
  4966. fm.site,
  4967. fm.bu_no AS buNo,
  4968. '' AS partNo,
  4969. fm.file_no AS sopNo,
  4970. fm.file_name AS sopName,
  4971. fm.url_add_ress AS sopUrl,
  4972. fm.sop_rev_no AS [version],
  4973. fm.status AS sopStatus,
  4974. fm.phase_in_date AS phaseInDate,
  4975. fm.phase_out_date AS phaseOutDate,
  4976. fm.created_by AS createdBy,
  4977. fm.create_date AS creationDate,
  4978. fm.file_type AS sopType,
  4979. fm.item_no AS operationDesc
  4980. FROM file_management fm
  4981. WHERE fm.site = #{params.site}
  4982. AND fm.file_type = '生产'
  4983. AND (
  4984. ISNULL(fm.public_flag, 'N') = 'Y'
  4985. OR fm.order_no = #{params.orderNo}
  4986. )
  4987. ) AS CombinedResults
  4988. </select>
  4989. <!-- 查询检验页面的SOP文件列表(从file_management表) -->
  4990. <select id="searchQcSopFileList" resultType="map">
  4991. <!-- SELECT DISTINCT-->
  4992. <!-- fm.ID AS id,-->
  4993. <!-- fm.url_add_ress AS sopUrl,-->
  4994. <!-- fm.create_date AS creationDate,-->
  4995. <!-- fm.file_name AS sopName,-->
  4996. <!-- fm.new_file_name AS newFileName,-->
  4997. <!-- fm.created_by AS createdBy,-->
  4998. <!-- fm.file_type AS fileType,&#45;&#45;-->
  4999. <!-- fm.file_suffix AS fileSuffix,-->
  5000. <!-- fm.sop_rev_no AS version,-->
  5001. <!-- fm.phase_in_date AS phaseInDate,-->
  5002. <!-- fm.phase_out_date AS phaseOutDate-->
  5003. <!-- FROM file_management fm-->
  5004. SELECT DISTINCT
  5005. site,
  5006. buNo,
  5007. partNo,
  5008. sopNo,
  5009. sopName,
  5010. sopUrl,
  5011. [version],
  5012. sopStatus,
  5013. phaseInDate,
  5014. phaseOutDate,
  5015. createdBy,
  5016. creationDate,
  5017. sopType as fileType,
  5018. operationDesc
  5019. FROM (
  5020. -- 来源1: part_sop(零件SOP)
  5021. SELECT
  5022. ps.site,
  5023. ps.bu_no AS buNo,
  5024. ps.part_no AS partNo,
  5025. ps.sop_no AS sopNo,
  5026. ps.sop_name AS sopName,
  5027. ps.sop_url AS sopUrl,
  5028. ps.[version ] AS [version],
  5029. ps.sop_status AS sopStatus,
  5030. ps.phase_in_date AS phaseInDate,
  5031. ps.phase_out_date AS phaseOutDate,
  5032. ps.created_by AS createdBy,
  5033. ps.creation_date AS creationDate,
  5034. ps.sop_type AS sopType,
  5035. ps.operation_desc AS operationDesc
  5036. FROM part_sop ps
  5037. WHERE ps.site = #{params.site}
  5038. AND ps.part_no = #{params.partNo}
  5039. UNION ALL
  5040. -- 来源2: file_management(公共生产文件 或 订单关联文件)
  5041. SELECT
  5042. fm.site,
  5043. fm.bu_no AS buNo,
  5044. '' AS partNo,
  5045. fm.file_no AS sopNo,
  5046. fm.file_name AS sopName,
  5047. fm.url_add_ress AS sopUrl,
  5048. fm.sop_rev_no AS [version],
  5049. fm.status AS sopStatus,
  5050. fm.phase_in_date AS phaseInDate,
  5051. fm.phase_out_date AS phaseOutDate,
  5052. fm.created_by AS createdBy,
  5053. fm.create_date AS creationDate,
  5054. fm.file_type AS sopType,
  5055. fm.item_no AS operationDesc
  5056. FROM file_management fm
  5057. WHERE fm.site = #{params.site}
  5058. AND fm.file_type = '质量'
  5059. AND (
  5060. ISNULL(fm.public_flag, 'N') = 'Y'
  5061. OR fm.order_no = #{params.orderNo}
  5062. )
  5063. ) AS CombinedResults
  5064. </select>
  5065. <!-- 查询可用的SOP文件 -->
  5066. <select id="sopAvailableFiles" resultType="map">
  5067. SELECT
  5068. A.site,
  5069. A.bu_no as buNo,
  5070. A.file_no as fileNo,
  5071. A.file_name as fileName,
  5072. A.file_type as fileType,
  5073. A.file_suffix as fileSuffix,
  5074. A.sop_rev_no as sopRevNo,
  5075. A.url_add_ress as sopUrl,
  5076. A.sop_type as sopType,
  5077. A.source_system as sourceSystem
  5078. FROM file_management A
  5079. LEFT JOIN part_sop B ON A.SITE = B.SITE AND A.BU_NO = B.BU_NO AND A.FILE_NO = B.sop_no and b.part_no = #{params.partNo}
  5080. <where>
  5081. B.SITE IS NULL
  5082. AND A.status_tb = 0
  5083. and ISNULL(public_flag,'N') = 'N'
  5084. <if test="params.site != null and params.site != ''">
  5085. AND A.site = #{params.site}
  5086. </if>
  5087. <if test="params.fileNo != null and params.fileNo != ''">
  5088. AND A.file_no LIKE '%' + #{params.fileNo} + '%'
  5089. </if>
  5090. <if test="params.fileName != null and params.fileName != ''">
  5091. AND A.file_name LIKE '%' + #{params.fileName} + '%'
  5092. </if>
  5093. <if test="params.fileType != null and params.fileType != ''">
  5094. AND A.file_type LIKE '%' + #{params.fileType} + '%'
  5095. </if>
  5096. <if test="params.sopRevNo != null and params.sopRevNo != ''">
  5097. AND A.sop_rev_no LIKE '%' + #{params.sopRevNo} + '%'
  5098. </if>
  5099. </where>
  5100. ORDER BY A.file_no
  5101. </select>
  5102. <!-- 插入SOP记录 -->
  5103. <insert id="insertSopRecord">
  5104. INSERT INTO part_sop (
  5105. site,
  5106. bu_no,
  5107. part_no,
  5108. sop_no,
  5109. sop_name,
  5110. sop_url,
  5111. sop_type,
  5112. version,
  5113. sop_status,
  5114. phase_in_date,
  5115. phase_out_date,
  5116. created_by,
  5117. creation_date,
  5118. operation_desc
  5119. ) VALUES (
  5120. #{data.site},
  5121. #{data.buNo},
  5122. #{data.partNo},
  5123. #{data.sopNo},
  5124. #{data.sopName},
  5125. #{data.sopUrl},
  5126. #{data.sopType},
  5127. #{data.version},
  5128. #{data.sopStatus},
  5129. <choose>
  5130. <when test="data.phaseInDate != null and data.phaseInDate != ''">
  5131. CONVERT(DATE, #{data.phaseInDate})
  5132. </when>
  5133. <otherwise>
  5134. NULL
  5135. </otherwise>
  5136. </choose>,
  5137. <choose>
  5138. <when test="data.phaseOutDate != null and data.phaseOutDate != ''">
  5139. CONVERT(DATE, #{data.phaseOutDate})
  5140. </when>
  5141. <otherwise>
  5142. NULL
  5143. </otherwise>
  5144. </choose>,
  5145. #{data.createdBy},
  5146. <choose>
  5147. <when test="data.creationDate != null and data.creationDate != ''">
  5148. CONVERT(DATE, #{data.creationDate})
  5149. </when>
  5150. <otherwise>
  5151. GETDATE()
  5152. </otherwise>
  5153. </choose>,
  5154. #{data.operationDesc}
  5155. )
  5156. </insert>
  5157. <!-- 删除SOP记录 -->
  5158. <delete id="deleteSopRecord">
  5159. DELETE FROM part_sop
  5160. <where>
  5161. <if test="params.site != null and params.site != ''">
  5162. AND site = #{params.site}
  5163. </if>
  5164. <if test="params.buNo != null and params.buNo != ''">
  5165. AND bu_no = #{params.buNo}
  5166. </if>
  5167. <if test="params.partNo != null and params.partNo != ''">
  5168. AND part_no = #{params.partNo}
  5169. </if>
  5170. <if test="params.sopNo != null and params.sopNo != ''">
  5171. AND sop_no = #{params.sopNo}
  5172. </if>
  5173. </where>
  5174. </delete>
  5175. <!-- ================================================= BOM清单相关SQL ================================================= -->
  5176. <!-- BOM清单查询 -->
  5177. <select id="bomListSearch" resultType="com.gaotao.modules.pms.data.BomListData">
  5178. SELECT
  5179. bh.site,
  5180. bh.bu_no as buNo,
  5181. bh.revno,
  5182. bh.bomtype,
  5183. bh.status,
  5184. bh.phaseindate,
  5185. bh.phaseoutdate
  5186. FROM BOMHeader bh
  5187. <where>
  5188. <if test="query.site != null and query.site != ''">
  5189. AND bh.site = #{query.site}
  5190. </if>
  5191. <if test="query.buNo != null and query.buNo != ''">
  5192. AND bh.bu_no = #{query.buNo}
  5193. </if>
  5194. <if test="query.partNo != null and query.partNo != ''">
  5195. AND bh.bu_no = #{query.partNo}
  5196. </if>
  5197. </where>
  5198. ORDER BY bh.phaseindate DESC
  5199. </select>
  5200. <!-- ================================================= Routing清单相关SQL ================================================= -->
  5201. <!-- Routing清单查询 -->
  5202. <select id="routingListSearch" resultType="com.gaotao.modules.pms.data.RoutingListData">
  5203. SELECT
  5204. rh.site,
  5205. rh.bu_no as buNo,
  5206. rh.revno,
  5207. rh.routingtype,
  5208. rh.status,
  5209. rh.phaseindate,
  5210. rh.phaseoutdate
  5211. FROM RoutingHeader rh
  5212. <where>
  5213. <if test="query.site != null and query.site != ''">
  5214. AND rh.site = #{query.site}
  5215. </if>
  5216. <if test="query.buNo != null and query.buNo != ''">
  5217. AND rh.bu_no = #{query.buNo}
  5218. </if>
  5219. <if test="query.partNo != null and query.partNo != ''">
  5220. AND rh.bu_no = #{query.partNo}
  5221. </if>
  5222. </where>
  5223. ORDER BY rh.phaseindate DESC
  5224. </select>
  5225. <update id="updateInboundNotificationStatus">
  5226. update inbound_notification_head
  5227. set order_status = #{status}
  5228. <if test="inspectionFlag != null and inspectionFlag != ''">
  5229. , inspection_flag = #{inspectionFlag}
  5230. </if>
  5231. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  5232. </update>
  5233. <!-- 查询过程检验待检验记录数量(只统计首件检和自检类型) -->
  5234. <select id="checkProcessInspectionPendingCount" resultType="int">
  5235. SELECT COUNT(1)
  5236. FROM qc_ipqc_record
  5237. WHERE site = #{site}
  5238. AND order_no = #{orderNo}
  5239. AND state IN ('未开始', '待检验')
  5240. AND seq_no = #{seqNo}
  5241. AND inspection_type_no IN ('首件检', '自检', '末件检')
  5242. </select>
  5243. <select id="queryResourceList3" resultType="com.gaotao.modules.pms.data.ResourceData">
  5244. select DISTINCT ResourceId,ResourceDesc from WorkCenterResource
  5245. </select>
  5246. <update id="updateSaleBoxManageStatus">
  5247. update outbound_notification_head
  5248. set order_status = #{status}
  5249. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  5250. </update>
  5251. <update id="updateSaleBoxManageInspectionFlag">
  5252. update outbound_notification_detail
  5253. set inspection_flag = #{inspectionFlag}
  5254. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  5255. </update>
  5256. <select id="queryEquipmentFolderLocationList"
  5257. resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
  5258. select efl.*,
  5259. dbo.get_bu_desc(efl.site, efl.bu_no) as buDesc
  5260. from Equipment_folder_location efl
  5261. <where>
  5262. <if test="params.site != null and params.site != ''">
  5263. and efl.site = #{params.site}
  5264. </if>
  5265. <if test="params.buNo != null and params.buNo != ''">
  5266. and efl.bu_no = #{params.buNo}
  5267. </if>
  5268. <if test="params.equipmentNo != null and params.equipmentNo != ''">
  5269. and efl.equipment_no like '%'+ #{params.equipmentNo} +'%'
  5270. </if>
  5271. <if test="params.equipmentDesc != null and params.equipmentDesc != ''">
  5272. and efl.equipment_desc like '%'+ #{params.equipmentDesc} +'%'
  5273. </if>
  5274. <if test="params.IP != null and params.IP != ''">
  5275. and efl.IP like '%'+ #{params.IP} +'%'
  5276. </if>
  5277. <if test="params.suffix != null and params.suffix != ''">
  5278. and efl.suffix like '%'+ #{params.suffix} +'%'
  5279. </if>
  5280. </where>
  5281. order by equipment_no
  5282. </select>
  5283. <insert id="saveEquipmentFolderLocationList">
  5284. insert into Equipment_folder_location
  5285. (folder_path,equipment_no,site,bu_no,file_no,backup_folder_path,IP,suffix,equipment_desc,backup_photo_path,batch_date,port,register_address,
  5286. register_num,register_num_columntype,register_address_inspection,register_num_inspection,register_num_inspection_columntype,unit_id,
  5287. excel_compare_fields_x,excel_compare_fields_y,initial_line,data_row,data_column,skip_line,cutting_symbol,transparent_flag,Formula_calculation,
  5288. Formula,Group_calculation,regexp,data_storage_mode,serial_no,repair_type,buzzer,equipment_classification)
  5289. values (#{folderPath}, #{equipmentNo}, #{site}, #{buNo}, #{fileNo}, #{backupFolderPath}, #{IP}, #{suffix}, #{equipmentDesc}, #{backupPhotoPath}, #{batchDate}, #{port}, #{registerAddress},
  5290. #{registerNum}, #{registerNumColumntype}, #{registerAddressInspection}, #{registerNumInspection}, #{registerNumInspectionColumntype}, #{unitId},
  5291. #{excelCompareFieldsX}, #{excelCompareFieldsY}, #{initialLine}, #{dataRow}, #{dataColumn}, #{skipLine}, #{cuttingSymbol}, #{transparentFlag}, #{formulaCalculation},
  5292. #{formula}, #{groupCalculation}, #{regexp}, #{dataStorageMode}, #{serialNo}, #{repairType}, #{buzzer}, #{equipmentClassification})
  5293. </insert>
  5294. <update id="updateEquipmentFolderLocation">
  5295. UPDATE Equipment_folder_location
  5296. SET
  5297. folder_path = #{folderPath},
  5298. equipment_no = #{equipmentNo},
  5299. bu_no = #{buNo},
  5300. file_no = #{fileNo},
  5301. backup_folder_path = #{backupFolderPath},
  5302. IP = #{IP},
  5303. suffix = #{suffix},
  5304. equipment_desc = #{equipmentDesc},
  5305. backup_photo_path = #{backupPhotoPath},
  5306. batch_date = #{batchDate},
  5307. port = #{port},
  5308. register_address = #{registerAddress},
  5309. register_num = #{registerNum},
  5310. register_num_columntype = #{registerNumColumntype},
  5311. register_address_inspection = #{registerAddressInspection},
  5312. register_num_inspection = #{registerNumInspection},
  5313. register_num_inspection_columntype = #{registerNumInspectionColumntype},
  5314. unit_id = #{unitId},
  5315. excel_compare_fields_x = #{excelCompareFieldsX},
  5316. excel_compare_fields_y = #{excelCompareFieldsY},
  5317. initial_line = #{initialLine},
  5318. data_row = #{dataRow},
  5319. data_column = #{dataColumn},
  5320. skip_line = #{skipLine},
  5321. cutting_symbol = #{cuttingSymbol},
  5322. transparent_flag = #{transparentFlag},
  5323. Formula_calculation = #{formulaCalculation},
  5324. Formula = #{formula},
  5325. Group_calculation = #{groupCalculation},
  5326. regexp = #{regexp},
  5327. data_storage_mode = #{dataStorageMode},
  5328. serial_no = #{serialNo},
  5329. repair_type = #{repairType},
  5330. buzzer = #{buzzer},
  5331. equipment_classification = #{equipmentClassification},
  5332. update_by = #{updateBy},
  5333. update_time = getDate()
  5334. WHERE id = #{id}
  5335. </update>
  5336. <delete id="deleteEquipmentFolderLocationList">
  5337. delete from Equipment_folder_location
  5338. where id = #{id}
  5339. </delete>
  5340. <select id="checkEquipmentFolderLocation" resultType="java.lang.Integer">
  5341. select count(1)
  5342. from Equipment_folder_location
  5343. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  5344. </select>
  5345. <select id="getSuffixList" resultType="java.lang.String">
  5346. select distinct suffix from Equipment_folder_location
  5347. </select>
  5348. <!-- 获取检验单物料编码 -->
  5349. <select id="getInspectionPartNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5350. select part_no from
  5351. <choose>
  5352. <when test="flag == 'ipqc'">qc_ipqc_record</when>
  5353. <when test="flag == 'sqc'">qc_sqc_record</when>
  5354. <when test="flag == 'fqc'">qc_fqc_record</when>
  5355. <when test="flag == 'fai'">qc_fai_record</when>
  5356. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
  5357. <otherwise>qc_iqc_record</otherwise>
  5358. </choose>
  5359. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5360. </select>
  5361. <!-- 获取检验单工序(仅 IPQC/FQC/OQC 主表维护 operation_desc) -->
  5362. <select id="getInspectionOperationDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5363. <choose>
  5364. <when test="flag == 'ipqc'">
  5365. select operation_desc from qc_ipqc_record
  5366. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5367. </when>
  5368. <when test="flag == 'fqc'">
  5369. select operation_desc from qc_fqc_record
  5370. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5371. </when>
  5372. <when test="flag == 'fqas' or flag == 'oqc'">
  5373. select operation_desc from qc_oqc_record
  5374. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5375. </when>
  5376. <otherwise>
  5377. select null
  5378. </otherwise>
  5379. </choose>
  5380. </select>
  5381. <!-- 获取检验单检验类型 -->
  5382. <select id="getInspectionTypeNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5383. select inspection_type_no from
  5384. <choose>
  5385. <when test="flag == 'ipqc'">qc_ipqc_record</when>
  5386. <when test="flag == 'sqc'">qc_sqc_record</when>
  5387. <when test="flag == 'fqc'">qc_fqc_record</when>
  5388. <when test="flag == 'fai'">qc_fai_record</when>
  5389. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
  5390. <otherwise>qc_iqc_record</otherwise>
  5391. </choose>
  5392. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5393. </select>
  5394. <!-- 获取检验单全部子明细实测值 -->
  5395. <select id="listInspectionSubDetailValues" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  5396. select
  5397. item_no as itemNo,
  5398. sub_detail_value as subDetailValue,
  5399. sub_detail_value_b as subDetailValueB,
  5400. sub_detail_value_c as subDetailValueC,
  5401. sub_detail_value_d as subDetailValueD,
  5402. sub_detail_value_e as subDetailValueE,
  5403. sampling_location as samplingLocation,
  5404. sampling_location_b as samplingLocationB,
  5405. num,
  5406. file_name as fileName,
  5407. is_transfer as isTransfer,
  5408. is_qualified as isQualified,
  5409. defect_qty as defectQty,
  5410. roll_no as rollNo
  5411. from
  5412. <choose>
  5413. <when test="flag == 'ipqc'">qc_ipqc_sub_detail_record</when>
  5414. <when test="flag == 'sqc'">qc_sqc_sub_detail_record</when>
  5415. <when test="flag == 'fqc'">qc_fqc_sub_detail_record</when>
  5416. <when test="flag == 'fai'">qc_fai_sub_detail_record</when>
  5417. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_sub_detail_record</when>
  5418. <otherwise>qc_iqc_sub_detail_record</otherwise>
  5419. </choose>
  5420. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5421. order by item_no, num
  5422. </select>
  5423. <!-- 获取检验单明细项目编码 -->
  5424. <select id="listInspectionItemNos" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5425. select item_no from
  5426. <choose>
  5427. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  5428. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  5429. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  5430. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  5431. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  5432. <otherwise>qc_iqc_detailed_record</otherwise>
  5433. </choose>
  5434. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5435. </select>
  5436. <!-- 获取检验单明细行实测值(含规格,用于复制与合格判定) -->
  5437. <select id="listInspectionDetailMeasuredValues" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5438. select
  5439. item_no as itemNo,
  5440. number_value as numberValue,
  5441. text_value as textValue,
  5442. value_type_db as valueTypeDb,
  5443. min_value as minValue,
  5444. max_value as maxValue,
  5445. item_result as itemResult,
  5446. unqualified_quantity as unqualifiedQuantity
  5447. from
  5448. <choose>
  5449. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  5450. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  5451. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  5452. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  5453. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  5454. <otherwise>qc_iqc_detailed_record</otherwise>
  5455. </choose>
  5456. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5457. </select>
  5458. <!-- 更新明细行实测值(数值/文本) -->
  5459. <update id="updateInspectionDetailMeasuredValue" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5460. update
  5461. <choose>
  5462. <when test="flag == 'ipqc'">qc_ipqc_detailed_record</when>
  5463. <when test="flag == 'sqc'">qc_sqc_detailed_record</when>
  5464. <when test="flag == 'fqc'">qc_fqc_detailed_record</when>
  5465. <when test="flag == 'fai'">qc_fai_detailed_record</when>
  5466. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_detailed_record</when>
  5467. <otherwise>qc_iqc_detailed_record</otherwise>
  5468. </choose>
  5469. set
  5470. number_value = #{numberValue,jdbcType=DECIMAL},
  5471. text_value = #{textValue}
  5472. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  5473. </update>
  5474. <!-- 查询检验单提交标识 -->
  5475. <select id="getInspectionSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5476. select submit_flag from
  5477. <choose>
  5478. <when test="flag == 'ipqc'">qc_ipqc_record</when>
  5479. <when test="flag == 'sqc'">qc_sqc_record</when>
  5480. <when test="flag == 'fqc'">qc_fqc_record</when>
  5481. <when test="flag == 'fai'">qc_fai_record</when>
  5482. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_record</when>
  5483. <otherwise>qc_iqc_record</otherwise>
  5484. </choose>
  5485. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  5486. </select>
  5487. <!-- 按物料+设备查询文件列映射 -->
  5488. <select id="listPartFileCollectByPartAndEquipment" resultType="com.gaotao.modules.pms.data.QcPartFileCollectData">
  5489. SELECT
  5490. file_column_no AS fileColumnNo,
  5491. item_no AS itemNo,
  5492. item_desc AS itemDesc,
  5493. operation
  5494. FROM qc_part_file_collect
  5495. WHERE site = #{site}
  5496. AND bu_no = #{buNo}
  5497. AND part_no = #{partNo}
  5498. AND equipment_no = #{equipmentNo}
  5499. ORDER BY file_column_no, id
  5500. </select>
  5501. <!-- 按物料查询已配置的设备编码 -->
  5502. <select id="listEquipmentNoByPartFileCollect" resultType="java.lang.String">
  5503. SELECT DISTINCT equipment_no
  5504. FROM qc_part_file_collect
  5505. WHERE site = #{site}
  5506. AND bu_no = #{buNo}
  5507. AND part_no = #{partNo}
  5508. AND equipment_no IS NOT NULL
  5509. AND equipment_no <![CDATA[<>]]> ''
  5510. ORDER BY equipment_no
  5511. </select>
  5512. <!-- 获取项目默认关联设备(优先 default_flag=Y) -->
  5513. <select id="getDefaultItemObjectId" resultType="java.lang.String">
  5514. SELECT TOP 1 ObjectID
  5515. FROM qc_item_object
  5516. WHERE site = #{site}
  5517. AND bu_no = #{buNo}
  5518. AND ItemNo = #{itemNo}
  5519. ORDER BY CASE WHEN default_flag = 'Y' THEN 0 ELSE 1 END, ObjectID
  5520. </select>
  5521. <!-- 校验项目是否关联指定设备 -->
  5522. <select id="countItemObject" resultType="int">
  5523. SELECT COUNT(1)
  5524. FROM qc_item_object
  5525. WHERE site = #{site}
  5526. AND bu_no = #{buNo}
  5527. AND ItemNo = #{itemNo}
  5528. AND ObjectID = #{objectId}
  5529. </select>
  5530. <!-- 按设备编码查询文件夹配置 -->
  5531. <select id="getEquipmentFolderLocationByEquipmentNo"
  5532. resultType="com.gaotao.modules.pms.data.QCEquipmentFolderLocation">
  5533. SELECT TOP 1
  5534. equipment_no AS equipmentNo,
  5535. equipment_desc AS equipmentDesc,
  5536. data_storage_mode AS dataStorageMode
  5537. FROM Equipment_folder_location
  5538. WHERE site = #{site}
  5539. AND bu_no = #{buNo}
  5540. AND equipment_no = #{equipmentNo}
  5541. </select>
  5542. <!-- 查询项目采集配置 -->
  5543. <select id="getItemCollectionConfig" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  5544. SELECT
  5545. ItemNo AS itemNo,
  5546. ItemDesc AS itemDesc,
  5547. collection_source AS collectionSource,
  5548. collection_method AS collectionMethod,
  5549. collection_data_content AS collectionDataContent
  5550. FROM eam_properties_item
  5551. WHERE site = #{site}
  5552. AND bu_no = #{buNo}
  5553. AND ItemNo = #{itemNo}
  5554. </select>
  5555. <!-- 查询设备最新批次解析数据(含列号元数据) -->
  5556. <select id="listLatestEquipmentDataDetail" resultType="com.gaotao.modules.reader.entity.EquipmentDataDetail">
  5557. SELECT
  5558. id,
  5559. site,
  5560. bu_no AS buNo,
  5561. equipment_no AS equipmentNo,
  5562. value0,
  5563. source_column_no AS sourceColumnNo,
  5564. num,
  5565. serial_no AS serialNo,
  5566. batch_no AS batchNo,
  5567. file_name AS fileName
  5568. FROM Equipment_data_detail
  5569. WHERE site = #{site}
  5570. AND bu_no = #{buNo}
  5571. AND equipment_no = #{equipmentNo}
  5572. AND batch_no = (
  5573. SELECT MAX(batch_no)
  5574. FROM Equipment_data_detail
  5575. WHERE site = #{site} AND bu_no = #{buNo} AND equipment_no = #{equipmentNo}
  5576. )
  5577. AND source_column_no IS NOT NULL
  5578. AND source_column_no != -1
  5579. ORDER BY source_column_no, num
  5580. </select>
  5581. <!-- 按列号查询设备最新批次解析数据;collectionDataContent 非空时作为 value0 的 SQL 过滤条件 -->
  5582. <select id="listLatestEquipmentDataDetailByColumn" resultType="com.gaotao.modules.reader.entity.EquipmentDataDetail">
  5583. SELECT
  5584. id,
  5585. site,
  5586. bu_no AS buNo,
  5587. equipment_no AS equipmentNo,
  5588. value0,
  5589. source_column_no AS sourceColumnNo,
  5590. num,
  5591. serial_no AS serialNo,
  5592. batch_no AS batchNo,
  5593. file_name AS fileName
  5594. FROM Equipment_data_detail
  5595. WHERE site = #{site}
  5596. AND bu_no = #{buNo}
  5597. AND equipment_no = #{equipmentNo}
  5598. <choose>
  5599. <when test="matchBySerialNo == true">
  5600. AND LTRIM(RTRIM(CONVERT(VARCHAR(50), serial_no))) = CONVERT(VARCHAR(50), #{fileColumnNo})
  5601. </when>
  5602. <otherwise>
  5603. AND source_column_no = #{fileColumnNo}
  5604. </otherwise>
  5605. </choose>
  5606. AND batch_no = (
  5607. SELECT MAX(batch_no)
  5608. FROM Equipment_data_detail
  5609. WHERE site = #{site} AND bu_no = #{buNo} AND equipment_no = #{equipmentNo}
  5610. )
  5611. <if test="collectionDataContent != null and collectionDataContent != ''">
  5612. AND value0 ${collectionDataContent}
  5613. </if>
  5614. ORDER BY num
  5615. </select>
  5616. <!-- 数据采集后更新明细不合格数量与项目检验结果 -->
  5617. <update id="updateIQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5618. UPDATE qc_iqc_detailed_record
  5619. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5620. item_result = #{itemResult}
  5621. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5622. </update>
  5623. <update id="refreshIQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5624. UPDATE qc_iqc_record
  5625. SET unqualified_qty = (
  5626. SELECT COUNT(*) FROM qc_iqc_detailed_record
  5627. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5628. )
  5629. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5630. </update>
  5631. <update id="updateIPQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5632. UPDATE qc_ipqc_detailed_record
  5633. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5634. item_result = #{itemResult}
  5635. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5636. </update>
  5637. <update id="refreshIPQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5638. UPDATE qc_ipqc_record
  5639. SET unqualified_qty = (
  5640. SELECT COUNT(*) FROM qc_ipqc_detailed_record
  5641. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5642. )
  5643. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5644. </update>
  5645. <update id="updateSQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5646. UPDATE qc_sqc_detailed_record
  5647. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5648. item_result = #{itemResult}
  5649. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5650. </update>
  5651. <update id="refreshSQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5652. UPDATE qc_sqc_record
  5653. SET unqualified_qty = (
  5654. SELECT COUNT(*) FROM qc_sqc_detailed_record
  5655. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5656. )
  5657. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5658. </update>
  5659. <update id="updateFQCDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5660. UPDATE qc_fqc_detailed_record
  5661. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5662. item_result = #{itemResult}
  5663. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5664. </update>
  5665. <update id="refreshFQCMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5666. UPDATE qc_fqc_record
  5667. SET unqualified_qty = (
  5668. SELECT COUNT(*) FROM qc_fqc_detailed_record
  5669. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5670. )
  5671. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5672. </update>
  5673. <update id="updateFQASDetailUnqualifiedResult" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5674. UPDATE qc_oqc_detailed_record
  5675. SET unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  5676. item_result = #{itemResult}
  5677. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  5678. </update>
  5679. <update id="refreshFQASMasterUnqualifiedQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  5680. UPDATE qc_oqc_record
  5681. SET unqualified_qty = (
  5682. SELECT COUNT(*) FROM qc_oqc_detailed_record
  5683. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo} AND item_result = 'N'
  5684. )
  5685. WHERE site = #{site} AND bu_no = #{buNo} AND inspection_no = #{inspectionNo}
  5686. </update>
  5687. <select id="getLatestEquipmentDetailBatchNo" resultType="java.lang.Integer">
  5688. SELECT MAX(batch_no)
  5689. FROM Equipment_data_detail
  5690. WHERE site = #{site}
  5691. AND bu_no = #{buNo}
  5692. AND equipment_no = #{equipmentNo}
  5693. </select>
  5694. <update id="updateEquipmentDataAcquisitionBatchNo">
  5695. UPDATE Equipment_data_acquisition
  5696. SET batch_no = #{batchNo}
  5697. WHERE site = #{site}
  5698. AND bu_no = #{buNo}
  5699. AND inspection_no = #{inspectionNo}
  5700. AND equipment_no = #{equipmentNo}
  5701. </update>
  5702. <update id="updateEquipmentDataAcquisitionCollectMode">
  5703. UPDATE Equipment_data_acquisition
  5704. SET accumulate_collect = #{accumulateCollect},
  5705. delete_after_collect = #{deleteAfterCollect}
  5706. WHERE site = #{site}
  5707. AND bu_no = #{buNo}
  5708. AND inspection_no = #{inspectionNo}
  5709. AND equipment_no = #{equipmentNo}
  5710. </update>
  5711. <!-- 累计采集时用于续号 -->
  5712. <select id="getSubDetailMaxNum" resultType="java.lang.Integer">
  5713. SELECT ISNULL(MAX(num), 0)
  5714. FROM
  5715. <choose>
  5716. <when test="flag == 'ipqc'">qc_ipqc_sub_detail_record</when>
  5717. <when test="flag == 'sqc'">qc_sqc_sub_detail_record</when>
  5718. <when test="flag == 'fqc'">qc_fqc_sub_detail_record</when>
  5719. <when test="flag == 'fai'">qc_fai_sub_detail_record</when>
  5720. <when test="flag == 'fqas' or flag == 'oqc'">qc_oqc_sub_detail_record</when>
  5721. <otherwise>qc_iqc_sub_detail_record</otherwise>
  5722. </choose>
  5723. WHERE site = #{site}
  5724. AND bu_no = #{buNo}
  5725. AND inspection_no = #{inspectionNo}
  5726. AND item_no = #{itemNo}
  5727. </select>
  5728. <!-- 检验单弹框:最近设备解析时间 -->
  5729. <select id="getLatestEquipmentParseTime" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="java.lang.String">
  5730. SELECT TOP 1
  5731. N'最近解析时间:' + a.equipment_no + N' - ' + ISNULL(b.equipment_desc, N'') + N' - '
  5732. + CONVERT(varchar(19), c.create_date, 120)
  5733. FROM Equipment_data_acquisition A
  5734. INNER JOIN Equipment_folder_location B
  5735. ON A.site = B.site AND A.bu_no = B.bu_no AND A.equipment_no = B.equipment_no
  5736. INNER JOIN Equipment_folder_sort C
  5737. ON B.site = C.site AND B.bu_no = C.bu_no AND B.file_no = C.file_no
  5738. WHERE A.site = #{site}
  5739. AND A.bu_no = #{buNo}
  5740. AND A.inspection_no = #{inspectionNo}
  5741. ORDER BY C.create_date DESC
  5742. </select>
  5743. </mapper>