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.

5849 lines
254 KiB

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