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.

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