祥兆质量后端
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.

4197 lines
184 KiB

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