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
169 KiB

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