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.

3108 lines
135 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  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.methodNo != null and query.methodNo != ''">
  26. AND qm.method_no LIKE '%' + #{query.methodNo} +'%'
  27. </if>
  28. <if test="query.methodName != null and query.methodName != ''">
  29. AND qm.method_name LIKE '%' + #{query.methodName} +'%'
  30. </if>
  31. <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  32. AND qm.inspection_type_no = #{query.inspectionTypeNo}
  33. </if>
  34. </where>
  35. </select>
  36. <!-- 获得检验方法单号 -->
  37. <select id="getMethodNo" resultType="string" parameterType="QcMethodData">
  38. SELECT
  39. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(method_no,4))),0)+1),4)
  40. FROM qc_method
  41. WHERE site = #{site} AND inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  42. </select>
  43. <!-- 新增检验方法 -->
  44. <insert id="qcMethodSave" parameterType="QcMethodData">
  45. INSERT INTO qc_method (site, bu_no, method_no, method_name, create_date, create_by, method_remark, update_date, update_by, inspection_type_no)
  46. VALUES (#{site}, #{buNo}, #{methodNo}, #{methodName}, GetDate(), #{createBy}, #{methodRemark}, getDate(), #{updateBy}, #{inspectionTypeNo})
  47. </insert>
  48. <!-- 修改检验方法 -->
  49. <update id="qcMethodUpdate" parameterType="QcMethodData">
  50. UPDATE qc_method
  51. SET method_name = #{methodName},
  52. method_remark = #{methodRemark},
  53. update_date = getDate(),
  54. update_by = #{updateBy},
  55. inspection_type_no = #{inspectionTypeNo}
  56. WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
  57. </update>
  58. <!-- 检查方法是否在被项目使用 -->
  59. <select id="checkMethodIsUsed" parameterType="QcMethodData" resultType="EamPropertiesItemData">
  60. SELECT
  61. ItemNo
  62. FROM qc_method_item
  63. WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
  64. </select>
  65. <!-- 删除检验方法 -->
  66. <delete id="qcMethodDelete" parameterType="QcMethodData">
  67. DELETE FROM qc_method
  68. WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
  69. </delete>
  70. <!-- ================================================= 检验项目 ================================================= -->
  71. <!-- 根据条件查询检验项目 -->
  72. <select id="qcItemSearch" parameterType="QcItemData" resultType="QcItemData">
  73. SELECT
  74. epi.site,
  75. epi.bu_no,
  76. dbo.get_bu_desc(epi.site, epi.bu_no) as buDesc,
  77. epi.ItemNo,
  78. epi.ItemDesc,
  79. epi.DefaultValue,
  80. epi.ValueType,
  81. epi.ValueType_DB as valueTypeDb,
  82. epi.ValueChooseFlag,
  83. epi.CreatedDate,
  84. epi.CreatedBy,
  85. epi.MaxValue,
  86. epi.MinValue,
  87. epi.ItemRemark,
  88. epi.ItemType,
  89. epi.update_date,
  90. epi.update_by,
  91. qm.method_no,
  92. qm.method_name,
  93. qm.method_remark,
  94. epi.inspection_type_no,
  95. qit.inspection_type_name,
  96. epi.item_sampling_quantity,
  97. epi.sampling_programme_no,
  98. qsip.sampling_programme_desc,
  99. epi.sampling_level_no,
  100. qsil.sampling_level_desc,
  101. epi.default_sampling_proportion
  102. FROM eam_properties_item as epi
  103. LEFT JOIN qc_method_item as qmi on epi.ItemNo = qmi.ItemNo and epi.site = qmi.site and epi.bu_no = qmi.bu_no
  104. 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
  105. LEFT JOIN qc_inspection_type as qit on qit.inspection_type_no = epi.inspection_type_no and qit.site = epi.site
  106. 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
  107. 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
  108. <where>
  109. epi.site in (select site from eam_access_site where username = #{query.userName})
  110. and (epi.site + '-' + epi.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  111. and epi.ItemType = #{query.itemType}
  112. <if test="query.itemDesc != null and query.itemDesc != ''">
  113. AND epi.ItemDesc LIKE '%' + #{query.itemDesc} +'%'
  114. </if>
  115. <if test="query.itemNo != null and query.itemNo != ''">
  116. AND epi.ItemNo LIKE '%' + #{query.itemNo} +'%'
  117. </if>
  118. <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  119. AND epi.inspection_type_no = #{query.inspectionTypeNo}
  120. </if>
  121. </where>
  122. </select>
  123. <!-- 检测是否存在该项目 -->
  124. <select id="checkQcItem" parameterType="QcItemData" resultType="QcItemData">
  125. SELECT ItemNo,
  126. ItemDesc
  127. FROM eam_properties_item
  128. WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType}
  129. </select>
  130. <!-- 获得检验项目单号 -->
  131. <select id="getItemNo" resultType="string" parameterType="QcItemData">
  132. SELECT
  133. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(ItemNo,4))),0)+1),4)
  134. FROM eam_properties_item
  135. WHERE site = #{site} and ItemType = 'D' and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  136. </select>
  137. <!-- 新增检验项目 -->
  138. <insert id="qcItemSave" parameterType="QcItemData">
  139. 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)
  140. 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})
  141. </insert>
  142. <!-- 新增项目里的方法 -->
  143. <insert id="qcItemMethodSave" parameterType="QcItemData">
  144. INSERT INTO qc_method_item (ItemNo, method_no, site, bu_no)
  145. VALUES (#{itemNo}, #{methodNo}, #{site}, #{buNo})
  146. </insert>
  147. <!-- 修改检验项目 -->
  148. <update id="qcItemUpdate" parameterType="QcItemData">
  149. UPDATE eam_properties_item
  150. SET ItemDesc = #{itemDesc},
  151. DefaultValue = #{defaultValue},
  152. ValueType = #{valueType},
  153. ValueType_DB = #{valueTypeDb},
  154. ValueChooseFlag = #{valueChooseFlag},
  155. MaxValue = #{maxValue,jdbcType=DECIMAL},
  156. MinValue = #{minValue,jdbcType=DECIMAL},
  157. ItemRemark = #{itemRemark},
  158. update_date = getDate(),
  159. update_by = #{updateBy},
  160. inspection_type_no = #{inspectionTypeNo},
  161. item_sampling_quantity = #{itemSamplingQuantity},
  162. sampling_programme_no = #{samplingProgrammeNo},
  163. sampling_level_no = #{samplingLevelNo},
  164. default_sampling_proportion = #{defaultSamplingProportion}
  165. WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType}
  166. </update>
  167. <!-- 修改项目中的方法 -->
  168. <update id="qcItemMethodUpdate" parameterType="QcItemData">
  169. UPDATE qc_method_item
  170. SET method_no = #{methodNo}
  171. WHERE site = #{site} and ItemNo = #{itemNo}
  172. </update>
  173. <!-- 检查项目是否在被模板使用 -->
  174. <select id="checkItemIsUsed" parameterType="QcItemData" resultType="EamPropertiesModelDetailData">
  175. SELECT template_id
  176. FROM qc_template_detailed
  177. WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
  178. </select>
  179. <!-- 删除检验项目 -->
  180. <delete id="qcItemDelete" parameterType="QcItemData">
  181. DELETE
  182. FROM eam_properties_item
  183. WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo}
  184. </delete>
  185. <!-- 删除项目-方法中间表数据 -->
  186. <delete id="qcItemMethodDelete" parameterType="QcItemData">
  187. DELETE
  188. FROM qc_method_item
  189. WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
  190. </delete>
  191. <!-- ================================================= 质检员信息维护 ================================================= -->
  192. <!-- 查询质检员信息列表 -->
  193. <select id="inspectorSearch" resultType="QcInspectorData">
  194. SELECT inspector_no,
  195. inspector_name,
  196. inspector_phone,
  197. inspector_type,
  198. inspector_active
  199. FROM qc_inspector
  200. </select>
  201. <!-- 检验是否已存在该质检员 -->
  202. <select id="checkInspector" resultType="QcInspectorData">
  203. SELECT inspector_name
  204. FROM qc_inspector
  205. WHERE inspector_no = #{inspectorNo}
  206. </select>
  207. <!-- 新增质检员 -->
  208. <insert id="inspectorSave" parameterType="QcInspectorData">
  209. INSERT INTO qc_inspector (inspector_no, inspector_name, inspector_phone, inspector_type, inspector_active, create_time)
  210. VALUES (#{inspectorNo}, #{inspectorName}, #{inspectorPhone}, #{inspectorType}, #{inspectorActive}, getDate())
  211. </insert>
  212. <!-- 修改质检员 -->
  213. <update id="inspectorUpdate" parameterType="QcInspectorData">
  214. UPDATE qc_inspector
  215. SET inspector_name = #{inspectorName},
  216. inspector_phone = #{inspectorPhone},
  217. inspector_type = #{inspectorType},
  218. inspector_active = #{inspectorActive}
  219. WHERE inspector_no = #{inspectorNo}
  220. </update>
  221. <!-- 删除质检员 -->
  222. <delete id="inspectorDelete" parameterType="QcInspectorData">
  223. DELETE FROM qc_inspector
  224. WHERE inspector_no = #{inspectorNo}
  225. </delete>
  226. <!-- ================================================= 抽样矩阵维护 ================================================= -->
  227. <!-- 查询抽样矩阵 -->
  228. <select id="samplingInspectionPlanSearch" parameterType="QcSamplingInspectionPlanData" resultType="QcSamplingInspectionPlanData">
  229. SELECT
  230. qsip.site,
  231. qsip.bu_no,
  232. dbo.get_bu_desc(qsip.site, qsip.bu_no) as buDesc,
  233. qsip.sampling_plan_no,
  234. qsip.sampling_plan_desc,
  235. qsip.sampling_qty_no,
  236. qsiq.sampling_qty,
  237. qsiq.sampling_qty_desc,
  238. qsip.sampling_qty_rank_no,
  239. qsiqr.sampling_qty_rank_desc,
  240. qsiqr.min_qty,
  241. qsiqr.max_qty,
  242. qsip.sampling_level_no,
  243. qsil.sampling_level_desc,
  244. qsip.sampling_plan_active,
  245. qsip.create_date,
  246. qsip.create_by,
  247. qsip.update_date,
  248. qsip.update_by
  249. FROM qc_sampling_inspection_plan as qsip
  250. 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
  251. 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
  252. 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
  253. <where>
  254. qsip.site in (select site from eam_access_site where username = #{query.userName})
  255. and (qsip.site + '-' + qsip.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  256. <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''">
  257. AND qsiq.sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc}+'%'
  258. </if>
  259. <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''">
  260. AND qsil.sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%'
  261. </if>
  262. <if test="query.samplingPlanActive != null and query.samplingPlanActive != ''">
  263. AND qsip.sampling_plan_active = #{query.samplingPlanActive}
  264. </if>
  265. </where>
  266. </select>
  267. <!-- 根据三个编码查矩阵 -->
  268. <select id="selectSamplingPlanByNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionPlanData">
  269. SELECT
  270. site,
  271. bu_no,
  272. sampling_plan_no,
  273. sampling_qty_no,
  274. sampling_qty_rank_no,
  275. sampling_level_no,
  276. sampling_plan_active
  277. FROM qc_sampling_inspection_plan
  278. WHERE sampling_qty_no = #{samplingQtyNo} AND sampling_qty_rank_no = #{samplingQtyRankNo} AND sampling_level_no = #{samplingLevelNo} AND site = #{site} and bu_no = #{buNo}
  279. </select>
  280. <!-- 根据名称查矩阵 -->
  281. <select id="selectSamplingPlanByDesc" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionPlanData">
  282. SELECT
  283. site,
  284. bu_no,
  285. sampling_plan_no,
  286. sampling_qty_no,
  287. sampling_qty_rank_no,
  288. sampling_level_no,
  289. sampling_plan_active
  290. FROM qc_sampling_inspection_plan
  291. WHERE sampling_plan_desc = #{samplingPlanDesc} AND site = #{site} and bu_no = #{buNo}
  292. </select>
  293. <!-- 获取最大方矩阵编码 -->
  294. <select id="queryLastSamplingPlanNo" resultType="string" parameterType="QcSamplingInspectionPlanData">
  295. SELECT top 1 sampling_plan_no
  296. FROM qc_sampling_inspection_plan
  297. where site = #{site} and bu_no = #{buNo}
  298. ORDER BY sampling_plan_no Desc
  299. </select>
  300. <!-- 新增抽样矩阵 -->
  301. <insert id="samplingInspectionPlanSave" parameterType="QcSamplingInspectionPlanData">
  302. 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)
  303. VALUES (#{site}, #{buNo}, #{samplingPlanNo}, #{samplingPlanDesc}, #{samplingQtyRankNo}, #{samplingLevelNo}, #{samplingQtyNo}, #{samplingPlanActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  304. </insert>
  305. <!-- 修改抽样矩阵 -->
  306. <update id="samplingInspectionPlanUpdate" parameterType="QcSamplingInspectionPlanData">
  307. UPDATE qc_sampling_inspection_plan
  308. SET sampling_qty_rank_no = #{samplingQtyRankNo},
  309. sampling_level_no = #{samplingLevelNo},
  310. sampling_qty_no = #{samplingQtyNo},
  311. sampling_plan_active = #{samplingPlanActive},
  312. update_date = getDate(),
  313. update_by = #{updateBy}
  314. WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo}
  315. </update>
  316. <!-- 删除抽样矩阵 -->
  317. <delete id="samplingInspectionPlanDelete" parameterType="QcSamplingInspectionPlanData">
  318. DELETE FROM qc_sampling_inspection_plan
  319. WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo}
  320. </delete>
  321. <!-- ================================================= 检验模板维护 ================================================= -->
  322. <!-- 查询模板 -->
  323. <select id="templateSearch" parameterType="QcTemplateData" resultType="QcTemplateData">
  324. SELECT
  325. qt.site,
  326. qt.bu_no,
  327. dbo.get_bu_desc(qt.site, qt.bu_no) as buDesc,
  328. qt.template_id,
  329. qt.template_name,
  330. qt.template_remark,
  331. qt.template_type,
  332. qt.template_version,
  333. qt.sampling_programme_no,
  334. qsip.sampling_programme_Desc,
  335. qt.inspection_type_no,
  336. qit.inspection_type_name,
  337. qt.sampling_level_no,
  338. qsil.sampling_level_desc,
  339. qt.inspection_cycle,
  340. qt.create_time,
  341. qt.create_by,
  342. qt.update_date,
  343. qt.update_by,
  344. qt.AQL,
  345. qt.AC,
  346. qt.RE,
  347. qt.default_sampling_quantity,
  348. qt.default_sampling_proportion
  349. FROM qc_template as qt
  350. LEFT JOIN qc_inspection_type as qit on qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  351. 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
  352. 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
  353. <where>
  354. qt.site in (select site from eam_access_site where username = #{query.userName})
  355. and (qt.site + '-' + qt.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  356. <if test = "query.templateId != null and query.templateId != ''">
  357. AND qt.template_id LIKE '%' + #{query.templateId}+'%'
  358. </if>
  359. <if test = "query.templateName != null and query.templateName != ''">
  360. AND qt.template_name LIKE '%' + #{query.templateName}+'%'
  361. </if>
  362. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  363. AND qt.inspection_type_no = #{query.inspectionTypeNo}
  364. </if>
  365. </where>
  366. </select>
  367. <!-- 获得检验模板单号 -->
  368. <select id="getTemplateNo" resultType="string" parameterType="QcTemplateData">
  369. SELECT
  370. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(template_id,3))),0)+1),3)
  371. FROM qc_template
  372. WHERE site = #{site} and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  373. </select>
  374. <!-- 新增模板 -->
  375. <insert id="templateSave" parameterType="QcTemplateData">
  376. 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)
  377. VALUES (#{site}, #{buNo}, #{templateId}, #{templateName},#{templateVersion}, #{templateRemark}, #{templateType}, #{samplingProgrammeNo}, #{inspectionTypeNo}, getDate(), #{createBy}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{aql}, #{ac}, #{re}, #{defaultSamplingQuantity}, #{defaultSamplingProportion}, getDate(), #{updateBy})
  378. </insert>
  379. <!-- 修改模板 -->
  380. <update id="templateUpdate" parameterType="QcTemplateData">
  381. UPDATE qc_template
  382. SET template_name = #{templateName},
  383. template_version = #{templateVersion},
  384. template_remark = #{templateRemark},
  385. template_type = #{templateType},
  386. sampling_programme_no = #{samplingProgrammeNo},
  387. inspection_cycle = #{inspectionCycle},
  388. inspection_type_no = #{inspectionTypeNo},
  389. sampling_level_no = #{samplingLevelNo},
  390. AQL = #{aql},
  391. AC = #{ac},
  392. RE = #{re},
  393. default_sampling_quantity = #{defaultSamplingQuantity},
  394. default_sampling_proportion = #{defaultSamplingProportion},
  395. update_date = getDate(),
  396. update_by = #{updateBy}
  397. WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
  398. </update>
  399. <!-- 查询模板里的项目详情 -->
  400. <select id="templateDetailsSearch" resultType="QcTemplateData">
  401. SELECT
  402. a.site,
  403. a.bu_no,
  404. a.template_id,
  405. a.ItemNo,
  406. b.ItemDesc,
  407. a.default_value,
  408. b.ValueType,
  409. b.ValueType_DB,
  410. a.max_value,
  411. a.min_value,
  412. b.ItemRemark,
  413. b.ItemType,
  414. a.object_id,
  415. eo.objectDesc,
  416. b.item_sampling_quantity,
  417. b.sampling_programme_no,
  418. c.sampling_programme_desc,
  419. b.sampling_level_no,
  420. d.sampling_level_desc,
  421. b.default_sampling_proportion
  422. FROM qc_template_detailed a
  423. LEFT JOIN eam_properties_item b ON a.ItemNo = b.ItemNo and a.site = b.site and a.bu_no = b.bu_no
  424. 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
  425. 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
  426. LEFT JOIN eam_object eo ON a.object_id = eo.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  427. WHERE a.template_id = #{templateId} AND b.ItemType = #{itemType} and a.site = #{site} and a.bu_no = #{buNo}
  428. </select>
  429. <!-- 查询模板里是否已存在该项目 -->
  430. <select id="selectItemDetails" resultType="QcTemplateData">
  431. SELECT template_id,
  432. ItemNo,
  433. default_value,
  434. max_value,
  435. min_value
  436. FROM qc_template_detailed
  437. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  438. </select>
  439. <!-- 查询项目的最大最小值 -->
  440. <select id="selectDetail" resultType="QcTemplateData">
  441. SELECT ItemNo,
  442. DefaultValue,
  443. MaxValue,
  444. MinValue
  445. FROM eam_properties_item
  446. WHERE ItemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  447. </select>
  448. <!-- 新增模板的检验项目 -->
  449. <insert id="addItemDetails" parameterType="QcTemplateData">
  450. INSERT INTO qc_template_detailed (template_id, ItemNo, default_value, max_value, min_value, site, bu_no)
  451. VALUES (#{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{site}, #{buNo})
  452. </insert>
  453. <!-- 删除模板的检验项目 -->
  454. <delete id="delItemDetails" >
  455. DELETE FROM qc_template_detailed
  456. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  457. </delete>
  458. <!-- 获取当前模板不包含的项目 -->
  459. <select id="getItemList" resultType="QcTemplateData">
  460. SELECT
  461. a.site,
  462. a.bu_no,
  463. a.itemNo,
  464. a.ItemDesc,
  465. a.DefaultValue,
  466. a.MaxValue,
  467. a.MinValue
  468. FROM eam_properties_item a
  469. 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
  470. WHERE a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo}
  471. </select>
  472. <!-- 查询项目 -->
  473. <select id="getItem" resultType="QcTemplateData">
  474. SELECT
  475. a.site,
  476. a.bu_no,
  477. a.itemNo,
  478. a.ItemDesc,
  479. a.DefaultValue,
  480. a.MaxValue,
  481. a.MinValue
  482. FROM eam_properties_item a
  483. 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
  484. <where>
  485. a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo}
  486. <if test = "itemNo != null and itemNo != ''">
  487. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  488. </if>
  489. <if test = "itemDesc != null and itemDesc != ''">
  490. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  491. </if>
  492. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  493. AND a.inspection_type_no = #{inspectionTypeNo}
  494. </if>
  495. </where>
  496. </select>
  497. <!-- 删除模板 -->
  498. <delete id="templateDelete" parameterType="QcTemplateData">
  499. DELETE FROM qc_template
  500. WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
  501. </delete>
  502. <!-- 删除模板-项目中间表 -->
  503. <delete id="itemItemDelete" parameterType="QcTemplateData">
  504. DELETE FROM qc_template_detailed
  505. WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
  506. </delete>
  507. <!-- 搜索所有检验类型 -->
  508. <select id="inspectionTypeSearch" resultType="QcInspectionTypeData" parameterType="QcInspectionTypeData">
  509. SELECT inspection_type_no,
  510. inspection_type_name
  511. FROM qc_inspection_type
  512. WHERE site = #{site}
  513. </select>
  514. <!-- 搜索所有设备 -->
  515. <select id="objectSearch" resultType="EamObjectData">
  516. SELECT ObjectID,
  517. ObjectDesc
  518. FROM eam_object
  519. WHERE Active = 'Y' and site = #{site} and bu_no = #{buNo}
  520. </select>
  521. <!-- 导入文件检验 -->
  522. <select id="getItemByItemNo" resultType="EamPropertiesItemData" parameterType="QcItemData">
  523. SELECT ItemDesc,
  524. ItemType
  525. FROM eam_properties_item
  526. WHERE ItemDesc = #{itemDesc}
  527. AND DefaultValue = #{defaultValue}
  528. AND MaxValue = #{maxValue}
  529. AND MinValue = #{minValue}
  530. AND ItemType = #{itemType}
  531. </select>
  532. <!-- 新增检验项目 -->
  533. <insert id="insertItem" parameterType="EamPropertiesItemData">
  534. INSERT INTO eam_properties_item (ItemNo, ItemDesc,DefaultValue,ValueType,ValueType_DB, CreatedDate,CreatedBy,MaxValue, MinValue, ItemRemark,ItemType)
  535. VALUES(#{itemNo},#{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, GetDate(), #{createdBy}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{itemRemark}, #{itemType})
  536. </insert>
  537. <!-- &lt;!&ndash; 获取最大项目编码 &ndash;&gt;-->
  538. <!-- <select id="queryLastItemNo" resultType="string" parameterType="QcItemData">-->
  539. <!-- SELECT top 1 ItemNo-->
  540. <!-- FROM eam_properties_item-->
  541. <!-- WHERE ItemType = #{itemType}-->
  542. <!-- ORDER BY ItemNo Desc-->
  543. <!-- </select>-->
  544. <!-- 根据模板名称查询模板 -->
  545. <select id="selectTemplateByDesc" parameterType="QcTemplateData" resultType="QcTemplateData">
  546. SELECT template_id,
  547. template_name,
  548. template_version
  549. FROM qc_template
  550. WHERE template_name = #{templateName}
  551. AND site = #{site}
  552. AND template_version = #{templateVersion}
  553. </select>
  554. <!-- 修改项目明细的最大最小值 -->
  555. <update id="saveItemDetailed" parameterType="QcTemplateData">
  556. UPDATE qc_template_detailed
  557. SET default_value = #{defaultValue},
  558. max_value = #{maxValue,jdbcType=DECIMAL},
  559. min_value = #{minValue,jdbcType=DECIMAL},
  560. object_id = #{objectID}
  561. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  562. </update>
  563. <!-- 查询项目明细 -->
  564. <select id="selectItem" resultType="QcTemplateData">
  565. SELECT ItemNo,
  566. ItemDesc,
  567. DefaultValue,
  568. ValueType,
  569. ValueType_DB,
  570. MaxValue,
  571. MinValue,
  572. ItemRemark,
  573. ItemType
  574. FROM eam_properties_item
  575. WHERE ItemNo = #{itemNo}
  576. AND ItemType = #{itemType}
  577. </select>
  578. <!-- ================================================= 样本量维护 ================================================= -->
  579. <!-- 查询样本量 -->
  580. <select id="samplingQtySearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  581. SELECT
  582. site,
  583. bu_no,
  584. dbo.get_bu_desc(site, bu_no) as buDesc,
  585. sampling_qty_no,
  586. sampling_qty_desc,
  587. sampling_qty,
  588. sampling_qty_remark,
  589. sampling_qty_active,
  590. create_date,
  591. create_by,
  592. update_date,
  593. update_by
  594. FROM qc_sampling_inspection_qty
  595. <where>
  596. site in (select site from eam_access_site where username = #{query.userName})
  597. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  598. <if test="query.samplingQtyNo != null and query.samplingQtyNo != ''">
  599. AND sampling_qty_no LIKE '%' + #{query.samplingQtyNo} + '%'
  600. </if>
  601. <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''">
  602. AND sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc} + '%'
  603. </if>
  604. <if test="query.samplingQty != null">
  605. AND sampling_qty = #{query.samplingQty,jdbcType=DECIMAL}
  606. </if>
  607. <if test="query.samplingQtyActive != null and query.samplingQtyActive != ''">
  608. AND sampling_qty_active = #{query.samplingQtyActive}
  609. </if>
  610. </where>
  611. </select>
  612. <!-- 新增样本量 -->
  613. <insert id="samplingQtySave" parameterType="QcSamplingInspectionQtyData">
  614. 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)
  615. VALUES(#{site}, #{buNo}, #{samplingQtyNo}, #{samplingQty,jdbcType=DECIMAL}, #{samplingQtyRemark}, #{samplingQtyActive}, #{samplingQtyDesc}, getDate(), #{createBy}, getDate(), #{updateBy})
  616. </insert>
  617. <!-- 根据样本量字码查询样本量 -->
  618. <select id="selectSamplingQtyByDesc" parameterType="QcSamplingInspectionQtyData" resultType="QcSamplingInspectionQtyData">
  619. SELECT
  620. site,
  621. bu_no,
  622. sampling_qty_no,
  623. sampling_qty_desc,
  624. sampling_qty,
  625. sampling_qty_remark,
  626. sampling_qty_active
  627. FROM qc_sampling_inspection_qty
  628. WHERE sampling_qty_desc = #{samplingQtyDesc} AND site = #{site} and bu_no = #{buNo}
  629. </select>
  630. <!-- 获取最大样本量编码 -->
  631. <select id="queryLastSamplingQtyNo" resultType="string" parameterType="QcSamplingInspectionQtyData">
  632. SELECT top 1 sampling_qty_no
  633. FROM qc_sampling_inspection_qty
  634. where site = #{site} and bu_no = #{buNo}
  635. ORDER BY sampling_qty_no Desc
  636. </select>
  637. <!-- 修改样本量 -->
  638. <update id="samplingQtyUpdate" parameterType="QcSamplingInspectionQtyData">
  639. UPDATE qc_sampling_inspection_qty
  640. SET sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  641. sampling_qty_desc = #{samplingQtyDesc},
  642. sampling_qty_remark = #{samplingQtyRemark},
  643. sampling_qty_active = #{samplingQtyActive},
  644. update_date = getDate(),
  645. update_by = #{updateBy}
  646. WHERE sampling_qty_no = #{samplingQtyNo} AND site = #{site} and bu_no = #{buNo}
  647. </update>
  648. <!-- 根据样本量编码查询矩阵 -->
  649. <select id="selectSamplingPlanBySamplingQtyNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionQtyData">
  650. SELECT
  651. site,
  652. sampling_plan_no,
  653. sampling_qty_no,
  654. sampling_qty_rank_no,
  655. sampling_level_no,
  656. sampling_plan_active
  657. FROM qc_sampling_inspection_plan
  658. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} and bu_no = #{buNo}
  659. </select>
  660. <!-- 删除样本量 -->
  661. <delete id="samplingQtyDelete" parameterType="QcSamplingInspectionQtyData">
  662. DELETE FROM qc_sampling_inspection_qty
  663. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} AND sampling_qty_desc = #{samplingQtyDesc} and bu_no = #{buNo}
  664. </delete>
  665. <!-- ================================================= 批量级次维护 ================================================= -->
  666. <!-- 查询批量级次 -->
  667. <select id="samplingQtyRankSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  668. SELECT
  669. site,
  670. bu_no,
  671. dbo.get_bu_desc(site, bu_no) as buDesc,
  672. sampling_qty_rank_no,
  673. sampling_qty_rank_desc,
  674. min_qty,
  675. max_qty,
  676. sampling_qty_rank_active,
  677. sampling_qty_rank_Remark,
  678. create_date,
  679. create_by,
  680. update_date,
  681. update_by
  682. FROM qc_sampling_inspection_qty_rank
  683. <where>
  684. site in (select site from eam_access_site where username = #{query.userName})
  685. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  686. <if test="query.samplingQtyRankNo != null and query.samplingQtyRankNo != ''">
  687. AND sampling_qty_rank_no LIKE '%' + #{query.samplingQtyRankNo}+'%'
  688. </if>
  689. <if test="query.samplingQtyRankDesc != null and query.samplingQtyRankDesc != ''">
  690. AND sampling_qty_rank_desc LIKE '%' + #{query.samplingQtyRankDesc}+'%'
  691. </if>
  692. <if test="query.samplingQtyRankActive != null and query.samplingQtyRankActive != ''">
  693. AND sampling_qty_rank_active = #{query.samplingQtyRankActive}
  694. </if>
  695. </where>
  696. </select>
  697. <!-- 根据名称查询批量级次 -->
  698. <select id="selectSamplingQtyRankByDesc" parameterType="QcSamplingInspectionQtyRankData" resultType="QcSamplingInspectionQtyRankData">
  699. SELECT
  700. site,
  701. bu_no,
  702. sampling_qty_rank_no,
  703. sampling_qty_rank_desc,
  704. min_qty,
  705. max_qty,
  706. sampling_qty_rank_active,
  707. sampling_qty_rank_Remark
  708. FROM qc_sampling_inspection_qty_rank
  709. WHERE sampling_qty_rank_desc = #{samplingQtyRankDesc} AND site = #{site} and bu_no = #{buNo}
  710. </select>
  711. <!-- 获取最大批量级次编码 -->
  712. <select id="queryLastSamplingQtyRankNo" resultType="string" parameterType="QcSamplingInspectionQtyRankData">
  713. SELECT top 1 sampling_qty_rank_no
  714. FROM qc_sampling_inspection_qty_rank
  715. where site = #{site} and bu_no = #{buNo}
  716. ORDER BY sampling_qty_rank_no Desc
  717. </select>
  718. <!-- 新增批量级次 -->
  719. <insert id="samplingQtyRankSave" parameterType="QcSamplingInspectionQtyRankData">
  720. 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)
  721. VALUES(#{site}, #{buNo}, #{samplingQtyRankNo}, #{samplingQtyRankDesc}, #{minQty,jdbcType=DECIMAL}, #{maxQty,jdbcType=DECIMAL}, #{samplingQtyRankRemark}, #{samplingQtyRankActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  722. </insert>
  723. <!-- 根据批量级次编码查询矩阵 -->
  724. <select id="selectSamplingPlanBySamplingQtyRankNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionQtyRankData">
  725. SELECT
  726. site,
  727. bu_no,
  728. sampling_plan_no,
  729. sampling_qty_no,
  730. sampling_qty_rank_no,
  731. sampling_level_no,
  732. sampling_plan_active
  733. FROM qc_sampling_inspection_plan
  734. WHERE site = #{site} AND sampling_qty_rank_no = #{samplingQtyRankNo} and bu_no = #{buNo}
  735. </select>
  736. <!-- 修改批量级次 -->
  737. <update id="samplingQtyRankUpdate" parameterType="QcSamplingInspectionQtyRankData">
  738. UPDATE qc_sampling_inspection_qty_rank
  739. SET sampling_qty_rank_desc = #{samplingQtyRankDesc},
  740. min_qty = #{minQty,jdbcType=DECIMAL},
  741. max_qty = #{maxQty,jdbcType=DECIMAL},
  742. sampling_qty_rank_Remark = #{samplingQtyRankRemark},
  743. sampling_qty_rank_active = #{samplingQtyRankActive},
  744. update_date = getDate(),
  745. update_by = #{updateBy}
  746. WHERE sampling_qty_rank_no = #{samplingQtyRankNo} AND site = #{site} and bu_no = #{buNo}
  747. </update>
  748. <!-- 删除批量级次 -->
  749. <delete id="samplingQtyRankDelete" parameterType="QcSamplingInspectionQtyRankData">
  750. DELETE FROM qc_sampling_inspection_qty_rank
  751. WHERE site = #{site} and bu_no = #{buNo}
  752. AND sampling_qty_rank_no = #{samplingQtyRankNo}
  753. AND sampling_qty_rank_desc = #{samplingQtyRankDesc}
  754. </delete>
  755. <!-- ================================================= 检验等级维护 ================================================= -->
  756. <!-- 查询检验等级 -->
  757. <select id="samplingLevelSearch" parameterType="QcSamplingInspectionLevelData" resultType="QcSamplingInspectionLevelData">
  758. SELECT
  759. site,
  760. bu_no,
  761. dbo.get_bu_desc(site, bu_no) as buDesc,
  762. sampling_level_no,
  763. sampling_level_desc,
  764. sampling_level_remark,
  765. sampling_level_active,
  766. create_date,
  767. create_by,
  768. update_date,
  769. update_by
  770. FROM qc_sampling_inspection_level
  771. <where>
  772. site in (select site from eam_access_site where username = #{query.userName})
  773. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  774. <if test="query.samplingLevelNo != null and query.samplingLevelNo != ''">
  775. AND sampling_level_no LIKE '%' + #{query.samplingLevelNo}+'%'
  776. </if>
  777. <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''">
  778. AND sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%'
  779. </if>
  780. <if test="query.samplingLevelActive != null and query.samplingLevelActive != ''">
  781. AND sampling_level_active = #{query.samplingLevelActive}
  782. </if>
  783. </where>
  784. </select>
  785. <!-- 根据名称查询检验等级 -->
  786. <select id="selectSamplingLevelByDesc" parameterType="QcSamplingInspectionLevelData" resultType="QcSamplingInspectionLevelData">
  787. SELECT
  788. site,
  789. bu_no,
  790. sampling_level_no,
  791. sampling_level_desc,
  792. sampling_level_remark,
  793. sampling_level_active
  794. FROM qc_sampling_inspection_level
  795. WHERE sampling_level_desc = #{samplingLevelDesc} AND site = #{site} and bu_no = #{buNo}
  796. </select>
  797. <!-- 获取最大检验等级编码 -->
  798. <select id="queryLastSamplingLevelNo" resultType="string" parameterType="QcSamplingInspectionLevelData">
  799. SELECT top 1 sampling_level_no
  800. FROM qc_sampling_inspection_level
  801. where site = #{site} and bu_no = #{buNo}
  802. ORDER BY sampling_level_no Desc
  803. </select>
  804. <!-- 新增检验等级 -->
  805. <insert id="samplingLevelSave" parameterType="QcSamplingInspectionLevelData">
  806. 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)
  807. VALUES (#{site}, #{buNo}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingLevelRemark}, #{samplingLevelActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  808. </insert>
  809. <!-- 根据检验等级编码查询矩阵 -->
  810. <select id="selectSamplingPlanBySamplingLevelNo" resultType="QcSamplingInspectionPlanData" parameterType="QcSamplingInspectionLevelData">
  811. SELECT
  812. site,
  813. bu_no,
  814. sampling_plan_no,
  815. sampling_qty_no,
  816. sampling_qty_rank_no,
  817. sampling_level_no,
  818. sampling_plan_active
  819. FROM qc_sampling_inspection_plan
  820. WHERE site = #{site} and bu_no = #{buNo}
  821. AND sampling_level_no = #{samplingLevelNo}
  822. </select>
  823. <!-- 修改检验等级 -->
  824. <update id="samplingLevelUpdate" parameterType="QcSamplingInspectionLevelData">
  825. UPDATE qc_sampling_inspection_level
  826. SET sampling_level_desc = #{samplingLevelDesc},
  827. sampling_level_remark = #{samplingLevelRemark},
  828. sampling_level_active = #{samplingLevelActive},
  829. update_date = getDate(),
  830. update_by = #{updateBy}
  831. WHERE sampling_level_no = #{samplingLevelNo}
  832. AND site = #{site} and bu_no = #{buNo}
  833. </update>
  834. <!-- 删除检验等级 -->
  835. <delete id="samplingLevelDelete" parameterType="QcSamplingInspectionLevelData">
  836. DELETE FROM qc_sampling_inspection_level
  837. WHERE site = #{site} and bu_no = #{buNo}
  838. AND sampling_level_no = #{samplingLevelNo}
  839. AND sampling_level_desc = #{samplingLevelDesc}
  840. </delete>
  841. <!-- ================================================= 物料属性设置维护 ================================================= -->
  842. <!-- 查询物料属性 -->
  843. <select id="qcPartAttributeSearch" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  844. SELECT
  845. qa.site,
  846. qa.bu_no,
  847. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  848. p.part_no as partNo,
  849. p.part_desc,
  850. dbo.qc_get_cinv_source_code(p.part_no) as cinvSourceCode,
  851. dbo.qc_get_sku(part_no) as sku,
  852. p.FamilyID,
  853. p.spec as FamilyName,
  854. p.umid,
  855. qa.supplier_no,
  856. dbo.qc_get_supplier_name(qa.site, qa.supplier_no) as supplierDesc,
  857. qa.attribute_remark,
  858. qa.create_time,
  859. qa.create_by,
  860. qa.attribute_type,
  861. qa.update_date,
  862. qa.update_by,
  863. qa.exempt_inspection
  864. FROM qc_part_attribute qa
  865. LEFT JOIN part p on qa.attribute_no = p.part_no and qa.site = p.site
  866. <where>
  867. qa.site in (select site from eam_access_site where username = #{query.userName})
  868. and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  869. and qa.attribute_type = #{query.attributeType}
  870. <if test = "query.partNo != null and query.partNo != ''">
  871. AND qa.attribute_no LIKE '%' + #{query.partNo}+'%'
  872. </if>
  873. <if test = "query.partDesc != null and query.partDesc != ''">
  874. AND p.part_desc LIKE '%' + #{query.partDesc}+'%'
  875. </if>
  876. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  877. AND dbo.qc_get_cinv_source_code(p.part_no) LIKE '%' + #{query.cinvSourceCode}+'%'
  878. </if>
  879. <if test = "query.sku != null and query.sku != ''">
  880. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku}+'%'
  881. </if>
  882. <if test = "query.familyName != null and query.familyName != ''">
  883. AND p.spec LIKE '%' + #{query.familyName}+'%'
  884. </if>
  885. </where>
  886. </select>
  887. <!-- 查询是否已有该物料属性 -->
  888. <select id="selectPartAttributeByNo" resultType="QcPartAttributeData" parameterType="QcPartAttributeData">
  889. SELECT
  890. attribute_no,
  891. supplier_no,
  892. attribute_remark,
  893. attribute_type
  894. FROM qc_part_attribute
  895. WHERE site = #{site} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  896. </select>
  897. <!-- 新增物料属性 -->
  898. <insert id="qcPartAttributeSave" parameterType="QcPartAttributeData">
  899. INSERT INTO qc_part_attribute (attribute_no, supplier_no, attribute_remark, create_time, create_by, attribute_type, site, exempt_inspection, bu_no)
  900. VALUES(#{partNo}, #{supplierNo}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{exemptInspection}, #{buNo})
  901. </insert>
  902. <!-- 物料属性修改 -->
  903. <update id="qcPartAttributeEdit" parameterType="QcPartAttributeData">
  904. UPDATE qc_part_attribute
  905. SET attribute_remark = #{attributeRemark},
  906. exempt_inspection = #{exemptInspection},
  907. update_date = getDate(),
  908. update_by = #{updateBy}
  909. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  910. </update>
  911. <!-- 删除物料属性 -->
  912. <delete id="qcPartAttributeDelete" parameterType="QcPartAttributeData">
  913. DELETE FROM qc_part_attribute
  914. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType}
  915. </delete>
  916. <!-- 删除物料属性模板 -->
  917. <delete id="deletePartAttributeTemplate" parameterType="QcPartAttributeData">
  918. DELETE FROM qc_attribute_template
  919. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType}
  920. </delete>
  921. <!-- 查询类别模板 -->
  922. <select id="searchPartAttributeDetails" resultType="QcTemplateData" parameterType="QcTemplateData">
  923. SELECT
  924. qat.site,
  925. qat.bu_no,
  926. qpa.attribute_no,
  927. qpa.attribute_type,
  928. qt.template_id,
  929. qt.template_name,
  930. qt.template_remark,
  931. qt.template_version,
  932. qat.sampling_programme_no,
  933. qsip.sampling_programme_desc,
  934. qat.AQL,
  935. qat.AC,
  936. qat.RE,
  937. qt.inspection_type_no,
  938. qit.inspection_type_name,
  939. qt.default_sampling_quantity,
  940. qt.default_sampling_proportion,
  941. qat.sampling_level_no,
  942. qsil.sampling_level_desc,
  943. qat.inspection_cycle,
  944. qat.operation,
  945. qat.manufacturer_id,
  946. dbo.qc_get_supplier_name(qat.site, qat.manufacturer_id) as manufacturerName,
  947. qat.resource_id
  948. FROM qc_attribute_template as qat
  949. 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
  950. 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
  951. 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
  952. LEFT JOIN qc_inspection_type as qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  953. 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
  954. WHERE qat.site = #{site} and qpa.attribute_type = #{attributeType} and qpa.attribute_no = #{attributeNo} and qat.bu_no = #{buNo}
  955. </select>
  956. <!-- 物料属性模板查重 -->
  957. <select id="searchPartRepeat" resultType="QcTemplateData" parameterType="QcTemplateData">
  958. SELECT
  959. attribute_no,
  960. template_id
  961. FROM qc_attribute_template
  962. WHERE attribute_no = #{attributeNo}
  963. AND template_id = #{templateId}
  964. AND attribute_type = #{attributeType}
  965. AND special_field = #{specialField}
  966. </select>
  967. <!-- 新增物料属性模板 -->
  968. <insert id="savePartAttributeDetails" parameterType="QcTemplateData">
  969. 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)
  970. VALUES (#{attributeNo}, #{templateId}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{samplingProgrammeNo}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{attributeType}, #{operation}, #{manufacturerID}, #{resourceID}, #{site}, #{buNo})
  971. </insert>
  972. <!-- 可选模板 -->
  973. <select id="getTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData">
  974. SELECT
  975. qt.template_id,
  976. qt.template_name,
  977. qit.inspection_type_name
  978. FROM qc_template as qt
  979. LEFT JOIN qc_attribute_template as qat ON qat.template_id = qt.template_id and qat.attribute_no = #{attributeNo}
  980. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no
  981. <where>
  982. qt.site = #{site}
  983. AND qat.attribute_no is null
  984. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  985. AND qt.inspection_type_no = #{inspectionTypeNo}
  986. </if>
  987. <if test = "templateId != null and templateId != ''">
  988. AND qt.template_id LIKE '%' + #{templateId}+'%'
  989. </if>
  990. <if test = "templateName != null and templateName != ''">
  991. AND qt.template_name LIKE '%' + #{templateName}+'%'
  992. </if>
  993. </where>
  994. </select>
  995. <!-- 已有模板 -->
  996. <select id="getPartTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData">
  997. SELECT
  998. qt.template_id,
  999. qt.template_name,
  1000. qit.inspection_type_name,
  1001. qat.operation,
  1002. qat.manufacturer_id,
  1003. dbo.qc_get_supplier_name(qt.site, qat.manufacturer_id) as manufacturerName,
  1004. qat.resource_id
  1005. FROM qc_attribute_template as qat
  1006. 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
  1007. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1008. WHERE qt.site = #{site} AND qat.attribute_no = #{attributeNo} and qt.bu_no = #{buNo}
  1009. </select>
  1010. <!-- 物料可选模板 -->
  1011. <select id="getTemplateListAll" resultType="QcTemplateData" parameterType="QcTemplateData">
  1012. SELECT
  1013. qt.template_id,
  1014. qt.template_name,
  1015. qit.inspection_type_name
  1016. FROM qc_template as qt
  1017. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1018. <where>
  1019. qt.site = #{site} and qt.bu_no = #{buNo}
  1020. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  1021. AND qt.inspection_type_no = #{inspectionTypeNo}
  1022. </if>
  1023. <if test = "templateId != null and templateId != ''">
  1024. AND qt.template_id LIKE '%' + #{templateId}+'%'
  1025. </if>
  1026. <if test = "templateName != null and templateName != ''">
  1027. AND qt.template_name LIKE '%' + #{templateName}+'%'
  1028. </if>
  1029. </where>
  1030. </select>
  1031. <!-- 删除物料属性模板 -->
  1032. <delete id="deletePartAttributeDetails" parameterType="QcTemplateData">
  1033. DELETE FROM qc_attribute_template
  1034. <where>
  1035. site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId} and attribute_type = #{attributeType}
  1036. <if test = "operation != null and operation != ''">
  1037. and operation = #{operation}
  1038. </if>
  1039. <if test = "resourceID != null and resourceID != ''">
  1040. and resource_id = #{resourceID}
  1041. </if>
  1042. <if test = "manufacturerID != null and manufacturerID != ''">
  1043. and manufacturer_id = #{manufacturerID}
  1044. </if>
  1045. </where>
  1046. </delete>
  1047. <!-- 查询模板的基础数据 -->
  1048. <select id="selectTemplateData" resultType="QcTemplateData" parameterType="QcTemplateData">
  1049. SELECT
  1050. template_id,
  1051. template_name,
  1052. sampling_programme_no,
  1053. sampling_level_no,
  1054. inspection_cycle,
  1055. AQL,
  1056. AC,
  1057. RE
  1058. FROM qc_template
  1059. WHERE site = #{site} AND template_id = #{templateId} and bu_no = #{buNo}
  1060. </select>
  1061. <!-- 新增物料属性模板详情 -->
  1062. <update id="saveAttributeDetailed" parameterType="QcTemplateData">
  1063. UPDATE qc_attribute_template
  1064. SET sampling_level_no = #{samplingLevelNo},
  1065. inspection_cycle = #{inspectionCycle,jdbcType=DECIMAL},
  1066. sampling_programme_no = #{samplingProgrammeNo},
  1067. AQL = #{aql,jdbcType=DECIMAL},
  1068. AC = #{ac,jdbcType=DECIMAL},
  1069. RE = #{re,jdbcType=DECIMAL}
  1070. <where>
  1071. site = #{site} and attribute_no = #{attributeNo} AND template_id = #{templateId} AND attribute_type = #{attributeType} and bu_no = #{buNo}
  1072. <if test = "operation != null and operation != ''">
  1073. AND operation = #{operation}
  1074. </if>
  1075. <if test = "resourceID != null and resourceID != ''">
  1076. AND resource_id = #{resourceID}
  1077. </if>
  1078. <if test = "manufacturerID != null and manufacturerID != ''">
  1079. AND manufacturer_id = #{manufacturerID}
  1080. </if>
  1081. </where>
  1082. </update>
  1083. <!-- 更新物料属性修改时间 -->
  1084. <update id="updatePartAttributeTime" parameterType="QcTemplateData">
  1085. UPDATE qc_part_attribute
  1086. SET update_date = getDate(),
  1087. update_by = #{updateBy}
  1088. WHERE site = #{site} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1089. </update>
  1090. <!-- ================================================= 类别属性设置维护 ================================================= -->
  1091. <!-- 查询类别属性 -->
  1092. <select id="qcFamilyAttributeSearch" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  1093. SELECT
  1094. qa.site,
  1095. qa.bu_no,
  1096. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  1097. qa.attribute_no as familyID,
  1098. pf.FamilyName,
  1099. qa.supplier_no,
  1100. qa.attribute_remark,
  1101. qa.create_time,
  1102. qa.create_by,
  1103. qa.update_date,
  1104. qa.update_by,
  1105. qa.attribute_type
  1106. FROM qc_part_attribute as qa
  1107. LEFT JOIN PartFamily as pf on qa.attribute_no = pf.FamilyID and qa.site = pf.site
  1108. <where>
  1109. qa.site in (select site from eam_access_site where username = #{query.userName})
  1110. and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1111. and qa.attribute_type = #{query.attributeType}
  1112. <if test = "query.familyID != null and query.familyID != ''">
  1113. AND qa.attribute_no LIKE '%' + #{query.familyID}+'%'
  1114. </if>
  1115. <if test = "query.familyName != null and query.familyName != ''">
  1116. AND pf.FamilyName LIKE '%' + #{query.familyName}+'%'
  1117. </if>
  1118. </where>
  1119. </select>
  1120. <!-- 新增类别属性 -->
  1121. <insert id="qcFamilyAttributeSave" parameterType="QcPartAttributeData">
  1122. INSERT INTO qc_part_attribute (attribute_no, attribute_remark, create_time, create_by, attribute_type, site, bu_no)
  1123. VALUES(#{familyID}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{buNo})
  1124. </insert>
  1125. <!-- 删除分类属性 -->
  1126. <delete id="qcFamilyAttributeDelete" parameterType="QcPartAttributeData">
  1127. DELETE FROM qc_part_attribute
  1128. WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1129. </delete>
  1130. <!-- 删除分类属性模板 -->
  1131. <delete id="deleteFamilyAttributeTemplate" parameterType="QcPartAttributeData">
  1132. DELETE FROM qc_attribute_template
  1133. WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1134. </delete>
  1135. <!-- ================================================= 抽样方案维护 ================================================= -->
  1136. <!-- 查询类别属性 -->
  1137. <select id="samplingProgrammeSearch" parameterType="QcSamplingInspectionProgrammeData" resultType="QcSamplingInspectionProgrammeData">
  1138. SELECT
  1139. site,
  1140. bu_no,
  1141. dbo.get_bu_desc(site, bu_no) as buDesc,
  1142. sampling_programme_no,
  1143. sampling_programme_desc,
  1144. sampling_programme_code,
  1145. create_time,
  1146. create_by,
  1147. update_date,
  1148. update_by
  1149. FROM qc_sampling_inspection_programme
  1150. <where>
  1151. site in (select site from eam_access_site where username = #{query.userName})
  1152. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1153. <if test = "query.samplingProgrammeNo != null and query.samplingProgrammeNo != ''">
  1154. AND sampling_programme_no LIKE '%' + #{query.samplingProgrammeNo}+'%'
  1155. </if>
  1156. <if test = "query.samplingProgrammeCode != null and query.samplingProgrammeCode != ''">
  1157. AND sampling_programme_code LIKE '%' + #{query.samplingProgrammeCode}+'%'
  1158. </if>
  1159. <if test = "query.samplingProgrammeDesc != null and query.samplingProgrammeDesc != ''">
  1160. AND sampling_programme_desc LIKE '%' + #{query.samplingProgrammeDesc}+'%'
  1161. </if>
  1162. </where>
  1163. </select>
  1164. <!-- 新增抽样方案 -->
  1165. <insert id="samplingProgrammeSave" parameterType="QcSamplingInspectionProgrammeData">
  1166. 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)
  1167. VALUES(#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{samplingProgrammeCode}, getDate(), #{createBy}, getDate(), #{updateBy})
  1168. </insert>
  1169. <!-- 删除抽样方案 -->
  1170. <delete id="samplingProgrammeDelete" parameterType="QcSamplingInspectionProgrammeData">
  1171. DELETE FROM qc_sampling_inspection_programme
  1172. WHERE site = #{site} and bu_no = #{buNo}
  1173. AND sampling_programme_no = #{samplingProgrammeNo}
  1174. </delete>
  1175. <!-- 删除抽样方案中的矩阵 -->
  1176. <delete id="deletePlanByProgrammeNo" parameterType="QcSamplingInspectionProgrammeData">
  1177. DELETE FROM qc_programme_plan
  1178. WHERE sampling_programme_no = #{samplingProgrammeNo} and site = #{site} and bu_no = #{buNo}
  1179. </delete>
  1180. <!-- 根据名称查询抽样方案 -->
  1181. <select id="selectSamplingProgrammeByDesc" parameterType="QcSamplingInspectionProgrammeData" resultType="QcSamplingInspectionProgrammeData">
  1182. SELECT
  1183. site,
  1184. bu_no,
  1185. sampling_programme_no,
  1186. sampling_programme_desc
  1187. FROM qc_sampling_inspection_programme
  1188. WHERE sampling_programme_desc = #{samplingProgrammeDesc} AND site = #{site} and bu_no = #{buNo}
  1189. </select>
  1190. <!-- 获取最大抽样方案编码 -->
  1191. <select id="queryLastSamplingProgrammeNo" resultType="string" parameterType="QcSamplingInspectionProgrammeData">
  1192. SELECT top 1 sampling_programme_no
  1193. FROM qc_sampling_inspection_programme
  1194. where site = #{site} and bu_no = #{buNo}
  1195. ORDER BY sampling_programme_no Desc
  1196. </select>
  1197. <!-- 搜索抽样方案中的矩阵 -->
  1198. <select id="searchSamplingProgrammeDetails" parameterType="QcSamplingInspectionProgrammeData" resultType="QcSamplingInspectionProgrammeData">
  1199. SELECT
  1200. qpp.site,
  1201. qpp.bu_no,
  1202. qpp.sampling_programme_no,
  1203. qsip.sampling_plan_no,
  1204. qsip.sampling_plan_Desc,
  1205. qsip.sampling_qty_no,
  1206. qsiq.sampling_qty_desc,
  1207. qsiq.sampling_qty,
  1208. qsip.sampling_qty_rank_no,
  1209. qsiqr.sampling_qty_rank_desc,
  1210. qsiqr.min_qty,
  1211. qsiqr.max_qty,
  1212. qsip.sampling_level_no,
  1213. qsil.sampling_level_desc,
  1214. qsip.sampling_plan_active
  1215. FROM qc_programme_plan as qpp
  1216. 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
  1217. 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
  1218. 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
  1219. 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
  1220. WHERE qpp.sampling_programme_no = #{samplingProgrammeNo} and qpp.site = #{site} and qpp.bu_no = #{buNo}
  1221. </select>
  1222. <!-- 获取该方案不包含的矩阵 -->
  1223. <select id="getPlanList" resultType="QcSamplingInspectionProgrammeData" parameterType="QcSamplingInspectionProgrammeData">
  1224. SELECT
  1225. qip.sampling_plan_no,
  1226. qip.sampling_plan_desc
  1227. FROM qc_sampling_inspection_plan as qip
  1228. 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
  1229. WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no is null
  1230. </select>
  1231. <!-- 获取当前方案所包含的矩阵 -->
  1232. <select id="getProgrammePlanList" resultType="QcSamplingInspectionProgrammeData" parameterType="QcSamplingInspectionProgrammeData">
  1233. SELECT
  1234. qip.sampling_plan_no,
  1235. qip.sampling_plan_desc
  1236. FROM qc_programme_plan as qpp
  1237. 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
  1238. WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no = #{samplingProgrammeNo}
  1239. </select>
  1240. <!-- 查重 -->
  1241. <select id="searchPlanRepeat" resultType="QcSamplingInspectionProgrammeData" parameterType="QcSamplingInspectionProgrammeData">
  1242. SELECT
  1243. sampling_plan_no,
  1244. sampling_programme_no
  1245. FROM qc_programme_plan
  1246. WHERE sampling_programme_no = #{samplingProgrammeNo} AND sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
  1247. </select>
  1248. <!-- 新增抽样方案中的矩阵 -->
  1249. <insert id="saveSamplingProgrammeDetails" parameterType="QcSamplingInspectionProgrammeData">
  1250. INSERT INTO qc_programme_plan (site, bu_no, sampling_programme_no, sampling_plan_no)
  1251. VALUES (#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingPlanNo})
  1252. </insert>
  1253. <!-- 更新抽样方案修改时间 -->
  1254. <update id="updateSamplingInspectionProgrammeDate" parameterType="QcSamplingInspectionProgrammeData">
  1255. UPDATE qc_sampling_inspection_programme
  1256. SET update_date = getDate(),
  1257. update_by = #{updateBy}
  1258. WHERE site = #{site} AND sampling_programme_no = #{samplingProgrammeNo} and bu_no = #{buNo}
  1259. </update>
  1260. <!-- 删除抽样方案中的矩阵 -->
  1261. <delete id="deleteSamplingProgrammeDetails" parameterType="QcSamplingInspectionProgrammeData">
  1262. DELETE FROM qc_programme_plan
  1263. WHERE sampling_programme_no = #{samplingProgrammeNo} and sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
  1264. </delete>
  1265. <!-- ================================================= FAI检验维护 ================================================= -->
  1266. <!-- 查询FAI基础数据 -->
  1267. <select id="selectFAIBasicData" resultType="QcFAIRecordData">
  1268. SELECT
  1269. top 1
  1270. a.orderno as orderNo,
  1271. j.part_no,
  1272. j.part_desc,
  1273. c.operation_desc,
  1274. b.approve_qty as rollQty,
  1275. a.s_resourceid as resourceId,
  1276. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1277. a.itemno as itemNo,
  1278. a.id as ssrId
  1279. FROM soscheduledrouting as a
  1280. LEFT JOIN sfdc as b
  1281. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  1282. select min(sfdc.id)
  1283. from sfdc
  1284. group by sfdc.assjob_seq_no, site
  1285. )
  1286. LEFT JOIN so_routing as c
  1287. ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site
  1288. LEFT JOIN part j
  1289. ON a.site = j.site and a.part_no = j.part_no
  1290. WHERE a.itemno = '10'
  1291. AND a.id not in (select ssr_id from qc_fai_record)
  1292. AND b.approve_qty is not null
  1293. ORDER BY a.id desc
  1294. </select>
  1295. <!-- 获取该物料属性下维护的iqc -->
  1296. <select id="selectPartAttributeByPartNo" resultType="QcFAIRecordData">
  1297. SELECT
  1298. qat.site,
  1299. qat.bu_no,
  1300. qat.attribute_no,
  1301. qat.template_id,
  1302. qat.sampling_level_no,
  1303. qsil.sampling_level_desc,
  1304. qat.inspection_cycle,
  1305. qat.sampling_programme_no,
  1306. qsip.sampling_programme_desc,
  1307. qat.AQL,
  1308. qat.AC,
  1309. qat.RE,
  1310. qt.default_sampling_quantity,
  1311. qt.default_sampling_proportion
  1312. FROM qc_attribute_template as qat
  1313. 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
  1314. 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
  1315. 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
  1316. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  1317. AND qat.attribute_no = #{partNo}
  1318. AND qat.attribute_type = #{attributeType}
  1319. AND qt.inspection_type_no = #{inspectionTypeNo}
  1320. AND qat.manufacturer_id = #{supplierNo}
  1321. </select>
  1322. <!-- 获取该物料属性下维护的ipqc -->
  1323. <select id="selectPartAttributeByOperationAndResource" resultType="QcFAIRecordData">
  1324. SELECT
  1325. qat.site,
  1326. qat.bu_no,
  1327. qat.attribute_no,
  1328. qat.template_id,
  1329. qat.sampling_level_no,
  1330. qsil.sampling_level_desc,
  1331. qat.inspection_cycle,
  1332. qat.sampling_programme_no,
  1333. qsip.sampling_programme_desc,
  1334. qat.AQL,
  1335. qat.AC,
  1336. qat.RE,
  1337. qt.default_sampling_quantity,
  1338. qt.default_sampling_proportion
  1339. FROM qc_attribute_template as qat
  1340. 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
  1341. 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
  1342. 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
  1343. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  1344. AND qat.attribute_no = #{partNo}
  1345. AND qat.attribute_type = #{attributeType1}
  1346. AND qt.inspection_type_no = #{inspectionTypeNo}
  1347. AND qat.operation = #{operationDesc}
  1348. AND qat.resource_id = #{resourceId}
  1349. </select>
  1350. <!-- 获取模板详情 -->
  1351. <select id="selectTemplate" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  1352. SELECT
  1353. qt.site,
  1354. qt.bu_no,
  1355. qt.template_id,
  1356. qt.sampling_level_no,
  1357. qsil.sampling_level_desc,
  1358. qt.inspection_cycle,
  1359. qt.sampling_programme_no,
  1360. qsip.sampling_programme_desc,
  1361. qt.AQL,
  1362. qt.AC,
  1363. qt.RE,
  1364. qt.default_sampling_quantity,
  1365. qt.default_sampling_proportion
  1366. FROM qc_template as qt
  1367. 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
  1368. 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
  1369. WHERE qt.site = #{site} and qt.template_id = #{templateId} and qt.bu_no = #{buNo}
  1370. </select>
  1371. <!-- 新增FAI主记录信息 -->
  1372. <insert id="saveFAIRecord" parameterType="QcFAIRecordData">
  1373. 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)
  1374. 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})
  1375. </insert>
  1376. <!-- 新增FAI明细记录信息 -->
  1377. <insert id="saveFAIDetailedRecord" parameterType="QcFAIRecordData">
  1378. 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)
  1379. 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})
  1380. </insert>
  1381. <!-- 查询FAI主记录信息 -->
  1382. <select id="qcFAIInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1383. SELECT
  1384. inspection_no,
  1385. site,
  1386. bu_no,
  1387. dbo.get_bu_desc(site, bu_no) as buDesc,
  1388. state,
  1389. inspection_result,
  1390. task_date,
  1391. inspection_type_no,
  1392. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName,
  1393. inspection_cycle,
  1394. order_no,
  1395. operation_desc,
  1396. resource_id,
  1397. dbo.qc_get_resource_desc(site, resource_id, work_center_no) as resourceDesc,
  1398. part_no,
  1399. dbo.qc_get_part_desc(part_no) as part_desc,
  1400. inspection_remark,
  1401. roll_qty,
  1402. sampling_qty,
  1403. disposal_measures,
  1404. disposal_remark,
  1405. inspector_date,
  1406. inspector_no,
  1407. dbo.qc_get_inspector_name(site, inspector_no) as inspectorName,
  1408. ssr_id,
  1409. unqualified_qty,
  1410. submit_flag,
  1411. dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode,
  1412. dbo.qc_get_sku(part_no) as sku,
  1413. dbo.qc_get_spec(part_no) as spec,
  1414. seq_no,
  1415. batch_roll_no,
  1416. special_requirements,
  1417. work_center_no,
  1418. roll_no,
  1419. um_id,
  1420. dbo.qc_get_um_name(site, um_id) as umName
  1421. FROM qc_fai_record
  1422. <where>
  1423. site in (select site from eam_access_site where username = #{query.userName})
  1424. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1425. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1426. AND inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1427. </if>
  1428. <if test = "query.partNo != null and query.partNo != ''">
  1429. AND part_no LIKE '%' + #{query.partNo} + '%'
  1430. </if>
  1431. <if test = "query.partDesc != null and query.partDesc != ''">
  1432. AND dbo.qc_get_part_desc(part_no) LIKE '%' + #{query.partDesc} + '%'
  1433. </if>
  1434. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1435. AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%'
  1436. </if>
  1437. <if test = "query.sku != null and query.sku != ''">
  1438. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%'
  1439. </if>
  1440. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1441. AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1442. </if>
  1443. <if test = "query.state != null and query.state != ''">
  1444. AND state = #{query.state}
  1445. </if>
  1446. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1447. AND inspection_result = #{query.inspectionResult}
  1448. </if>
  1449. <if test = "query.orderNo != null and query.orderNo != ''">
  1450. AND order_no LIKE '%' + #{query.orderNo} + '%'
  1451. </if>
  1452. <if test = "query.operationDesc != null and query.operationDesc != ''">
  1453. AND operation_desc LIKE '%' + #{query.operationDesc} + '%'
  1454. </if>
  1455. <if test="query.startDate != null">
  1456. AND inspector_date >= #{query.startDate}
  1457. </if>
  1458. <if test="query.endDate != null">
  1459. AND #{query.endDate} >= inspector_date
  1460. </if>
  1461. <if test="query.startDate2 != null">
  1462. AND task_date >= #{query.startDate2}
  1463. </if>
  1464. <if test="query.endDate2 != null">
  1465. AND #{query.endDate2} >= task_date
  1466. </if>
  1467. </where>
  1468. ORDER BY
  1469. CASE WHEN state = '待检验' THEN 1
  1470. WHEN state = '待审核' THEN 2
  1471. WHEN state = '已完成' THEN 3
  1472. END, task_date desc
  1473. </select>
  1474. <!-- 获取物料的类别编码 -->
  1475. <select id="selectFamilyIdByPartNo" parameterType="string" resultType="string">
  1476. SELECT FamilyID
  1477. FROM part
  1478. WHERE part_no = #{partNo} AND site = #{site}
  1479. </select>
  1480. <!-- FAI明细记录查询 -->
  1481. <select id="faiDetailSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1482. SELECT
  1483. a.site,
  1484. a.bu_no,
  1485. a.inspection_no,
  1486. a.order_no,
  1487. a.template_id,
  1488. a.sampling_level_no,
  1489. a.sampling_level_desc,
  1490. a.sampling_programme_no,
  1491. a.sampling_programme_desc,
  1492. a.AQL,
  1493. a.AC,
  1494. a.RE,
  1495. a.item_no,
  1496. a.item_desc,
  1497. a.object_id,
  1498. a.object_desc,
  1499. a.default_value,
  1500. a.min_value,
  1501. a.max_value,
  1502. a.text_value,
  1503. a.number_value,
  1504. a.value_type_db,
  1505. a.value_type,
  1506. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1507. a.is_submit,
  1508. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1509. a.sampling_qty,
  1510. dbo.qc_get_fai_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1511. c.method_no,
  1512. c.method_name,
  1513. c.method_remark
  1514. FROM qc_fai_detailed_record as a
  1515. 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
  1516. 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
  1517. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1518. </select>
  1519. <!-- 修改FAI主记录信息 -->
  1520. <update id="updateFAIMasterRecord" parameterType="QcFAIRecordData">
  1521. UPDATE qc_fai_record
  1522. SET disposal_measures = #{disposalMeasures},
  1523. disposal_remark = #{disposalRemark},
  1524. inspection_result = #{inspectionResult},
  1525. inspector_no = #{inspectorNo},
  1526. state = #{state},
  1527. inspection_remark = #{inspectionRemark},
  1528. inspector_date = getDate(),
  1529. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1530. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1531. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL}
  1532. WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1533. </update>
  1534. <!-- 修改FAI明细记录信息 -->
  1535. <update id="updateFAIDetailedRecord" parameterType="QcFAIRecordData">
  1536. UPDATE qc_fai_detailed_record
  1537. SET item_result = #{itemResult},
  1538. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1539. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1540. text_value = #{textValue},
  1541. number_value = #{numberValue,jdbcType=DECIMAL}
  1542. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1543. </update>
  1544. <!-- 修改子明细提交标识 -->
  1545. <update id="updateSubDetailedRecord" parameterType="QcFAIRecordData">
  1546. UPDATE qc_fai_sub_detail_record
  1547. SET is_submit = 'Y'
  1548. WHERE inspection_no = #{inspectionNo}
  1549. </update>
  1550. <!-- 删除FAI检验记录 -->
  1551. <delete id="deleteFAIRecord" parameterType="QcFAIRecordData">
  1552. DELETE FROM qc_fai_record
  1553. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1554. </delete>
  1555. <!-- 删除FAI明细记录信息 -->
  1556. <delete id="deleteFAIDetailedRecord" parameterType="QcFAIRecordData">
  1557. DELETE FROM qc_fai_detailed_record
  1558. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1559. </delete>
  1560. <!-- 删除FAI子明细记录信息 -->
  1561. <delete id="deleteFAISubDetailedRecord" parameterType="QcFAIRecordData">
  1562. DELETE FROM qc_fai_sub_detail_record
  1563. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1564. </delete>
  1565. <!-- 修改FAI主记录标识为已提交 -->
  1566. <update id="updateFAIMasterSubmitFlag" parameterType="QcFAIRecordData">
  1567. UPDATE qc_fai_record
  1568. SET submit_flag = 'Y',
  1569. state = '已完成'
  1570. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1571. </update>
  1572. <!-- 修改FAI明细记录标识为已提交 -->
  1573. <update id="updateFAIDetailSubmitFlag" parameterType="QcFAIRecordData">
  1574. UPDATE qc_fai_detailed_record
  1575. SET is_submit = 'Y'
  1576. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1577. </update>
  1578. <!-- 修改子明细记录标识为已提交 -->
  1579. <update id="updateFAISubDetailSubmitFlag" parameterType="QcFAIRecordData">
  1580. UPDATE qc_fai_sub_detail_record
  1581. SET is_submit = 'Y'
  1582. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1583. </update>
  1584. <!-- 查询FAI检验记录是否已提交 -->
  1585. <select id="checkFAIIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData">
  1586. SELECT submit_flag
  1587. FROM qc_fai_record
  1588. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1589. </select>
  1590. <!-- 删除子明细的老数据 -->
  1591. <delete id="delFAISubDetailedRecord" parameterType="QcSubDetailInformationData">
  1592. DELETE FROM qc_fai_sub_detail_record
  1593. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1594. </delete>
  1595. <!-- 新增FAI子明细信息 -->
  1596. <insert id="saveFAISubDetailed">
  1597. INSERT INTO qc_fai_sub_detail_record
  1598. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no)
  1599. VALUES
  1600. <foreach collection="list" item="item" separator=",">
  1601. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo})
  1602. </foreach>
  1603. </insert>
  1604. <!-- 查询FAI的子明细 -->
  1605. <select id="selectFAISubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues">
  1606. SELECT
  1607. site,
  1608. bu_no,
  1609. sub_detail_value,
  1610. sampling_location,
  1611. is_submit,
  1612. sampling_location_b
  1613. FROM qc_fai_sub_detail_record
  1614. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1615. </select>
  1616. <!-- 获取该项目的子明细值 -->
  1617. <select id="selectFAISubDetailValue" parameterType="string" resultType="SubDetailValues">
  1618. SELECT sub_detail_value,
  1619. sampling_location,
  1620. is_submit
  1621. FROM qc_fai_sub_detail_record
  1622. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1623. </select>
  1624. <!-- ================================================= IPQC检验维护 ================================================= -->
  1625. <!-- 查询IPQC基础数据 -->
  1626. <select id="selectIPQCBasicData" resultType="QcFAIRecordData">
  1627. SELECT
  1628. top 1
  1629. a.orderno as orderNo,
  1630. j.part_no,
  1631. j.part_desc,
  1632. c.operation_desc,
  1633. b.approve_qty as rollQty,
  1634. a.s_resourceid as resourceId,
  1635. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1636. a.itemno as itemNo,
  1637. a.id as ssrId
  1638. FROM soscheduledrouting as a
  1639. LEFT JOIN sfdc as b
  1640. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  1641. select max(sfdc.id)
  1642. from sfdc
  1643. group by sfdc.assjob_seq_no, site
  1644. )
  1645. LEFT JOIN so_routing as c
  1646. ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site
  1647. LEFT JOIN part j
  1648. ON a.site = j.site and a.part_no = j.part_no
  1649. LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
  1650. ON a.id = temp.ssr_id
  1651. WHERE b.approve_qty is not null and temp.ssr_id is null
  1652. ORDER BY a.id desc
  1653. </select>
  1654. <select id="qcExec" resultType="QcFAIRecordData" parameterType="string" statementType="CALLABLE">
  1655. {CALL
  1656. getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
  1657. }
  1658. </select>
  1659. <!-- 新增IPQC明细记录信息 -->
  1660. <insert id="saveIPQCDetailedRecord" parameterType="QcFAIRecordData">
  1661. 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)
  1662. 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})
  1663. </insert>
  1664. <!-- 新增IPQC记录到count表 -->
  1665. <insert id="saveIPQCRecordCount" parameterType="QcFAIRecordData">
  1666. INSERT INTO qc_ipqc_record_count (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id, part_no, roll_qty, sampling_qty, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id, new_data)
  1667. VALUES(#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId}, #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId}, 'Y')
  1668. </insert>
  1669. <!-- 新增IPQC主记录信息 -->
  1670. <insert id="saveIPQCRecord" parameterType="QcFAIRecordData">
  1671. 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)
  1672. 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})
  1673. </insert>
  1674. <!-- 查询IPQC主记录信息 -->
  1675. <select id="qcIPQCInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1676. SELECT
  1677. inspection_no,
  1678. site,
  1679. bu_no,
  1680. dbo.get_bu_desc(site, bu_no) as buDesc,
  1681. state,
  1682. inspection_result,
  1683. task_date,
  1684. inspection_type_no,
  1685. inspection_cycle,
  1686. order_no,
  1687. operation_desc,
  1688. resource_id,
  1689. dbo.qc_get_resource_desc(site, resource_id, work_center_no) as resourceDesc,
  1690. part_no,
  1691. dbo.qc_get_part_desc(part_no) as part_desc,
  1692. dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode,
  1693. inspection_remark,
  1694. roll_qty,
  1695. sampling_qty,
  1696. disposal_measures,
  1697. disposal_remark,
  1698. inspector_date,
  1699. inspector_no,
  1700. dbo.qc_get_inspector_name(site, inspector_no) as inspectorName,
  1701. ssr_id,
  1702. unqualified_qty,
  1703. submit_flag,
  1704. dbo.qc_get_sku(part_no) as sku,
  1705. dbo.qc_get_spec(part_no) as spec,
  1706. seq_no,
  1707. batch_roll_no,
  1708. special_requirements,
  1709. work_center_no,
  1710. roll_no,
  1711. um_id,
  1712. dbo.qc_get_um_name(site, um_id) as umName
  1713. FROM qc_ipqc_record
  1714. <where>
  1715. site in (select site from eam_access_site where username = #{query.userName})
  1716. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1717. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1718. AND inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1719. </if>
  1720. <if test = "query.partNo != null and query.partNo != ''">
  1721. AND part_no LIKE '%' + #{query.partNo} + '%'
  1722. </if>
  1723. <if test = "query.partDesc != null and query.partDesc != ''">
  1724. AND dbo.qc_get_part_desc(part_no) LIKE '%' + #{query.partDesc} + '%'
  1725. </if>
  1726. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1727. AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%'
  1728. </if>
  1729. <if test = "query.sku != null and query.sku != ''">
  1730. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%'
  1731. </if>
  1732. <if test = "query.state != null and query.state != ''">
  1733. AND state = #{query.state}
  1734. </if>
  1735. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  1736. AND inspection_type_no = #{query.inspectionTypeNo}
  1737. </if>
  1738. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1739. AND inspection_result = #{query.inspectionResult}
  1740. </if>
  1741. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1742. AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1743. </if>
  1744. <if test = "query.orderNo != null and query.orderNo != ''">
  1745. AND order_no LIKE '%' + #{query.orderNo} + '%'
  1746. </if>
  1747. <if test = "query.operationDesc != null and query.operationDesc != ''">
  1748. AND operation_desc LIKE '%' + #{query.operationDesc} + '%'
  1749. </if>
  1750. <if test="query.startDate != null">
  1751. AND inspector_date >= #{query.startDate}
  1752. </if>
  1753. <if test="query.endDate != null">
  1754. AND #{query.endDate} >= inspector_date
  1755. </if>
  1756. <if test="query.startDate2 != null">
  1757. AND task_date >= #{query.startDate2}
  1758. </if>
  1759. <if test="query.endDate2 != null">
  1760. AND #{query.endDate2} >= task_date
  1761. </if>
  1762. </where>
  1763. ORDER BY
  1764. CASE WHEN state = '待检验' THEN 1
  1765. WHEN state = '待审核' THEN 2
  1766. WHEN state = '已完成' THEN 3
  1767. END, task_date desc
  1768. </select>
  1769. <!-- IPQC明细记录查询 -->
  1770. <select id="ipqcDetailSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1771. SELECT
  1772. a.site,
  1773. a.bu_no,
  1774. a.inspection_no,
  1775. a.order_no,
  1776. a.template_id,
  1777. a.sampling_level_no,
  1778. a.sampling_level_desc,
  1779. a.sampling_programme_no,
  1780. a.sampling_programme_desc,
  1781. a.AQL,
  1782. a.AC,
  1783. a.RE,
  1784. a.item_no,
  1785. a.item_desc,
  1786. a.object_id,
  1787. a.object_desc,
  1788. a.default_value,
  1789. a.min_value,
  1790. a.max_value,
  1791. a.text_value,
  1792. a.number_value,
  1793. a.value_type_db,
  1794. a.value_type,
  1795. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1796. a.is_submit,
  1797. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1798. a.sampling_qty,
  1799. dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1800. c.method_no,
  1801. c.method_name,
  1802. c.method_remark
  1803. FROM qc_ipqc_detailed_record as a
  1804. 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
  1805. 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
  1806. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1807. </select>
  1808. <!-- 删除IPQC检验记录 -->
  1809. <delete id="deleteIPQCRecord" parameterType="QcFAIRecordData">
  1810. DELETE FROM qc_ipqc_record
  1811. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1812. </delete>
  1813. <!-- 删除IPQC检验记录 -->
  1814. <delete id="deleteIPQCRecordCount" parameterType="QcFAIRecordData">
  1815. DELETE FROM qc_ipqc_record_count
  1816. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1817. </delete>
  1818. <!-- 删除IPQC明细记录信息 -->
  1819. <delete id="deleteIPQCDetailedRecord" parameterType="QcFAIRecordData">
  1820. DELETE FROM qc_ipqc_detailed_record
  1821. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1822. </delete>
  1823. <!-- 删除IPQC子明细记录信息 -->
  1824. <delete id="deleteIPQCSubDetailedRecord" parameterType="QcFAIRecordData">
  1825. DELETE FROM qc_ipqc_sub_detail_record
  1826. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1827. </delete>
  1828. <!-- 修改IPQC主记录信息 -->
  1829. <update id="updateIPQCMasterRecord" parameterType="QcFAIRecordData">
  1830. UPDATE qc_ipqc_record
  1831. SET disposal_measures = #{disposalMeasures},
  1832. disposal_remark = #{disposalRemark},
  1833. inspection_result = #{inspectionResult},
  1834. inspector_no = #{inspectorNo},
  1835. state = #{state},
  1836. inspection_remark = #{inspectionRemark},
  1837. inspector_date = getDate(),
  1838. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1839. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1840. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL}
  1841. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1842. </update>
  1843. <!-- 修改IPQC明细记录信息 -->
  1844. <update id="updateIPQCDetailedRecord" parameterType="QcFAIRecordData">
  1845. UPDATE qc_ipqc_detailed_record
  1846. SET item_result = #{itemResult},
  1847. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1848. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1849. text_value = #{textValue},
  1850. number_value = #{numberValue,jdbcType=DECIMAL}
  1851. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1852. </update>
  1853. <!-- 修改IPQC主记录标识为已提交 -->
  1854. <update id="updateIPQCMasterSubmitFlag" parameterType="QcFAIRecordData">
  1855. UPDATE qc_ipqc_record
  1856. SET submit_flag = 'Y',
  1857. state = '已完成'
  1858. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1859. </update>
  1860. <!-- 修改IPQC明细记录标识为已提交 -->
  1861. <update id="updateIPQCDetailSubmitFlag" parameterType="QcFAIRecordData">
  1862. UPDATE qc_ipqc_detailed_record
  1863. SET is_submit = 'Y'
  1864. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1865. </update>
  1866. <!-- 修改IPQC子明细记录标识为已提交 -->
  1867. <update id="updateIPQCSubDetailSubmitFlag" parameterType="QcFAIRecordData">
  1868. UPDATE qc_ipqc_sub_detail_record
  1869. SET is_submit = 'Y'
  1870. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1871. </update>
  1872. <!-- 删除IPQC子明细的老数据 -->
  1873. <delete id="delIPQCSubDetailedRecord" parameterType="QcSubDetailInformationData">
  1874. DELETE FROM qc_ipqc_sub_detail_record
  1875. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1876. </delete>
  1877. <!-- 新增IPQC子明细信息 -->
  1878. <insert id="saveIPQCSubDetailed">
  1879. INSERT INTO qc_ipqc_sub_detail_record
  1880. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no)
  1881. VALUES
  1882. <foreach collection="list" item="item" separator=",">
  1883. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo})
  1884. </foreach>
  1885. </insert>
  1886. <!-- 查询IPQC的子明细 -->
  1887. <select id="selectIPQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues">
  1888. SELECT sub_detail_value,
  1889. sampling_location,
  1890. is_submit,
  1891. sampling_location_b
  1892. FROM qc_ipqc_sub_detail_record
  1893. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1894. </select>
  1895. <!-- 查询IPQC检验记录是否已提交 -->
  1896. <select id="checkIPQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData">
  1897. SELECT submit_flag
  1898. FROM qc_ipqc_record
  1899. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1900. </select>
  1901. <!-- 获取该项目的子明细值 -->
  1902. <select id="selectIPQCSubDetailValue" parameterType="string" resultType="SubDetailValues">
  1903. SELECT sub_detail_value,
  1904. sampling_location,
  1905. is_submit
  1906. FROM qc_ipqc_sub_detail_record
  1907. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1908. </select>
  1909. <!-- 查询工序列表 -->
  1910. <select id="getOperationList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1911. SELECT
  1912. DISTINCT
  1913. a.seqno as seqNo,
  1914. a.orderno as orderNo,
  1915. j.part_no,
  1916. j.part_desc,
  1917. j.spec,
  1918. j.sku,
  1919. c.operation_desc as operationDesc,
  1920. a.itemno as operationNo,
  1921. a.s_resourceid as resourceId,
  1922. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1923. c.work_center_no
  1924. FROM soscheduledrouting as a
  1925. LEFT JOIN so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no
  1926. LEFT JOIN part j ON a.part_no = j.part_no
  1927. WHERE a.seqno = #{seqNo}
  1928. </select>
  1929. <!-- 根据工单号和工序号查出所有数据 -->
  1930. <select id="getResourceList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1931. SELECT
  1932. a.s_resourceid as resourceId,
  1933. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1934. c.work_center_no
  1935. FROM soscheduledrouting as a
  1936. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  1937. LEFT JOIN so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site
  1938. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  1939. WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
  1940. ORDER BY a.id desc
  1941. </select>
  1942. <!-- a.orderno = #{orderNo} and c.operation_desc = #{operationDesc}-->
  1943. <!-- 查询机台名称 -->
  1944. <select id="selectResourceDesc" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1945. SELECT distinct
  1946. resource_desc
  1947. FROM resource
  1948. WHERE site = #{site} and resource_id = #{resourceId}
  1949. </select>
  1950. <!-- 查询物料名称 -->
  1951. <select id="selectPartDesc" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  1952. SELECT distinct
  1953. part_desc
  1954. FROM part
  1955. WHERE site = #{site} and part_no = #{partNo}
  1956. </select>
  1957. <!-- ================================================= IQC检验维护 ================================================= -->
  1958. <!-- 查询IQC基础数据 -->
  1959. <select id="selectIQCBasicData" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  1960. SELECT
  1961. qir.inspection_no,
  1962. qir.state,
  1963. qir.create_date as taskDate,
  1964. qir.roll_no,
  1965. qir.part_no,
  1966. p.part_desc,
  1967. p.cinv_source_code,
  1968. dbo.qc_get_sku(p.part_no) as sku,
  1969. qir.roll_qty,
  1970. qir.print_flag,
  1971. qir.create_by,
  1972. qir.supplier_no,
  1973. qir.site,
  1974. qir.bu_no,
  1975. qir.po_orderNo,
  1976. qir.po_itemNo,
  1977. qir.roll_count
  1978. FROM qc_iqc_record as qir
  1979. LEFT JOIN part p ON qir.part_no = p.part_no and qir.site = p.site
  1980. WHERE qir.site in (select site from eam_access_site where username = #{userName})
  1981. and (qir.site + '-' + qir.bu_no) in (select * from dbo.query_bu(#{userName}))
  1982. and qir.detail_flag = 'N'
  1983. </select>
  1984. <!-- 新增IQC明细记录信息 -->
  1985. <insert id="saveIQCDetailedRecord" parameterType="QcFAIRecordData">
  1986. 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)
  1987. 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})
  1988. </insert>
  1989. <!-- 修改IQC检验记录 -->
  1990. <update id="updateIQCRecord" parameterType="QcFAIRecordData">
  1991. UPDATE qc_iqc_record
  1992. SET inspection_type_no = #{inspectionTypeNo},
  1993. sampling_qty = #{samplingQty},
  1994. inspection_cycle = #{inspectionCycle},
  1995. part_desc = #{partDesc},
  1996. detail_flag = 'Y'
  1997. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1998. </update>
  1999. <!-- 查询IQC主记录信息 -->
  2000. <select id="qcIQCInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2001. SELECT
  2002. inspection_no,
  2003. site,
  2004. bu_no,
  2005. dbo.get_bu_desc(site, bu_no) as buDesc,
  2006. state,
  2007. inspection_result,
  2008. create_date as taskDate,
  2009. inspection_type_no,
  2010. inspection_cycle,
  2011. part_no,
  2012. part_desc,
  2013. dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode,
  2014. dbo.qc_get_sku(part_no) as sku,
  2015. dbo.qc_get_part_umid(site, part_no) as umId,
  2016. inspection_remark,
  2017. roll_qty,
  2018. sampling_qty,
  2019. disposal_measures,
  2020. disposal_remark,
  2021. inspector_date,
  2022. inspector_no,
  2023. dbo.qc_get_inspector_name(site, inspector_no) as inspectorName,
  2024. unqualified_quantity,
  2025. submit_flag,
  2026. roll_no,
  2027. supplier_no,
  2028. dbo.qc_get_supplier_name(site, supplier_no) as supplierDesc,
  2029. po_orderNo,
  2030. po_itemNo,
  2031. roll_count
  2032. FROM qc_iqc_record
  2033. <where>
  2034. site in (select site from eam_access_site where username = #{query.userName})
  2035. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2036. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2037. AND inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2038. </if>
  2039. <if test = "query.state != null and query.state != ''">
  2040. AND state = #{query.state}
  2041. </if>
  2042. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2043. AND inspection_result = #{query.inspectionResult}
  2044. </if>
  2045. <if test = "query.partNo != null and query.partNo != ''">
  2046. AND part_no LIKE '%' + #{query.partNo} + '%'
  2047. </if>
  2048. <if test = "query.partDesc != null and query.partDesc != ''">
  2049. AND part_desc LIKE '%' + #{query.partDesc} + '%'
  2050. </if>
  2051. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2052. AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%'
  2053. </if>
  2054. <if test = "query.sku != null and query.sku != ''">
  2055. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%'
  2056. </if>
  2057. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  2058. AND dbo.qc_get_supplier_name(site, supplier_no) LIKE '%' + #{query.supplierDesc} + '%'
  2059. </if>
  2060. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2061. AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2062. </if>
  2063. <if test = "query.inspectorName != null and query.inspectorName != ''">
  2064. AND dbo.qc_get_inspector_name(site, inspector_no) LIKE '%' + #{query.inspectorName} + '%'
  2065. </if>
  2066. <if test="query.startDate != null">
  2067. AND inspector_date >= #{query.startDate}
  2068. </if>
  2069. <if test="query.endDate != null">
  2070. AND #{query.endDate} >= inspector_date
  2071. </if>
  2072. <if test="query.startDate2 != null">
  2073. AND create_date >= #{query.startDate2}
  2074. </if>
  2075. <if test="query.endDate2 != null">
  2076. AND #{query.endDate2} >= create_date
  2077. </if>
  2078. </where>
  2079. ORDER BY
  2080. CASE WHEN state = '待检验' THEN 1
  2081. WHEN state = '待审核' THEN 2
  2082. WHEN state = '已完成' THEN 3
  2083. END, create_date desc
  2084. </select>
  2085. <!-- IQC明细记录查询 -->
  2086. <select id="iqcDetailSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2087. SELECT
  2088. a.site,
  2089. a.bu_no,
  2090. a.inspection_no,
  2091. a.template_id,
  2092. a.sampling_level_no,
  2093. a.sampling_level_desc,
  2094. a.sampling_programme_no,
  2095. a.sampling_programme_desc,
  2096. a.AQL,
  2097. a.AC,
  2098. a.RE,
  2099. a.item_no,
  2100. a.item_desc,
  2101. a.object_id,
  2102. a.object_desc,
  2103. a.default_value,
  2104. a.min_value,
  2105. a.max_value,
  2106. a.text_value,
  2107. a.number_value,
  2108. a.value_type_db,
  2109. a.value_type,
  2110. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2111. a.is_submit,
  2112. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2113. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2114. c.method_no,
  2115. c.method_name,
  2116. c.method_remark,
  2117. a.sampling_qty
  2118. FROM qc_iqc_detailed_record as a
  2119. 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
  2120. 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
  2121. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2122. </select>
  2123. <!-- 查询IQC的子明细 -->
  2124. <select id="selectIQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues">
  2125. SELECT
  2126. site,
  2127. bu_no,
  2128. sub_detail_value,
  2129. sampling_location,
  2130. is_submit,
  2131. sampling_location_b
  2132. FROM qc_iqc_sub_detail_record
  2133. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2134. </select>
  2135. <!-- 获取该项目的子明细值 -->
  2136. <select id="selectIQCSubDetailValue" parameterType="string" resultType="SubDetailValues">
  2137. SELECT sub_detail_value,
  2138. sampling_location,
  2139. is_submit
  2140. FROM qc_iqc_sub_detail_record
  2141. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2142. </select>
  2143. <!-- 修改IQC主记录信息 -->
  2144. <update id="updateIQCMasterRecord" parameterType="QcFAIRecordData">
  2145. UPDATE qc_iqc_record
  2146. SET disposal_measures = #{disposalMeasures},
  2147. disposal_remark = #{disposalRemark},
  2148. inspection_result = #{inspectionResult},
  2149. inspector_no = #{inspectorNo},
  2150. state = #{state},
  2151. inspection_remark = #{inspectionRemark},
  2152. inspector_date = getDate(),
  2153. roll_count = #{rollCount,jdbcType=DECIMAL},
  2154. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2155. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL}
  2156. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2157. </update>
  2158. <!-- 修改IQC明细记录信息 -->
  2159. <update id="updateIQCDetailedRecord" parameterType="QcFAIRecordData">
  2160. UPDATE qc_iqc_detailed_record
  2161. SET item_result = #{itemResult},
  2162. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2163. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2164. text_value = #{textValue},
  2165. number_value = #{numberValue,jdbcType=DECIMAL}
  2166. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2167. </update>
  2168. <!-- 查询该记录明细是否已存在 -->
  2169. <select id="checkIQCDetail" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2170. SELECT inspection_no,
  2171. template_id
  2172. FROM qc_iqc_detailed_record
  2173. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2174. </select>
  2175. <!-- 查询IQC检验记录是否已提交 -->
  2176. <select id="checkIQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData">
  2177. SELECT submit_flag
  2178. FROM qc_iqc_record
  2179. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2180. </select>
  2181. <!-- 删除IQC子明细的老数据 -->
  2182. <delete id="delIQCSubDetailedRecord" parameterType="QcSubDetailInformationData">
  2183. DELETE FROM qc_iqc_sub_detail_record
  2184. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2185. </delete>
  2186. <!-- 新增IQC子明细信息 -->
  2187. <insert id="saveIQCSubDetailed">
  2188. INSERT INTO qc_iqc_sub_detail_record
  2189. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no)
  2190. VALUES
  2191. <foreach collection="list" item="item" separator=",">
  2192. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo})
  2193. </foreach>
  2194. </insert>
  2195. <!-- 修改IQC主记录标识为已提交 -->
  2196. <update id="updateIQCMasterSubmitFlag" parameterType="QcFAIRecordData">
  2197. UPDATE qc_iqc_record
  2198. SET submit_flag = 'Y',
  2199. state = '已完成'
  2200. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2201. </update>
  2202. <!-- 修改IQC明细记录标识为已提交 -->
  2203. <update id="updateIQCDetailSubmitFlag" parameterType="QcFAIRecordData">
  2204. UPDATE qc_iqc_detailed_record
  2205. SET is_submit = 'Y'
  2206. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2207. </update>
  2208. <!-- 修改IQC子明细记录标识为已提交 -->
  2209. <update id="updateIQCSubDetailSubmitFlag" parameterType="QcFAIRecordData">
  2210. UPDATE qc_iqc_sub_detail_record
  2211. SET is_submit = 'Y'
  2212. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2213. </update>
  2214. <!-- 删除IQC检验记录 -->
  2215. <delete id="deleteIQCRecord" parameterType="QcFAIRecordData">
  2216. DELETE FROM qc_iqc_record
  2217. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2218. </delete>
  2219. <!-- 删除IQC明细记录信息 -->
  2220. <delete id="deleteIQCDetailedRecord" parameterType="QcFAIRecordData">
  2221. DELETE FROM qc_iqc_detailed_record
  2222. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2223. </delete>
  2224. <!-- 删除IQC子明细记录信息 -->
  2225. <delete id="deleteIQCSubDetailedRecord" parameterType="QcFAIRecordData">
  2226. DELETE FROM qc_iqc_sub_detail_record
  2227. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2228. </delete>
  2229. <!-- 查询文件ID -->
  2230. <select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
  2231. SELECT id, file_name
  2232. FROM sys_oss
  2233. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  2234. </select>
  2235. <!-- 获取工序列表 -->
  2236. <select id="getOperationDescList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  2237. SELECT distinct
  2238. operation_desc
  2239. FROM so_routing
  2240. <where>
  2241. <if test = "operationDesc != null and operationDesc != ''">
  2242. AND operation_desc LIKE '%' + #{operationDesc} + '%'
  2243. </if>
  2244. </where>
  2245. </select>
  2246. <!-- 获取供应商列表 -->
  2247. <select id="getManufacturerList" parameterType="QcPartAttributeData" resultType="QcPartAttributeData">
  2248. SELECT
  2249. supplierID as manufacturerID,
  2250. supplierName as manufacturerName
  2251. FROM view_Supplier
  2252. <where>
  2253. site = #{site}
  2254. <if test = "manufacturerID != null and manufacturerID != ''">
  2255. AND supplierID LIKE '%' + #{manufacturerID} + '%'
  2256. </if>
  2257. <if test = "manufacturerName != null and manufacturerName != ''">
  2258. AND supplierName LIKE '%' + #{manufacturerName} + '%'
  2259. </if>
  2260. </where>
  2261. </select>
  2262. <!-- 获取机台列表 -->
  2263. <select id="getAllResourceList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2264. SELECT distinct
  2265. resource_id,
  2266. resource_desc
  2267. FROM resource
  2268. <where>
  2269. site = #{site}
  2270. <if test = "resourceId != null and resourceId != ''">
  2271. AND resource_id LIKE '%' + #{resourceId} + '%'
  2272. </if>
  2273. <if test = "resourceDesc != null and resourceDesc != ''">
  2274. AND resource_desc LIKE '%' + #{resourceDesc} + '%'
  2275. </if>
  2276. </where>
  2277. </select>
  2278. <!-- 获取工单列表 -->
  2279. <select id="getOrderNoList" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2280. SELECT DISTINCT
  2281. a.orderno as orderNo
  2282. FROM soscheduledrouting as a
  2283. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2284. LEFT JOIN so_routing as c ON c.order_no = a.orderno and a.itemno = c.item_no and c.site = a.site
  2285. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2286. <where>
  2287. a.site = #{site}
  2288. AND b.approve_qty is not null
  2289. <if test = "orderNo != null and orderNo != ''">
  2290. AND a.orderno LIKE '%' + #{orderNo} + '%'
  2291. </if>
  2292. </where>
  2293. order by a.orderno DESC
  2294. </select>
  2295. <!-- 查询FQC主记录信息 -->
  2296. <select id="qcFQCInspectionSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2297. SELECT
  2298. inspection_no,
  2299. site,
  2300. bu_no,
  2301. dbo.get_bu_desc(site, bu_no) as buDesc,
  2302. state,
  2303. inspection_result,
  2304. task_date,
  2305. inspection_type_no,
  2306. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName,
  2307. inspection_cycle,
  2308. order_no,
  2309. operation_desc,
  2310. resource_id,
  2311. dbo.qc_get_resource_desc(site, resource_id, work_center_no) as resourceDesc,
  2312. part_no,
  2313. dbo.qc_get_part_desc(part_no) as part_desc,
  2314. inspection_remark,
  2315. roll_qty,
  2316. sampling_qty,
  2317. disposal_measures,
  2318. disposal_remark,
  2319. inspector_date,
  2320. inspector_no,
  2321. dbo.qc_get_inspector_name(site, inspector_no) as inspectorName,
  2322. ssr_id,
  2323. unqualified_qty,
  2324. submit_flag,
  2325. dbo.qc_get_cinv_source_code(part_no) as cinvSourceCode,
  2326. dbo.qc_get_sku(part_no) as sku,
  2327. dbo.qc_get_spec(part_no) as spec,
  2328. seq_no,
  2329. batch_roll_no,
  2330. special_requirements,
  2331. work_center_no,
  2332. roll_no,
  2333. um_id,
  2334. dbo.qc_get_um_name(site, um_id) as umName
  2335. FROM qc_fqc_record
  2336. <where>
  2337. site in (select site from eam_access_site where username = #{query.userName})
  2338. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2339. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2340. AND inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2341. </if>
  2342. <if test = "query.partNo != null and query.partNo != ''">
  2343. AND part_no LIKE '%' + #{query.partNo} + '%'
  2344. </if>
  2345. <if test = "query.partDesc != null and query.partDesc != ''">
  2346. AND dbo.qc_get_part_desc(part_no) LIKE '%' + #{query.partDesc} + '%'
  2347. </if>
  2348. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2349. AND dbo.qc_get_cinv_source_code(part_no) LIKE '%' + #{query.cinvSourceCode} + '%'
  2350. </if>
  2351. <if test = "query.sku != null and query.sku != ''">
  2352. AND dbo.qc_get_sku(part_no) LIKE '%' + #{query.sku} + '%'
  2353. </if>
  2354. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2355. AND disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2356. </if>
  2357. <if test = "query.state != null and query.state != ''">
  2358. AND state = #{query.state}
  2359. </if>
  2360. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2361. AND inspection_result = #{query.inspectionResult}
  2362. </if>
  2363. <if test = "query.orderNo != null and query.orderNo != ''">
  2364. AND order_no LIKE '%' + #{query.orderNo} + '%'
  2365. </if>
  2366. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2367. AND operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2368. </if>
  2369. <if test="query.startDate != null">
  2370. AND inspector_date >= #{query.startDate}
  2371. </if>
  2372. <if test="query.endDate != null">
  2373. AND #{query.endDate} >= inspector_date
  2374. </if>
  2375. <if test="query.startDate2 != null">
  2376. AND task_date >= #{query.startDate2}
  2377. </if>
  2378. <if test="query.endDate2 != null">
  2379. AND #{query.endDate2} >= task_date
  2380. </if>
  2381. </where>
  2382. ORDER BY
  2383. CASE WHEN state = '待检验' THEN 1
  2384. WHEN state = '待审核' THEN 2
  2385. WHEN state = '已完成' THEN 3
  2386. END, task_date desc
  2387. </select>
  2388. <!-- 新增FQC明细记录信息 -->
  2389. <insert id="saveFQCDetailedRecord" parameterType="QcFAIRecordData">
  2390. 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)
  2391. 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})
  2392. </insert>
  2393. <!-- 新增FQC主记录信息 -->
  2394. <insert id="saveFQCRecord" parameterType="QcFAIRecordData">
  2395. 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)
  2396. 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})
  2397. </insert>
  2398. <!-- FQC明细记录查询 -->
  2399. <select id="fqcDetailSearch" parameterType="QcFAIRecordData" resultType="QcFAIRecordData">
  2400. SELECT
  2401. a.site,
  2402. a.bu_no,
  2403. a.inspection_no,
  2404. a.order_no,
  2405. a.template_id,
  2406. a.sampling_level_no,
  2407. a.sampling_level_desc,
  2408. a.sampling_programme_no,
  2409. a.sampling_programme_desc,
  2410. a.AQL,
  2411. a.AC,
  2412. a.RE,
  2413. a.item_no,
  2414. a.item_desc,
  2415. a.object_id,
  2416. a.object_desc,
  2417. a.default_value,
  2418. a.min_value,
  2419. a.max_value,
  2420. a.text_value,
  2421. a.number_value,
  2422. a.value_type_db,
  2423. a.value_type,
  2424. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2425. a.is_submit,
  2426. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2427. a.sampling_qty,
  2428. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2429. c.method_no,
  2430. c.method_name,
  2431. c.method_remark
  2432. FROM qc_fqc_detailed_record as a
  2433. 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
  2434. 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
  2435. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2436. </select>
  2437. <!-- 删除FQC检验记录 -->
  2438. <delete id="deleteFQCRecord" parameterType="QcFAIRecordData">
  2439. DELETE FROM qc_fqc_record
  2440. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2441. </delete>
  2442. <!-- 删除FQC明细记录信息 -->
  2443. <delete id="deleteFQCDetailedRecord" parameterType="QcFAIRecordData">
  2444. DELETE FROM qc_fqc_detailed_record
  2445. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2446. </delete>
  2447. <!-- 删除FQC子明细记录信息 -->
  2448. <delete id="deleteFQCSubDetailedRecord" parameterType="QcFAIRecordData">
  2449. DELETE FROM qc_fqc_sub_detail_record
  2450. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2451. </delete>
  2452. <!-- 修改FQC主记录信息 -->
  2453. <update id="updateFQCMasterRecord" parameterType="QcFAIRecordData">
  2454. UPDATE qc_fqc_record
  2455. SET disposal_measures = #{disposalMeasures},
  2456. disposal_remark = #{disposalRemark},
  2457. inspection_result = #{inspectionResult},
  2458. inspector_no = #{inspectorNo},
  2459. state = #{state},
  2460. inspection_remark = #{inspectionRemark},
  2461. inspector_date = getDate(),
  2462. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2463. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2464. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL}
  2465. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2466. </update>
  2467. <!-- 修改FQC明细记录信息 -->
  2468. <update id="updateFQCDetailedRecord" parameterType="QcFAIRecordData">
  2469. UPDATE qc_fqc_detailed_record
  2470. SET item_result = #{itemResult},
  2471. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2472. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2473. text_value = #{textValue},
  2474. number_value = #{numberValue,jdbcType=DECIMAL}
  2475. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2476. </update>
  2477. <!-- 修改FQC主记录标识为已提交 -->
  2478. <update id="updateFQCMasterSubmitFlag" parameterType="QcFAIRecordData">
  2479. UPDATE qc_fqc_record
  2480. SET submit_flag = 'Y',
  2481. state = '已完成'
  2482. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2483. </update>
  2484. <!-- 修改FAI明细记录标识为已提交 -->
  2485. <update id="updateFQCDetailSubmitFlag" parameterType="QcFAIRecordData">
  2486. UPDATE qc_fqc_detailed_record
  2487. SET is_submit = 'Y'
  2488. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2489. </update>
  2490. <!-- 修改子明细记录标识为已提交 -->
  2491. <update id="updateFQCSubDetailSubmitFlag" parameterType="QcFAIRecordData">
  2492. UPDATE qc_fqc_sub_detail_record
  2493. SET is_submit = 'Y'
  2494. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2495. </update>
  2496. <!-- 删除子明细的老数据 -->
  2497. <delete id="delFQCSubDetailedRecord" parameterType="QcSubDetailInformationData">
  2498. DELETE FROM qc_fqc_sub_detail_record
  2499. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2500. </delete>
  2501. <!-- 新增子明细信息 -->
  2502. <insert id="saveFQCSubDetailed">
  2503. INSERT INTO qc_fqc_sub_detail_record
  2504. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no)
  2505. VALUES
  2506. <foreach collection="list" item="item" separator=",">
  2507. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo})
  2508. </foreach>
  2509. </insert>
  2510. <!-- 查询FQC的子明细 -->
  2511. <select id="selectFQCSubDetailedRecord" parameterType="SubDetailValues" resultType="SubDetailValues">
  2512. SELECT
  2513. site,
  2514. bu_no,
  2515. sub_detail_value,
  2516. sampling_location,
  2517. is_submit,
  2518. sampling_location_b
  2519. FROM qc_fqc_sub_detail_record
  2520. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2521. </select>
  2522. <!-- 查询FQC检验记录是否已提交 -->
  2523. <select id="checkFQCIsSubmit" parameterType="SubDetailValues" resultType="QcFAIRecordData">
  2524. SELECT submit_flag
  2525. FROM qc_fqc_record
  2526. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2527. </select>
  2528. <!-- 获取该项目的子明细值 -->
  2529. <select id="selectFQCSubDetailValue" parameterType="string" resultType="SubDetailValues">
  2530. SELECT sub_detail_value,
  2531. sampling_location,
  2532. is_submit
  2533. FROM qc_fqc_sub_detail_record
  2534. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2535. </select>
  2536. <!-- 生成FQC检验单号 -->
  2537. <select id="selectFQCInspectionNo" resultType="string" parameterType="QcFAIRecordData">
  2538. SELECT
  2539. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2540. FROM qc_fqc_record
  2541. WHERE site = #{site} and bu_no = #{buNo}
  2542. </select>
  2543. <!-- 生成IPQC检验单号 -->
  2544. <select id="selectIPQCInspectionNo" resultType="string" parameterType="QcFAIRecordData">
  2545. SELECT
  2546. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  2547. FROM qc_ipqc_record
  2548. WHERE site = #{site} and bu_no = #{buNo}
  2549. </select>
  2550. <!-- 生成FAI检验单号 -->
  2551. <select id="selectFAIInspectionNo" resultType="string" parameterType="QcFAIRecordData">
  2552. SELECT
  2553. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2554. FROM qc_fai_record
  2555. WHERE site = #{site} and bu_no = #{buNo}
  2556. </select>
  2557. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  2558. <select id="queryDataFromViewPoOrder" resultType="PoOrderData" parameterType="QcFAIRecordData">
  2559. SELECT
  2560. site,
  2561. order_no,
  2562. item_no,
  2563. part_no,
  2564. part_desc,
  2565. spec,
  2566. supplier_id,
  2567. supplier_name,
  2568. order_qty,
  2569. created_date,
  2570. status,
  2571. citem_code,
  2572. citem_class,
  2573. sendto_address,
  2574. order_type
  2575. FROM view_po_order
  2576. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  2577. </select>
  2578. <!-- 向收货任务表里添加数据 -->
  2579. <insert id="saveReceivingTask" parameterType="PoOrderData">
  2580. 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)
  2581. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, #{createdDate}, #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo})
  2582. </insert>
  2583. <!-- 检查动控是否开启 -->
  2584. <select id="queryController" parameterType="SysSceneDynamicControlModelEntity" resultType="SysSceneDynamicControlModelEntity">
  2585. SELECT
  2586. type,
  2587. base_data,
  2588. base_desc,
  2589. status,
  2590. remark,
  2591. third_type,
  2592. second_type,
  2593. page_control,
  2594. control_style
  2595. FROM sys_scene_dynamic_control_model
  2596. where site = #{site} and control_no = #{controlNo}
  2597. </select>
  2598. <!-- 查询检验模板列表 -->
  2599. <select id="queryTemplateList" resultType="QcTemplateData" parameterType="QcTemplateData">
  2600. SELECT
  2601. site,
  2602. bu_no,
  2603. template_id as templateId,
  2604. template_name as templateName,
  2605. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2606. FROM qc_template
  2607. <where>
  2608. site = #{site} and bu_no = #{buNo}
  2609. <if test = "templateId != null and templateId != ''">
  2610. AND template_id LIKE '%' + #{templateId}+'%'
  2611. </if>
  2612. <if test = "templateName != null and templateName != ''">
  2613. AND template_name LIKE '%' + #{templateName}+'%'
  2614. </if>
  2615. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2616. AND inspection_type_no = #{inspectionTypeNo}
  2617. </if>
  2618. </where>
  2619. </select>
  2620. <!-- 查询检验模板列表 -->
  2621. <select id="getPartInformation" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2622. select
  2623. part_no,
  2624. part_desc,
  2625. spec,
  2626. sku
  2627. from part
  2628. where site = #{site} and part_no = #{partNo}
  2629. </select>
  2630. <!-- 获取特殊工序列表 -->
  2631. <select id="getSpecialOperationList" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2632. select
  2633. site,
  2634. operation_no,
  2635. operation_desc
  2636. from qc_special_task_operation
  2637. where site = #{site}
  2638. </select>
  2639. <!-- 获取处置措施列表 -->
  2640. <select id="disposalMeasuresSearch" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2641. SELECT
  2642. id,
  2643. disposal_measures
  2644. FROM qc_disposal_measures
  2645. <where>
  2646. <if test = "inspectionTypeNo != '101'">
  2647. inspection_type != 'IPQC'
  2648. </if>
  2649. </where>
  2650. </select>
  2651. <!-- 查询文件路径 -->
  2652. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="QcFAIRecordData">
  2653. SELECT
  2654. id,
  2655. url,
  2656. file_name
  2657. FROM sys_oss
  2658. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2659. </select>
  2660. <!-- 删除图片-->
  2661. <delete id="imageDelete" parameterType="SysOssEntity">
  2662. DELETE FROM sys_oss
  2663. WHERE id = #{id}
  2664. </delete>
  2665. <!-- 模糊查询标签号 -->
  2666. <select id="getRollNo" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2667. SELECT DISTINCT top 3
  2668. a.seqno,
  2669. a.orderno,
  2670. b.roll_no
  2671. FROM soscheduledrouting AS a
  2672. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  2673. WHERE a.site = #{site} and b.roll_no like '%' + #{rollNo} + '%'
  2674. </select>
  2675. <!-- 标签号回车事件 -->
  2676. <select id="rollNoEnter" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2677. SELECT
  2678. a.site,
  2679. a.seqno as seqNo,
  2680. a.orderno as orderNo,
  2681. b.roll_no
  2682. FROM soscheduledrouting AS a
  2683. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  2684. WHERE b.roll_no = #{rollNo}
  2685. </select>
  2686. <!-- 查询物料列表 -->
  2687. <select id="queryPartList" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2688. SELECT
  2689. site,
  2690. part_no,
  2691. part_desc,
  2692. sku,
  2693. spec
  2694. FROM part
  2695. <where>
  2696. site = #{site}
  2697. <if test = "partNo != null and partNo != ''">
  2698. AND part_no LIKE '%' + #{partNo} + '%'
  2699. </if>
  2700. <if test = "partDesc != null and partDesc != ''">
  2701. AND part_desc LIKE '%' + #{partDesc} + '%'
  2702. </if>
  2703. <if test = "sku != null and sku != ''">
  2704. AND sku LIKE '%' + #{sku} + '%'
  2705. </if>
  2706. </where>
  2707. </select>
  2708. <!-- 查询单位列表 -->
  2709. <select id="umSearch" resultType="QcFAIRecordData" parameterType="QcFAIRecordData">
  2710. SELECT
  2711. site,
  2712. UMID as umId,
  2713. UMName as umName
  2714. FROM UM
  2715. WHERE site = #{site} and active = #{active}
  2716. </select>
  2717. <!-- 查询单位列表 -->
  2718. <select id="checkItem" resultType="SubDetailValues" parameterType="SubDetailValues">
  2719. SELECT
  2720. site,
  2721. bu_no,
  2722. inspection_no,
  2723. item_no,
  2724. value_type_db,
  2725. min_value,
  2726. max_value
  2727. <if test = "flag == 'IPQC'">
  2728. FROM qc_ipqc_detailed_record
  2729. </if>
  2730. <if test = "flag == 'IQC'">
  2731. FROM qc_iqc_detailed_record
  2732. </if>
  2733. <if test = "flag == 'FQC'">
  2734. FROM qc_fqc_detailed_record
  2735. </if>
  2736. <if test = "flag == 'FAI'">
  2737. FROM qc_fai_detailed_record
  2738. </if>
  2739. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  2740. </select>
  2741. <!-- 查询检验方法列表 -->
  2742. <select id="queryMethodList" resultType="QcMethodData" parameterType="QcMethodData">
  2743. SELECT
  2744. site,
  2745. bu_no,
  2746. method_no,
  2747. method_name,
  2748. inspection_type_no,
  2749. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2750. FROM qc_method
  2751. <where>
  2752. site = #{site} and bu_no = #{buNo}
  2753. <if test = "methodNo != null and methodNo != ''">
  2754. AND method_no LIKE '%' + #{methodNo} + '%'
  2755. </if>
  2756. <if test = "methodName != null and methodName != ''">
  2757. AND method_name LIKE '%' + #{methodName} + '%'
  2758. </if>
  2759. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2760. AND inspection_type_no = #{inspectionTypeNo}
  2761. </if>
  2762. </where>
  2763. </select>
  2764. <!-- 修改detailFlag字段为N -->
  2765. <update id="updateIQCDetailFlag" parameterType="QcFAIRecordData">
  2766. UPDATE qc_iqc_record
  2767. SET detail_flag = 'N'
  2768. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2769. </update>
  2770. <!-- 查询检验方法唯一 -->
  2771. <select id="checkMethodOnlyOne" resultType="QcMethodData" parameterType="QcMethodData">
  2772. SELECT
  2773. site,
  2774. bu_no,
  2775. method_no
  2776. FROM qc_method
  2777. <where>
  2778. site = #{site} and bu_no = #{buNo} and method_no = #{methodNo}
  2779. </where>
  2780. </select>
  2781. <!-- 查询检验项目唯一 -->
  2782. <select id="checkItemOnlyOne" resultType="QcItemData" parameterType="QcItemData">
  2783. SELECT
  2784. site,
  2785. bu_no,
  2786. ItemNo,
  2787. ItemDesc
  2788. FROM eam_properties_item
  2789. <where>
  2790. site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ItemType = #{itemType}
  2791. </where>
  2792. </select>
  2793. <!-- 查询检验项目唯一 -->
  2794. <select id="checkTemplateOnlyOne" resultType="QcTemplateData" parameterType="QcTemplateData">
  2795. SELECT
  2796. site,
  2797. bu_no,
  2798. template_id,
  2799. template_name
  2800. FROM qc_template
  2801. <where>
  2802. site = #{site} and bu_no = #{buNo} and template_id = #{templateId}
  2803. </where>
  2804. </select>
  2805. <select id="searchSeqInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2806. SELECT DISTINCT
  2807. a.seqno,
  2808. a.orderno,
  2809. J.part_no,
  2810. J.part_desc,
  2811. t.lotsize,
  2812. a.qtyrequired,
  2813. c.operation_desc,
  2814. J.sku
  2815. FROM
  2816. soscheduledrouting AS a
  2817. inner JOIN so_routing AS c ON c.order_no = a.orderno
  2818. AND a.itemno = c.item_no
  2819. AND c.site = a.site
  2820. inner JOIN part AS J ON a.site = J.site
  2821. AND a.part_no = J.part_no
  2822. inner JOIN shoporder AS t ON t.orderno = a.orderno
  2823. AND a.site = t.site
  2824. WHERE
  2825. a.site = #{query.site}
  2826. AND t.status = '下达'
  2827. <if test="query.orderNo != null and query.orderNo != ''">
  2828. AND a.orderno LIKE '%' + #{query.orderNo} + '%'
  2829. </if>
  2830. <if test="query.seqNo != null and query.seqNo != ''">
  2831. AND a.seqno LIKE '%' + #{query.seqNo} + '%'
  2832. </if>
  2833. <if test="query.sku != null and query.sku != ''">
  2834. AND dbo.qc_get_sku(a.part_no) LIKE '%' + #{query.sku} + '%'
  2835. </if>
  2836. <if test="query.partNo != null and query.partNo != ''">
  2837. AND J.part_no LIKE '%' + #{query.partNo} + '%'
  2838. </if>
  2839. <if test="query.partDesc != null and query.partDesc != ''">
  2840. AND J.part_desc LIKE '%' + #{query.partDesc} + '%'
  2841. </if>
  2842. <if test="query.operationDesc != null and query.operationDesc != ''">
  2843. AND c.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2844. </if>
  2845. </select>
  2846. <select id="searchPartInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2847. select
  2848. part_no,
  2849. part_desc,
  2850. sku,
  2851. cinv_source_code
  2852. from
  2853. part
  2854. where
  2855. 1=1
  2856. <if test="query.partNo != null and query.partNo != ''">
  2857. AND part_no LIKE '%' + #{query.partNo} + '%'
  2858. </if>
  2859. <if test="query.partDesc != null and query.partDesc != ''">
  2860. AND part_desc LIKE '%' + #{query.partDesc} + '%'
  2861. </if>
  2862. <if test="query.sku != null and query.sku != ''">
  2863. AND sku LIKE '%' + #{query.sku} + '%'
  2864. </if>
  2865. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2866. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2867. </if>
  2868. </select>
  2869. </mapper>