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

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