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.

3810 lines
168 KiB

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