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.

3805 lines
167 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}, #{item.minValue})
  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}
  607. AND ItemType = #{itemType}
  608. </select>
  609. <!-- ================================================= 样本量维护 ================================================= -->
  610. <!-- 查询样本量 -->
  611. <select id="samplingQtySearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  612. SELECT
  613. site,
  614. bu_no,
  615. dbo.get_bu_desc(site, bu_no) as buDesc,
  616. sampling_qty_no,
  617. sampling_qty_desc,
  618. sampling_qty,
  619. sampling_qty_remark,
  620. sampling_qty_active,
  621. create_date,
  622. create_by,
  623. update_date,
  624. update_by
  625. FROM qc_sampling_inspection_qty
  626. <where>
  627. site in (select site from eam_access_site where username = #{query.userName})
  628. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  629. <if test="query.buDesc != null and query.buDesc != ''">
  630. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  631. </if>
  632. <if test="query.samplingQtyNo != null and query.samplingQtyNo != ''">
  633. AND sampling_qty_no LIKE '%' + #{query.samplingQtyNo} + '%'
  634. </if>
  635. <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''">
  636. AND sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc} + '%'
  637. </if>
  638. <if test="query.samplingQty != null">
  639. AND sampling_qty = #{query.samplingQty,jdbcType=DECIMAL}
  640. </if>
  641. <if test="query.samplingQtyActive != null and query.samplingQtyActive != ''">
  642. AND sampling_qty_active = #{query.samplingQtyActive}
  643. </if>
  644. </where>
  645. </select>
  646. <!-- 新增样本量 -->
  647. <insert id="samplingQtySave" parameterType="QcSamplingInspectionQtyData">
  648. 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)
  649. VALUES(#{site}, #{buNo}, #{samplingQtyNo}, #{samplingQty,jdbcType=DECIMAL}, #{samplingQtyRemark}, #{samplingQtyActive}, #{samplingQtyDesc}, getDate(), #{createBy}, getDate(), #{updateBy})
  650. </insert>
  651. <!-- 根据样本量字码查询样本量 -->
  652. <select id="selectSamplingQtyByDesc" parameterType="QcSamplingInspectionQtyData" resultType="QcSamplingInspectionQtyData">
  653. SELECT
  654. site,
  655. bu_no,
  656. sampling_qty_no,
  657. sampling_qty_desc,
  658. sampling_qty,
  659. sampling_qty_remark,
  660. sampling_qty_active
  661. FROM qc_sampling_inspection_qty
  662. WHERE sampling_qty_desc = #{samplingQtyDesc} AND site = #{site} and bu_no = #{buNo}
  663. </select>
  664. <!-- 获取最大样本量编码 -->
  665. <select id="queryLastSamplingQtyNo" resultType="string" parameterType="QcSamplingInspectionQtyData">
  666. SELECT top 1 sampling_qty_no
  667. FROM qc_sampling_inspection_qty
  668. where site = #{site} and bu_no = #{buNo}
  669. ORDER BY sampling_qty_no Desc
  670. </select>
  671. <!-- 修改样本量 -->
  672. <update id="samplingQtyUpdate" parameterType="QcSamplingInspectionQtyData">
  673. UPDATE qc_sampling_inspection_qty
  674. SET sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  675. sampling_qty_desc = #{samplingQtyDesc},
  676. sampling_qty_remark = #{samplingQtyRemark},
  677. sampling_qty_active = #{samplingQtyActive},
  678. update_date = getDate(),
  679. update_by = #{updateBy}
  680. WHERE sampling_qty_no = #{samplingQtyNo} AND site = #{site} and bu_no = #{buNo}
  681. </update>
  682. <!-- 根据样本量编码查询矩阵 -->
  683. <select id="selectSamplingPlanBySamplingQtyNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionQtyData">
  684. SELECT
  685. site,
  686. sampling_plan_no,
  687. sampling_qty_no,
  688. sampling_qty_rank_no,
  689. sampling_level_no,
  690. sampling_plan_active
  691. FROM qc_sampling_inspection_plan
  692. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} and bu_no = #{buNo}
  693. </select>
  694. <!-- 删除样本量 -->
  695. <delete id="samplingQtyDelete" parameterType="QcSamplingInspectionQtyData">
  696. DELETE FROM qc_sampling_inspection_qty
  697. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} AND sampling_qty_desc = #{samplingQtyDesc} and bu_no = #{buNo}
  698. </delete>
  699. <!-- ================================================= 批量级次维护 ================================================= -->
  700. <!-- 查询批量级次 -->
  701. <select id="samplingQtyRankSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  702. SELECT
  703. site,
  704. bu_no,
  705. dbo.get_bu_desc(site, bu_no) as buDesc,
  706. sampling_qty_rank_no,
  707. sampling_qty_rank_desc,
  708. min_qty,
  709. max_qty,
  710. sampling_qty_rank_active,
  711. sampling_qty_rank_Remark,
  712. create_date,
  713. create_by,
  714. update_date,
  715. update_by
  716. FROM qc_sampling_inspection_qty_rank
  717. <where>
  718. site in (select site from eam_access_site where username = #{query.userName})
  719. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  720. <if test="query.buDesc != null and query.buDesc != ''">
  721. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  722. </if>
  723. <if test="query.samplingQtyRankNo != null and query.samplingQtyRankNo != ''">
  724. AND sampling_qty_rank_no LIKE '%' + #{query.samplingQtyRankNo}+'%'
  725. </if>
  726. <if test="query.samplingQtyRankDesc != null and query.samplingQtyRankDesc != ''">
  727. AND sampling_qty_rank_desc LIKE '%' + #{query.samplingQtyRankDesc}+'%'
  728. </if>
  729. <if test="query.samplingQtyRankActive != null and query.samplingQtyRankActive != ''">
  730. AND sampling_qty_rank_active = #{query.samplingQtyRankActive}
  731. </if>
  732. </where>
  733. </select>
  734. <!-- 根据名称查询批量级次 -->
  735. <select id="selectSamplingQtyRankByDesc" parameterType="QcSamplingInspectionQtyRankData" resultType="QcSamplingInspectionQtyRankData">
  736. SELECT
  737. site,
  738. bu_no,
  739. sampling_qty_rank_no,
  740. sampling_qty_rank_desc,
  741. min_qty,
  742. max_qty,
  743. sampling_qty_rank_active,
  744. sampling_qty_rank_Remark
  745. FROM qc_sampling_inspection_qty_rank
  746. WHERE sampling_qty_rank_desc = #{samplingQtyRankDesc} AND site = #{site} and bu_no = #{buNo}
  747. </select>
  748. <!-- 获取最大批量级次编码 -->
  749. <select id="queryLastSamplingQtyRankNo" resultType="string" parameterType="QcSamplingInspectionQtyRankData">
  750. SELECT top 1 sampling_qty_rank_no
  751. FROM qc_sampling_inspection_qty_rank
  752. where site = #{site} and bu_no = #{buNo}
  753. ORDER BY sampling_qty_rank_no Desc
  754. </select>
  755. <!-- 新增批量级次 -->
  756. <insert id="samplingQtyRankSave" parameterType="QcSamplingInspectionQtyRankData">
  757. 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)
  758. VALUES(#{site}, #{buNo}, #{samplingQtyRankNo}, #{samplingQtyRankDesc}, #{minQty,jdbcType=DECIMAL}, #{maxQty,jdbcType=DECIMAL}, #{samplingQtyRankRemark}, #{samplingQtyRankActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  759. </insert>
  760. <!-- 根据批量级次编码查询矩阵 -->
  761. <select id="selectSamplingPlanBySamplingQtyRankNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionQtyRankData">
  762. SELECT
  763. site,
  764. bu_no,
  765. sampling_plan_no,
  766. sampling_qty_no,
  767. sampling_qty_rank_no,
  768. sampling_level_no,
  769. sampling_plan_active
  770. FROM qc_sampling_inspection_plan
  771. WHERE site = #{site} AND sampling_qty_rank_no = #{samplingQtyRankNo} and bu_no = #{buNo}
  772. </select>
  773. <!-- 修改批量级次 -->
  774. <update id="samplingQtyRankUpdate" parameterType="QcSamplingInspectionQtyRankData">
  775. UPDATE qc_sampling_inspection_qty_rank
  776. SET sampling_qty_rank_desc = #{samplingQtyRankDesc},
  777. min_qty = #{minQty,jdbcType=DECIMAL},
  778. max_qty = #{maxQty,jdbcType=DECIMAL},
  779. sampling_qty_rank_Remark = #{samplingQtyRankRemark},
  780. sampling_qty_rank_active = #{samplingQtyRankActive},
  781. update_date = getDate(),
  782. update_by = #{updateBy}
  783. WHERE sampling_qty_rank_no = #{samplingQtyRankNo} AND site = #{site} and bu_no = #{buNo}
  784. </update>
  785. <!-- 删除批量级次 -->
  786. <delete id="samplingQtyRankDelete" parameterType="QcSamplingInspectionQtyRankData">
  787. DELETE FROM qc_sampling_inspection_qty_rank
  788. WHERE site = #{site} and bu_no = #{buNo}
  789. AND sampling_qty_rank_no = #{samplingQtyRankNo}
  790. AND sampling_qty_rank_desc = #{samplingQtyRankDesc}
  791. </delete>
  792. <!-- ================================================= 检验等级维护 ================================================= -->
  793. <!-- 查询检验等级 -->
  794. <select id="samplingLevelSearch" parameterType="QcSamplingInspectionLevelData" resultType="QcSamplingInspectionLevelData">
  795. SELECT
  796. site,
  797. bu_no,
  798. dbo.get_bu_desc(site, bu_no) as buDesc,
  799. sampling_level_no,
  800. sampling_level_desc,
  801. sampling_level_remark,
  802. sampling_level_active,
  803. create_date,
  804. create_by,
  805. update_date,
  806. update_by
  807. FROM qc_sampling_inspection_level
  808. <where>
  809. site in (select site from eam_access_site where username = #{query.userName})
  810. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  811. <if test="query.buDesc != null and query.buDesc != ''">
  812. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  813. </if>
  814. <if test="query.samplingLevelNo != null and query.samplingLevelNo != ''">
  815. AND sampling_level_no LIKE '%' + #{query.samplingLevelNo}+'%'
  816. </if>
  817. <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''">
  818. AND sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%'
  819. </if>
  820. <if test="query.samplingLevelActive != null and query.samplingLevelActive != ''">
  821. AND sampling_level_active = #{query.samplingLevelActive}
  822. </if>
  823. </where>
  824. </select>
  825. <!-- 根据名称查询检验等级 -->
  826. <select id="selectSamplingLevelByDesc" parameterType="QcSamplingInspectionLevelData" resultType="QcSamplingInspectionLevelData">
  827. SELECT
  828. site,
  829. bu_no,
  830. sampling_level_no,
  831. sampling_level_desc,
  832. sampling_level_remark,
  833. sampling_level_active
  834. FROM qc_sampling_inspection_level
  835. WHERE sampling_level_desc = #{samplingLevelDesc} AND site = #{site} and bu_no = #{buNo}
  836. </select>
  837. <!-- 获取最大检验等级编码 -->
  838. <select id="queryLastSamplingLevelNo" resultType="string" parameterType="QcSamplingInspectionLevelData">
  839. SELECT top 1 sampling_level_no
  840. FROM qc_sampling_inspection_level
  841. where site = #{site} and bu_no = #{buNo}
  842. ORDER BY sampling_level_no Desc
  843. </select>
  844. <!-- 新增检验等级 -->
  845. <insert id="samplingLevelSave" parameterType="QcSamplingInspectionLevelData">
  846. 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)
  847. VALUES (#{site}, #{buNo}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingLevelRemark}, #{samplingLevelActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  848. </insert>
  849. <!-- 根据检验等级编码查询矩阵 -->
  850. <select id="selectSamplingPlanBySamplingLevelNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionLevelData">
  851. SELECT
  852. site,
  853. bu_no,
  854. sampling_plan_no,
  855. sampling_qty_no,
  856. sampling_qty_rank_no,
  857. sampling_level_no,
  858. sampling_plan_active
  859. FROM qc_sampling_inspection_plan
  860. WHERE site = #{site} and bu_no = #{buNo}
  861. AND sampling_level_no = #{samplingLevelNo}
  862. </select>
  863. <!-- 修改检验等级 -->
  864. <update id="samplingLevelUpdate" parameterType="QcSamplingInspectionLevelData">
  865. UPDATE qc_sampling_inspection_level
  866. SET sampling_level_desc = #{samplingLevelDesc},
  867. sampling_level_remark = #{samplingLevelRemark},
  868. sampling_level_active = #{samplingLevelActive},
  869. update_date = getDate(),
  870. update_by = #{updateBy}
  871. WHERE sampling_level_no = #{samplingLevelNo}
  872. AND site = #{site} and bu_no = #{buNo}
  873. </update>
  874. <!-- 删除检验等级 -->
  875. <delete id="samplingLevelDelete" parameterType="QcSamplingInspectionLevelData">
  876. DELETE FROM qc_sampling_inspection_level
  877. WHERE site = #{site} and bu_no = #{buNo}
  878. AND sampling_level_no = #{samplingLevelNo}
  879. AND sampling_level_desc = #{samplingLevelDesc}
  880. </delete>
  881. <!-- ================================================= 物料属性设置维护 ================================================= -->
  882. <!-- 查询物料属性 -->
  883. <select id="qcPartAttributeSearch" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  884. SELECT
  885. qa.site,
  886. qa.bu_no,
  887. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  888. p.part_no as partNo,
  889. p.part_desc,
  890. dbo.qc_get_cinv_source_code(p.part_no) as cinvSourceCode,
  891. dbo.qc_get_sku(part_no) as sku,
  892. p.FamilyID,
  893. p.spec as FamilyName,
  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.spec 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 = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1680. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1681. AND sub_detail_value ${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 = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1983. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1984. AND sub_detail_value ${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. FROM qc_iqc_record
  2133. <where>
  2134. site in (select site from eam_access_site where username = #{query.userName})
  2135. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2136. <if test="query.buDesc != null and query.buDesc != ''">
  2137. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  2138. </if>
  2139. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2140. AND inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2141. </if>
  2142. <if test = "query.states != null and query.states.size > 0">
  2143. AND state in
  2144. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2145. #{item}
  2146. </foreach>
  2147. </if>
  2148. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2149. AND inspection_result = #{query.inspectionResult}
  2150. </if>
  2151. <if test = "query.partNo != null and query.partNo != ''">
  2152. AND part_no LIKE '%' + #{query.partNo} + '%'
  2153. </if>
  2154. <if test = "query.partDesc != null and query.partDesc != ''">
  2155. AND part_desc LIKE '%' + #{query.partDesc} + '%'
  2156. </if>
  2157. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2158. AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%'
  2159. </if>
  2160. <if test = "query.sku != null and query.sku != ''">
  2161. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%'
  2162. </if>
  2163. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  2164. AND dbo.qc_get_supplier_name(site, supplier_no) LIKE '%' + #{query.supplierDesc} + '%'
  2165. </if>
  2166. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2167. AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2168. </if>
  2169. <if test = "query.inspectorName != null and query.inspectorName != ''">
  2170. AND dbo.qc_get_inspector_name(site, inspector_no) LIKE '%' + #{query.inspectorName} + '%'
  2171. </if>
  2172. <if test="query.startDate != null">
  2173. AND inspector_date >= #{query.startDate}
  2174. </if>
  2175. <if test="query.endDate != null">
  2176. AND #{query.endDate} >= inspector_date
  2177. </if>
  2178. <if test="query.startDate2 != null">
  2179. AND create_date >= #{query.startDate2}
  2180. </if>
  2181. <if test="query.endDate2 != null">
  2182. AND #{query.endDate2} >= create_date
  2183. </if>
  2184. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  2185. AND po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  2186. </if>
  2187. <if test = "query.poItemNo != null and query.poItemNo != ''">
  2188. AND po_itemNo LIKE '%' + #{query.poItemNo} + '%'
  2189. </if>
  2190. <if test = "query.orderType != null and query.orderType != ''">
  2191. AND dbo.qc_get_order_type(site, po_orderNo, po_itemNo) = #{query.orderType}
  2192. </if>
  2193. </where>
  2194. ORDER BY
  2195. CASE WHEN state = '待检验' THEN 1
  2196. WHEN state = '待审核' THEN 2
  2197. WHEN state = '已完成' THEN 3
  2198. END, create_date desc
  2199. </select>
  2200. <!-- IQC明细记录查询 -->
  2201. <select id="iqcDetailSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2202. SELECT
  2203. a.site,
  2204. a.bu_no,
  2205. a.inspection_no,
  2206. a.template_id,
  2207. a.sampling_level_no,
  2208. a.sampling_level_desc,
  2209. a.sampling_programme_no,
  2210. a.sampling_programme_desc,
  2211. a.AQL,
  2212. a.AC,
  2213. a.RE,
  2214. a.item_no,
  2215. a.item_desc,
  2216. a.object_id,
  2217. a.object_desc,
  2218. a.default_value,
  2219. a.min_value,
  2220. a.max_value,
  2221. a.text_value,
  2222. a.number_value,
  2223. a.value_type_db,
  2224. a.value_type,
  2225. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2226. a.is_submit,
  2227. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2228. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2229. c.method_no,
  2230. c.method_name,
  2231. c.method_remark,
  2232. a.sampling_qty
  2233. FROM qc_iqc_detailed_record as a
  2234. 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
  2235. 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
  2236. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2237. </select>
  2238. <!-- 查询IQC的子明细 -->
  2239. <select id="selectIQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues">
  2240. SELECT
  2241. site,
  2242. bu_no,
  2243. sub_detail_value,
  2244. sampling_location,
  2245. is_submit,
  2246. sampling_location_b,
  2247. num
  2248. FROM qc_iqc_sub_detail_record
  2249. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2250. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2251. AND sub_detail_value ${collectionDataContent}
  2252. </if>
  2253. order by num
  2254. </select>
  2255. <!-- 获取该项目的子明细值 -->
  2256. <select id="selectIQCSubDetailValue" parameterType="string" resultType="SubDetailValues">
  2257. SELECT sub_detail_value,
  2258. sampling_location,
  2259. is_submit
  2260. FROM qc_iqc_sub_detail_record
  2261. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2262. </select>
  2263. <!-- 修改IQC主记录信息 -->
  2264. <update id="updateIQCMasterRecord" parameterType="QcFAIRecordData">
  2265. UPDATE qc_iqc_record
  2266. SET disposal_measures = #{disposalMeasures},
  2267. disposal_remark = #{disposalRemark},
  2268. inspection_result = #{inspectionResult},
  2269. inspector_no = #{inspectorNo},
  2270. state = #{state},
  2271. inspection_remark = #{inspectionRemark},
  2272. inspector_date = getDate(),
  2273. roll_count = #{rollCount,jdbcType=DECIMAL},
  2274. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2275. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL}
  2276. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2277. </update>
  2278. <!-- 修改IQC明细记录信息 -->
  2279. <update id="updateIQCDetailedRecord" parameterType="QcFAIRecordData">
  2280. UPDATE qc_iqc_detailed_record
  2281. SET item_result = #{itemResult},
  2282. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2283. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2284. text_value = #{textValue},
  2285. number_value = #{numberValue,jdbcType=DECIMAL}
  2286. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2287. </update>
  2288. <!-- 查询该记录明细是否已存在 -->
  2289. <select id="checkIQCDetail" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2290. SELECT inspection_no,
  2291. template_id
  2292. FROM qc_iqc_detailed_record
  2293. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2294. </select>
  2295. <!-- 查询IQC检验记录是否已提交 -->
  2296. <select id="checkIQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData">
  2297. SELECT submit_flag
  2298. FROM qc_iqc_record
  2299. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2300. </select>
  2301. <!-- 删除IQC子明细的老数据 -->
  2302. <delete id="delIQCSubDetailedRecord" parameterType="QcSubDetailInformationData">
  2303. DELETE FROM qc_iqc_sub_detail_record
  2304. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2305. </delete>
  2306. <!-- 新增IQC子明细信息 -->
  2307. <insert id="saveIQCSubDetailed">
  2308. INSERT INTO qc_iqc_sub_detail_record
  2309. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b)
  2310. VALUES
  2311. <foreach collection="list" item="item" separator=",">
  2312. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB})
  2313. </foreach>
  2314. </insert>
  2315. <!-- 修改IQC主记录标识为已提交 -->
  2316. <update id="updateIQCMasterSubmitFlag" parameterType="QcFAIRecordData">
  2317. UPDATE qc_iqc_record
  2318. SET submit_flag = 'Y',
  2319. state = '已完成'
  2320. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2321. </update>
  2322. <!-- 修改IQC明细记录标识为已提交 -->
  2323. <update id="updateIQCDetailSubmitFlag" parameterType="QcFAIRecordData">
  2324. UPDATE qc_iqc_detailed_record
  2325. SET is_submit = 'Y'
  2326. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2327. </update>
  2328. <!-- 修改IQC子明细记录标识为已提交 -->
  2329. <update id="updateIQCSubDetailSubmitFlag" parameterType="QcFAIRecordData">
  2330. UPDATE qc_iqc_sub_detail_record
  2331. SET is_submit = 'Y'
  2332. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2333. </update>
  2334. <!-- 删除IQC检验记录 -->
  2335. <delete id="deleteIQCRecord" parameterType="QcFAIRecordData">
  2336. DELETE FROM qc_iqc_record
  2337. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2338. </delete>
  2339. <!-- 删除IQC明细记录信息 -->
  2340. <delete id="deleteIQCDetailedRecord" parameterType="QcFAIRecordData">
  2341. DELETE FROM qc_iqc_detailed_record
  2342. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2343. </delete>
  2344. <!-- 删除IQC子明细记录信息 -->
  2345. <delete id="deleteIQCSubDetailedRecord" parameterType="QcFAIRecordData">
  2346. DELETE FROM qc_iqc_sub_detail_record
  2347. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2348. </delete>
  2349. <!-- 查询文件ID -->
  2350. <select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
  2351. SELECT id, file_name
  2352. FROM sys_oss
  2353. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  2354. </select>
  2355. <!-- 获取工序列表 -->
  2356. <select id="getOperationDescList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  2357. SELECT distinct
  2358. operation_desc
  2359. FROM so_routing
  2360. <where>
  2361. <if test = "operationDesc != null and operationDesc != ''">
  2362. AND operation_desc LIKE '%' + #{operationDesc} + '%'
  2363. </if>
  2364. </where>
  2365. </select>
  2366. <!-- 获取供应商列表 -->
  2367. <select id="getManufacturerList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  2368. SELECT
  2369. supplierID as manufacturerID,
  2370. supplierName as manufacturerName
  2371. FROM view_Supplier
  2372. <where>
  2373. site = #{site}
  2374. <if test = "manufacturerID != null and manufacturerID != ''">
  2375. AND supplierID LIKE '%' + #{manufacturerID} + '%'
  2376. </if>
  2377. <if test = "manufacturerName != null and manufacturerName != ''">
  2378. AND supplierName LIKE '%' + #{manufacturerName} + '%'
  2379. </if>
  2380. </where>
  2381. </select>
  2382. <!-- 获取机台列表 -->
  2383. <select id="getAllResourceList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2384. SELECT distinct
  2385. resource_id,
  2386. resource_desc
  2387. FROM resource
  2388. <where>
  2389. site = #{site}
  2390. <if test = "resourceId != null and resourceId != ''">
  2391. AND resource_id LIKE '%' + #{resourceId} + '%'
  2392. </if>
  2393. <if test = "resourceDesc != null and resourceDesc != ''">
  2394. AND resource_desc LIKE '%' + #{resourceDesc} + '%'
  2395. </if>
  2396. </where>
  2397. </select>
  2398. <!-- 获取工单列表 -->
  2399. <select id="getOrderNoList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2400. SELECT DISTINCT
  2401. a.orderno as orderNo
  2402. FROM soscheduledrouting as a
  2403. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2404. LEFT JOIN so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site
  2405. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2406. <where>
  2407. a.site = #{site}
  2408. AND b.approve_qty is not null
  2409. <if test = "orderNo != null and orderNo != ''">
  2410. AND a.orderno LIKE '%' + #{orderNo} + '%'
  2411. </if>
  2412. </where>
  2413. order by a.orderno DESC
  2414. </select>
  2415. <!-- 查询FQC主记录信息 -->
  2416. <select id="qcFQCInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2417. SELECT
  2418. inspection_no,
  2419. site,
  2420. bu_no,
  2421. dbo.get_bu_desc(site, bu_no) as buDesc,
  2422. state,
  2423. inspection_result,
  2424. task_date,
  2425. inspection_type_no,
  2426. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName,
  2427. inspection_cycle,
  2428. order_no,
  2429. operation_desc,
  2430. resource_id,
  2431. dbo.qc_get_resource_desc(site, resource_id, work_center_no) as resourceDesc,
  2432. part_no,
  2433. dbo.qc_get_part_desc(part_no) as part_desc,
  2434. inspection_remark,
  2435. roll_qty,
  2436. sampling_qty,
  2437. disposal_measures,
  2438. disposal_remark,
  2439. inspector_date,
  2440. inspector_no,
  2441. dbo.qc_get_inspector_name(site, inspector_no) as inspectorName,
  2442. ssr_id,
  2443. unqualified_qty,
  2444. submit_flag,
  2445. dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode,
  2446. dbo.qc_get_sku(part_no) as sku,
  2447. dbo.qc_get_spec(part_no) as spec,
  2448. seq_no,
  2449. batch_roll_no,
  2450. special_requirements,
  2451. work_center_no,
  2452. roll_no,
  2453. um_id,
  2454. dbo.qc_get_um_name(site, um_id) as umName,
  2455. action_date,
  2456. action_by,
  2457. isnull(dbo.joint_id(site, bu_no, inspection_no, 'coordination'), '') as operator,
  2458. isnull(dbo.joint_name(site, bu_no, inspection_no, 'coordination'), '') as operatorName,
  2459. isnull(dbo.joint_id(site, bu_no, inspection_no, 'responsible'), '') as responsiblePerson,
  2460. isnull(dbo.joint_name2(site, bu_no, inspection_no, 'responsible'), '') as responsiblePersonName
  2461. FROM qc_fqc_record
  2462. <where>
  2463. site in (select site from eam_access_site where username = #{query.userName})
  2464. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2465. <if test="query.buDesc != null and query.buDesc != ''">
  2466. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  2467. </if>
  2468. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2469. AND inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2470. </if>
  2471. <if test = "query.partNo != null and query.partNo != ''">
  2472. AND part_no LIKE '%' + #{query.partNo} + '%'
  2473. </if>
  2474. <if test = "query.partDesc != null and query.partDesc != ''">
  2475. AND dbo.qc_get_part_desc(part_no) LIKE '%' + #{query.partDesc} + '%'
  2476. </if>
  2477. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2478. AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%'
  2479. </if>
  2480. <if test = "query.sku != null and query.sku != ''">
  2481. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%'
  2482. </if>
  2483. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2484. AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2485. </if>
  2486. <if test = "query.states != null and query.states.size > 0">
  2487. AND state in
  2488. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2489. #{item}
  2490. </foreach>
  2491. </if>
  2492. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2493. AND inspection_result = #{query.inspectionResult}
  2494. </if>
  2495. <if test = "query.orderNo != null and query.orderNo != ''">
  2496. AND order_no LIKE '%' + #{query.orderNo} + '%'
  2497. </if>
  2498. <if test = "query.seqNo != null and query.seqNo != ''">
  2499. AND seq_no LIKE '%' + #{query.seqNo} + '%'
  2500. </if>
  2501. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2502. AND operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2503. </if>
  2504. <if test="query.startDate != null">
  2505. AND inspector_date >= #{query.startDate}
  2506. </if>
  2507. <if test="query.endDate != null">
  2508. AND #{query.endDate} >= inspector_date
  2509. </if>
  2510. <if test="query.startDate2 != null">
  2511. AND task_date >= #{query.startDate2}
  2512. </if>
  2513. <if test="query.endDate2 != null">
  2514. AND #{query.endDate2} >= task_date
  2515. </if>
  2516. </where>
  2517. ORDER BY
  2518. CASE WHEN state = '待检验' THEN 1
  2519. WHEN state = '待审核' THEN 2
  2520. WHEN state = '已完成' THEN 3
  2521. END, task_date desc
  2522. </select>
  2523. <!-- 新增FQC明细记录信息 -->
  2524. <insert id="saveFQCDetailedRecord" parameterType="QcFAIRecordData">
  2525. 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)
  2526. 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})
  2527. </insert>
  2528. <!-- 新增FQC主记录信息 -->
  2529. <insert id="saveFQCRecord" parameterType="QcFAIRecordData">
  2530. 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)
  2531. 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})
  2532. </insert>
  2533. <!-- FQC明细记录查询 -->
  2534. <select id="fqcDetailSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2535. SELECT
  2536. a.site,
  2537. a.bu_no,
  2538. a.inspection_no,
  2539. a.order_no,
  2540. a.template_id,
  2541. a.sampling_level_no,
  2542. a.sampling_level_desc,
  2543. a.sampling_programme_no,
  2544. a.sampling_programme_desc,
  2545. a.AQL,
  2546. a.AC,
  2547. a.RE,
  2548. a.item_no,
  2549. a.item_desc,
  2550. a.object_id,
  2551. a.object_desc,
  2552. a.default_value,
  2553. a.min_value,
  2554. a.max_value,
  2555. a.text_value,
  2556. a.number_value,
  2557. a.value_type_db,
  2558. a.value_type,
  2559. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2560. a.is_submit,
  2561. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2562. a.sampling_qty,
  2563. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2564. c.method_no,
  2565. c.method_name,
  2566. c.method_remark
  2567. FROM qc_fqc_detailed_record as a
  2568. 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
  2569. 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
  2570. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2571. </select>
  2572. <!-- 删除FQC检验记录 -->
  2573. <delete id="deleteFQCRecord" parameterType="QcFAIRecordData">
  2574. DELETE FROM qc_fqc_record
  2575. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2576. </delete>
  2577. <!-- 删除FQC明细记录信息 -->
  2578. <delete id="deleteFQCDetailedRecord" parameterType="QcFAIRecordData">
  2579. DELETE FROM qc_fqc_detailed_record
  2580. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2581. </delete>
  2582. <!-- 删除FQC子明细记录信息 -->
  2583. <delete id="deleteFQCSubDetailedRecord" parameterType="QcFAIRecordData">
  2584. DELETE FROM qc_fqc_sub_detail_record
  2585. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2586. </delete>
  2587. <!-- 修改FQC主记录信息 -->
  2588. <update id="updateFQCMasterRecord" parameterType="QcFAIRecordData">
  2589. UPDATE qc_fqc_record
  2590. SET disposal_measures = #{disposalMeasures},
  2591. disposal_remark = #{disposalRemark},
  2592. inspection_result = #{inspectionResult},
  2593. inspector_no = #{inspectorNo},
  2594. state = #{state},
  2595. inspection_remark = #{inspectionRemark},
  2596. inspector_date = getDate(),
  2597. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2598. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2599. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL}
  2600. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2601. </update>
  2602. <!-- 修改FQC明细记录信息 -->
  2603. <update id="updateFQCDetailedRecord" parameterType="QcFAIRecordData">
  2604. UPDATE qc_fqc_detailed_record
  2605. SET item_result = #{itemResult},
  2606. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2607. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2608. text_value = #{textValue},
  2609. number_value = #{numberValue,jdbcType=DECIMAL}
  2610. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2611. </update>
  2612. <!-- 修改FQC主记录标识为已提交 -->
  2613. <update id="updateFQCMasterSubmitFlag" parameterType="QcFAIRecordData">
  2614. UPDATE qc_fqc_record
  2615. SET submit_flag = 'Y',
  2616. state = '已完成'
  2617. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2618. </update>
  2619. <!-- 修改FAI明细记录标识为已提交 -->
  2620. <update id="updateFQCDetailSubmitFlag" parameterType="QcFAIRecordData">
  2621. UPDATE qc_fqc_detailed_record
  2622. SET is_submit = 'Y'
  2623. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2624. </update>
  2625. <!-- 修改子明细记录标识为已提交 -->
  2626. <update id="updateFQCSubDetailSubmitFlag" parameterType="QcFAIRecordData">
  2627. UPDATE qc_fqc_sub_detail_record
  2628. SET is_submit = 'Y'
  2629. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2630. </update>
  2631. <!-- 删除子明细的老数据 -->
  2632. <delete id="delFQCSubDetailedRecord" parameterType="QcSubDetailInformationData">
  2633. DELETE FROM qc_fqc_sub_detail_record
  2634. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2635. </delete>
  2636. <!-- 新增子明细信息 -->
  2637. <insert id="saveFQCSubDetailed">
  2638. INSERT INTO qc_fqc_sub_detail_record
  2639. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b)
  2640. VALUES
  2641. <foreach collection="list" item="item" separator=",">
  2642. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB})
  2643. </foreach>
  2644. </insert>
  2645. <!-- 查询FQC的子明细 -->
  2646. <select id="selectFQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues">
  2647. SELECT
  2648. site,
  2649. bu_no,
  2650. sub_detail_value,
  2651. sampling_location,
  2652. is_submit,
  2653. sampling_location_b,
  2654. num
  2655. FROM qc_fqc_sub_detail_record
  2656. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2657. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2658. AND sub_detail_value ${collectionDataContent}
  2659. </if>
  2660. order by num
  2661. </select>
  2662. <!-- 查询FQC检验记录是否已提交 -->
  2663. <select id="checkFQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData">
  2664. SELECT submit_flag
  2665. FROM qc_fqc_record
  2666. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2667. </select>
  2668. <!-- 获取该项目的子明细值 -->
  2669. <select id="selectFQCSubDetailValue" parameterType="string" resultType="SubDetailValues">
  2670. SELECT sub_detail_value,
  2671. sampling_location,
  2672. is_submit
  2673. FROM qc_fqc_sub_detail_record
  2674. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2675. </select>
  2676. <!-- 生成FQC检验单号 -->
  2677. <select id="selectFQCInspectionNo" resultType="string" parameterType="QcFAIRecordData">
  2678. SELECT
  2679. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2680. FROM qc_fqc_record
  2681. WHERE site = #{site} and bu_no = #{buNo}
  2682. </select>
  2683. <!-- 生成IPQC检验单号 -->
  2684. <select id="selectIPQCInspectionNo" resultType="string" parameterType="QcFAIRecordData">
  2685. SELECT
  2686. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  2687. FROM qc_ipqc_record
  2688. WHERE site = #{site} and bu_no = #{buNo}
  2689. </select>
  2690. <!-- 生成FAI检验单号 -->
  2691. <select id="selectFAIInspectionNo" resultType="string" parameterType="QcFAIRecordData">
  2692. SELECT
  2693. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2694. FROM qc_fai_record
  2695. WHERE site = #{site} and bu_no = #{buNo}
  2696. </select>
  2697. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  2698. <select id="queryDataFromViewPoOrder" resultType="PoOrderData" parameterType="QcFAIRecordData">
  2699. SELECT
  2700. site,
  2701. order_no,
  2702. item_no,
  2703. part_no,
  2704. part_desc,
  2705. spec,
  2706. supplier_id,
  2707. supplier_name,
  2708. order_qty,
  2709. created_date,
  2710. status,
  2711. citem_code,
  2712. citem_class,
  2713. sendto_address,
  2714. order_type
  2715. FROM view_po_order
  2716. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  2717. </select>
  2718. <!-- 向收货任务表里添加数据 -->
  2719. <insert id="saveReceivingTask" parameterType="PoOrderData">
  2720. 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)
  2721. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo})
  2722. </insert>
  2723. <!-- 检查动控是否开启 -->
  2724. <select id="queryController" parameterType="SysSceneDynamicControlModelEntity" resultType="SysSceneDynamicControlModelEntity">
  2725. SELECT
  2726. type,
  2727. base_data,
  2728. base_desc,
  2729. status,
  2730. remark,
  2731. third_type,
  2732. second_type,
  2733. page_control,
  2734. control_style
  2735. FROM sys_scene_dynamic_control_model
  2736. where site = #{site} and control_no = #{controlNo}
  2737. </select>
  2738. <!-- 查询检验模板列表 -->
  2739. <select id="queryTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData">
  2740. SELECT
  2741. site,
  2742. bu_no,
  2743. template_id as templateId,
  2744. template_name as templateName,
  2745. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2746. FROM qc_template
  2747. <where>
  2748. site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  2749. <if test = "templateId != null and templateId != ''">
  2750. AND template_id LIKE '%' + #{templateId}+'%'
  2751. </if>
  2752. <if test = "templateName != null and templateName != ''">
  2753. AND template_name LIKE '%' + #{templateName}+'%'
  2754. </if>
  2755. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2756. AND inspection_type_no = #{inspectionTypeNo}
  2757. </if>
  2758. </where>
  2759. </select>
  2760. <!-- 查询检验模板列表 -->
  2761. <select id="getPartInformation" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2762. select
  2763. part_no,
  2764. part_desc,
  2765. spec,
  2766. sku,
  2767. control_mes,
  2768. DefaultWarehouseID as defaultWarehouseId
  2769. from part
  2770. where site = #{site} and part_no = #{partNo}
  2771. </select>
  2772. <!-- 获取特殊工序列表 -->
  2773. <select id="getSpecialOperationList" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2774. select
  2775. site,
  2776. operation_no,
  2777. operation_desc
  2778. from qc_special_task_operation
  2779. where site = #{site}
  2780. </select>
  2781. <!-- 获取处置措施列表 -->
  2782. <select id="disposalMeasuresSearch" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2783. SELECT
  2784. id,
  2785. disposal_measures
  2786. FROM qc_disposal_measures
  2787. <where>
  2788. <if test = "inspectionTypeNo != '101'">
  2789. inspection_type != 'IPQC'
  2790. </if>
  2791. </where>
  2792. </select>
  2793. <!-- 查询文件路径 -->
  2794. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="QcFAIRecordData">
  2795. SELECT
  2796. id,
  2797. url,
  2798. file_name
  2799. FROM sys_oss
  2800. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2801. </select>
  2802. <!-- 删除图片-->
  2803. <delete id="imageDelete" parameterType="SysOssEntity">
  2804. DELETE FROM sys_oss
  2805. WHERE id = #{id}
  2806. </delete>
  2807. <!-- 模糊查询标签号 -->
  2808. <select id="getRollNo" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2809. SELECT DISTINCT top 3
  2810. a.seqno,
  2811. a.orderno,
  2812. b.roll_no
  2813. FROM soscheduledrouting AS a
  2814. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  2815. WHERE a.site = #{site} and b.roll_no like '%' + #{rollNo} + '%'
  2816. </select>
  2817. <!-- 标签号回车事件 -->
  2818. <select id="rollNoEnter" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2819. SELECT
  2820. a.site,
  2821. a.seqno as seqNo,
  2822. a.orderno as orderNo,
  2823. b.roll_no
  2824. FROM soscheduledrouting AS a
  2825. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  2826. WHERE b.roll_no = #{rollNo}
  2827. </select>
  2828. <!-- 查询物料列表 -->
  2829. <select id="queryPartList" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2830. SELECT
  2831. site,
  2832. part_no,
  2833. part_desc,
  2834. sku,
  2835. spec
  2836. FROM part
  2837. <where>
  2838. site = #{site}
  2839. <if test = "partNo != null and partNo != ''">
  2840. AND part_no LIKE '%' + #{partNo} + '%'
  2841. </if>
  2842. <if test = "partDesc != null and partDesc != ''">
  2843. AND part_desc LIKE '%' + #{partDesc} + '%'
  2844. </if>
  2845. <if test = "sku != null and sku != ''">
  2846. AND sku LIKE '%' + #{sku} + '%'
  2847. </if>
  2848. </where>
  2849. </select>
  2850. <!-- 查询单位列表 -->
  2851. <select id="umSearch" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2852. SELECT
  2853. site,
  2854. UMID as umId,
  2855. UMName as umName
  2856. FROM UM
  2857. WHERE site = #{site} and active = #{active}
  2858. </select>
  2859. <!-- 查询单位列表 -->
  2860. <select id="checkItem" resultType="SubDetailValues" parameterType="SubDetailValues">
  2861. SELECT
  2862. site,
  2863. bu_no,
  2864. inspection_no,
  2865. item_no,
  2866. value_type_db,
  2867. min_value,
  2868. max_value
  2869. <if test = "flag == 'IPQC'">
  2870. FROM qc_ipqc_detailed_record
  2871. </if>
  2872. <if test = "flag == 'IQC'">
  2873. FROM qc_iqc_detailed_record
  2874. </if>
  2875. <if test = "flag == 'FQC'">
  2876. FROM qc_fqc_detailed_record
  2877. </if>
  2878. <if test = "flag == 'FAI'">
  2879. FROM qc_fai_detailed_record
  2880. </if>
  2881. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  2882. </select>
  2883. <!-- 查询检验方法列表 -->
  2884. <select id="queryMethodList" resultType="QcMethodData" parameterType="QcMethodData">
  2885. SELECT
  2886. site,
  2887. bu_no,
  2888. method_no,
  2889. method_name,
  2890. inspection_type_no,
  2891. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2892. FROM qc_method
  2893. <where>
  2894. site = #{site} and bu_no = #{buNo}
  2895. <if test = "methodNo != null and methodNo != ''">
  2896. AND method_no LIKE '%' + #{methodNo} + '%'
  2897. </if>
  2898. <if test = "methodName != null and methodName != ''">
  2899. AND method_name LIKE '%' + #{methodName} + '%'
  2900. </if>
  2901. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2902. AND inspection_type_no = #{inspectionTypeNo}
  2903. </if>
  2904. <if test="inspectionTypeName != null and inspectionTypeName != ''">
  2905. AND dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  2906. </if>
  2907. </where>
  2908. </select>
  2909. <!-- 修改detailFlag字段为N -->
  2910. <update id="updateIQCDetailFlag" parameterType="QcFAIRecordData">
  2911. UPDATE qc_iqc_record
  2912. SET detail_flag = 'N'
  2913. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2914. </update>
  2915. <!-- 查询检验方法唯一 -->
  2916. <select id="checkMethodOnlyOne" resultType="QcMethodData" parameterType="QcMethodData">
  2917. SELECT
  2918. site,
  2919. bu_no,
  2920. method_no
  2921. FROM qc_method
  2922. <where>
  2923. site = #{site} and bu_no = #{buNo} and method_no = #{methodNo}
  2924. </where>
  2925. </select>
  2926. <!-- 查询检验项目唯一 -->
  2927. <select id="checkItemOnlyOne" resultType="QcItemData" parameterType="QcItemData">
  2928. SELECT
  2929. site,
  2930. bu_no,
  2931. ItemNo,
  2932. ItemDesc
  2933. FROM eam_properties_item
  2934. <where>
  2935. site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ItemType = #{itemType} and inspection_type_no = #{inspectionTypeNo}
  2936. </where>
  2937. </select>
  2938. <!-- 查询检验项目唯一 -->
  2939. <select id="checkTemplateOnlyOne" resultType="QcTemplateData" parameterType="QcTemplateData">
  2940. SELECT
  2941. site,
  2942. bu_no,
  2943. template_id,
  2944. template_name
  2945. FROM qc_template
  2946. <where>
  2947. site = #{site} and bu_no = #{buNo} and template_id = #{templateId}
  2948. </where>
  2949. </select>
  2950. <select id="searchSeqInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2951. SELECT DISTINCT
  2952. a.seqno,
  2953. a.orderno,
  2954. J.part_no,
  2955. J.part_desc,
  2956. t.lotsize,
  2957. a.qtyrequired,
  2958. c.operation_desc,
  2959. J.sku,
  2960. (select sum(roll_qty) from qc_ipqc_record where order_no = #{query.orderNo}) as sjzs
  2961. FROM
  2962. soscheduledrouting AS a
  2963. inner JOIN so_routing AS c ON c.order_no = a.orderno
  2964. AND a.itemno = c.item_no
  2965. AND c.site = a.site
  2966. inner JOIN part AS J ON a.site = J.site
  2967. AND a.part_no = J.part_no
  2968. inner JOIN shoporder AS t ON t.orderno = a.orderno
  2969. AND a.site = t.site
  2970. WHERE
  2971. a.site = #{query.site}
  2972. <if test="query.status != null and query.status != ''">
  2973. AND t.status = #{query.status}
  2974. </if>
  2975. <if test="query.orderNo != null and query.orderNo != ''">
  2976. AND a.orderno LIKE '%' + #{query.orderNo} + '%'
  2977. </if>
  2978. <if test="query.seqNo != null and query.seqNo != ''">
  2979. AND a.seqno LIKE '%' + #{query.seqNo} + '%'
  2980. </if>
  2981. <if test="query.sku != null and query.sku != ''">
  2982. AND dbo.qc_get_sku(a.part_no) LIKE '%' + #{query.sku} + '%'
  2983. </if>
  2984. <if test="query.partNo != null and query.partNo != ''">
  2985. AND J.part_no LIKE '%' + #{query.partNo} + '%'
  2986. </if>
  2987. <if test="query.partDesc != null and query.partDesc != ''">
  2988. AND J.part_desc LIKE '%' + #{query.partDesc} + '%'
  2989. </if>
  2990. <if test="query.operationDesc != null and query.operationDesc != ''">
  2991. AND c.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2992. </if>
  2993. </select>
  2994. <select id="searchPartInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2995. select
  2996. part_no,
  2997. part_desc,
  2998. sku,
  2999. cinv_source_code,
  3000. sourceBu
  3001. from
  3002. part
  3003. where
  3004. sourceBu = #{query.buNo}
  3005. <if test="query.partNo != null and query.partNo != ''">
  3006. AND part_no LIKE '%' + #{query.partNo} + '%'
  3007. </if>
  3008. <if test="query.partDesc != null and query.partDesc != ''">
  3009. AND part_desc LIKE '%' + #{query.partDesc} + '%'
  3010. </if>
  3011. <if test="query.sku != null and query.sku != ''">
  3012. AND sku LIKE '%' + #{query.sku} + '%'
  3013. </if>
  3014. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  3015. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  3016. </if>
  3017. </select>
  3018. <select id="getInterfaceTimeData" parameterType="String" resultType="InterfaceTimeData">
  3019. SELECT
  3020. id,
  3021. start_time,
  3022. end_time,
  3023. del_flag
  3024. FROM interface_time
  3025. WHERE del_flag = 'N' and site = #{site}
  3026. </select>
  3027. <update id="updateInterfaceTimeData" parameterType="InterfaceTimeData">
  3028. UPDATE interface_time
  3029. set
  3030. updated_by = #{updatedBy},
  3031. updated_date = #{updatedDate},
  3032. del_flag = #{delFlag}
  3033. </update>
  3034. <select id="getInterfaceRdStyleData" parameterType="String" resultType="RdStyleData">
  3035. SELECT
  3036. crdcode,
  3037. crdname,
  3038. iRdGrade,
  3039. rdtype,
  3040. brdend
  3041. FROM view_custdev_mes_rdstyle
  3042. WHERE crdname = #{crdName}
  3043. </select>
  3044. <insert id="insertHardtagPurchaseInStorageData" parameterType="HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
  3045. INSERT INTO purchase_in_storage_count
  3046. (site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
  3047. cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
  3048. values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
  3049. #{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
  3050. </insert>
  3051. <insert id="batchSaveHrdtagTransHeader" parameterType="HardtagTransHeaderData">
  3052. insert into TransHeader
  3053. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
  3054. TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
  3055. department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
  3056. values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
  3057. #{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
  3058. #{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
  3059. </insert>
  3060. <insert id="batchSaveHardtagTransDetail" parameterType="HardtagTransDetailData">
  3061. INSERT INTO TransDetail
  3062. (TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
  3063. values
  3064. (#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
  3065. </insert>
  3066. <select id="getSendMailAddress" parameterType="String" resultType="MailAddressData">
  3067. SELECT
  3068. id,
  3069. site,
  3070. mail_address,
  3071. send_type,
  3072. del_flag,
  3073. created_by,
  3074. created_date,
  3075. orderref1
  3076. FROM mailAddress
  3077. WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
  3078. </select>
  3079. <select id="getSendMailFromAddress" resultType="MailSendAddressData">
  3080. SELECT
  3081. port,
  3082. host,
  3083. username,
  3084. password,
  3085. emailForm,
  3086. timeout,
  3087. personal,
  3088. id
  3089. FROM mailSendAddress
  3090. where delFlag = 'N'
  3091. </select>
  3092. <!-- 新增发送邮件记录 -->
  3093. <insert id="saveSendMailRecord" parameterType="SendMailRecord">
  3094. insert into send_mail_record
  3095. (site, bu_no, document_no, sender, recipient, send_date)
  3096. values
  3097. (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate())
  3098. </insert>
  3099. <select id="orderTypeSearch" resultType="QcFAIRecordData">
  3100. SELECT distinct
  3101. order_type
  3102. FROM view_po_order
  3103. </select>
  3104. <update id="actionIQCInspection" parameterType="EamObjectInData">
  3105. update qc_iqc_record
  3106. set action_date = getDate(),
  3107. action_by = #{actionBy},
  3108. state = #{state}
  3109. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3110. </update>
  3111. <update id="actionFAIInspection" parameterType="EamObjectInData">
  3112. update qc_fai_record
  3113. set action_date = getDate(),
  3114. action_by = #{actionBy},
  3115. state = #{state}
  3116. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3117. </update>
  3118. <update id="actionIPQCInspection" parameterType="EamObjectInData">
  3119. update qc_ipqc_record
  3120. set action_date = getDate(),
  3121. action_by = #{actionBy},
  3122. state = #{state}
  3123. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3124. </update>
  3125. <update id="actionFQCInspection" parameterType="EamObjectInData">
  3126. update qc_fqc_record
  3127. set action_date = getDate(),
  3128. action_by = #{actionBy},
  3129. state = #{state}
  3130. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3131. </update>
  3132. <insert id="addEquipmentDataAcquisition">
  3133. insert into Equipment_data_acquisition
  3134. (site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
  3135. values
  3136. <foreach collection="list" item="item" separator=",">
  3137. (#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
  3138. </foreach>
  3139. </insert>
  3140. <!-- 新增人员信息 -->
  3141. <insert id="saveOperator" >
  3142. INSERT INTO eam_actual_operator
  3143. (site, order_no, function_type, operator, bu_no)
  3144. VALUES
  3145. <foreach collection="list" item="item" separator=",">
  3146. (#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
  3147. </foreach>
  3148. </insert>
  3149. <!-- 删除之前的人员-->
  3150. <delete id="delOperator" parameterType="QcFAIRecordData">
  3151. DELETE FROM eam_actual_operator
  3152. WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
  3153. </delete>
  3154. <select id="getInspectionNo" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData">
  3155. select
  3156. site,
  3157. bu_no,
  3158. equipment_no,
  3159. inspection_no,
  3160. create_date,
  3161. create_by,
  3162. item_no,
  3163. collection_source,
  3164. collection_method
  3165. from Equipment_data_acquisition
  3166. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3167. </select>
  3168. <select id="getInspectionNoByItem" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData">
  3169. select
  3170. site,
  3171. bu_no,
  3172. equipment_no,
  3173. inspection_no,
  3174. create_date,
  3175. create_by,
  3176. item_no,
  3177. collection_source,
  3178. collection_method
  3179. from Equipment_data_acquisition
  3180. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  3181. </select>
  3182. <select id="dataAcquisition" parameterType="EquipmentDataAcquisitionData" resultType="SubDetailValues">
  3183. select
  3184. site,
  3185. bu_no,
  3186. #{inspectionNo} as inspectionNo,
  3187. #{itemNo} as itemNo,
  3188. ${collectionSource} as subDetailValue,
  3189. num,
  3190. #{collectionSource} as collectionSource
  3191. from Equipment_data_detail
  3192. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3193. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3194. </select>
  3195. <select id="dataAcquisitionB" parameterType="EquipmentDataAcquisitionData" resultType="SubDetailValues">
  3196. select
  3197. site,
  3198. bu_no,
  3199. #{inspectionNo} as inspectionNo,
  3200. #{itemNo} as itemNo,
  3201. ${collectionSource} as subDetailValueB,
  3202. num,
  3203. #{collectionSource} as collectionSource
  3204. from Equipment_data_detail
  3205. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3206. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3207. </select>
  3208. <select id="dataAcquisition2" parameterType="EquipmentDataAcquisitionData" resultType="SysOssEntity">
  3209. select
  3210. site as orderRef1,
  3211. bu_no as orderRef4,
  3212. #{inspectionNo} as orderRef2,
  3213. #{itemNo} as orderRef3,
  3214. ${collectionSource} as url
  3215. from Equipment_data_detail
  3216. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3217. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3218. </select>
  3219. <select id="getIQCDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData">
  3220. select
  3221. a.site,
  3222. a.bu_no,
  3223. b.collection_condition as equipmentNo,
  3224. #{inspectionNo} as inspectionNo,
  3225. a.item_no,
  3226. b.collection_source,
  3227. #{actionBy} as actionBy,
  3228. b.collection_method
  3229. from qc_iqc_detailed_record as a
  3230. 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
  3231. 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'
  3232. </select>
  3233. <select id="getFAIDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData">
  3234. select
  3235. a.site,
  3236. a.bu_no,
  3237. b.collection_condition as equipmentNo,
  3238. #{inspectionNo} as inspectionNo,
  3239. a.item_no,
  3240. b.collection_source,
  3241. #{actionBy} as actionBy,
  3242. b.collection_method
  3243. from qc_fai_detailed_record as a
  3244. 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
  3245. 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'
  3246. </select>
  3247. <select id="getIPQCDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData">
  3248. select
  3249. a.site,
  3250. a.bu_no,
  3251. b.collection_condition as equipmentNo,
  3252. #{inspectionNo} as inspectionNo,
  3253. a.item_no,
  3254. b.collection_source,
  3255. #{actionBy} as actionBy,
  3256. b.collection_method
  3257. from qc_ipqc_detailed_record as a
  3258. 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
  3259. 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'
  3260. </select>
  3261. <select id="getFQCDetail" parameterType="QcFAIRecordData" resultType="EquipmentDataAcquisitionData">
  3262. select
  3263. a.site,
  3264. a.bu_no,
  3265. b.collection_condition as equipmentNo,
  3266. #{inspectionNo} as inspectionNo,
  3267. a.item_no,
  3268. b.collection_source,
  3269. #{actionBy} as actionBy,
  3270. b.collection_method
  3271. from qc_fqc_detailed_record as a
  3272. 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
  3273. 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'
  3274. </select>
  3275. <select id="querySubDetails" parameterType="QcFAIRecordData" resultType="SubDetailValues">
  3276. select
  3277. b.site,
  3278. b.bu_no,
  3279. b.inspection_no,
  3280. b.item_no,
  3281. b.default_value,
  3282. b.min_value,
  3283. b.max_value,
  3284. b.value_type_db,
  3285. a.sub_detail_value
  3286. <if test="flag == 'iqc'">
  3287. from qc_iqc_sub_detail_record as a
  3288. 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
  3289. </if>
  3290. <if test="flag == 'ipqc'">
  3291. from qc_ipqc_sub_detail_record as a
  3292. 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
  3293. </if>
  3294. <if test="flag == 'fqc'">
  3295. from qc_fqc_sub_detail_record as a
  3296. 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
  3297. </if>
  3298. <if test="flag == 'fai'">
  3299. from qc_fai_sub_detail_record as a
  3300. 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
  3301. </if>
  3302. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
  3303. </select>
  3304. <insert id="saveFileList">
  3305. INSERT INTO sys_oss
  3306. (url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
  3307. VALUES
  3308. <foreach collection="list" item="item" separator=",">
  3309. (#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
  3310. </foreach>
  3311. </insert>
  3312. <select id="getEquipmentNoList" parameterType="EquipmentFolderLocationData" resultType="EquipmentFolderLocationData">
  3313. select
  3314. equipment_no
  3315. from Equipment_folder_location
  3316. where site = #{site} and bu_no = #{buNo}
  3317. </select>
  3318. <!-- 获取责任人员列表 -->
  3319. <select id="getResponsibleOperatorList" resultType="EamAdminData" parameterType="EamAdminData">
  3320. SELECT
  3321. operator_id as adminID,
  3322. operator_name as adminName
  3323. FROM operator
  3324. <where>
  3325. site in (select site from eam_access_site where username = #{userName})
  3326. <if test = "adminID != null and adminID != ''">
  3327. AND operator_id LIKE '%' + #{adminID} + '%'
  3328. </if>
  3329. <if test = "adminName != null and adminName != ''">
  3330. AND operator_name LIKE '%' + #{adminName} + '%'
  3331. </if>
  3332. </where>
  3333. </select>
  3334. <select id="getDataContentList" parameterType="QcCollectionDataContentData" resultType="QcCollectionDataContentData">
  3335. select
  3336. content_desc
  3337. from qc_collection_data_content
  3338. where site = #{site} and bu_no = #{buNo} and active = 'Y'
  3339. </select>
  3340. <select id="getItemCollectionDataContent" parameterType="SubDetailValues" resultType="string">
  3341. select
  3342. collection_data_content
  3343. from eam_properties_item
  3344. where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
  3345. </select>
  3346. <!-- 获取当前项目不包含的设备 -->
  3347. <select id="getObjectList1" resultType="EamObjectInData" parameterType="EamObjectInData">
  3348. SELECT
  3349. a.site,
  3350. a.bu_no,
  3351. a.ObjectID,
  3352. a.ObjectDesc
  3353. FROM eam_object as a
  3354. 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}
  3355. where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  3356. </select>
  3357. <!-- 获取当前项目所包含的设备 -->
  3358. <select id="getObjectList2" resultType="EamObjectInData" parameterType="EamObjectInData">
  3359. SELECT
  3360. a.site,
  3361. a.bu_no,
  3362. a.ObjectID,
  3363. b.ObjectDesc,
  3364. a.default_flag
  3365. FROM qc_item_object a
  3366. LEFT JOIN eam_object b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID
  3367. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
  3368. </select>
  3369. <!-- 获取当前项目不包含的设备 -->
  3370. <select id="getObjectListBy" resultType="EamObjectInData" parameterType="EamObjectInData">
  3371. SELECT
  3372. a.site,
  3373. a.bu_no,
  3374. a.ObjectID,
  3375. a.ObjectDesc
  3376. FROM eam_object as a
  3377. 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}
  3378. <where>
  3379. a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  3380. <if test = "objectID != null and objectID != ''">
  3381. AND a.ObjectID LIKE '%' + #{objectID} + '%'
  3382. </if>
  3383. <if test = "objectDesc != null and objectDesc != ''">
  3384. AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
  3385. </if>
  3386. </where>
  3387. </select>
  3388. <!-- 新增项目设备 -->
  3389. <insert id="addItemObject">
  3390. INSERT INTO qc_item_object
  3391. (site, bu_no, ItemNo, ObjectID, default_flag)
  3392. VALUES
  3393. <foreach collection="list" item="item" separator=",">
  3394. (#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
  3395. </foreach>
  3396. </insert>
  3397. <delete id="deleteItemObject">
  3398. DELETE FROM qc_item_object
  3399. WHERE
  3400. <foreach collection="list" item="item" separator=" or " index="index">
  3401. (site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
  3402. </foreach>
  3403. </delete>
  3404. <update id="updateItemObject">
  3405. UPDATE qc_item_object
  3406. SET default_flag = #{defaultFlag}
  3407. WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
  3408. </update>
  3409. <select id="getIQCInspectionDetail" parameterType="EamObjectInData" resultType="EamObjectInData">
  3410. select
  3411. a.site,
  3412. a.bu_no,
  3413. a.inspection_no,
  3414. a.item_no,
  3415. a.item_desc,
  3416. b.collection_source,
  3417. b.collection_method
  3418. from qc_iqc_detailed_record as a
  3419. 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
  3420. 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'
  3421. </select>
  3422. <select id="getFAIInspectionDetail" parameterType="EamObjectInData" resultType="EamObjectInData">
  3423. select
  3424. a.site,
  3425. a.bu_no,
  3426. a.inspection_no,
  3427. a.item_no,
  3428. a.item_desc,
  3429. b.collection_source,
  3430. b.collection_method
  3431. from qc_fai_detailed_record as a
  3432. 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
  3433. 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'
  3434. </select>
  3435. <select id="getFQCInspectionDetail" parameterType="EamObjectInData" resultType="EamObjectInData">
  3436. select
  3437. a.site,
  3438. a.bu_no,
  3439. a.inspection_no,
  3440. a.item_no,
  3441. a.item_desc,
  3442. b.collection_source,
  3443. b.collection_method
  3444. from qc_fqc_detailed_record as a
  3445. 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
  3446. 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'
  3447. </select>
  3448. <select id="getIPQCInspectionDetail" parameterType="EamObjectInData" resultType="EamObjectInData">
  3449. select
  3450. a.site,
  3451. a.bu_no,
  3452. a.inspection_no,
  3453. a.item_no,
  3454. a.item_desc,
  3455. b.collection_source,
  3456. b.collection_method
  3457. from qc_ipqc_detailed_record as a
  3458. 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
  3459. 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'
  3460. </select>
  3461. <delete id="deleteEquipmentDataAcquisition" parameterType="QcFAIRecordData">
  3462. delete from Equipment_data_acquisition
  3463. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3464. </delete>
  3465. <select id="getInspectionStandards" parameterType="QcInspectionStandardData" resultType="QcInspectionStandardData">
  3466. select
  3467. site,
  3468. bu_no,
  3469. template_id,
  3470. item_no,
  3471. default_value,
  3472. min_value,
  3473. max_value,
  3474. condition,
  3475. collection_source,
  3476. seq_no
  3477. from qc_inspection_standards
  3478. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  3479. </select>
  3480. <delete id="deleteInspectionStandard" parameterType="QcInspectionStandardData">
  3481. delete from qc_inspection_standards
  3482. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  3483. </delete>
  3484. <delete id="deleteInspectionStandard2" parameterType="QcTemplateData">
  3485. delete from qc_inspection_standards
  3486. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  3487. </delete>
  3488. <insert id="saveInspectionStandard">
  3489. INSERT INTO qc_inspection_standards
  3490. (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
  3491. VALUES
  3492. <foreach collection="list" item="item" separator=",">
  3493. (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
  3494. </foreach>
  3495. </insert>
  3496. <select id="getInspectionTemplateDetail" parameterType="QcFAIRecordData" resultType="QcInspectionStandardData">
  3497. select
  3498. site,
  3499. bu_no,
  3500. template_id,
  3501. item_no
  3502. <if test="flag == 'iqc'">
  3503. from qc_iqc_detailed_record
  3504. </if>
  3505. <if test="flag == 'ipqc'">
  3506. from qc_ipqc_detailed_record
  3507. </if>
  3508. <if test="flag == 'fqc'">
  3509. from qc_fqc_detailed_record
  3510. </if>
  3511. <if test="flag == 'fai'">
  3512. from qc_fai_detailed_record
  3513. </if>
  3514. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3515. </select>
  3516. </mapper>