O
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.

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