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.

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