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.

4213 lines
182 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
7 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
11 months ago
11 months ago
11 months ago
5 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
5 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
4 months ago
4 months ago
11 months ago
4 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
2 months ago
2 months ago
2 months ago
2 months ago
9 months ago
9 months ago
9 months ago
4 months ago
9 months ago
9 months ago
9 months ago
5 months ago
11 months 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,
  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. left join part as d on a.site = d.site and a.bu_no = d.bu_no 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. FROM qc_fai_detailed_record as a
  293. 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
  294. 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
  295. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  296. order by a.order_id
  297. </select>
  298. <!-- 修改FAI主记录信息 -->
  299. <update id="updateFAIMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  300. UPDATE qc_fai_record
  301. SET disposal_measures = #{disposalMeasures},
  302. disposal_remark = #{disposalRemark},
  303. inspection_result = #{inspectionResult},
  304. inspector_no = #{inspectorNo},
  305. state = #{state},
  306. inspection_remark = #{inspectionRemark},
  307. inspector_date = getDate(),
  308. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  309. roll_qty = #{rollQty,jdbcType=DECIMAL},
  310. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  311. pass_qty = #{passQty,jdbcType=DECIMAL},
  312. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  313. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  314. submit_date = getDate()
  315. WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
  316. </update>
  317. <!-- 修改FAI明细记录信息 -->
  318. <update id="updateFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  319. UPDATE qc_fai_detailed_record
  320. SET item_result = #{itemResult},
  321. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  322. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  323. text_value = #{textValue},
  324. number_value = #{numberValue,jdbcType=DECIMAL}
  325. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  326. </update>
  327. <!-- 修改子明细提交标识 -->
  328. <update id="updateSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  329. UPDATE qc_fai_sub_detail_record
  330. SET is_submit = 'Y'
  331. WHERE inspection_no = #{inspectionNo}
  332. </update>
  333. <!-- 删除FAI检验记录 -->
  334. <delete id="deleteFAIRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  335. DELETE FROM qc_fai_record
  336. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  337. </delete>
  338. <!-- 删除FAI明细记录信息 -->
  339. <delete id="deleteFAIDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  340. DELETE FROM qc_fai_detailed_record
  341. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  342. </delete>
  343. <!-- 删除FAI子明细记录信息 -->
  344. <delete id="deleteFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  345. DELETE FROM qc_fai_sub_detail_record
  346. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  347. </delete>
  348. <!-- 修改FAI主记录标识为已提交 -->
  349. <update id="updateFAIMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  350. UPDATE qc_fai_record
  351. SET submit_flag = 'Y',
  352. state = '已完成',
  353. submit_date = getDate()
  354. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  355. </update>
  356. <!-- 修改FAI明细记录标识为已提交 -->
  357. <update id="updateFAIDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  358. UPDATE qc_fai_detailed_record
  359. SET is_submit = 'Y'
  360. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  361. </update>
  362. <!-- 修改子明细记录标识为已提交 -->
  363. <update id="updateFAISubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  364. UPDATE qc_fai_sub_detail_record
  365. SET is_submit = 'Y'
  366. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  367. </update>
  368. <!-- 查询FAI检验记录是否已提交 -->
  369. <select id="checkFAIIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  370. SELECT submit_flag
  371. FROM qc_fai_record
  372. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  373. </select>
  374. <!-- 查询FAI检验记录状态(用于保存前校验) -->
  375. <select id="getFAIRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  376. SELECT submit_flag, state
  377. FROM qc_fai_record
  378. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  379. </select>
  380. <!-- 删除子明细的老数据 -->
  381. <delete id="delFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  382. DELETE FROM qc_fai_sub_detail_record
  383. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  384. </delete>
  385. <!-- 新增FAI子明细信息 -->
  386. <insert id="saveFAISubDetailed">
  387. INSERT INTO qc_fai_sub_detail_record
  388. (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)
  389. VALUES
  390. <foreach collection="list" item="item" separator=",">
  391. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  392. </foreach>
  393. </insert>
  394. <!-- 查询FAI的子明细 -->
  395. <select id="selectFAISubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  396. SELECT
  397. site,
  398. bu_no,
  399. sub_detail_value,
  400. sampling_location,
  401. is_submit,
  402. sampling_location_b,
  403. num,
  404. sub_detail_value_b,
  405. sub_detail_value_c,
  406. sub_detail_value_d,
  407. sub_detail_value_e
  408. FROM qc_fai_sub_detail_record
  409. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  410. <if test = "collectionDataContent != null and collectionDataContent != ''">
  411. AND sub_detail_value ${collectionDataContent}
  412. </if>
  413. </select>
  414. <!-- 获取该项目的子明细值 -->
  415. <select id="selectFAISubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  416. SELECT sub_detail_value,
  417. sampling_location,
  418. is_submit
  419. FROM qc_fai_sub_detail_record
  420. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  421. </select>
  422. <!-- ================================================= IPQC检验维护 ================================================= -->
  423. <!-- 查询IPQC基础数据 -->
  424. <select id="selectIPQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  425. SELECT
  426. top 1
  427. a.orderno as orderNo,
  428. j.partNo,
  429. j.PartDescription as partDesc,
  430. c.operationDesc,
  431. b.approve_qty as rollQty,
  432. a.s_resourceid as resourceId,
  433. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  434. a.itemno as itemNo,
  435. a.id as ssrId
  436. FROM soscheduledrouting as a
  437. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  438. LEFT JOIN sfdc as b
  439. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  440. select max(sfdc.id)
  441. from sfdc
  442. group by sfdc.assjob_seq_no, site
  443. )
  444. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  445. LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
  446. LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
  447. ON a.id = temp.ssr_id
  448. WHERE b.approve_qty is not null and temp.ssr_id is null
  449. ORDER BY a.id desc
  450. </select>
  451. <select id="qcExec" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="string" statementType="CALLABLE">
  452. {CALL
  453. getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
  454. }
  455. </select>
  456. <insert id="saveIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  457. INSERT INTO qc_ipqc_detailed_record
  458. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  459. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  460. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  461. VALUES
  462. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  463. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  464. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  465. </insert>
  466. <!-- 新增IPQC明细记录信息 -->
  467. <insert id="saveIPQCDetailedRecords">
  468. INSERT INTO qc_ipqc_detailed_record
  469. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  470. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  471. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  472. VALUES
  473. <foreach collection="list" item="item" separator=",">
  474. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  475. #{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},
  476. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  477. </foreach>
  478. </insert>
  479. <!-- 新增IPQC主记录信息 -->
  480. <insert id="saveIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  481. INSERT INTO qc_ipqc_record
  482. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  483. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  484. VALUES
  485. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  486. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  487. </insert>
  488. <!-- 查询IPQC主记录信息 -->
  489. <select id="qcIPQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  490. SELECT
  491. a.inspection_no,
  492. a.site,
  493. a.bu_no,
  494. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  495. a.state,
  496. a.inspection_result,
  497. a.task_date,
  498. a.inspection_type_no,
  499. a.inspection_cycle,
  500. a.order_no,
  501. a.operation_desc,
  502. a.resource_id,
  503. r.resourceDesc,
  504. a.part_no,
  505. d.PartDescription as part_desc,
  506. d.cinv_source_code as cinvSourceCode,
  507. d.sku as sku,
  508. d.PartType as invdefinetype,
  509. d.spec,
  510. a.inspection_remark,
  511. a.roll_qty,
  512. a.sampling_qty,
  513. a.disposal_measures,
  514. a.disposal_remark,
  515. a.inspector_date,
  516. a.submit_date as submitDate,
  517. a.inspector_no,
  518. u.user_display as inspectorName,
  519. a.ssr_id,
  520. a.unqualified_qty,
  521. a.submit_flag,
  522. a.seq_no,
  523. a.batch_roll_no,
  524. a.special_requirements,
  525. a.work_center_no,
  526. a.roll_no,
  527. a.um_id,
  528. um.UMName as umName,
  529. a.action_date,
  530. a.action_by,
  531. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  532. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  533. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  534. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  535. a.pass_qty,
  536. a.not_pass_qty,
  537. a.batch_qualified_qty,
  538. w.WorkCenterDesc
  539. FROM qc_ipqc_record as a
  540. left join part as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.partNo
  541. left join sys_user as u on a.inspector_no = u.username
  542. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  543. left join WorkCenter as w on a.site = w.site and a.work_center_no = w.workCenterNo and a.bu_no = w.bu_no
  544. left join UM as um on a.site = um.site and a.um_id = um.UMID
  545. <where>
  546. a.site in (select site from AccessSite where userID = #{query.userName})
  547. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  548. <if test="query.buNo != null and query.buNo != ''">
  549. AND a.bu_no = #{query.buNo}
  550. </if>
  551. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  552. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  553. </if>
  554. <if test = "query.partNo != null and query.partNo != ''">
  555. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  556. </if>
  557. <if test = "query.partDesc != null and query.partDesc != ''">
  558. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  559. </if>
  560. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  561. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  562. </if>
  563. <if test = "query.sku != null and query.sku != ''">
  564. AND d.sku LIKE '%' + #{query.sku} + '%'
  565. </if>
  566. <if test = "query.states != null and query.states.size > 0">
  567. AND a.state in
  568. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  569. #{item}
  570. </foreach>
  571. </if>
  572. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  573. AND a.inspection_type_no = #{query.inspectionTypeNo}
  574. </if>
  575. <if test = "query.inspectionTypeNos != null and query.inspectionTypeNos.size > 0">
  576. AND a.inspection_type_no in
  577. <foreach item="item" collection="query.inspectionTypeNos" open="(" separator="," close=")">
  578. #{item}
  579. </foreach>
  580. </if>
  581. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  582. AND a.inspection_result = #{query.inspectionResult}
  583. </if>
  584. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  585. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  586. </if>
  587. <if test = "query.orderNo != null and query.orderNo != ''">
  588. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  589. </if>
  590. <if test = "query.seqNo != null and query.seqNo != ''">
  591. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  592. </if>
  593. <if test = "query.operationDesc != null and query.operationDesc != ''">
  594. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  595. </if>
  596. <if test = "query.resourceId != null and query.resourceId != ''">
  597. AND a.resource_id = #{query.resourceId}
  598. </if>
  599. <if test = "query.workCenterNo != null and query.workCenterNo != ''">
  600. AND a.work_center_no = #{query.workCenterNo}
  601. </if>
  602. <if test="query.startDate != null">
  603. AND a.inspector_date >= #{query.startDate}
  604. </if>
  605. <if test="query.endDate != null">
  606. AND #{query.endDate} >= a.inspector_date
  607. </if>
  608. <if test="query.startDate2 != null">
  609. AND a.task_date >= #{query.startDate2}
  610. </if>
  611. <if test="query.endDate2 != null">
  612. AND #{query.endDate2} >= a.task_date
  613. </if>
  614. <if test = "query.spec != null and query.spec != ''">
  615. AND d.spec LIKE '%' + #{query.spec} + '%'
  616. </if>
  617. </where>
  618. ORDER BY
  619. CASE WHEN a.state = '未开始' THEN 1
  620. WHEN a.state = '待检验' THEN 2
  621. END, a.action_date,a.task_date,a.inspector_date desc
  622. </select>
  623. <!-- IPQC明细记录查询 -->
  624. <select id="ipqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  625. SELECT
  626. a.site,
  627. a.bu_no,
  628. a.inspection_no,
  629. a.order_no,
  630. a.template_id,
  631. a.sampling_level_no,
  632. a.sampling_level_desc,
  633. a.sampling_programme_no,
  634. a.sampling_programme_desc,
  635. a.AQL,
  636. a.AC,
  637. a.RE,
  638. a.item_no,
  639. a.item_desc,
  640. a.object_id,
  641. a.object_desc,
  642. a.default_value,
  643. a.min_value,
  644. a.max_value,
  645. a.text_value,
  646. a.number_value,
  647. a.value_type_db,
  648. a.value_type,
  649. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  650. a.is_submit,
  651. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  652. a.sampling_qty,
  653. dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  654. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  655. c.method_no,
  656. c.method_name,
  657. c.method_remark
  658. FROM qc_ipqc_detailed_record as a
  659. 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
  660. 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
  661. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  662. order by a.order_id
  663. </select>
  664. <!-- 删除IPQC检验记录 -->
  665. <delete id="deleteIPQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  666. DELETE FROM qc_ipqc_record
  667. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  668. </delete>
  669. <!-- 删除IPQC明细记录信息 -->
  670. <delete id="deleteIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  671. DELETE FROM qc_ipqc_detailed_record
  672. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  673. </delete>
  674. <!-- 删除IPQC子明细记录信息 -->
  675. <delete id="deleteIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  676. DELETE FROM qc_ipqc_sub_detail_record
  677. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  678. </delete>
  679. <!-- 修改IPQC主记录信息 -->
  680. <update id="updateIPQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  681. UPDATE qc_ipqc_record
  682. SET disposal_measures = #{disposalMeasures},
  683. disposal_remark = #{disposalRemark},
  684. inspection_result = #{inspectionResult},
  685. inspector_no = #{inspectorNo},
  686. state = #{state},
  687. inspection_remark = #{inspectionRemark},
  688. inspector_date = getDate(),
  689. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  690. roll_qty = #{rollQty,jdbcType=DECIMAL},
  691. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  692. pass_qty = #{passQty,jdbcType=DECIMAL},
  693. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  694. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  695. submit_date = getDate()
  696. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  697. </update>
  698. <!-- 修改IPQC明细记录信息 -->
  699. <update id="updateIPQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  700. UPDATE qc_ipqc_detailed_record
  701. SET item_result = #{itemResult},
  702. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  703. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  704. text_value = #{textValue},
  705. number_value = #{numberValue,jdbcType=DECIMAL},
  706. default_value = #{defaultValue},
  707. min_value = #{minValue,jdbcType=DECIMAL},
  708. max_value = #{maxValue,jdbcType=DECIMAL}
  709. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  710. </update>
  711. <!-- 修改IPQC主记录标识为已提交 -->
  712. <update id="updateIPQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  713. UPDATE qc_ipqc_record
  714. SET submit_flag = 'Y',
  715. state = '已完成',
  716. submit_date = getDate()
  717. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  718. </update>
  719. <!-- 修改IPQC明细记录标识为已提交 -->
  720. <update id="updateIPQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  721. UPDATE qc_ipqc_detailed_record
  722. SET is_submit = 'Y'
  723. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  724. </update>
  725. <!-- 修改IPQC子明细记录标识为已提交 -->
  726. <update id="updateIPQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  727. UPDATE qc_ipqc_sub_detail_record
  728. SET is_submit = 'Y'
  729. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  730. </update>
  731. <!-- 删除IPQC子明细的老数据 -->
  732. <delete id="delIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  733. DELETE FROM qc_ipqc_sub_detail_record
  734. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  735. </delete>
  736. <!-- 新增IPQC子明细信息 -->
  737. <insert id="saveIPQCSubDetailed">
  738. INSERT INTO qc_ipqc_sub_detail_record
  739. (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)
  740. VALUES
  741. <foreach collection="list" item="item" separator=",">
  742. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  743. </foreach>
  744. </insert>
  745. <!-- 查询IPQC的子明细 -->
  746. <select id="selectIPQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  747. SELECT
  748. site,
  749. bu_no,
  750. sub_detail_value,
  751. sampling_location,
  752. is_submit,
  753. sampling_location_b,
  754. num,
  755. sub_detail_value_b,
  756. sub_detail_value_c,
  757. sub_detail_value_d,
  758. sub_detail_value_e
  759. FROM qc_ipqc_sub_detail_record
  760. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  761. <if test = "collectionDataContent != null and collectionDataContent != ''">
  762. AND sub_detail_value ${collectionDataContent}
  763. </if>
  764. </select>
  765. <!-- 查询IPQC检验记录是否已提交 -->
  766. <select id="checkIPQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  767. SELECT submit_flag
  768. FROM qc_ipqc_record
  769. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  770. </select>
  771. <!-- 查询IPQC检验记录状态(用于保存前校验) -->
  772. <select id="getIPQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  773. SELECT submit_flag, state, inspection_result
  774. FROM qc_ipqc_record
  775. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  776. </select>
  777. <!-- 获取该项目的子明细值 -->
  778. <select id="selectIPQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  779. SELECT sub_detail_value,
  780. sampling_location,
  781. is_submit
  782. FROM qc_ipqc_sub_detail_record
  783. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  784. </select>
  785. <!-- 查询工序列表 -->
  786. <select id="getOperationList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  787. SELECT
  788. DISTINCT
  789. a.seqno as seqNo,
  790. a.orderno as orderNo,
  791. j.partNo,
  792. j.PartDescription as partDesc,
  793. j.PartType as invdefinetype,
  794. j.sku,
  795. c.operationDesc as operationDesc,
  796. a.itemno as operationNo,
  797. a.s_resourceid as resourceId,
  798. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  799. c.WorkCenterNo
  800. FROM soscheduledrouting as a
  801. inner join ShopOrder as so on a.site = so.site and a.orderno = so.orderNo
  802. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  803. LEFT JOIN part j ON so.site = j.site and so.partno = j.partNo
  804. WHERE a.site = #{site} and a.seqno = #{seqNo}
  805. </select>
  806. <!-- 根据工单号和工序号查出所有数据 -->
  807. <select id="getResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  808. SELECT
  809. a.s_resourceid as resourceId,
  810. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  811. c.workCenterNo
  812. FROM soscheduledrouting as a
  813. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  814. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  815. <!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
  816. WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
  817. ORDER BY a.id desc
  818. </select>
  819. <!-- 查询机台名称 -->
  820. <select id="selectResourceDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  821. SELECT distinct
  822. resourceDesc
  823. FROM WorkCenterResource
  824. WHERE site = #{site} and resourceId = #{resourceId}
  825. </select>
  826. <!-- 查询物料名称 -->
  827. <select id="selectPartDesc" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  828. SELECT distinct
  829. PartDescription as part_desc
  830. FROM part
  831. WHERE site = #{site} and partNo = #{partNo}
  832. </select>
  833. <!-- ================================================= IQC检验维护 ================================================= -->
  834. <!-- 查询IQC基础数据 -->
  835. <select id="selectIQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  836. SELECT
  837. qir.inspection_no,
  838. qir.state,
  839. qir.defect_tracking_flag as defectTrackingFlag,
  840. qir.create_date as taskDate,
  841. qir.roll_no,
  842. qir.part_no,
  843. p.PartDescription as part_desc,
  844. p.cinv_source_code,
  845. p.sku as sku,
  846. qir.roll_qty,
  847. qir.print_flag,
  848. qir.create_by,
  849. qir.supplier_no,
  850. qir.site,
  851. qir.bu_no,
  852. qir.po_orderNo,
  853. qir.po_itemNo,
  854. qir.roll_count,
  855. qir.document_no
  856. FROM qc_iqc_record as qir
  857. LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
  858. WHERE qir.site in (select site from AccessSite where userID = #{userName})
  859. and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
  860. and qir.detail_flag = 'N'
  861. </select>
  862. <!-- 新增IQC明细记录信息 -->
  863. <insert id="saveIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  864. 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)
  865. 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})
  866. </insert>
  867. <!-- 修改IQC检验记录 -->
  868. <update id="updateIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  869. UPDATE qc_iqc_record
  870. SET inspection_type_no = #{inspectionTypeNo},
  871. sampling_qty = #{samplingQty},
  872. inspection_cycle = #{inspectionCycle},
  873. part_desc = #{partDesc},
  874. detail_flag = 'Y',
  875. state = '未开始',
  876. action_date = '',
  877. action_by = ''
  878. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  879. </update>
  880. <!-- 查询IQC主记录信息 -->
  881. <select id="qcIQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  882. SELECT
  883. a.inspection_no,
  884. a.site,
  885. a.bu_no,
  886. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  887. a.state,
  888. a.defect_tracking_flag as defectTrackingFlag,
  889. a.inspection_result,
  890. a.create_date as taskDate,
  891. a.inspection_type_no,
  892. a.inspection_cycle,
  893. a.part_no,
  894. a.part_desc,
  895. d.cinv_source_code as cinvSourceCode,
  896. d.sku,
  897. d.umid as umId,
  898. um.UMName as umName,
  899. d.PartType as invdefinetype,
  900. d.spec,
  901. a.inspection_remark,
  902. a.roll_qty,
  903. a.sampling_qty,
  904. a.disposal_measures,
  905. a.disposal_remark,
  906. a.inspector_date,
  907. a.submit_date as submitDate,
  908. a.inspector_no,
  909. u.user_display as inspectorName,
  910. a.unqualified_quantity,
  911. a.submit_flag,
  912. a.roll_no,
  913. a.supplier_no,
  914. s.SupplierName as supplierDesc,
  915. a.po_orderNo,
  916. a.po_itemNo,
  917. a.roll_count,
  918. a.roll_count as dhjs,
  919. dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) as orderType,
  920. a.action_date,
  921. a.action_by,
  922. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  923. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  924. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  925. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  926. a.submission_remark,
  927. a.submission_type,
  928. a.batch_no,
  929. a.production_date,
  930. a.expiration_warning_date,
  931. a.expiration_date,
  932. a.pass_qty,
  933. a.not_pass_qty,
  934. a.batch_qualified_qty,
  935. a.document_no
  936. FROM qc_iqc_record as a
  937. left join part as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.partNo
  938. left join view_Supplier as s on a.site = s.site and a.supplier_no = s.SupplierID
  939. left join sys_user as u on a.inspector_no = u.username
  940. left join um as um on d.site = um.site and d.umid = um.UMID
  941. <where>
  942. a.site in (select site from AccessSite where userID = #{query.userName})
  943. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  944. <if test="query.buNo != null and query.buNo != ''">
  945. AND a.bu_no = #{query.buNo}
  946. </if>
  947. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  948. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  949. </if>
  950. <if test = "query.states != null and query.states.size > 0">
  951. AND a.state in
  952. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  953. #{item}
  954. </foreach>
  955. </if>
  956. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  957. AND a.inspection_result = #{query.inspectionResult}
  958. </if>
  959. <if test = "query.partNo != null and query.partNo != ''">
  960. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  961. </if>
  962. <if test = "query.partDesc != null and query.partDesc != ''">
  963. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  964. </if>
  965. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  966. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  967. </if>
  968. <if test = "query.sku != null and query.sku != ''">
  969. AND d.sku LIKE '%' + #{query.sku} + '%'
  970. </if>
  971. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  972. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  973. </if>
  974. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  975. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  976. </if>
  977. <if test = "query.inspectorName != null and query.inspectorName != ''">
  978. u.user_display LIKE '%' + #{query.inspectorName} + '%'
  979. </if>
  980. <if test="query.startDate != null">
  981. AND a.inspector_date >= #{query.startDate}
  982. </if>
  983. <if test="query.endDate != null">
  984. AND #{query.endDate} >= a.inspector_date
  985. </if>
  986. <if test="query.startDate2 != null">
  987. AND a.create_date >= #{query.startDate2}
  988. </if>
  989. <if test="query.endDate2 != null">
  990. AND #{query.endDate2} >= a.create_date
  991. </if>
  992. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  993. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  994. </if>
  995. <if test = "query.poItemNo != null and query.poItemNo != ''">
  996. AND a.po_itemNo LIKE '%' + #{query.poItemNo} + '%'
  997. </if>
  998. <if test = "query.orderType != null and query.orderType != ''">
  999. AND dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) = #{query.orderType}
  1000. </if>
  1001. <if test = "query.submissionType != null and query.submissionType != ''">
  1002. AND a.submission_type = #{query.submissionType}
  1003. </if>
  1004. <if test = "query.invdefinetype != null and query.invdefinetype != ''">
  1005. AND d.PartType LIKE '%' + #{query.invdefinetype} + '%'
  1006. </if>
  1007. <if test = "query.spec != null and query.spec != ''">
  1008. AND d.spec LIKE '%' + #{query.spec} + '%'
  1009. </if>
  1010. <if test = "query.documentNo != null and query.documentNo != ''">
  1011. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  1012. </if>
  1013. </where>
  1014. ORDER BY
  1015. CASE WHEN a.state = '待检验' THEN 1
  1016. WHEN a.state = '待审核' THEN 2
  1017. WHEN a.state = '已完成' THEN 3
  1018. END, a.create_date desc
  1019. </select>
  1020. <!-- IQC明细记录查询 -->
  1021. <select id="iqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1022. SELECT
  1023. a.site,
  1024. a.bu_no,
  1025. a.inspection_no,
  1026. a.template_id,
  1027. a.sampling_level_no,
  1028. a.sampling_level_desc,
  1029. a.sampling_programme_no,
  1030. a.sampling_programme_desc,
  1031. a.AQL,
  1032. a.AC,
  1033. a.RE,
  1034. a.item_no,
  1035. a.item_desc,
  1036. a.object_id,
  1037. a.object_desc,
  1038. a.default_value,
  1039. a.min_value,
  1040. a.max_value,
  1041. a.text_value,
  1042. a.number_value,
  1043. a.value_type_db,
  1044. a.value_type,
  1045. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1046. a.is_submit,
  1047. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1048. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1049. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  1050. c.method_no,
  1051. c.method_name,
  1052. c.method_remark,
  1053. a.sampling_qty
  1054. FROM qc_iqc_detailed_record as a
  1055. 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
  1056. 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
  1057. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1058. order by a.order_id
  1059. </select>
  1060. <!-- 查询IQC的子明细 -->
  1061. <select id="selectIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1062. SELECT
  1063. site,
  1064. bu_no,
  1065. sub_detail_value,
  1066. sampling_location,
  1067. is_submit,
  1068. sampling_location_b,
  1069. num,
  1070. sub_detail_value_b,
  1071. sub_detail_value_c,
  1072. sub_detail_value_d,
  1073. sub_detail_value_e
  1074. FROM qc_iqc_sub_detail_record
  1075. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1076. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1077. AND sub_detail_value ${collectionDataContent}
  1078. </if>
  1079. </select>
  1080. <!-- 获取该项目的子明细值 -->
  1081. <select id="selectIQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1082. SELECT sub_detail_value,
  1083. sampling_location,
  1084. is_submit
  1085. FROM qc_iqc_sub_detail_record
  1086. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1087. </select>
  1088. <!-- 修改IQC主记录信息 -->
  1089. <update id="updateIQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1090. UPDATE qc_iqc_record
  1091. SET disposal_measures = #{disposalMeasures},
  1092. disposal_remark = #{disposalRemark},
  1093. inspection_result = #{inspectionResult},
  1094. inspector_no = #{inspectorNo},
  1095. state = #{state},
  1096. inspection_remark = #{inspectionRemark},
  1097. inspector_date = getDate(),
  1098. roll_count = #{rollCount,jdbcType=DECIMAL},
  1099. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1100. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1101. pass_qty = #{passQty,jdbcType=DECIMAL},
  1102. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1103. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  1104. submit_date = getDate()
  1105. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1106. </update>
  1107. <!-- 修改IQC明细记录信息 -->
  1108. <update id="updateIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1109. UPDATE qc_iqc_detailed_record
  1110. SET item_result = #{itemResult},
  1111. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1112. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1113. text_value = #{textValue},
  1114. number_value = #{numberValue,jdbcType=DECIMAL},
  1115. default_value = #{defaultValue},
  1116. min_value = #{minValue,jdbcType=DECIMAL},
  1117. max_value = #{maxValue,jdbcType=DECIMAL}
  1118. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1119. </update>
  1120. <!-- 查询该记录明细是否已存在 -->
  1121. <select id="checkIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1122. SELECT inspection_no,
  1123. template_id
  1124. FROM qc_iqc_detailed_record
  1125. WHERE inspection_no = #{inspectionNo} and site = #{site}
  1126. </select>
  1127. <!-- 查询IQC检验记录是否已提交 -->
  1128. <select id="checkIQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1129. SELECT submit_flag
  1130. FROM qc_iqc_record
  1131. WHERE inspection_no = #{inspectionNo} and site = #{site}
  1132. </select>
  1133. <!-- 查询IQC检验记录状态(用于保存前校验) -->
  1134. <select id="getIQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1135. SELECT submit_flag, state, inspection_result
  1136. FROM qc_iqc_record
  1137. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1138. </select>
  1139. <!-- 删除IQC子明细的老数据 -->
  1140. <delete id="delIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  1141. DELETE FROM qc_iqc_sub_detail_record
  1142. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1143. </delete>
  1144. <!-- 新增IQC子明细信息 -->
  1145. <insert id="saveIQCSubDetailed">
  1146. INSERT INTO qc_iqc_sub_detail_record
  1147. (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)
  1148. VALUES
  1149. <foreach collection="list" item="item" separator=",">
  1150. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  1151. </foreach>
  1152. </insert>
  1153. <!-- 修改IQC主记录标识为已提交 -->
  1154. <update id="updateIQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1155. UPDATE qc_iqc_record
  1156. SET submit_flag = 'Y',
  1157. state = '已完成',
  1158. submit_date = getDate()
  1159. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1160. </update>
  1161. <!-- 修改IQC明细记录标识为已提交 -->
  1162. <update id="updateIQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1163. UPDATE qc_iqc_detailed_record
  1164. SET is_submit = 'Y'
  1165. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1166. </update>
  1167. <!-- 修改IQC子明细记录标识为已提交 -->
  1168. <update id="updateIQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1169. UPDATE qc_iqc_sub_detail_record
  1170. SET is_submit = 'Y'
  1171. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1172. </update>
  1173. <!-- 删除IQC检验记录 -->
  1174. <delete id="deleteIQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1175. DELETE FROM qc_iqc_record
  1176. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1177. </delete>
  1178. <!-- 删除IQC明细记录信息 -->
  1179. <delete id="deleteIQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1180. DELETE FROM qc_iqc_detailed_record
  1181. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1182. </delete>
  1183. <!-- 删除IQC子明细记录信息 -->
  1184. <delete id="deleteIQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1185. DELETE FROM qc_iqc_sub_detail_record
  1186. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1187. </delete>
  1188. <!-- 查询文件ID -->
  1189. <select id="queryFileId" parameterType="com.gaotao.modules.oss.entity.SysOssEntity" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  1190. SELECT id, file_name
  1191. FROM sys_oss
  1192. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  1193. </select>
  1194. <!-- 获取工序列表 -->
  1195. <select id="getOperationDescList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
  1196. SELECT distinct
  1197. operationDesc
  1198. FROM view_SO_Routing
  1199. <where>
  1200. <if test = "operationDesc != null and operationDesc != ''">
  1201. AND operationDesc LIKE '%' + #{operationDesc} + '%'
  1202. </if>
  1203. </where>
  1204. </select>
  1205. <!-- 获取供应商列表 -->
  1206. <select id="getManufacturerList" parameterType="com.gaotao.modules.pms.data.QcPartAttributeData" resultType="com.gaotao.modules.pms.data.QcPartAttributeData">
  1207. SELECT
  1208. supplierID as manufacturerID,
  1209. supplierName as manufacturerName
  1210. FROM view_Supplier
  1211. <where>
  1212. site = #{site}
  1213. <if test = "manufacturerID != null and manufacturerID != ''">
  1214. AND supplierID LIKE '%' + #{manufacturerID} + '%'
  1215. </if>
  1216. <if test = "manufacturerName != null and manufacturerName != ''">
  1217. AND supplierName LIKE '%' + #{manufacturerName} + '%'
  1218. </if>
  1219. </where>
  1220. </select>
  1221. <!-- 获取机台列表 -->
  1222. <select id="getAllResourceList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1223. SELECT distinct
  1224. resourceId,
  1225. resourceDesc
  1226. FROM WorkCenterResource
  1227. <where>
  1228. site = #{site}
  1229. <if test = "resourceId != null and resourceId != ''">
  1230. AND resourceId LIKE '%' + #{resourceId} + '%'
  1231. </if>
  1232. <if test = "resourceDesc != null and resourceDesc != ''">
  1233. AND resourceDesc LIKE '%' + #{resourceDesc} + '%'
  1234. </if>
  1235. </where>
  1236. </select>
  1237. <!-- 获取工单列表 -->
  1238. <select id="getOrderNoList" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1239. SELECT DISTINCT
  1240. a.orderno as orderNo
  1241. FROM soscheduledrouting as a
  1242. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  1243. LEFT JOIN view_SO_Routing as c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  1244. <!-- LEFT JOIN part j ON a.site = j.site and a.part_no = j.partNo-->
  1245. <where>
  1246. a.site = #{site}
  1247. AND b.approve_qty is not null
  1248. <if test = "orderNo != null and orderNo != ''">
  1249. AND a.orderno LIKE '%' + #{orderNo} + '%'
  1250. </if>
  1251. </where>
  1252. order by a.orderno DESC
  1253. </select>
  1254. <!-- 查询FQC主记录信息 -->
  1255. <select id="qcFQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1256. SELECT
  1257. a.inspection_no,
  1258. a.site,
  1259. a.bu_no,
  1260. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1261. a.state,
  1262. a.inspection_result,
  1263. a.task_date,
  1264. a.inspection_type_no,
  1265. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  1266. a.inspection_cycle,
  1267. a.order_no,
  1268. a.operation_desc,
  1269. a.resource_id,
  1270. r.resourceDesc,
  1271. a.part_no,
  1272. d.PartDescription as part_desc,
  1273. d.cinv_source_code as cinvSourceCode,
  1274. d.sku as sku,
  1275. d.PartType as invdefinetype,
  1276. d.spec,
  1277. a.inspection_remark,
  1278. a.roll_qty,
  1279. a.sampling_qty,
  1280. a.disposal_measures,
  1281. a.disposal_remark,
  1282. a.inspector_date,
  1283. a.submit_date as submitDate,
  1284. a.inspector_no,
  1285. u.user_display as inspectorName,
  1286. a.ssr_id,
  1287. a.unqualified_qty,
  1288. a.submit_flag,
  1289. a.seq_no,
  1290. a.batch_roll_no,
  1291. a.special_requirements,
  1292. a.work_center_no,
  1293. a.roll_no,
  1294. a.um_id,
  1295. um.UMName as umName,
  1296. a.action_date,
  1297. a.action_by,
  1298. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1299. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1300. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1301. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1302. a.pass_qty,
  1303. a.not_pass_qty,
  1304. a.batch_qualified_qty,
  1305. a.document_no
  1306. FROM qc_fqc_record as a
  1307. left join part as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.partNo
  1308. left join sys_user as u on a.inspector_no = u.username
  1309. left join WorkCenterResource as r on a.site = r.site and a.resource_id = r.resourceId and a.work_center_no = r.workCenterNo
  1310. left join UM as um on a.site = um.site and a.um_id = um.UMID
  1311. <where>
  1312. a.site in (select site from AccessSite where userID = #{query.userName})
  1313. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  1314. <if test="query.buNo != null and query.buNo != ''">
  1315. AND a.bu_no = #{query.buNo}
  1316. </if>
  1317. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1318. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1319. </if>
  1320. <if test = "query.partNo != null and query.partNo != ''">
  1321. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  1322. </if>
  1323. <if test = "query.partDesc != null and query.partDesc != ''">
  1324. AND d.PartDescription LIKE '%' + #{query.partDesc} + '%'
  1325. </if>
  1326. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1327. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1328. </if>
  1329. <if test = "query.sku != null and query.sku != ''">
  1330. AND d.sku LIKE '%' + #{query.sku} + '%'
  1331. </if>
  1332. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1333. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1334. </if>
  1335. <if test = "query.states != null and query.states.size > 0">
  1336. AND a.state in
  1337. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  1338. #{item}
  1339. </foreach>
  1340. </if>
  1341. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1342. AND a.inspection_result = #{query.inspectionResult}
  1343. </if>
  1344. <if test = "query.orderNo != null and query.orderNo != ''">
  1345. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  1346. </if>
  1347. <if test = "query.seqNo != null and query.seqNo != ''">
  1348. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  1349. </if>
  1350. <if test = "query.operationDesc != null and query.operationDesc != ''">
  1351. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  1352. </if>
  1353. <if test="query.startDate != null">
  1354. AND a.inspector_date >= #{query.startDate}
  1355. </if>
  1356. <if test="query.endDate != null">
  1357. AND #{query.endDate} >= a.inspector_date
  1358. </if>
  1359. <if test="query.startDate2 != null">
  1360. AND a.task_date >= #{query.startDate2}
  1361. </if>
  1362. <if test="query.endDate2 != null">
  1363. AND #{query.endDate2} >= a.task_date
  1364. </if>
  1365. <if test = "query.spec != null and query.spec != ''">
  1366. AND d.spec LIKE '%' + #{query.spec} + '%'
  1367. </if>
  1368. <if test = "query.documentNo != null and query.documentNo != ''">
  1369. AND a.document_no LIKE '%' + #{query.documentNo} + '%'
  1370. </if>
  1371. </where>
  1372. ORDER BY
  1373. CASE WHEN a.state = '待检验' THEN 1
  1374. WHEN a.state = '待审核' THEN 2
  1375. WHEN a.state = '已完成' THEN 3
  1376. END, a.task_date desc
  1377. </select>
  1378. <insert id="saveFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1379. INSERT INTO qc_fqc_detailed_record
  1380. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1381. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1382. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  1383. VALUES
  1384. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  1385. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  1386. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  1387. </insert>
  1388. <!-- 新增FQC明细记录信息 -->
  1389. <insert id="saveFQCDetailedRecords">
  1390. INSERT INTO qc_fqc_detailed_record
  1391. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1392. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1393. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  1394. VALUES
  1395. <foreach collection="list" item="item" separator=",">
  1396. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  1397. #{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},
  1398. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  1399. </foreach>
  1400. </insert>
  1401. <!-- 新增FQC主记录信息 -->
  1402. <insert id="saveFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1403. INSERT INTO qc_fqc_record
  1404. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  1405. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  1406. VALUES
  1407. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  1408. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  1409. </insert>
  1410. <!-- FQC明细记录查询 -->
  1411. <select id="fqcDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1412. SELECT
  1413. a.site,
  1414. a.bu_no,
  1415. a.inspection_no,
  1416. a.order_no,
  1417. a.template_id,
  1418. a.sampling_level_no,
  1419. a.sampling_level_desc,
  1420. a.sampling_programme_no,
  1421. a.sampling_programme_desc,
  1422. a.AQL,
  1423. a.AC,
  1424. a.RE,
  1425. a.item_no,
  1426. a.item_desc,
  1427. a.object_id,
  1428. a.object_desc,
  1429. a.default_value,
  1430. a.min_value,
  1431. a.max_value,
  1432. a.text_value,
  1433. a.number_value,
  1434. a.value_type_db,
  1435. a.value_type,
  1436. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1437. a.is_submit,
  1438. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1439. a.sampling_qty,
  1440. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1441. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  1442. c.method_no,
  1443. c.method_name,
  1444. c.method_remark
  1445. FROM qc_fqc_detailed_record as a
  1446. 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
  1447. 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
  1448. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1449. order by a.order_id
  1450. </select>
  1451. <!-- 删除FQC检验记录 -->
  1452. <delete id="deleteFQCRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1453. DELETE FROM qc_fqc_record
  1454. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1455. </delete>
  1456. <!-- 删除FQC明细记录信息 -->
  1457. <delete id="deleteFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1458. DELETE FROM qc_fqc_detailed_record
  1459. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1460. </delete>
  1461. <!-- 删除FQC子明细记录信息 -->
  1462. <delete id="deleteFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1463. DELETE FROM qc_fqc_sub_detail_record
  1464. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1465. </delete>
  1466. <!-- 修改FQC主记录信息 -->
  1467. <update id="updateFQCMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1468. UPDATE qc_fqc_record
  1469. SET disposal_measures = #{disposalMeasures},
  1470. disposal_remark = #{disposalRemark},
  1471. inspection_result = #{inspectionResult},
  1472. inspector_no = #{inspectorNo},
  1473. state = #{state},
  1474. inspection_remark = #{inspectionRemark},
  1475. inspector_date = getDate(),
  1476. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1477. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1478. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1479. pass_qty = #{passQty,jdbcType=DECIMAL},
  1480. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1481. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  1482. submit_date = getDate()
  1483. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1484. </update>
  1485. <!-- 修改FQC明细记录信息 -->
  1486. <update id="updateFQCDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1487. UPDATE qc_fqc_detailed_record
  1488. SET item_result = #{itemResult},
  1489. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1490. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1491. text_value = #{textValue},
  1492. number_value = #{numberValue,jdbcType=DECIMAL},
  1493. default_value = #{defaultValue},
  1494. min_value = #{minValue,jdbcType=DECIMAL},
  1495. max_value = #{maxValue,jdbcType=DECIMAL}
  1496. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1497. </update>
  1498. <!-- 修改FQC主记录标识为已提交 -->
  1499. <update id="updateFQCMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1500. UPDATE qc_fqc_record
  1501. SET submit_flag = 'Y',
  1502. state = '已完成',
  1503. submit_date = getDate()
  1504. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1505. </update>
  1506. <!-- 修改FAI明细记录标识为已提交 -->
  1507. <update id="updateFQCDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1508. UPDATE qc_fqc_detailed_record
  1509. SET is_submit = 'Y'
  1510. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1511. </update>
  1512. <!-- 修改子明细记录标识为已提交 -->
  1513. <update id="updateFQCSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1514. UPDATE qc_fqc_sub_detail_record
  1515. SET is_submit = 'Y'
  1516. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1517. </update>
  1518. <!-- 删除子明细的老数据 -->
  1519. <delete id="delFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  1520. DELETE FROM qc_fqc_sub_detail_record
  1521. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1522. </delete>
  1523. <!-- 新增子明细信息 -->
  1524. <insert id="saveFQCSubDetailed">
  1525. INSERT INTO qc_fqc_sub_detail_record
  1526. (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)
  1527. VALUES
  1528. <foreach collection="list" item="item" separator=",">
  1529. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  1530. </foreach>
  1531. </insert>
  1532. <!-- 查询FQC的子明细 -->
  1533. <select id="selectFQCSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1534. SELECT
  1535. site,
  1536. bu_no,
  1537. sub_detail_value,
  1538. sampling_location,
  1539. is_submit,
  1540. sampling_location_b,
  1541. num,
  1542. sub_detail_value_b,
  1543. sub_detail_value_c,
  1544. sub_detail_value_d,
  1545. sub_detail_value_e
  1546. FROM qc_fqc_sub_detail_record
  1547. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1548. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1549. AND sub_detail_value ${collectionDataContent}
  1550. </if>
  1551. </select>
  1552. <!-- 查询FQC检验记录是否已提交 -->
  1553. <select id="checkFQCIsSubmit" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1554. SELECT submit_flag
  1555. FROM qc_fqc_record
  1556. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1557. </select>
  1558. <!-- 查询FQC检验记录状态(用于保存前校验) -->
  1559. <select id="getFQCRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1560. SELECT submit_flag, state, inspection_result
  1561. FROM qc_fqc_record
  1562. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1563. </select>
  1564. <!-- 获取该项目的子明细值 -->
  1565. <select id="selectFQCSubDetailValue" parameterType="string" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  1566. SELECT sub_detail_value,
  1567. sampling_location,
  1568. is_submit
  1569. FROM qc_fqc_sub_detail_record
  1570. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1571. </select>
  1572. <!-- 生成FQC检验单号 -->
  1573. <select id="selectFQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1574. SELECT
  1575. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  1576. FROM qc_fqc_record
  1577. WHERE site = #{site} and bu_no = #{buNo}
  1578. </select>
  1579. <!-- 生成IPQC检验单号 -->
  1580. <select id="selectIPQCInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1581. SELECT
  1582. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  1583. FROM qc_ipqc_record
  1584. WHERE site = #{site} and bu_no = #{buNo}
  1585. </select>
  1586. <!-- 生成FAI检验单号 -->
  1587. <select id="selectFAIInspectionNo" resultType="string" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1588. SELECT
  1589. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  1590. FROM qc_fai_record
  1591. WHERE site = #{site} and bu_no = #{buNo}
  1592. </select>
  1593. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  1594. <select id="queryDataFromViewPoOrder" resultType="com.gaotao.modules.pms.data.PoOrderData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1595. SELECT
  1596. site,
  1597. order_no,
  1598. item_no,
  1599. part_no,
  1600. part_desc,
  1601. spec,
  1602. supplier_id,
  1603. supplier_name,
  1604. order_qty,
  1605. created_date,
  1606. status,
  1607. citem_code,
  1608. citem_class,
  1609. sendto_address,
  1610. order_type
  1611. FROM view_po_order
  1612. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  1613. </select>
  1614. <!-- 向收货任务表里添加数据 -->
  1615. <insert id="saveReceivingTask" parameterType="com.gaotao.modules.pms.data.PoOrderData">
  1616. 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)
  1617. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}, #{batchNo}, #{productionDate}, #{expirationWarningDate}, #{expirationDate})
  1618. </insert>
  1619. <!-- 检查动控是否开启 -->
  1620. <select id="queryController" parameterType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity" resultType="com.gaotao.modules.sys.entity.SysSceneDynamicControlModelEntity">
  1621. SELECT
  1622. type,
  1623. base_data,
  1624. base_desc,
  1625. status,
  1626. remark,
  1627. third_type,
  1628. second_type,
  1629. page_control,
  1630. control_style
  1631. FROM sys_scene_dynamic_control_model
  1632. where site = #{site} and control_no = #{controlNo}
  1633. </select>
  1634. <!-- 查询检验模板列表 -->
  1635. <select id="queryTemplateList" resultType="com.gaotao.modules.pms.data.QcTemplateData" parameterType="com.gaotao.modules.pms.data.QcTemplateData">
  1636. SELECT
  1637. site,
  1638. bu_no,
  1639. template_id as templateId,
  1640. template_name as templateName,
  1641. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  1642. FROM qc_template
  1643. <where>
  1644. site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  1645. <if test = "templateId != null and templateId != ''">
  1646. AND template_id LIKE '%' + #{templateId}+'%'
  1647. </if>
  1648. <if test = "templateName != null and templateName != ''">
  1649. AND template_name LIKE '%' + #{templateName}+'%'
  1650. </if>
  1651. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  1652. AND inspection_type_no = #{inspectionTypeNo}
  1653. </if>
  1654. </where>
  1655. </select>
  1656. <!-- 查询检验模板列表 -->
  1657. <select id="getPartInformation" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1658. select
  1659. partNo,
  1660. PartDescription as partDesc,
  1661. spec,
  1662. sku,
  1663. DefaultWarehouseID as defaultWarehouseId
  1664. from part
  1665. where site = #{site} and partNo = #{partNo}
  1666. </select>
  1667. <!-- 获取特殊工序列表 -->
  1668. <select id="getSpecialOperationList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1669. select
  1670. site,
  1671. operation_no,
  1672. operation_desc
  1673. from qc_special_task_operation
  1674. where site = #{site}
  1675. </select>
  1676. <!-- 获取处置措施列表 -->
  1677. <select id="disposalMeasuresSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1678. SELECT
  1679. id,
  1680. disposal_measures
  1681. FROM qc_disposal_measures
  1682. <where>
  1683. <if test = "inspectionTypeNo != '101'">
  1684. inspection_type != 'IPQC'
  1685. </if>
  1686. </where>
  1687. </select>
  1688. <!-- 查询文件路径 -->
  1689. <select id="searchItemFileUrl" resultType="com.gaotao.modules.oss.entity.SysOssEntity" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1690. SELECT
  1691. id,
  1692. url,
  1693. file_name
  1694. FROM sys_oss
  1695. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  1696. </select>
  1697. <!-- 删除图片-->
  1698. <delete id="imageDelete" parameterType="com.gaotao.modules.oss.entity.SysOssEntity">
  1699. DELETE FROM sys_oss
  1700. WHERE id = #{id}
  1701. </delete>
  1702. <!-- 模糊查询标签号 -->
  1703. <select id="getRollNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1704. SELECT DISTINCT top 3
  1705. a.seqno,
  1706. a.orderno,
  1707. b.RollNo
  1708. FROM soscheduledrouting AS a
  1709. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
  1710. WHERE a.site = #{site} and b.RollNo like '%' + #{rollNo} + '%'
  1711. </select>
  1712. <!-- 标签号回车事件 -->
  1713. <select id="rollNoEnter" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1714. SELECT
  1715. a.site,
  1716. a.seqno as seqNo,
  1717. a.orderno as orderNo,
  1718. b.RollNo,
  1719. #{inspectionTypeNo} as inspectionTypeNo
  1720. FROM soscheduledrouting AS a
  1721. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.CreatedOpsSeqNo
  1722. WHERE a.site = #{site} and b.RollNo = #{rollNo}
  1723. </select>
  1724. <!-- 查询物料列表 -->
  1725. <select id="queryPartList" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1726. SELECT
  1727. site,
  1728. partNo,
  1729. PartDescription as part_desc,
  1730. sku,
  1731. spec
  1732. FROM part
  1733. <where>
  1734. site = #{site}
  1735. <if test = "partNo != null and partNo != ''">
  1736. AND partNo LIKE '%' + #{partNo} + '%'
  1737. </if>
  1738. <if test = "partDesc != null and partDesc != ''">
  1739. AND PartDescription LIKE '%' + #{partDesc} + '%'
  1740. </if>
  1741. <if test = "sku != null and sku != ''">
  1742. AND sku LIKE '%' + #{sku} + '%'
  1743. </if>
  1744. </where>
  1745. </select>
  1746. <!-- 查询单位列表 -->
  1747. <select id="umSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1748. SELECT
  1749. site,
  1750. UMID as umId,
  1751. UMName as umName
  1752. FROM UM
  1753. WHERE site = #{site} and active = #{active}
  1754. </select>
  1755. <!-- 查询单位列表 -->
  1756. <select id="checkItem" resultType="com.gaotao.modules.pms.data.SubDetailValues" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
  1757. SELECT
  1758. site,
  1759. bu_no,
  1760. inspection_no,
  1761. item_no,
  1762. value_type_db,
  1763. min_value,
  1764. max_value
  1765. <if test = "flag == 'IPQC'">
  1766. FROM qc_ipqc_detailed_record
  1767. </if>
  1768. <if test = "flag == 'IQC'">
  1769. FROM qc_iqc_detailed_record
  1770. </if>
  1771. <if test = "flag == 'FQC'">
  1772. FROM qc_fqc_detailed_record
  1773. </if>
  1774. <if test = "flag == 'FAI'">
  1775. FROM qc_fai_detailed_record
  1776. </if>
  1777. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  1778. order by order_id
  1779. </select>
  1780. <!-- 修改detailFlag字段为N -->
  1781. <update id="updateIQCDetailFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1782. UPDATE qc_iqc_record
  1783. SET detail_flag = 'N'
  1784. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1785. </update>
  1786. <select id="searchSeqInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1787. SELECT
  1788. a.seqno,
  1789. a.orderno,
  1790. J.partNo,
  1791. J.PartDescription as partDesc,
  1792. j.PartType as invdefinetype,
  1793. t.lotsize,--订单数量
  1794. a.QtyReported, --完工数量
  1795. c.operationDesc,
  1796. sum(roll_qty) as sjzs, --送检总数
  1797. work_center_no,
  1798. a.S_ResourceID as resourceId,
  1799. D.ResourceDesc as resourceDesc
  1800. FROM shoporder T
  1801. INNER JOIN soscheduledrouting a ON a.site = t.site AND t.orderno = a.orderno
  1802. INNER JOIN SORouting c ON c.site = a.site and c.orderNo = a.orderno and a.itemno = c.itemNo
  1803. INNER JOIN WorkCenterResource D ON C.Site = D.SITE AND C.WorkCenterNo = D.WorkCenterNo AND a.S_ResourceID = D.ResourceID
  1804. INNER JOIN part J ON t.site = J.site AND t.partNo = J.partNo
  1805. left join qc_ipqc_record r on a.site = r.site and a.seqno = r.seq_no
  1806. WHERE
  1807. a.site = #{query.site} and J.bu_no = #{query.buNo}
  1808. <if test="query.status != null and query.status != ''">
  1809. AND t.status = #{query.status}
  1810. </if>
  1811. <if test="query.orderNo != null and query.orderNo != ''">
  1812. AND a.orderno LIKE '%' + #{query.orderNo} + '%'
  1813. </if>
  1814. <if test="query.seqNo != null and query.seqNo != ''">
  1815. AND a.seqno LIKE '%' + #{query.seqNo} + '%'
  1816. </if>
  1817. <if test="query.sku != null and query.sku != ''">
  1818. AND j.sku LIKE '%' + #{query.sku} + '%'
  1819. </if>
  1820. <if test="query.partNo != null and query.partNo != ''">
  1821. AND J.partNo LIKE '%' + #{query.partNo} + '%'
  1822. </if>
  1823. <if test="query.partDesc != null and query.partDesc != ''">
  1824. AND J.PartDescription LIKE '%' + #{query.partDesc} + '%'
  1825. </if>
  1826. <if test="query.operationDesc != null and query.operationDesc != ''">
  1827. AND c.operationDesc LIKE '%' + #{query.operationDesc} + '%'
  1828. </if>
  1829. group by a.seqno, a.orderno, J.partNo, J.PartDescription, t.lotsize, a.QtyReported, c.operationDesc ,work_center_no ,PartType,a.S_ResourceID,D.ResourceDesc,C.ItemNo
  1830. </select>
  1831. <select id="searchPartInfo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1832. select
  1833. partNo,
  1834. PartDescription as partDesc,
  1835. sku,
  1836. <!-- cinv_source_code,-->
  1837. bu_no
  1838. from
  1839. part
  1840. where
  1841. bu_no = #{query.buNo}
  1842. <if test="query.partNo != null and query.partNo != ''">
  1843. AND partNo LIKE '%' + #{query.partNo} + '%'
  1844. </if>
  1845. <if test="query.partDesc != null and query.partDesc != ''">
  1846. AND PartDescription LIKE '%' + #{query.partDesc} + '%'
  1847. </if>
  1848. <if test="query.sku != null and query.sku != ''">
  1849. AND sku LIKE '%' + #{query.sku} + '%'
  1850. </if>
  1851. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1852. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1853. </if>
  1854. </select>
  1855. <select id="getInterfaceTimeData" parameterType="String" resultType="com.gaotao.modules.pms.data.InterfaceTimeData">
  1856. SELECT
  1857. id,
  1858. start_time,
  1859. end_time,
  1860. del_flag
  1861. FROM interface_time
  1862. WHERE del_flag = 'N' and site = #{site}
  1863. </select>
  1864. <update id="updateInterfaceTimeData" parameterType="com.gaotao.modules.pms.data.InterfaceTimeData">
  1865. UPDATE interface_time
  1866. set
  1867. updated_by = #{updatedBy},
  1868. updated_date = #{updatedDate},
  1869. del_flag = #{delFlag}
  1870. </update>
  1871. <select id="getInterfaceRdStyleData" parameterType="String" resultType="com.gaotao.modules.pms.data.RdStyleData">
  1872. SELECT
  1873. crdcode,
  1874. crdname,
  1875. iRdGrade,
  1876. rdtype,
  1877. brdend
  1878. FROM view_custdev_mes_rdstyle
  1879. WHERE crdname = #{crdName}
  1880. </select>
  1881. <insert id="insertHardtagPurchaseInStorageData" parameterType="com.gaotao.modules.pms.data.HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
  1882. INSERT INTO purchase_in_storage_count
  1883. (site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
  1884. cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
  1885. values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
  1886. #{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
  1887. </insert>
  1888. <insert id="batchSaveHrdtagTransHeader" parameterType="com.gaotao.modules.pms.data.HardtagTransHeaderData">
  1889. insert into TransHeader
  1890. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
  1891. TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
  1892. department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
  1893. values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
  1894. #{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
  1895. #{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
  1896. </insert>
  1897. <insert id="batchSaveHardtagTransDetail" parameterType="com.gaotao.modules.pms.data.HardtagTransDetailData">
  1898. INSERT INTO TransDetail
  1899. (TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
  1900. values
  1901. (#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
  1902. </insert>
  1903. <select id="getSendMailAddress" parameterType="String" resultType="com.gaotao.modules.pms.data.MailAddressData">
  1904. SELECT
  1905. id,
  1906. site,
  1907. bu_no,
  1908. mail_address,
  1909. send_type,
  1910. del_flag,
  1911. created_by,
  1912. created_date,
  1913. orderref1
  1914. FROM mailAddress
  1915. WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
  1916. <if test="buNo != null and buNo != ''">
  1917. AND bu_no = #{buNo}
  1918. </if>
  1919. </select>
  1920. <select id="getSendMailFromAddress" resultType="com.gaotao.modules.pms.data.MailSendAddressData">
  1921. SELECT
  1922. port,
  1923. host,
  1924. username,
  1925. password,
  1926. emailForm,
  1927. timeout,
  1928. personal,
  1929. id
  1930. FROM mailSendAddress
  1931. where delFlag = 'N'
  1932. </select>
  1933. <!-- 新增发送邮件记录 -->
  1934. <insert id="saveSendMailRecord" parameterType="com.gaotao.modules.pms.data.SendMailRecord">
  1935. insert into send_mail_record
  1936. (site, bu_no, document_no, sender, recipient, send_date, type)
  1937. values
  1938. (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate(), #{type})
  1939. </insert>
  1940. <select id="orderTypeSearch" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1941. SELECT distinct
  1942. order_type
  1943. FROM view_po_order
  1944. </select>
  1945. <update id="actionIQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  1946. update qc_iqc_record
  1947. set action_date = getDate(),
  1948. action_by = #{actionBy},
  1949. state = #{state}
  1950. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1951. </update>
  1952. <update id="actionFAIInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  1953. update qc_fai_record
  1954. set action_date = getDate(),
  1955. action_by = #{actionBy},
  1956. state = #{state}
  1957. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1958. </update>
  1959. <update id="actionIPQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  1960. update qc_ipqc_record
  1961. set action_date = getDate(),
  1962. action_by = #{actionBy},
  1963. state = #{state}
  1964. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1965. </update>
  1966. <update id="actionFQCInspection" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  1967. update qc_fqc_record
  1968. set action_date = getDate(),
  1969. action_by = #{actionBy},
  1970. state = #{state}
  1971. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  1972. </update>
  1973. <insert id="addEquipmentDataAcquisition">
  1974. insert into Equipment_data_acquisition
  1975. (site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
  1976. values
  1977. <foreach collection="list" item="item" separator=",">
  1978. (#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
  1979. </foreach>
  1980. </insert>
  1981. <!-- 新增人员信息 -->
  1982. <insert id="saveOperator" >
  1983. INSERT INTO eam_actual_operator
  1984. (site, order_no, function_type, operator, bu_no)
  1985. VALUES
  1986. <foreach collection="list" item="item" separator=",">
  1987. (#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
  1988. </foreach>
  1989. </insert>
  1990. <!-- 删除之前的人员-->
  1991. <delete id="delOperator" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  1992. DELETE FROM eam_actual_operator
  1993. WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
  1994. </delete>
  1995. <select id="getInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  1996. select distinct
  1997. site,
  1998. bu_no,
  1999. equipment_no,
  2000. inspection_no,
  2001. item_no,
  2002. collection_source,
  2003. collection_method
  2004. from Equipment_data_acquisition
  2005. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2006. </select>
  2007. <select id="getInspectionNoByItem" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  2008. select distinct
  2009. site,
  2010. bu_no,
  2011. equipment_no,
  2012. inspection_no,
  2013. item_no,
  2014. collection_source,
  2015. collection_method
  2016. from Equipment_data_acquisition
  2017. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  2018. </select>
  2019. <select id="dataAcquisition" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2020. select
  2021. id,
  2022. site,
  2023. bu_no,
  2024. #{inspectionNo} as inspectionNo,
  2025. #{itemNo} as itemNo,
  2026. <if test='subDetailValueType == 0'>
  2027. ${collectionSource} as subDetailValue,
  2028. </if>
  2029. <if test='subDetailValueType == 1'>
  2030. ${collectionSource} as subDetailValueB,
  2031. </if>
  2032. <if test='subDetailValueType == 2'>
  2033. ${collectionSource} as subDetailValueC,
  2034. </if>
  2035. <if test='subDetailValueType == 3'>
  2036. ${collectionSource} as subDetailValueD,
  2037. </if>
  2038. <if test='subDetailValueType == 4'>
  2039. ${collectionSource} as subDetailValueE,
  2040. </if>
  2041. num,
  2042. #{collectionSource} as collectionSource,
  2043. #{collectionMethod} as collectionMethod
  2044. from Equipment_data_detail
  2045. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  2046. <if test='collectionMethod == "plc"'>
  2047. AND inspection_no = #{inspectionNo}
  2048. </if>
  2049. <if test='collectionMethod == "RS232"'>
  2050. AND (inspection_no is null or inspection_no = '')
  2051. </if>
  2052. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2053. AND ${collectionSource} ${collectionDataContent}
  2054. </if>
  2055. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  2056. </select>
  2057. <select id="dataAcquisitionB" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2058. select
  2059. id,
  2060. site,
  2061. bu_no,
  2062. #{inspectionNo} as inspectionNo,
  2063. #{itemNo} as itemNo,
  2064. ${collectionSource} as subDetailValueB,
  2065. num,
  2066. #{collectionSource} as collectionSource
  2067. from Equipment_data_detail
  2068. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  2069. <if test='collectionMethod == "plc"'>
  2070. AND inspection_no = #{inspectionNo}
  2071. </if>
  2072. <if test='collectionMethod == "RS232"'>
  2073. AND (inspection_no is null or inspection_no = '')
  2074. </if>
  2075. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  2076. </select>
  2077. <select id="dataAcquisition2" parameterType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  2078. select
  2079. site as orderRef1,
  2080. bu_no as orderRef4,
  2081. #{inspectionNo} as orderRef2,
  2082. #{itemNo} as orderRef3,
  2083. ${collectionSource} as url
  2084. from Equipment_data_detail
  2085. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  2086. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  2087. </select>
  2088. <select id="getIQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  2089. select
  2090. a.site,
  2091. a.bu_no,
  2092. b.collection_condition as equipmentNo,
  2093. #{inspectionNo} as inspectionNo,
  2094. a.item_no,
  2095. b.collection_source,
  2096. #{actionBy} as actionBy,
  2097. b.collection_method
  2098. from qc_iqc_detailed_record as a
  2099. 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
  2100. 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'
  2101. order by a.order_id
  2102. </select>
  2103. <select id="getFAIDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  2104. select
  2105. a.site,
  2106. a.bu_no,
  2107. b.collection_condition as equipmentNo,
  2108. #{inspectionNo} as inspectionNo,
  2109. a.item_no,
  2110. b.collection_source,
  2111. #{actionBy} as actionBy,
  2112. b.collection_method
  2113. from qc_fai_detailed_record as a
  2114. 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
  2115. 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'
  2116. order by order_id
  2117. </select>
  2118. <select id="getIPQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  2119. select
  2120. a.site,
  2121. a.bu_no,
  2122. b.collection_condition as equipmentNo,
  2123. #{inspectionNo} as inspectionNo,
  2124. a.item_no,
  2125. b.collection_source,
  2126. #{actionBy} as actionBy,
  2127. b.collection_method
  2128. from qc_ipqc_detailed_record as a
  2129. 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
  2130. 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'
  2131. order by a.order_id
  2132. </select>
  2133. <select id="getFQCDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.EquipmentDataAcquisitionData">
  2134. select
  2135. a.site,
  2136. a.bu_no,
  2137. b.collection_condition as equipmentNo,
  2138. #{inspectionNo} as inspectionNo,
  2139. a.item_no,
  2140. b.collection_source,
  2141. #{actionBy} as actionBy,
  2142. b.collection_method
  2143. from qc_fqc_detailed_record as a
  2144. 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
  2145. 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'
  2146. order by a.order_id
  2147. </select>
  2148. <select id="querySubDetails" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.SubDetailValues">
  2149. select
  2150. b.site,
  2151. b.bu_no,
  2152. b.inspection_no,
  2153. b.item_no,
  2154. b.default_value,
  2155. b.min_value,
  2156. b.max_value,
  2157. b.value_type_db,
  2158. a.sub_detail_value
  2159. <if test="flag == 'iqc'">
  2160. from qc_iqc_sub_detail_record as a
  2161. 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
  2162. </if>
  2163. <if test="flag == 'ipqc'">
  2164. from qc_ipqc_sub_detail_record as a
  2165. 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
  2166. </if>
  2167. <if test="flag == 'fqc'">
  2168. from qc_fqc_sub_detail_record as a
  2169. 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
  2170. </if>
  2171. <if test="flag == 'fai'">
  2172. from qc_fai_sub_detail_record as a
  2173. 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
  2174. </if>
  2175. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
  2176. order by b.order_id
  2177. </select>
  2178. <insert id="saveFileList">
  2179. INSERT INTO sys_oss
  2180. (url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
  2181. VALUES
  2182. <foreach collection="list" item="item" separator=",">
  2183. (#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
  2184. </foreach>
  2185. </insert>
  2186. <select id="getEquipmentNoList" parameterType="com.gaotao.modules.pms.data.EquipmentFolderLocationData" resultType="com.gaotao.modules.pms.data.EquipmentFolderLocationData">
  2187. select
  2188. equipment_no
  2189. from Equipment_folder_location
  2190. where site = #{site} and bu_no = #{buNo}
  2191. </select>
  2192. <!-- 获取责任人员列表 -->
  2193. <select id="getResponsibleOperatorList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  2194. SELECT
  2195. operator_id as adminID,
  2196. operator_name as adminName
  2197. FROM operator
  2198. <where>
  2199. site in (select site from AccessSite where userID = #{userName})
  2200. <if test = "adminID != null and adminID != ''">
  2201. AND operator_id LIKE '%' + #{adminID} + '%'
  2202. </if>
  2203. <if test = "adminName != null and adminName != ''">
  2204. AND operator_name LIKE '%' + #{adminName} + '%'
  2205. </if>
  2206. </where>
  2207. </select>
  2208. <select id="getDataContentList" parameterType="com.gaotao.modules.pms.data.QcCollectionDataContentData" resultType="com.gaotao.modules.pms.data.QcCollectionDataContentData">
  2209. select
  2210. content_desc
  2211. from qc_collection_data_content
  2212. where site = #{site} and bu_no = #{buNo} and active = 'Y'
  2213. </select>
  2214. <select id="getItemCollectionDataContent" parameterType="com.gaotao.modules.pms.data.SubDetailValues" resultType="string">
  2215. select
  2216. collection_data_content
  2217. from eam_properties_item
  2218. where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
  2219. </select>
  2220. <!-- 获取当前项目不包含的设备 -->
  2221. <select id="getObjectList1" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  2222. SELECT
  2223. a.site,
  2224. a.bu_no,
  2225. a.ObjectID,
  2226. a.ObjectDesc
  2227. FROM eam_object as a
  2228. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID and b.ItemNo = #{itemNo}
  2229. where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  2230. </select>
  2231. <!-- 获取当前项目所包含的设备 -->
  2232. <select id="getObjectList2" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  2233. SELECT
  2234. a.site,
  2235. a.bu_no,
  2236. a.ObjectID,
  2237. b.ObjectDesc,
  2238. a.default_flag
  2239. FROM qc_item_object a
  2240. LEFT JOIN eam_object b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID
  2241. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
  2242. </select>
  2243. <!-- 获取当前项目不包含的设备 -->
  2244. <select id="getObjectListBy" resultType="com.gaotao.modules.pms.data.EamObjectInData" parameterType="com.gaotao.modules.pms.data.EamObjectInData">
  2245. SELECT
  2246. a.site,
  2247. a.bu_no,
  2248. a.ObjectID,
  2249. a.ObjectDesc
  2250. FROM eam_object as a
  2251. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID and b.ItemNo = #{itemNo}
  2252. <where>
  2253. a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  2254. <if test = "objectID != null and objectID != ''">
  2255. AND a.ObjectID LIKE '%' + #{objectID} + '%'
  2256. </if>
  2257. <if test = "objectDesc != null and objectDesc != ''">
  2258. AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
  2259. </if>
  2260. </where>
  2261. </select>
  2262. <!-- 新增项目设备 -->
  2263. <insert id="addItemObject">
  2264. INSERT INTO qc_item_object
  2265. (site, bu_no, ItemNo, ObjectID, default_flag)
  2266. VALUES
  2267. <foreach collection="list" item="item" separator=",">
  2268. (#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
  2269. </foreach>
  2270. </insert>
  2271. <delete id="deleteItemObject">
  2272. DELETE FROM qc_item_object
  2273. WHERE
  2274. <foreach collection="list" item="item" separator=" or " index="index">
  2275. (site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
  2276. </foreach>
  2277. </delete>
  2278. <update id="updateItemObject">
  2279. UPDATE qc_item_object
  2280. SET default_flag = #{defaultFlag}
  2281. WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
  2282. </update>
  2283. <select id="getIQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  2284. select
  2285. a.site,
  2286. a.bu_no,
  2287. a.inspection_no,
  2288. a.item_no,
  2289. a.item_desc,
  2290. b.collection_source,
  2291. b.collection_method
  2292. from qc_iqc_detailed_record as a
  2293. 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
  2294. 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'
  2295. order by a.order_id
  2296. </select>
  2297. <select id="getFAIInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  2298. select
  2299. a.site,
  2300. a.bu_no,
  2301. a.inspection_no,
  2302. a.item_no,
  2303. a.item_desc,
  2304. b.collection_source,
  2305. b.collection_method
  2306. from qc_fai_detailed_record as a
  2307. 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
  2308. 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'
  2309. order by a.order_id
  2310. </select>
  2311. <select id="getFQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  2312. select
  2313. a.site,
  2314. a.bu_no,
  2315. a.inspection_no,
  2316. a.item_no,
  2317. a.item_desc,
  2318. b.collection_source,
  2319. b.collection_method
  2320. from qc_fqc_detailed_record as a
  2321. 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
  2322. 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'
  2323. order by a.order_id
  2324. </select>
  2325. <select id="getIPQCInspectionDetail" parameterType="com.gaotao.modules.pms.data.EamObjectInData" resultType="com.gaotao.modules.pms.data.EamObjectInData">
  2326. select
  2327. a.site,
  2328. a.bu_no,
  2329. a.inspection_no,
  2330. a.item_no,
  2331. a.item_desc,
  2332. b.collection_source,
  2333. b.collection_method
  2334. from qc_ipqc_detailed_record as a
  2335. 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
  2336. 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'
  2337. order by a.order_id
  2338. </select>
  2339. <delete id="deleteEquipmentDataAcquisition" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2340. delete from Equipment_data_acquisition
  2341. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2342. </delete>
  2343. <!-- IPQC检验项目操作相关SQL -->
  2344. <!-- 查询可选的IPQC检验项目(未添加到当前检验单的) -->
  2345. <select id="getIPQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2346. SELECT
  2347. ItemNo as itemNo,
  2348. ItemDesc as itemDesc,
  2349. DefaultValue as defaultValue,
  2350. MaxValue as maxValue,
  2351. MinValue as minValue,
  2352. ValueType as valueType,
  2353. ValueType_DB as valueTypeDb
  2354. FROM eam_properties_item
  2355. WHERE site = #{site}
  2356. AND bu_no = #{buNo}
  2357. AND inspection_type_no = '101'
  2358. <if test="itemNo != null and itemNo != ''">
  2359. AND ItemNo LIKE '%' + #{itemNo} + '%'
  2360. </if>
  2361. <if test="itemDesc != null and itemDesc != ''">
  2362. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  2363. </if>
  2364. AND ItemNo NOT IN (
  2365. SELECT item_no
  2366. FROM qc_ipqc_detailed_record
  2367. WHERE site = #{site}
  2368. AND bu_no = #{buNo}
  2369. AND inspection_no = #{inspectionNo}
  2370. )
  2371. ORDER BY ItemNo
  2372. </select>
  2373. <!-- 查询已有的IPQC检验项目(当前检验单已添加的) -->
  2374. <select id="getIPQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2375. SELECT
  2376. d.item_no as itemNo,
  2377. d.item_desc as itemDesc
  2378. FROM qc_ipqc_detailed_record d
  2379. WHERE d.site = #{site}
  2380. AND d.bu_no = #{buNo}
  2381. AND d.inspection_no = #{inspectionNo}
  2382. ORDER BY d.item_no
  2383. </select>
  2384. <!-- 查询当前检验单已有的项目(用于获取template_id) -->
  2385. <select id="getExistingIPQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2386. SELECT TOP 1
  2387. template_id as templateId,
  2388. item_no as itemNo,
  2389. item_desc as itemDesc
  2390. FROM qc_ipqc_detailed_record
  2391. WHERE site = #{site}
  2392. AND bu_no = #{buNo}
  2393. AND inspection_no = #{inspectionNo}
  2394. ORDER BY item_no
  2395. </select>
  2396. <!-- 插入IPQC检验项目明细 -->
  2397. <insert id="insertIPQCItemDetail" parameterType="java.util.Map">
  2398. INSERT INTO qc_ipqc_detailed_record (
  2399. inspection_no,
  2400. order_no,
  2401. template_id,
  2402. item_no,
  2403. item_desc,
  2404. default_value,
  2405. min_value,
  2406. max_value,
  2407. value_type_db,
  2408. value_type,
  2409. site,
  2410. bu_no,
  2411. foreign_flag,
  2412. order_id
  2413. ) VALUES (
  2414. #{inspectionNo},
  2415. #{orderNo},
  2416. #{templateId},
  2417. #{itemNo},
  2418. #{itemDesc},
  2419. #{defaultValue},
  2420. #{minValue},
  2421. #{maxValue},
  2422. #{valueTypeDb},
  2423. #{valueType},
  2424. #{site},
  2425. #{buNo},
  2426. #{foreignFlag},
  2427. #{orderId}
  2428. )
  2429. </insert>
  2430. <!-- 获取检验单中最大的order_id -->
  2431. <select id="getMaxOrderIdForIPQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  2432. SELECT ISNULL(MAX(order_id), 0)
  2433. FROM qc_ipqc_detailed_record
  2434. WHERE site = #{site}
  2435. AND bu_no = #{buNo}
  2436. AND inspection_no = #{inspectionNo}
  2437. </select>
  2438. <!-- 删除IPQC检验项目明细 -->
  2439. <delete id="deleteIPQCItemDetail" parameterType="java.util.Map">
  2440. DELETE FROM qc_ipqc_detailed_record
  2441. WHERE site = #{site}
  2442. AND bu_no = #{buNo}
  2443. AND inspection_no = #{inspectionNo}
  2444. AND item_no = #{itemNo}
  2445. </delete>
  2446. <!-- 删除IPQC检验项目的子明细 -->
  2447. <delete id="deleteIPQCSubDetailByItem" parameterType="java.util.Map">
  2448. DELETE FROM qc_ipqc_sub_detail_record
  2449. WHERE site = #{site}
  2450. AND bu_no = #{buNo}
  2451. AND inspection_no = #{inspectionNo}
  2452. AND item_no = #{itemNo}
  2453. </delete>
  2454. <!-- IPQC模板导入相关SQL -->
  2455. <!-- 查询IPQC模板列表 -->
  2456. <select id="getIPQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  2457. SELECT
  2458. t.template_id as templateId,
  2459. t.template_name as templateName,
  2460. t.template_remark as remark,
  2461. (SELECT COUNT(*) FROM qc_template_detailed d
  2462. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  2463. FROM qc_template t
  2464. WHERE t.site = #{site}
  2465. AND t.bu_no = #{buNo}
  2466. AND t.inspection_type_no = '101'
  2467. <if test="templateId != null and templateId != ''">
  2468. AND t.template_id LIKE '%' + #{templateId} + '%'
  2469. </if>
  2470. <if test="templateDesc != null and templateDesc != ''">
  2471. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  2472. </if>
  2473. ORDER BY t.template_id
  2474. </select>
  2475. <!-- 查询模板的所有检验项目(按order_id排序) -->
  2476. <select id="getTemplateItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2477. SELECT
  2478. d.ItemNo as itemNo,
  2479. p.ItemDesc as itemDesc,
  2480. d.default_value as defaultValue,
  2481. d.max_value as maxValue,
  2482. d.min_value as minValue,
  2483. p.ValueType as valueType,
  2484. p.ValueType_DB as valueTypeDb,
  2485. d.order_id as orderId
  2486. FROM qc_template_detailed d
  2487. LEFT JOIN eam_properties_item p
  2488. ON d.site = p.site
  2489. AND d.bu_no = p.bu_no
  2490. AND d.ItemNo = p.ItemNo
  2491. WHERE d.site = #{site}
  2492. AND d.bu_no = #{buNo}
  2493. AND d.template_id = #{templateId}
  2494. ORDER BY COALESCE(d.order_id, 99999) ASC, d.ItemNo ASC
  2495. </select>
  2496. <!-- 查询检验单已有的项目编码列表 -->
  2497. <select id="getExistingItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  2498. SELECT item_no
  2499. FROM qc_ipqc_detailed_record
  2500. WHERE site = #{site}
  2501. AND bu_no = #{buNo}
  2502. AND inspection_no = #{inspectionNo}
  2503. </select>
  2504. <!-- ======================== IQC检验项目操作和模板导入 ======================== -->
  2505. <!-- 查询IQC可选的检验项目 -->
  2506. <select id="getIQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2507. SELECT
  2508. ItemNo as itemNo,
  2509. ItemDesc as itemDesc,
  2510. DefaultValue as defaultValue,
  2511. MaxValue as maxValue,
  2512. MinValue as minValue,
  2513. ValueType as valueType,
  2514. ValueType_DB as valueTypeDb
  2515. FROM eam_properties_item
  2516. WHERE site = #{site}
  2517. AND bu_no = #{buNo}
  2518. AND inspection_type_no = '105'
  2519. <if test="itemNo != null and itemNo != ''">
  2520. AND ItemNo LIKE '%' + #{itemNo} + '%'
  2521. </if>
  2522. <if test="itemDesc != null and itemDesc != ''">
  2523. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  2524. </if>
  2525. AND ItemNo NOT IN (
  2526. SELECT item_no
  2527. FROM qc_iqc_detailed_record
  2528. WHERE site = #{site}
  2529. AND bu_no = #{buNo}
  2530. AND inspection_no = #{inspectionNo}
  2531. )
  2532. ORDER BY ItemNo
  2533. </select>
  2534. <!-- 查询IQC已选的检验项目 -->
  2535. <select id="getIQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2536. SELECT
  2537. d.item_no as itemNo,
  2538. d.item_desc as itemDesc
  2539. FROM qc_iqc_detailed_record d
  2540. WHERE d.site = #{site}
  2541. AND d.bu_no = #{buNo}
  2542. AND d.inspection_no = #{inspectionNo}
  2543. ORDER BY d.item_no
  2544. </select>
  2545. <!-- 查询当前IQC检验单已有的项目 -->
  2546. <select id="getExistingIQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2547. SELECT TOP 1
  2548. template_id as templateId,
  2549. item_no as itemNo,
  2550. foreign_flag as foreignFlag
  2551. FROM qc_iqc_detailed_record
  2552. WHERE site = #{site}
  2553. AND bu_no = #{buNo}
  2554. AND inspection_no = #{inspectionNo}
  2555. </select>
  2556. <!-- 插入IQC检验项目 -->
  2557. <insert id="insertIQCItemDetail" parameterType="java.util.Map">
  2558. INSERT INTO qc_iqc_detailed_record (
  2559. inspection_no,
  2560. template_id,
  2561. item_no,
  2562. item_desc,
  2563. default_value,
  2564. min_value,
  2565. max_value,
  2566. value_type_db,
  2567. value_type,
  2568. site,
  2569. bu_no,
  2570. foreign_flag,
  2571. order_id
  2572. ) VALUES (
  2573. #{inspectionNo},
  2574. #{templateId},
  2575. #{itemNo},
  2576. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2577. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2578. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2579. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2580. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2581. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2582. #{site},
  2583. #{buNo},
  2584. #{foreignFlag},
  2585. #{orderId}
  2586. )
  2587. </insert>
  2588. <!-- 获取IQC检验单中最大的order_id -->
  2589. <select id="getMaxOrderIdForIQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  2590. SELECT ISNULL(MAX(order_id), 0)
  2591. FROM qc_iqc_detailed_record
  2592. WHERE site = #{site}
  2593. AND bu_no = #{buNo}
  2594. AND inspection_no = #{inspectionNo}
  2595. </select>
  2596. <!-- 删除IQC检验项目 -->
  2597. <delete id="deleteIQCItemDetail" parameterType="java.util.Map">
  2598. DELETE FROM qc_iqc_detailed_record
  2599. WHERE site = #{site}
  2600. AND bu_no = #{buNo}
  2601. AND inspection_no = #{inspectionNo}
  2602. AND item_no = #{itemNo}
  2603. </delete>
  2604. <!-- 删除IQC检验项目的子明细 -->
  2605. <delete id="deleteIQCSubDetailByItem" parameterType="java.util.Map">
  2606. DELETE FROM qc_iqc_sub_detail_record
  2607. WHERE site = #{site}
  2608. AND bu_no = #{buNo}
  2609. AND inspection_no = #{inspectionNo}
  2610. AND item_no = #{itemNo}
  2611. </delete>
  2612. <!-- 查询IQC模板列表 -->
  2613. <select id="getIQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  2614. SELECT
  2615. t.template_id as templateId,
  2616. t.template_name as templateName,
  2617. t.template_remark as remark,
  2618. (SELECT COUNT(*) FROM qc_template_detailed d
  2619. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  2620. FROM qc_template t
  2621. WHERE t.site = #{site}
  2622. AND t.bu_no = #{buNo}
  2623. AND t.inspection_type_no = '105'
  2624. <if test="templateId != null and templateId != ''">
  2625. AND t.template_id LIKE '%' + #{templateId} + '%'
  2626. </if>
  2627. <if test="templateDesc != null and templateDesc != ''">
  2628. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  2629. </if>
  2630. ORDER BY t.template_id
  2631. </select>
  2632. <!-- 查询IQC检验单已有的项目编码 -->
  2633. <select id="getExistingIQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  2634. SELECT item_no
  2635. FROM qc_iqc_detailed_record
  2636. WHERE site = #{site}
  2637. AND bu_no = #{buNo}
  2638. AND inspection_no = #{inspectionNo}
  2639. </select>
  2640. <!-- ======================== FQC检验项目操作和模板导入 ======================== -->
  2641. <!-- 查询FQC可选的检验项目 -->
  2642. <select id="getFQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2643. SELECT
  2644. ItemNo as itemNo,
  2645. ItemDesc as itemDesc,
  2646. DefaultValue as defaultValue,
  2647. MaxValue as maxValue,
  2648. MinValue as minValue,
  2649. ValueType as valueType,
  2650. ValueType_DB as valueTypeDb
  2651. FROM eam_properties_item
  2652. WHERE site = #{site}
  2653. AND bu_no = #{buNo}
  2654. AND inspection_type_no = '107'
  2655. <if test="itemNo != null and itemNo != ''">
  2656. AND ItemNo LIKE '%' + #{itemNo} + '%'
  2657. </if>
  2658. <if test="itemDesc != null and itemDesc != ''">
  2659. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  2660. </if>
  2661. AND ItemNo NOT IN (
  2662. SELECT item_no
  2663. FROM qc_fqc_detailed_record
  2664. WHERE site = #{site}
  2665. AND bu_no = #{buNo}
  2666. AND inspection_no = #{inspectionNo}
  2667. )
  2668. ORDER BY ItemNo
  2669. </select>
  2670. <!-- 查询FQC已选的检验项目 -->
  2671. <select id="getFQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2672. SELECT
  2673. d.item_no as itemNo,
  2674. d.item_desc as itemDesc
  2675. FROM qc_fqc_detailed_record d
  2676. WHERE d.site = #{site}
  2677. AND d.bu_no = #{buNo}
  2678. AND d.inspection_no = #{inspectionNo}
  2679. ORDER BY d.item_no
  2680. </select>
  2681. <!-- 查询当前FQC检验单已有的项目 -->
  2682. <select id="getExistingFQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2683. SELECT TOP 1
  2684. template_id as templateId,
  2685. item_no as itemNo,
  2686. foreign_flag as foreignFlag
  2687. FROM qc_fqc_detailed_record
  2688. WHERE site = #{site}
  2689. AND bu_no = #{buNo}
  2690. AND inspection_no = #{inspectionNo}
  2691. </select>
  2692. <!-- 插入FQC检验项目 -->
  2693. <insert id="insertFQCItemDetail" parameterType="java.util.Map">
  2694. INSERT INTO qc_fqc_detailed_record (
  2695. inspection_no,
  2696. template_id,
  2697. item_no,
  2698. item_desc,
  2699. default_value,
  2700. min_value,
  2701. max_value,
  2702. value_type_db,
  2703. value_type,
  2704. site,
  2705. bu_no,
  2706. foreign_flag,
  2707. order_id
  2708. ) VALUES (
  2709. #{inspectionNo},
  2710. #{templateId},
  2711. #{itemNo},
  2712. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2713. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2714. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2715. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2716. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2717. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2718. #{site},
  2719. #{buNo},
  2720. #{foreignFlag},
  2721. #{orderId}
  2722. )
  2723. </insert>
  2724. <!-- 获取FQC检验单中最大的order_id -->
  2725. <select id="getMaxOrderIdForFQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  2726. SELECT ISNULL(MAX(order_id), 0)
  2727. FROM qc_fqc_detailed_record
  2728. WHERE site = #{site}
  2729. AND bu_no = #{buNo}
  2730. AND inspection_no = #{inspectionNo}
  2731. </select>
  2732. <!-- 删除FQC检验项目 -->
  2733. <delete id="deleteFQCItemDetail" parameterType="java.util.Map">
  2734. DELETE FROM qc_fqc_detailed_record
  2735. WHERE site = #{site}
  2736. AND bu_no = #{buNo}
  2737. AND inspection_no = #{inspectionNo}
  2738. AND item_no = #{itemNo}
  2739. </delete>
  2740. <!-- 删除FQC检验项目的子明细 -->
  2741. <delete id="deleteFQCSubDetailByItem" parameterType="java.util.Map">
  2742. DELETE FROM qc_fqc_sub_detail_record
  2743. WHERE site = #{site}
  2744. AND bu_no = #{buNo}
  2745. AND inspection_no = #{inspectionNo}
  2746. AND item_no = #{itemNo}
  2747. </delete>
  2748. <!-- 查询FQC模板列表 -->
  2749. <select id="getFQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  2750. SELECT
  2751. t.template_id as templateId,
  2752. t.template_name as templateName,
  2753. t.template_remark as remark,
  2754. (SELECT COUNT(*) FROM qc_template_detailed d
  2755. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  2756. FROM qc_template t
  2757. WHERE t.site = #{site}
  2758. AND t.bu_no = #{buNo}
  2759. AND t.inspection_type_no = '107'
  2760. <if test="templateId != null and templateId != ''">
  2761. AND t.template_id LIKE '%' + #{templateId} + '%'
  2762. </if>
  2763. <if test="templateDesc != null and templateDesc != ''">
  2764. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  2765. </if>
  2766. ORDER BY t.template_id
  2767. </select>
  2768. <!-- 查询FQC检验单已有的项目编码 -->
  2769. <select id="getExistingFQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  2770. SELECT item_no
  2771. FROM qc_fqc_detailed_record
  2772. WHERE site = #{site}
  2773. AND bu_no = #{buNo}
  2774. AND inspection_no = #{inspectionNo}
  2775. </select>
  2776. <!-- ======================== OQC检验项目操作和模板导入 ======================== -->
  2777. <!-- 查询OQC可选的检验项目 -->
  2778. <select id="getOQCAvailableItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2779. SELECT
  2780. ItemNo as itemNo,
  2781. ItemDesc as itemDesc,
  2782. DefaultValue as defaultValue,
  2783. MaxValue as maxValue,
  2784. MinValue as minValue,
  2785. ValueType as valueType,
  2786. ValueType_DB as valueTypeDb
  2787. FROM eam_properties_item
  2788. WHERE site = #{site}
  2789. AND bu_no = #{buNo}
  2790. AND inspection_type_no = '109'
  2791. <if test="itemNo != null and itemNo != ''">
  2792. AND ItemNo LIKE '%' + #{itemNo} + '%'
  2793. </if>
  2794. <if test="itemDesc != null and itemDesc != ''">
  2795. AND ItemDesc LIKE '%' + #{itemDesc} + '%'
  2796. </if>
  2797. AND ItemNo NOT IN (
  2798. SELECT item_no
  2799. FROM qc_oqc_detailed_record
  2800. WHERE site = #{site}
  2801. AND bu_no = #{buNo}
  2802. AND inspection_no = #{inspectionNo}
  2803. )
  2804. ORDER BY ItemNo
  2805. </select>
  2806. <!-- 查询OQC已选的检验项目 -->
  2807. <select id="getOQCSelectedItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2808. SELECT
  2809. d.item_no as itemNo,
  2810. d.item_desc as itemDesc
  2811. FROM qc_oqc_detailed_record d
  2812. WHERE d.site = #{site}
  2813. AND d.bu_no = #{buNo}
  2814. AND d.inspection_no = #{inspectionNo}
  2815. ORDER BY d.item_no
  2816. </select>
  2817. <!-- 查询当前OQC检验单已有的项目 -->
  2818. <select id="getExistingOQCItems" parameterType="java.util.Map" resultType="com.gaotao.modules.pms.data.EamPropertiesItemData">
  2819. SELECT TOP 1
  2820. template_id as templateId,
  2821. item_no as itemNo,
  2822. foreign_flag as foreignFlag
  2823. FROM qc_oqc_detailed_record
  2824. WHERE site = #{site}
  2825. AND bu_no = #{buNo}
  2826. AND inspection_no = #{inspectionNo}
  2827. </select>
  2828. <!-- 插入OQC检验项目 -->
  2829. <insert id="insertOQCItemDetail" parameterType="java.util.Map">
  2830. INSERT INTO qc_oqc_detailed_record (
  2831. inspection_no,
  2832. template_id,
  2833. item_no,
  2834. item_desc,
  2835. default_value,
  2836. min_value,
  2837. max_value,
  2838. value_type_db,
  2839. value_type,
  2840. site,
  2841. bu_no,
  2842. foreign_flag,
  2843. order_id
  2844. ) VALUES (
  2845. #{inspectionNo},
  2846. #{templateId},
  2847. #{itemNo},
  2848. (SELECT ItemDesc FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2849. (SELECT DefaultValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2850. (SELECT MinValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2851. (SELECT MaxValue FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2852. (SELECT ValueType_DB FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2853. (SELECT ValueType FROM eam_properties_item WHERE site = #{site} AND bu_no = #{buNo} AND ItemNo = #{itemNo}),
  2854. #{site},
  2855. #{buNo},
  2856. #{foreignFlag},
  2857. #{orderId}
  2858. )
  2859. </insert>
  2860. <!-- 获取OQC检验单中最大的order_id -->
  2861. <select id="getMaxOrderIdForOQC" parameterType="java.util.Map" resultType="java.lang.Integer">
  2862. SELECT ISNULL(MAX(order_id), 0)
  2863. FROM qc_oqc_detailed_record
  2864. WHERE site = #{site}
  2865. AND bu_no = #{buNo}
  2866. AND inspection_no = #{inspectionNo}
  2867. </select>
  2868. <!-- 删除OQC检验项目 -->
  2869. <delete id="deleteOQCItemDetail" parameterType="java.util.Map">
  2870. DELETE FROM qc_oqc_detailed_record
  2871. WHERE site = #{site}
  2872. AND bu_no = #{buNo}
  2873. AND inspection_no = #{inspectionNo}
  2874. AND item_no = #{itemNo}
  2875. </delete>
  2876. <!-- 删除OQC检验项目的子明细 -->
  2877. <delete id="deleteOQCSubDetailByItem" parameterType="java.util.Map">
  2878. DELETE FROM qc_oqc_sub_detail_record
  2879. WHERE site = #{site}
  2880. AND bu_no = #{buNo}
  2881. AND inspection_no = #{inspectionNo}
  2882. AND item_no = #{itemNo}
  2883. </delete>
  2884. <!-- 查询OQC模板列表 -->
  2885. <select id="getOQCTemplateList" parameterType="java.util.Map" resultType="java.util.HashMap">
  2886. SELECT
  2887. t.template_id as templateId,
  2888. t.template_name as templateName,
  2889. t.template_remark as remark,
  2890. (SELECT COUNT(*) FROM qc_template_detailed d
  2891. WHERE d.site = t.site AND d.bu_no = t.bu_no AND d.template_id = t.template_id) as itemCount
  2892. FROM qc_template t
  2893. WHERE t.site = #{site}
  2894. AND t.bu_no = #{buNo}
  2895. AND t.inspection_type_no = '109'
  2896. <if test="templateId != null and templateId != ''">
  2897. AND t.template_id LIKE '%' + #{templateId} + '%'
  2898. </if>
  2899. <if test="templateDesc != null and templateDesc != ''">
  2900. AND t.template_name LIKE '%' + #{templateDesc} + '%'
  2901. </if>
  2902. ORDER BY t.template_id
  2903. </select>
  2904. <!-- 查询OQC检验单已有的项目编码 -->
  2905. <select id="getExistingOQCItemNos" parameterType="java.util.Map" resultType="java.lang.String">
  2906. SELECT item_no
  2907. FROM qc_oqc_detailed_record
  2908. WHERE site = #{site}
  2909. AND bu_no = #{buNo}
  2910. AND inspection_no = #{inspectionNo}
  2911. </select>
  2912. <select id="getInspectionStandards" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  2913. select
  2914. site,
  2915. bu_no,
  2916. template_id,
  2917. item_no,
  2918. default_value,
  2919. min_value,
  2920. max_value,
  2921. condition,
  2922. collection_source,
  2923. seq_no
  2924. from qc_inspection_standards
  2925. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  2926. </select>
  2927. <delete id="deleteInspectionStandard" parameterType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  2928. delete from qc_inspection_standards
  2929. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  2930. </delete>
  2931. <insert id="saveInspectionStandard">
  2932. INSERT INTO qc_inspection_standards
  2933. (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
  2934. VALUES
  2935. <foreach collection="list" item="item" separator=",">
  2936. (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
  2937. </foreach>
  2938. </insert>
  2939. <select id="getInspectionTemplateDetail" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcInspectionStandardData">
  2940. select
  2941. site,
  2942. bu_no,
  2943. template_id,
  2944. item_no
  2945. <if test="flag == 'iqc'">
  2946. from qc_iqc_detailed_record
  2947. </if>
  2948. <if test="flag == 'ipqc'">
  2949. from qc_ipqc_detailed_record
  2950. </if>
  2951. <if test="flag == 'fqc'">
  2952. from qc_fqc_detailed_record
  2953. </if>
  2954. <if test="flag == 'fai'">
  2955. from qc_fai_detailed_record
  2956. </if>
  2957. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2958. order by order_id
  2959. </select>
  2960. <update id="updateEquipmentDataDetailInspectionNo" parameterType="com.gaotao.modules.pms.data.SubDetailValues">
  2961. update Equipment_data_detail
  2962. set inspection_no = #{inspectionNo}
  2963. where id = #{id}
  2964. </update>
  2965. <delete id="deleteInspectionFiles" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  2966. delete sys_oss
  2967. where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo}
  2968. </delete>
  2969. <select id="getUpItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
  2970. select
  2971. top 1
  2972. site,
  2973. bu_no,
  2974. template_id,
  2975. ItemNo,
  2976. order_id
  2977. from qc_template_detailed
  2978. where #{orderId} > order_id
  2979. and site = #{site}
  2980. and bu_no= #{buNo}
  2981. and template_id = #{templateId}
  2982. order by order_id desc
  2983. </select>
  2984. <select id="getDownItemdata" resultType="com.gaotao.modules.pms.data.QcTemplateData">
  2985. select
  2986. top 1
  2987. site,
  2988. bu_no,
  2989. template_id,
  2990. ItemNo,
  2991. order_id
  2992. from qc_template_detailed
  2993. where order_id > #{orderId}
  2994. and site = #{site}
  2995. and bu_no= #{buNo}
  2996. and template_id = #{templateId}
  2997. order by order_id
  2998. </select>
  2999. <update id="updateQcItemOrder">
  3000. update qc_template_detailed
  3001. set order_id=#{orderId}
  3002. where site = #{site}
  3003. and bu_no= #{buNo}
  3004. and template_id = #{templateId}
  3005. and ItemNo = #{itemNo}
  3006. </update>
  3007. <select id="selectInfoByInspectionNo" resultType="com.gaotao.modules.pms.data.PoOrderRollNoData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3008. select
  3009. site,
  3010. bu_no,
  3011. inspection_no
  3012. from po_order_roll_no
  3013. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3014. </select>
  3015. <update id="updateIQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3016. UPDATE qc_iqc_record
  3017. SET submit_flag = 'N',
  3018. state = '待检验',
  3019. cancel_check_by = #{updateBy},
  3020. cancel_check_date = getDate()
  3021. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3022. </update>
  3023. <update id="updateIQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3024. UPDATE qc_iqc_detailed_record
  3025. SET is_submit = 'N'
  3026. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3027. </update>
  3028. <update id="updateIQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3029. UPDATE qc_iqc_sub_detail_record
  3030. SET is_submit = 'N'
  3031. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3032. </update>
  3033. <update id="updatePartDefectTracking" statementType="CALLABLE">
  3034. {CALL UspUpdatePartDefectTracking(
  3035. #{site,mode=IN,jdbcType=VARCHAR},
  3036. #{buNo,mode=IN,jdbcType=VARCHAR},
  3037. #{partNo,mode=IN,jdbcType=VARCHAR},
  3038. #{supplierId,mode=IN,jdbcType=VARCHAR},
  3039. #{passFlag,mode=IN,jdbcType=BIT}
  3040. )}
  3041. </update>
  3042. <update id="updateFAIMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3043. UPDATE qc_fai_record
  3044. SET submit_flag = 'N',
  3045. state = '待检验',
  3046. cancel_check_by = #{updateBy},
  3047. cancel_check_date = getDate()
  3048. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3049. </update>
  3050. <update id="updateFAIDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3051. UPDATE qc_fai_detailed_record
  3052. SET is_submit = 'N'
  3053. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3054. </update>
  3055. <update id="updateFAISubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3056. UPDATE qc_fai_sub_detail_record
  3057. SET is_submit = 'N'
  3058. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3059. </update>
  3060. <update id="updateIPQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3061. UPDATE qc_ipqc_record
  3062. SET submit_flag = 'N',
  3063. state = '待检验',
  3064. cancel_check_by = #{updateBy},
  3065. cancel_check_date = getDate()
  3066. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3067. </update>
  3068. <update id="updateIPQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3069. UPDATE qc_ipqc_detailed_record
  3070. SET is_submit = 'N'
  3071. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3072. </update>
  3073. <update id="updateIPQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3074. UPDATE qc_ipqc_sub_detail_record
  3075. SET is_submit = 'N'
  3076. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3077. </update>
  3078. <update id="updateFQCMasterSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3079. UPDATE qc_fqc_record
  3080. SET submit_flag = 'N',
  3081. state = '待检验',
  3082. cancel_check_by = #{updateBy},
  3083. cancel_check_date = getDate()
  3084. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3085. </update>
  3086. <update id="updateFQCDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3087. UPDATE qc_fqc_detailed_record
  3088. SET is_submit = 'N'
  3089. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3090. </update>
  3091. <update id="updateFQCSubDetailSubmitFlag2" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3092. UPDATE qc_fqc_sub_detail_record
  3093. SET is_submit = 'N'
  3094. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3095. </update>
  3096. <delete id="deleteReceivingTaskByInspectionNo" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3097. delete receiving_task
  3098. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  3099. </delete>
  3100. <delete id="deleteObjectFile">
  3101. delete from sys_oss where id = #{id}
  3102. </delete>
  3103. <!-- 获取用户角色列表 -->
  3104. <select id="getUserRoleList" resultType="com.gaotao.modules.sys.entity.SysRoleEntity">
  3105. SELECT
  3106. role_id,
  3107. role_name
  3108. FROM sys_role
  3109. </select>
  3110. <select id="getOperatorListByOrder" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  3111. SELECT
  3112. a.user_id, a.username AS adminID, a.email, a.mobile AS phone, a.user_display AS adminName,
  3113. d.role_id, e.role_name, c.site, c.bu_no,
  3114. -- 获取计划工单数
  3115. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) AS planOrderCount,
  3116. -- 获取实际工单数
  3117. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) AS actualOrderCount,
  3118. -- 负荷率(%)
  3119. CASE
  3120. WHEN dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username) = 0 THEN 0
  3121. ELSE
  3122. CAST(
  3123. dbo.get_actual_order_count(c.site, c.bu_no, #{functionType}, a.username) * 100.0 /
  3124. dbo.get_plan_order_count(c.site, c.bu_no, #{functionType}, a.username)
  3125. AS DECIMAL(5,2))
  3126. END AS load_rate
  3127. FROM
  3128. sys_user AS a
  3129. LEFT JOIN AccessSite AS b ON a.username = b.userID
  3130. LEFT JOIN AccessBu AS c ON b.userID = c.username AND b.site = c.site
  3131. LEFT JOIN sys_user_role AS d ON a.user_id = d.user_id
  3132. LEFT JOIN sys_role AS e ON d.role_id = e.role_id
  3133. <where>
  3134. b.site = #{site} and c.bu_no = #{buNo}
  3135. <if test = "adminID != null and adminID != ''">
  3136. AND a.username LIKE '%' + #{adminID} + '%'
  3137. </if>
  3138. <if test = "adminName != null and adminName != ''">
  3139. AND a.user_display LIKE '%' + #{adminName} + '%'
  3140. </if>
  3141. <if test = "roleId != null and roleId != ''">
  3142. AND d.role_id = #{roleId}
  3143. </if>
  3144. <if test = "date != null and classesCode != null and classesCode != ''">
  3145. AND a.username IN (
  3146. SELECT tpm_scheduling_record.admin_id
  3147. FROM tpm_scheduling
  3148. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3149. 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'
  3150. )
  3151. </if>
  3152. <if test = "date != null and (classesCode == null or classesCode == '')">
  3153. AND a.username IN (
  3154. SELECT tpm_scheduling_record.admin_id
  3155. FROM tpm_scheduling
  3156. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3157. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.date= #{date} and tpm_scheduling_record.isHoliday = 'N'
  3158. )
  3159. </if>
  3160. <if test = "classesCode != null and classesCode != '' and date == null">
  3161. AND a.username IN (
  3162. SELECT tpm_scheduling_record.admin_id
  3163. FROM tpm_scheduling
  3164. join tpm_scheduling_record on tpm_scheduling.id = tpm_scheduling_record.head_id
  3165. WHERE tpm_scheduling.bu_no = #{buNo} and tpm_scheduling.site = #{site} and tpm_scheduling.classes_code = #{classesCode} and tpm_scheduling_record.isHoliday = 'N'
  3166. )
  3167. </if>
  3168. </where>
  3169. order by load_rate desc
  3170. </select>
  3171. <!-- 查询OQC基础数据 -->
  3172. <select id="selectOQCBasicData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3173. SELECT
  3174. qir.inspection_no,
  3175. qir.state,
  3176. qir.create_date as taskDate,
  3177. qir.roll_no,
  3178. qir.part_no,
  3179. dbo.Get_Part_DescSpec(qir.site, qir.part_no) as part_desc,
  3180. qir.roll_qty,
  3181. qir.print_flag,
  3182. qir.create_by,
  3183. qir.site,
  3184. qir.bu_no,
  3185. qir.roll_count
  3186. FROM qc_oqc_record as qir
  3187. LEFT JOIN part p ON qir.part_no = p.partNo and qir.site = p.site
  3188. WHERE qir.site in (select site from AccessSite where userID = #{userName})
  3189. and qir.bu_no in (select bu_no from AccessBu where username = #{userName})
  3190. and qir.detail_flag = 'N'
  3191. </select>
  3192. <select id="selectFQASPartAttributeByPartNo" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3193. SELECT
  3194. qat.site,
  3195. qat.bu_no,
  3196. qat.attribute_no,
  3197. qat.template_id,
  3198. qat.sampling_level_no,
  3199. qsil.sampling_level_desc,
  3200. qat.inspection_cycle,
  3201. qat.sampling_programme_no,
  3202. qsip.sampling_programme_desc,
  3203. qat.AQL,
  3204. qat.AC,
  3205. qat.RE,
  3206. qt.default_sampling_quantity,
  3207. qt.default_sampling_proportion
  3208. FROM qc_attribute_template as qat
  3209. 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
  3210. 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
  3211. 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
  3212. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  3213. AND qat.attribute_no = #{partNo}
  3214. AND qat.attribute_type = #{attributeType}
  3215. AND qt.inspection_type_no = #{inspectionTypeNo}
  3216. </select>
  3217. <!-- 新增OQC明细记录信息 -->
  3218. <insert id="saveFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3219. INSERT INTO qc_oqc_detailed_record
  3220. (inspection_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc, AQL, AC, RE,
  3221. 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)
  3222. VALUES
  3223. (#{inspectionNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL},
  3224. #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL}, #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty}, #{buNo}, #{orderId})
  3225. </insert>
  3226. <!-- 修改OQC检验记录 -->
  3227. <update id="updateFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3228. UPDATE qc_oqc_record
  3229. SET inspection_type_no = #{inspectionTypeNo},
  3230. sampling_qty = #{samplingQty},
  3231. inspection_cycle = #{inspectionCycle},
  3232. part_desc = #{partDesc},
  3233. detail_flag = 'Y',
  3234. pass_qty = #{samplingQty},
  3235. not_pass_qty = 0
  3236. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3237. </update>
  3238. <!-- 查询OQC主记录信息 -->
  3239. <select id="qcOQCInspectionSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3240. SELECT
  3241. a.inspection_no,
  3242. a.site,
  3243. a.bu_no,
  3244. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  3245. a.state,
  3246. a.inspection_result,
  3247. a.create_date as taskDate,
  3248. a.inspection_type_no,
  3249. a.inspection_cycle,
  3250. a.part_no,
  3251. a.part_desc,
  3252. d.umid as umId,
  3253. um.UMName as umName,
  3254. d.spec,
  3255. a.inspection_remark,
  3256. a.roll_qty,
  3257. a.sampling_qty,
  3258. a.disposal_measures,
  3259. a.disposal_remark,
  3260. a.inspector_date,
  3261. a.submit_date as submitDate,
  3262. a.submit_flag,
  3263. a.roll_no,
  3264. a.roll_count,
  3265. a.action_date,
  3266. a.action_by,
  3267. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  3268. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  3269. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  3270. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  3271. a.pass_qty,
  3272. a.not_pass_qty,
  3273. a.create_by,
  3274. a.customer_no,
  3275. dbo.Get_CustomerDesc(a.site, a.customer_no) as customerName,
  3276. a.po_orderNo,
  3277. a.po_itemNo,
  3278. a.document_no
  3279. FROM qc_oqc_record as a
  3280. left join part as d on a.site = d.site and a.bu_no = d.bu_no and a.part_no = d.partNo
  3281. left join um as um on d.site = um.site and d.umid = um.UMID
  3282. <where>
  3283. a.site in (select site from AccessSite where userID = #{query.userName})
  3284. and a.bu_no in (select bu_no from AccessBu where username = #{query.userName})
  3285. <if test="query.buDesc != null and query.buDesc != ''">
  3286. AND dbo.get_bu_desc (a.site, a.bu_no) = #{query.buDesc}
  3287. </if>
  3288. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  3289. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  3290. </if>
  3291. <if test = "query.states != null and query.states.size > 0">
  3292. AND a.state in
  3293. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  3294. #{item}
  3295. </foreach>
  3296. </if>
  3297. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  3298. AND a.inspection_result = #{query.inspectionResult}
  3299. </if>
  3300. <if test = "query.partNo != null and query.partNo != ''">
  3301. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  3302. </if>
  3303. <if test = "query.partDesc != null and query.partDesc != ''">
  3304. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  3305. </if>
  3306. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  3307. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  3308. </if>
  3309. <if test="query.startDate != null">
  3310. AND a.inspector_date >= #{query.startDate}
  3311. </if>
  3312. <if test="query.endDate != null">
  3313. AND #{query.endDate} >= a.inspector_date
  3314. </if>
  3315. <if test="query.startDate2 != null">
  3316. AND a.create_date >= #{query.startDate2}
  3317. </if>
  3318. <if test="query.endDate2 != null">
  3319. AND #{query.endDate2} >= a.create_date
  3320. </if>
  3321. <if test = "query.customerNo != null and query.customerNo != ''">
  3322. AND a.customer_no LIKE '%' + #{query.customerNo} + '%'
  3323. </if>
  3324. <if test = "query.customerName != null and query.customerName != ''">
  3325. AND dbo.Get_CustomerDesc(a.site, a.customer_no) LIKE '%' + #{query.customerName} + '%'
  3326. </if>
  3327. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  3328. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  3329. </if>
  3330. <if test = "query.spec != null and query.spec != ''">
  3331. AND d.spec LIKE '%' + #{query.spec} + '%'
  3332. </if>
  3333. </where>
  3334. ORDER BY
  3335. CASE WHEN a.state = '待检验' THEN 1
  3336. WHEN a.state = '待审核' THEN 2
  3337. WHEN a.state = '已完成' THEN 3
  3338. END, a.create_date desc
  3339. </select>
  3340. <!-- IQC明细记录查询 -->
  3341. <select id="fqasDetailSearch" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3342. SELECT
  3343. a.site,
  3344. a.bu_no,
  3345. a.inspection_no,
  3346. a.template_id,
  3347. a.sampling_level_no,
  3348. a.sampling_level_desc,
  3349. a.sampling_programme_no,
  3350. a.sampling_programme_desc,
  3351. a.AQL,
  3352. a.AC,
  3353. a.RE,
  3354. a.item_no,
  3355. a.item_desc,
  3356. a.object_id,
  3357. a.object_desc,
  3358. a.default_value,
  3359. a.min_value,
  3360. a.max_value,
  3361. a.text_value,
  3362. a.number_value,
  3363. a.value_type_db,
  3364. a.value_type,
  3365. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  3366. a.is_submit,
  3367. a.unqualified_quantity,
  3368. dbo.qc_get_fqas_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  3369. dbo.qc_get_record_image_num(a.site, a.bu_no, a.inspection_no, a.item_no) as detailImageNum,
  3370. c.method_no,
  3371. c.method_name,
  3372. c.method_remark,
  3373. a.sampling_qty
  3374. FROM qc_oqc_detailed_record as a
  3375. 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
  3376. 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
  3377. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  3378. ORDER BY COALESCE(a.order_id, 99999) ASC
  3379. </select>
  3380. <!-- 查询FQAS的子明细 -->
  3381. <select id="selectFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3382. SELECT
  3383. site,
  3384. bu_no,
  3385. sub_detail_value,
  3386. sampling_location,
  3387. is_submit,
  3388. sampling_location_b,
  3389. num,
  3390. sub_detail_value_b,
  3391. sub_detail_value_c,
  3392. sub_detail_value_d,
  3393. sub_detail_value_e
  3394. FROM qc_oqc_sub_detail_record
  3395. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  3396. </select>
  3397. <select id="getSupplier" parameterType="java.lang.String" resultType="com.gaotao.modules.base.entity.SupplierData">
  3398. SELECT
  3399. site,
  3400. SupplierID,
  3401. SupplierName
  3402. FROM Supplier
  3403. WHERE site = #{site} and SupplierID = #{supplierID} and Active = #{active}
  3404. </select>
  3405. <!-- 修改FQAS主记录信息 -->
  3406. <update id="updateFQASMasterRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3407. UPDATE qc_oqc_record
  3408. SET disposal_measures = #{disposalMeasures},
  3409. disposal_remark = #{disposalRemark},
  3410. inspection_result = #{inspectionResult},
  3411. inspector_no = #{inspectorNo},
  3412. state = #{state},
  3413. inspection_remark = #{inspectionRemark},
  3414. inspector_date = getDate(),
  3415. roll_count = #{rollCount,jdbcType=DECIMAL},
  3416. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  3417. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  3418. pass_qty = #{passQty,jdbcType=DECIMAL},
  3419. not_pass_qty = #{notPassQty,jdbcType=DECIMAL}
  3420. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  3421. </update>
  3422. <!-- 修改FQAS明细记录信息 -->
  3423. <update id="updateFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3424. UPDATE qc_oqc_detailed_record
  3425. SET item_result = #{itemResult},
  3426. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  3427. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  3428. text_value = #{textValue},
  3429. number_value = #{numberValue,jdbcType=DECIMAL},
  3430. default_value = #{defaultValue},
  3431. min_value = #{minValue,jdbcType=DECIMAL},
  3432. max_value = #{maxValue,jdbcType=DECIMAL}
  3433. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  3434. </update>
  3435. <!-- 查询FQAS主记录信息 -->
  3436. <select id="getFQASInspectionRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3437. SELECT
  3438. site,
  3439. bu_no,
  3440. inspection_no,
  3441. not_pass_qty,
  3442. roll_count,
  3443. inspection_result,
  3444. disposal_measures,
  3445. part_no
  3446. FROM qc_oqc_record
  3447. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3448. </select>
  3449. <!-- 修改FQAS主记录标识为已提交 -->
  3450. <update id="updateFQASMasterSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3451. UPDATE qc_oqc_record
  3452. SET submit_flag = 'Y',
  3453. state = '已完成'
  3454. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3455. </update>
  3456. <!-- 修改FQAS明细记录标识为已提交 -->
  3457. <update id="updateFQASDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3458. UPDATE qc_oqc_detailed_record
  3459. SET is_submit = 'Y'
  3460. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3461. </update>
  3462. <!-- 修改FQAS子明细记录标识为已提交 -->
  3463. <update id="updateFQASSubDetailSubmitFlag" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3464. UPDATE qc_oqc_sub_detail_record
  3465. SET is_submit = 'Y'
  3466. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3467. </update>
  3468. <!-- 查询FQAS检验记录是否已提交 -->
  3469. <select id="checkFQASIsSubmit" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3470. SELECT submit_flag
  3471. FROM qc_oqc_record
  3472. WHERE inspection_no = #{inspectionNo} and site = #{site}
  3473. </select>
  3474. <!-- 删除FQAS子明细的老数据 -->
  3475. <delete id="delFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcSubDetailInformationData">
  3476. DELETE FROM qc_oqc_sub_detail_record
  3477. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  3478. </delete>
  3479. <!-- 新增FQAS子明细信息 -->
  3480. <insert id="saveFQASSubDetailed">
  3481. INSERT INTO qc_oqc_sub_detail_record
  3482. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no)
  3483. VALUES
  3484. <foreach collection="list" item="item" separator=",">
  3485. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo})
  3486. </foreach>
  3487. </insert>
  3488. <!-- 删除FQAS检验记录 -->
  3489. <delete id="deleteFQASRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3490. DELETE FROM qc_oqc_record
  3491. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3492. </delete>
  3493. <!-- 删除FQAS明细记录信息 -->
  3494. <delete id="deleteFQASDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3495. DELETE FROM qc_oqc_detailed_record
  3496. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3497. </delete>
  3498. <!-- 删除FQAS子明细记录信息 -->
  3499. <delete id="deleteFQASSubDetailedRecord" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3500. DELETE FROM qc_oqc_sub_detail_record
  3501. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3502. </delete>
  3503. <!-- 查询FQAS(OQC)检验单当前状态 -->
  3504. <select id="getFQASRecordStatus" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData" resultType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3505. SELECT submit_flag, state, inspection_result
  3506. FROM qc_oqc_record
  3507. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3508. </select>
  3509. <update id="actionFQASInspection" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3510. update qc_oqc_record
  3511. set action_date = getDate(),
  3512. action_by = #{actionBy},
  3513. state = #{state}
  3514. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3515. </update>
  3516. <update id="updateSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3517. update
  3518. <if test = "inspectionTypeNo == '105'">
  3519. qc_iqc_record
  3520. </if>
  3521. <if test = "inspectionTypeNo == '108'">
  3522. qc_oqc_record
  3523. </if>
  3524. set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
  3525. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3526. </update>
  3527. <update id="updateDetailSamplingQty" parameterType="com.gaotao.modules.pms.data.QcFAIRecordData">
  3528. update
  3529. <if test = "inspectionTypeNo == '105'">
  3530. qc_iqc_detailed_record
  3531. </if>
  3532. <if test = "inspectionTypeNo == '108'">
  3533. qc_oqc_detailed_record
  3534. </if>
  3535. set sampling_qty = #{samplingQty,jdbcType=DECIMAL}
  3536. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3537. </update>
  3538. <!-- 获取审核人员列表 -->
  3539. <select id="getCheckerList" resultType="com.gaotao.modules.pms.data.EamAdminData" parameterType="com.gaotao.modules.pms.data.EamAdminData">
  3540. SELECT
  3541. a.user_id,
  3542. a.username as adminID,
  3543. a.email,
  3544. a.mobile as phone,
  3545. a.user_display as adminName,
  3546. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  3547. d.role_id,
  3548. e.role_name
  3549. FROM sys_user as a
  3550. LEFT JOIN AccessSite as b on a.username = b.userID
  3551. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  3552. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  3553. LEFT JOIN sys_role as e on d.role_id = e.role_id
  3554. <where>
  3555. b.site = #{site} and c.bu_no = #{buNo}
  3556. <if test = "adminID != null and adminID != ''">
  3557. AND a.username LIKE '%' + #{adminID}+'%'
  3558. </if>
  3559. <if test = "adminName != null and adminName != ''">
  3560. AND a.user_display LIKE '%' + #{adminName}+'%'
  3561. </if>
  3562. <if test = "buDesc != null and buDesc != ''">
  3563. AND dbo.get_bu_desc(a.site,c.bu_no) LIKE '%' + #{buDesc} + '%'
  3564. </if>
  3565. <if test = "roleId != null and roleId != ''">
  3566. AND d.role_id = #{roleId}
  3567. </if>
  3568. </where>
  3569. </select>
  3570. <!-- ================================================= SOP清单相关SQL ================================================= -->
  3571. <!-- SOP清单查询 -->
  3572. <select id="sopListSearch" resultType="map">
  3573. <!-- SELECT-->
  3574. <!-- ps.site,-->
  3575. <!-- ps.bu_no as buNo,-->
  3576. <!-- ps.part_no as partNo,-->
  3577. <!-- ps.sop_no as sopNo,-->
  3578. <!-- ps.sop_name as sopName,-->
  3579. <!-- ps.sop_url as sopUrl,-->
  3580. <!-- ps.version,-->
  3581. <!-- ps.sop_status as sopStatus,-->
  3582. <!-- ps.phase_in_date as phaseInDate,-->
  3583. <!-- ps.phase_out_date as phaseOutDate,-->
  3584. <!-- ps.created_by as createdBy,-->
  3585. <!-- ps.creation_date as creationDate,-->
  3586. <!-- ps.sop_type as sopType,-->
  3587. <!-- ps.operation_desc as operationDesc-->
  3588. <!-- FROM part_sop ps-->
  3589. <!-- <where>-->
  3590. <!-- <if test="params.site != null and params.site != ''">-->
  3591. <!-- AND ps.site = #{params.site}-->
  3592. <!-- </if>-->
  3593. <!-- <if test="params.partNo != null and params.partNo != ''">-->
  3594. <!-- AND ps.part_no = #{params.partNo}-->
  3595. <!-- </if>-->
  3596. <!-- </where>-->
  3597. <!-- ORDER BY ps.creation_date DESC-->
  3598. SELECT DISTINCT
  3599. site,
  3600. buNo,
  3601. partNo,
  3602. sopNo,
  3603. sopName,
  3604. sopUrl,
  3605. [version],
  3606. sopStatus,
  3607. phaseInDate,
  3608. phaseOutDate,
  3609. createdBy,
  3610. creationDate,
  3611. sopType,
  3612. operationDesc
  3613. FROM (
  3614. -- 来源1: part_sop(零件SOP)
  3615. SELECT
  3616. ps.site,
  3617. ps.bu_no AS buNo,
  3618. ps.part_no AS partNo,
  3619. ps.sop_no AS sopNo,
  3620. ps.sop_name AS sopName,
  3621. ps.sop_url AS sopUrl,
  3622. ps.[version ] AS [version],
  3623. ps.sop_status AS sopStatus,
  3624. ps.phase_in_date AS phaseInDate,
  3625. ps.phase_out_date AS phaseOutDate,
  3626. ps.created_by AS createdBy,
  3627. ps.creation_date AS creationDate,
  3628. ps.sop_type AS sopType,
  3629. ps.operation_desc AS operationDesc
  3630. FROM part_sop ps
  3631. WHERE ps.site = #{params.site}
  3632. AND ps.part_no = #{params.partNo}
  3633. UNION ALL
  3634. -- 来源2: file_management(公共生产文件 或 订单关联文件)
  3635. SELECT
  3636. fm.site,
  3637. fm.bu_no AS buNo,
  3638. '' AS partNo,
  3639. fm.file_no AS sopNo,
  3640. fm.file_name AS sopName,
  3641. fm.url_add_ress AS sopUrl,
  3642. fm.sop_rev_no AS [version],
  3643. fm.status AS sopStatus,
  3644. fm.phase_in_date AS phaseInDate,
  3645. fm.phase_out_date AS phaseOutDate,
  3646. fm.created_by AS createdBy,
  3647. fm.create_date AS creationDate,
  3648. fm.file_type AS sopType,
  3649. fm.item_no AS operationDesc
  3650. FROM file_management fm
  3651. WHERE fm.site = #{params.site}
  3652. AND fm.file_type = '生产'
  3653. AND (
  3654. ISNULL(fm.public_flag, 'N') = 'Y'
  3655. OR fm.order_no = #{params.orderNo}
  3656. )
  3657. ) AS CombinedResults
  3658. </select>
  3659. <!-- 查询检验页面的SOP文件列表(从file_management表) -->
  3660. <select id="searchQcSopFileList" resultType="map">
  3661. <!-- SELECT DISTINCT-->
  3662. <!-- fm.ID AS id,-->
  3663. <!-- fm.url_add_ress AS sopUrl,-->
  3664. <!-- fm.create_date AS creationDate,-->
  3665. <!-- fm.file_name AS sopName,-->
  3666. <!-- fm.new_file_name AS newFileName,-->
  3667. <!-- fm.created_by AS createdBy,-->
  3668. <!-- fm.file_type AS fileType,&#45;&#45;-->
  3669. <!-- fm.file_suffix AS fileSuffix,-->
  3670. <!-- fm.sop_rev_no AS version,-->
  3671. <!-- fm.phase_in_date AS phaseInDate,-->
  3672. <!-- fm.phase_out_date AS phaseOutDate-->
  3673. <!-- FROM file_management fm-->
  3674. SELECT DISTINCT
  3675. site,
  3676. buNo,
  3677. partNo,
  3678. sopNo,
  3679. sopName,
  3680. sopUrl,
  3681. [version],
  3682. sopStatus,
  3683. phaseInDate,
  3684. phaseOutDate,
  3685. createdBy,
  3686. creationDate,
  3687. sopType as fileType,
  3688. operationDesc
  3689. FROM (
  3690. -- 来源1: part_sop(零件SOP)
  3691. SELECT
  3692. ps.site,
  3693. ps.bu_no AS buNo,
  3694. ps.part_no AS partNo,
  3695. ps.sop_no AS sopNo,
  3696. ps.sop_name AS sopName,
  3697. ps.sop_url AS sopUrl,
  3698. ps.[version ] AS [version],
  3699. ps.sop_status AS sopStatus,
  3700. ps.phase_in_date AS phaseInDate,
  3701. ps.phase_out_date AS phaseOutDate,
  3702. ps.created_by AS createdBy,
  3703. ps.creation_date AS creationDate,
  3704. ps.sop_type AS sopType,
  3705. ps.operation_desc AS operationDesc
  3706. FROM part_sop ps
  3707. WHERE ps.site = #{params.site}
  3708. AND ps.part_no = #{params.partNo}
  3709. UNION ALL
  3710. -- 来源2: file_management(公共生产文件 或 订单关联文件)
  3711. SELECT
  3712. fm.site,
  3713. fm.bu_no AS buNo,
  3714. '' AS partNo,
  3715. fm.file_no AS sopNo,
  3716. fm.file_name AS sopName,
  3717. fm.url_add_ress AS sopUrl,
  3718. fm.sop_rev_no AS [version],
  3719. fm.status AS sopStatus,
  3720. fm.phase_in_date AS phaseInDate,
  3721. fm.phase_out_date AS phaseOutDate,
  3722. fm.created_by AS createdBy,
  3723. fm.create_date AS creationDate,
  3724. fm.file_type AS sopType,
  3725. fm.item_no AS operationDesc
  3726. FROM file_management fm
  3727. WHERE fm.site = #{params.site}
  3728. AND fm.file_type = '质量'
  3729. AND (
  3730. ISNULL(fm.public_flag, 'N') = 'Y'
  3731. OR fm.order_no = #{params.orderNo}
  3732. )
  3733. ) AS CombinedResults
  3734. </select>
  3735. <!-- 查询可用的SOP文件 -->
  3736. <select id="sopAvailableFiles" resultType="map">
  3737. SELECT
  3738. A.site,
  3739. A.bu_no as buNo,
  3740. A.file_no as fileNo,
  3741. A.file_name as fileName,
  3742. A.file_type as fileType,
  3743. A.file_suffix as fileSuffix,
  3744. A.sop_rev_no as sopRevNo,
  3745. A.url_add_ress as sopUrl,
  3746. A.sop_type as sopType,
  3747. A.source_system as sourceSystem
  3748. FROM file_management A
  3749. 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}
  3750. <where>
  3751. B.SITE IS NULL
  3752. AND A.status_tb = 0
  3753. and ISNULL(public_flag,'N') = 'N'
  3754. <if test="params.site != null and params.site != ''">
  3755. AND A.site = #{params.site}
  3756. </if>
  3757. <if test="params.fileNo != null and params.fileNo != ''">
  3758. AND A.file_no LIKE '%' + #{params.fileNo} + '%'
  3759. </if>
  3760. <if test="params.fileName != null and params.fileName != ''">
  3761. AND A.file_name LIKE '%' + #{params.fileName} + '%'
  3762. </if>
  3763. <if test="params.fileType != null and params.fileType != ''">
  3764. AND A.file_type LIKE '%' + #{params.fileType} + '%'
  3765. </if>
  3766. <if test="params.sopRevNo != null and params.sopRevNo != ''">
  3767. AND A.sop_rev_no LIKE '%' + #{params.sopRevNo} + '%'
  3768. </if>
  3769. </where>
  3770. ORDER BY A.file_no
  3771. </select>
  3772. <!-- 插入SOP记录 -->
  3773. <insert id="insertSopRecord">
  3774. INSERT INTO part_sop (
  3775. site,
  3776. bu_no,
  3777. part_no,
  3778. sop_no,
  3779. sop_name,
  3780. sop_url,
  3781. sop_type,
  3782. version,
  3783. sop_status,
  3784. phase_in_date,
  3785. phase_out_date,
  3786. created_by,
  3787. creation_date,
  3788. operation_desc
  3789. ) VALUES (
  3790. #{data.site},
  3791. #{data.buNo},
  3792. #{data.partNo},
  3793. #{data.sopNo},
  3794. #{data.sopName},
  3795. #{data.sopUrl},
  3796. #{data.sopType},
  3797. #{data.version},
  3798. #{data.sopStatus},
  3799. <choose>
  3800. <when test="data.phaseInDate != null and data.phaseInDate != ''">
  3801. CONVERT(DATE, #{data.phaseInDate})
  3802. </when>
  3803. <otherwise>
  3804. NULL
  3805. </otherwise>
  3806. </choose>,
  3807. <choose>
  3808. <when test="data.phaseOutDate != null and data.phaseOutDate != ''">
  3809. CONVERT(DATE, #{data.phaseOutDate})
  3810. </when>
  3811. <otherwise>
  3812. NULL
  3813. </otherwise>
  3814. </choose>,
  3815. #{data.createdBy},
  3816. <choose>
  3817. <when test="data.creationDate != null and data.creationDate != ''">
  3818. CONVERT(DATE, #{data.creationDate})
  3819. </when>
  3820. <otherwise>
  3821. GETDATE()
  3822. </otherwise>
  3823. </choose>,
  3824. #{data.operationDesc}
  3825. )
  3826. </insert>
  3827. <!-- 删除SOP记录 -->
  3828. <delete id="deleteSopRecord">
  3829. DELETE FROM part_sop
  3830. <where>
  3831. <if test="params.site != null and params.site != ''">
  3832. AND site = #{params.site}
  3833. </if>
  3834. <if test="params.buNo != null and params.buNo != ''">
  3835. AND bu_no = #{params.buNo}
  3836. </if>
  3837. <if test="params.partNo != null and params.partNo != ''">
  3838. AND part_no = #{params.partNo}
  3839. </if>
  3840. <if test="params.sopNo != null and params.sopNo != ''">
  3841. AND sop_no = #{params.sopNo}
  3842. </if>
  3843. </where>
  3844. </delete>
  3845. <!-- ================================================= BOM清单相关SQL ================================================= -->
  3846. <!-- BOM清单查询 -->
  3847. <select id="bomListSearch" resultType="com.gaotao.modules.pms.data.BomListData">
  3848. SELECT
  3849. bh.site,
  3850. bh.bu_no as buNo,
  3851. bh.revno,
  3852. bh.bomtype,
  3853. bh.status,
  3854. bh.phaseindate,
  3855. bh.phaseoutdate
  3856. FROM BOMHeader bh
  3857. <where>
  3858. <if test="query.site != null and query.site != ''">
  3859. AND bh.site = #{query.site}
  3860. </if>
  3861. <if test="query.buNo != null and query.buNo != ''">
  3862. AND bh.bu_no = #{query.buNo}
  3863. </if>
  3864. <if test="query.partNo != null and query.partNo != ''">
  3865. AND bh.bu_no = #{query.partNo}
  3866. </if>
  3867. </where>
  3868. ORDER BY bh.phaseindate DESC
  3869. </select>
  3870. <!-- ================================================= Routing清单相关SQL ================================================= -->
  3871. <!-- Routing清单查询 -->
  3872. <select id="routingListSearch" resultType="com.gaotao.modules.pms.data.RoutingListData">
  3873. SELECT
  3874. rh.site,
  3875. rh.bu_no as buNo,
  3876. rh.revno,
  3877. rh.routingtype,
  3878. rh.status,
  3879. rh.phaseindate,
  3880. rh.phaseoutdate
  3881. FROM RoutingHeader rh
  3882. <where>
  3883. <if test="query.site != null and query.site != ''">
  3884. AND rh.site = #{query.site}
  3885. </if>
  3886. <if test="query.buNo != null and query.buNo != ''">
  3887. AND rh.bu_no = #{query.buNo}
  3888. </if>
  3889. <if test="query.partNo != null and query.partNo != ''">
  3890. AND rh.bu_no = #{query.partNo}
  3891. </if>
  3892. </where>
  3893. ORDER BY rh.phaseindate DESC
  3894. </select>
  3895. <update id="updateInboundNotificationStatus">
  3896. update inbound_notification_head
  3897. set order_status = #{status}
  3898. <if test="inspectionFlag != null and inspectionFlag != ''">
  3899. , inspection_flag = #{inspectionFlag}
  3900. </if>
  3901. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  3902. </update>
  3903. <!-- 查询过程检验待检验记录数量(只统计首件检和自检类型) -->
  3904. <select id="checkProcessInspectionPendingCount" resultType="int">
  3905. SELECT COUNT(1)
  3906. FROM qc_ipqc_record
  3907. WHERE site = #{site}
  3908. AND order_no = #{orderNo}
  3909. AND state IN ('未开始', '待检验')
  3910. AND seq_no = #{seqNo}
  3911. AND inspection_type_no IN ('首件检', '自检', '末件检')
  3912. </select>
  3913. <select id="queryResourceList3" resultType="com.gaotao.modules.pms.data.ResourceData">
  3914. select DISTINCT ResourceId,ResourceDesc from WorkCenterResource
  3915. </select>
  3916. <update id="updateSaleBoxManageStatus">
  3917. update outbound_notification_head
  3918. set order_status = #{status}
  3919. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  3920. </update>
  3921. <update id="updateSaleBoxManageInspectionFlag">
  3922. update outbound_notification_detail
  3923. set inspection_flag = #{inspectionFlag}
  3924. where site = #{site} and bu_no = #{buNo} and order_no = #{documentNo}
  3925. </update>
  3926. </mapper>