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.

4146 lines
180 KiB

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