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.

4239 lines
196 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
1 year ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
10 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
10 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
3 years ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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 year ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year 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="com.xujie.sys.modules.pms.data.QcMethodData" resultType="com.xujie.sys.modules.pms.data.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. dbo.getOperatorDesc(qm.site, qm.create_by) as createByDesc,
  16. qm.method_remark,
  17. qm.update_date,
  18. qm.update_by,
  19. dbo.getOperatorDesc(qm.site, qm.update_by) as updateByDesc,
  20. qm.inspection_type_no,
  21. qit.inspection_type_name
  22. FROM qc_method as qm
  23. LEFT JOIN qc_inspection_type as qit on qm.site = qit.site and qm.inspection_type_no = qit.inspection_type_no
  24. <where>
  25. qm.site in (select site from eam_access_site where username = #{query.userName})
  26. and (qm.site + '-' + qm.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  27. <if test="query.buDesc != null and query.buDesc != ''">
  28. AND dbo.get_bu_desc ( qm.site, qm.bu_no ) = #{query.buDesc}
  29. </if>
  30. <if test="query.methodNo != null and query.methodNo != ''">
  31. AND qm.method_no LIKE '%' + #{query.methodNo} +'%'
  32. </if>
  33. <if test="query.methodName != null and query.methodName != ''">
  34. AND qm.method_name LIKE '%' + #{query.methodName} +'%'
  35. </if>
  36. <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  37. AND qm.inspection_type_no = #{query.inspectionTypeNo}
  38. </if>
  39. </where>
  40. </select>
  41. <!-- 获得检验方法单号 -->
  42. <select id="getMethodNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  43. SELECT
  44. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(method_no,4))),0)+1),4)
  45. FROM qc_method
  46. WHERE site = #{site} AND inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  47. </select>
  48. <!-- 新增检验方法 -->
  49. <insert id="qcMethodSave" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  50. INSERT INTO qc_method (site, bu_no, method_no, method_name, create_date, create_by, method_remark, update_date, update_by, inspection_type_no)
  51. VALUES (#{site}, #{buNo}, #{methodNo}, #{methodName}, GetDate(), #{createBy}, #{methodRemark}, getDate(), #{updateBy}, #{inspectionTypeNo})
  52. </insert>
  53. <!-- 修改检验方法 -->
  54. <update id="qcMethodUpdate" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  55. UPDATE qc_method
  56. SET method_name = #{methodName},
  57. method_remark = #{methodRemark},
  58. update_date = getDate(),
  59. update_by = #{updateBy},
  60. inspection_type_no = #{inspectionTypeNo}
  61. WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
  62. </update>
  63. <!-- 检查方法是否在被项目使用 -->
  64. <select id="checkMethodIsUsed" parameterType="com.xujie.sys.modules.pms.data.QcMethodData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  65. SELECT
  66. ItemNo
  67. FROM qc_method_item
  68. WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
  69. </select>
  70. <!-- 删除检验方法 -->
  71. <delete id="qcMethodDelete" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  72. DELETE FROM qc_method
  73. WHERE site = #{site} and method_no = #{methodNo} and bu_no = #{buNo}
  74. </delete>
  75. <!-- ================================================= 检验项目 ================================================= -->
  76. <!-- 根据条件查询检验项目 -->
  77. <select id="qcItemSearch" parameterType="com.xujie.sys.modules.pms.data.QcItemData" resultType="com.xujie.sys.modules.pms.data.QcItemData">
  78. SELECT
  79. epi.site,
  80. epi.bu_no,
  81. dbo.get_bu_desc(epi.site, epi.bu_no) as buDesc,
  82. epi.ItemNo,
  83. epi.ItemDesc,
  84. epi.DefaultValue,
  85. epi.ValueType,
  86. epi.ValueType_DB as valueTypeDb,
  87. epi.ValueChooseFlag,
  88. epi.CreatedDate,
  89. epi.CreatedBy,
  90. dbo.getOperatorDesc(epi.site, epi.CreatedBy) as createdByDesc,
  91. epi.MaxValue,
  92. epi.MinValue,
  93. epi.ItemRemark,
  94. epi.ItemType,
  95. epi.update_date,
  96. epi.update_by,
  97. dbo.getOperatorDesc(epi.site, epi.update_by) as updateByDesc,
  98. qm.method_no,
  99. qm.method_name,
  100. qm.method_remark,
  101. epi.inspection_type_no,
  102. qit.inspection_type_name,
  103. epi.item_sampling_quantity,
  104. epi.sampling_programme_no,
  105. qsip.sampling_programme_desc,
  106. epi.sampling_level_no,
  107. qsil.sampling_level_desc,
  108. epi.default_sampling_proportion,
  109. epi.collection_flag,
  110. epi.collection_source,
  111. epi.collection_method,
  112. CASE WHEN epi.collection_method = 'plc' THEN 'PLC'
  113. WHEN epi.collection_method = 'file' THEN '文件'
  114. WHEN epi.collection_method = 'image' THEN '图片'
  115. else '' end as collectionMethodDesc,
  116. epi.collection_condition,
  117. epi.collection_data_content
  118. FROM eam_properties_item as epi
  119. LEFT JOIN qc_method_item as qmi on epi.ItemNo = qmi.ItemNo and epi.site = qmi.site and epi.bu_no = qmi.bu_no
  120. 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
  121. LEFT JOIN qc_inspection_type as qit on qit.inspection_type_no = epi.inspection_type_no and qit.site = epi.site
  122. 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
  123. 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
  124. <where>
  125. epi.site in (select site from eam_access_site where username = #{query.userName})
  126. and (epi.site + '-' + epi.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  127. and epi.ItemType = #{query.itemType}
  128. <if test="query.buDesc != null and query.buDesc != ''">
  129. AND dbo.get_bu_desc ( epi.site, epi.bu_no ) = #{query.buDesc}
  130. </if>
  131. <if test="query.itemDesc != null and query.itemDesc != ''">
  132. AND epi.ItemDesc LIKE '%' + #{query.itemDesc} +'%'
  133. </if>
  134. <if test="query.itemNo != null and query.itemNo != ''">
  135. AND epi.ItemNo LIKE '%' + #{query.itemNo} +'%'
  136. </if>
  137. <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  138. AND epi.inspection_type_no = #{query.inspectionTypeNo}
  139. </if>
  140. </where>
  141. </select>
  142. <!-- 检测是否存在该项目 -->
  143. <select id="checkQcItem" parameterType="com.xujie.sys.modules.pms.data.QcItemData" resultType="com.xujie.sys.modules.pms.data.QcItemData">
  144. SELECT ItemNo,
  145. ItemDesc
  146. FROM eam_properties_item
  147. WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType}
  148. </select>
  149. <!-- 获得检验项目单号 -->
  150. <select id="getItemNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  151. SELECT
  152. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(ItemNo,4))),0)+1),4)
  153. FROM eam_properties_item
  154. WHERE site = #{site} and ItemType = 'D' and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  155. </select>
  156. <!-- 新增检验项目 -->
  157. <insert id="qcItemSave" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  158. INSERT INTO eam_properties_item (site, bu_no, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, CreatedDate, CreatedBy, MaxValue, MinValue, ItemRemark, ItemType, update_date, update_by, inspection_type_no, item_sampling_quantity, sampling_programme_no, sampling_level_no, default_sampling_proportion, collection_flag, collection_source, collection_method, collection_condition, collection_data_content)
  159. VALUES (#{site}, #{buNo}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag}, GetDate(), #{createdBy}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{itemRemark}, #{itemType}, getDate(), #{updateBy}, #{inspectionTypeNo}, #{itemSamplingQuantity}, #{samplingProgrammeNo}, #{samplingLevelNo}, #{defaultSamplingProportion}, #{collectionFlag}, #{collectionSource}, #{collectionMethod}, #{collectionCondition}, #{collectionDataContent})
  160. </insert>
  161. <!-- 新增项目里的方法 -->
  162. <insert id="qcItemMethodSave" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  163. INSERT INTO qc_method_item (ItemNo, method_no, site, bu_no)
  164. VALUES (#{itemNo}, #{methodNo}, #{site}, #{buNo})
  165. </insert>
  166. <!-- 修改检验项目 -->
  167. <update id="qcItemUpdate" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  168. UPDATE eam_properties_item
  169. SET ItemDesc = #{itemDesc},
  170. DefaultValue = #{defaultValue},
  171. ValueType = #{valueType},
  172. ValueType_DB = #{valueTypeDb},
  173. ValueChooseFlag = #{valueChooseFlag},
  174. MaxValue = #{maxValue,jdbcType=DECIMAL},
  175. MinValue = #{minValue,jdbcType=DECIMAL},
  176. ItemRemark = #{itemRemark},
  177. update_date = getDate(),
  178. update_by = #{updateBy},
  179. inspection_type_no = #{inspectionTypeNo},
  180. item_sampling_quantity = #{itemSamplingQuantity},
  181. sampling_programme_no = #{samplingProgrammeNo},
  182. sampling_level_no = #{samplingLevelNo},
  183. default_sampling_proportion = #{defaultSamplingProportion},
  184. collection_flag = #{collectionFlag},
  185. collection_source = #{collectionSource},
  186. collection_method = #{collectionMethod},
  187. collection_condition = #{collectionCondition},
  188. collection_data_content = #{collectionDataContent}
  189. WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo}
  190. </update>
  191. <!-- 修改项目中的方法 -->
  192. <update id="qcItemMethodUpdate" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  193. UPDATE qc_method_item
  194. SET method_no = #{methodNo}
  195. WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
  196. </update>
  197. <!-- 检查项目是否在被模板使用 -->
  198. <select id="checkItemIsUsed" parameterType="com.xujie.sys.modules.pms.data.QcItemData" resultType="EamPropertiesModelDetailData">
  199. SELECT template_id
  200. FROM qc_template_detailed
  201. WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
  202. </select>
  203. <!-- 删除检验项目 -->
  204. <delete id="qcItemDelete" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  205. DELETE
  206. FROM eam_properties_item
  207. WHERE site = #{site} and ItemNo = #{itemNo} and ItemType = #{itemType} and bu_no = #{buNo}
  208. </delete>
  209. <!-- 删除项目-方法中间表数据 -->
  210. <delete id="qcItemMethodDelete" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  211. DELETE
  212. FROM qc_method_item
  213. WHERE site = #{site} and ItemNo = #{itemNo} and bu_no = #{buNo}
  214. </delete>
  215. <!-- ================================================= 质检员信息维护 ================================================= -->
  216. <!-- 查询质检员信息列表 -->
  217. <select id="inspectorSearch" resultType="com.xujie.sys.modules.pms.data.QcInspectorData">
  218. SELECT inspector_no,
  219. inspector_name,
  220. inspector_phone,
  221. inspector_type,
  222. inspector_active
  223. FROM qc_inspector
  224. </select>
  225. <!-- 检验是否已存在该质检员 -->
  226. <select id="checkInspector" resultType="com.xujie.sys.modules.pms.data.QcInspectorData">
  227. SELECT inspector_name
  228. FROM qc_inspector
  229. WHERE inspector_no = #{inspectorNo}
  230. </select>
  231. <!-- 新增质检员 -->
  232. <insert id="inspectorSave" parameterType="com.xujie.sys.modules.pms.data.QcInspectorData">
  233. INSERT INTO qc_inspector (inspector_no, inspector_name, inspector_phone, inspector_type, inspector_active, create_time)
  234. VALUES (#{inspectorNo}, #{inspectorName}, #{inspectorPhone}, #{inspectorType}, #{inspectorActive}, getDate())
  235. </insert>
  236. <!-- 修改质检员 -->
  237. <update id="inspectorUpdate" parameterType="com.xujie.sys.modules.pms.data.QcInspectorData">
  238. UPDATE qc_inspector
  239. SET inspector_name = #{inspectorName},
  240. inspector_phone = #{inspectorPhone},
  241. inspector_type = #{inspectorType},
  242. inspector_active = #{inspectorActive}
  243. WHERE inspector_no = #{inspectorNo}
  244. </update>
  245. <!-- 删除质检员 -->
  246. <delete id="inspectorDelete" parameterType="com.xujie.sys.modules.pms.data.QcInspectorData">
  247. DELETE FROM qc_inspector
  248. WHERE inspector_no = #{inspectorNo}
  249. </delete>
  250. <!-- ================================================= 抽样矩阵维护 ================================================= -->
  251. <!-- 查询抽样矩阵 -->
  252. <select id="samplingInspectionPlanSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  253. SELECT
  254. qsip.site,
  255. qsip.bu_no,
  256. dbo.get_bu_desc(qsip.site, qsip.bu_no) as buDesc,
  257. qsip.sampling_plan_no,
  258. qsip.sampling_plan_desc,
  259. qsip.sampling_qty_no,
  260. qsiq.sampling_qty,
  261. qsiq.sampling_qty_desc,
  262. qsip.sampling_qty_rank_no,
  263. qsiqr.sampling_qty_rank_desc,
  264. qsiqr.min_qty,
  265. qsiqr.max_qty,
  266. qsip.sampling_level_no,
  267. qsil.sampling_level_desc,
  268. qsip.sampling_plan_active,
  269. case when qsip.sampling_plan_active = 'Y' then '是' when qsip.sampling_plan_active = 'N' then '否' else '' end as samplingPlanActiveDesc,
  270. qsip.create_date,
  271. qsip.create_by,
  272. dbo.getOperatorDesc(qsip.site, qsip.create_by) as createByDesc,
  273. qsip.update_date,
  274. qsip.update_by,
  275. dbo.getOperatorDesc(qsip.site, qsip.update_by) as updateByDesc
  276. FROM qc_sampling_inspection_plan as qsip
  277. 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
  278. 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
  279. 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
  280. <where>
  281. qsip.site in (select site from eam_access_site where username = #{query.userName})
  282. and (qsip.site + '-' + qsip.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  283. <if test="query.buDesc != null and query.buDesc != ''">
  284. AND dbo.get_bu_desc ( qsip.site, qsip.bu_no ) = #{query.buDesc}
  285. </if>
  286. <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''">
  287. AND qsiq.sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc}+'%'
  288. </if>
  289. <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''">
  290. AND qsil.sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%'
  291. </if>
  292. <if test="query.samplingPlanActive != null and query.samplingPlanActive != ''">
  293. AND qsip.sampling_plan_active = #{query.samplingPlanActive}
  294. </if>
  295. </where>
  296. </select>
  297. <!-- 根据三个编码查矩阵 -->
  298. <select id="selectSamplingPlanByNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  299. SELECT
  300. site,
  301. bu_no,
  302. sampling_plan_no,
  303. sampling_qty_no,
  304. sampling_qty_rank_no,
  305. sampling_level_no,
  306. sampling_plan_active
  307. FROM qc_sampling_inspection_plan
  308. WHERE sampling_qty_no = #{samplingQtyNo} AND sampling_qty_rank_no = #{samplingQtyRankNo} AND sampling_level_no = #{samplingLevelNo} AND site = #{site} and bu_no = #{buNo}
  309. </select>
  310. <!-- 根据名称查矩阵 -->
  311. <select id="selectSamplingPlanByDesc" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  312. SELECT
  313. site,
  314. bu_no,
  315. sampling_plan_no,
  316. sampling_qty_no,
  317. sampling_qty_rank_no,
  318. sampling_level_no,
  319. sampling_plan_active
  320. FROM qc_sampling_inspection_plan
  321. WHERE sampling_plan_desc = #{samplingPlanDesc} AND site = #{site} and bu_no = #{buNo}
  322. </select>
  323. <!-- 获取最大方矩阵编码 -->
  324. <select id="queryLastSamplingPlanNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  325. SELECT top 1 sampling_plan_no
  326. FROM qc_sampling_inspection_plan
  327. where site = #{site} and bu_no = #{buNo}
  328. ORDER BY sampling_plan_no Desc
  329. </select>
  330. <!-- 新增抽样矩阵 -->
  331. <insert id="samplingInspectionPlanSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  332. 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)
  333. VALUES (#{site}, #{buNo}, #{samplingPlanNo}, #{samplingPlanDesc}, #{samplingQtyRankNo}, #{samplingLevelNo}, #{samplingQtyNo}, #{samplingPlanActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  334. </insert>
  335. <!-- 修改抽样矩阵 -->
  336. <update id="samplingInspectionPlanUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  337. UPDATE qc_sampling_inspection_plan
  338. SET sampling_qty_rank_no = #{samplingQtyRankNo},
  339. sampling_level_no = #{samplingLevelNo},
  340. sampling_qty_no = #{samplingQtyNo},
  341. sampling_plan_active = #{samplingPlanActive},
  342. update_date = getDate(),
  343. update_by = #{updateBy}
  344. WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo}
  345. </update>
  346. <!-- 删除抽样矩阵 -->
  347. <delete id="samplingInspectionPlanDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData">
  348. DELETE FROM qc_sampling_inspection_plan
  349. WHERE sampling_plan_no = #{samplingPlanNo} AND site = #{site} and bu_no = #{buNo}
  350. </delete>
  351. <!-- ================================================= 检验模板维护 ================================================= -->
  352. <!-- 查询模板 -->
  353. <select id="templateSearch" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  354. SELECT
  355. qt.site,
  356. qt.bu_no,
  357. dbo.get_bu_desc(qt.site, qt.bu_no) as buDesc,
  358. qt.template_id,
  359. qt.template_name,
  360. qt.template_remark,
  361. qt.template_type,
  362. qt.template_version,
  363. qt.sampling_programme_no,
  364. qsip.sampling_programme_Desc,
  365. qt.inspection_type_no,
  366. qit.inspection_type_name,
  367. qt.sampling_level_no,
  368. qsil.sampling_level_desc,
  369. qt.inspection_cycle,
  370. qt.create_time,
  371. qt.create_by,
  372. dbo.getOperatorDesc(qt.site, qt.create_by) as createByDesc,
  373. qt.update_date,
  374. qt.update_by,
  375. dbo.getOperatorDesc(qt.site, qt.update_by) as updateByDesc,
  376. qt.AQL,
  377. qt.AC,
  378. qt.RE,
  379. qt.default_sampling_quantity,
  380. qt.default_sampling_proportion
  381. FROM qc_template as qt
  382. LEFT JOIN qc_inspection_type as qit on qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  383. 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
  384. 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
  385. <where>
  386. qt.site in (select site from eam_access_site where username = #{query.userName})
  387. and (qt.site + '-' + qt.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  388. <if test="query.buDesc != null and query.buDesc != ''">
  389. AND dbo.get_bu_desc ( qt.site, qt.bu_no ) = #{query.buDesc}
  390. </if>
  391. <if test = "query.templateId != null and query.templateId != ''">
  392. AND qt.template_id LIKE '%' + #{query.templateId}+'%'
  393. </if>
  394. <if test = "query.templateName != null and query.templateName != ''">
  395. AND qt.template_name LIKE '%' + #{query.templateName}+'%'
  396. </if>
  397. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  398. AND qt.inspection_type_no = #{query.inspectionTypeNo}
  399. </if>
  400. </where>
  401. </select>
  402. <!-- 获得检验模板单号 -->
  403. <select id="getTemplateNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  404. SELECT
  405. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(template_id,3))),0)+1),3)
  406. FROM qc_template
  407. WHERE site = #{site} and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  408. </select>
  409. <!-- 新增模板 -->
  410. <insert id="templateSave" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  411. 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)
  412. VALUES (#{site}, #{buNo}, #{templateId}, #{templateName},#{templateVersion}, #{templateRemark}, #{templateType}, #{samplingProgrammeNo}, #{inspectionTypeNo}, getDate(), #{createBy}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{aql}, #{ac}, #{re}, #{defaultSamplingQuantity}, #{defaultSamplingProportion}, getDate(), #{updateBy})
  413. </insert>
  414. <!-- 修改模板 -->
  415. <update id="templateUpdate" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  416. UPDATE qc_template
  417. SET template_name = #{templateName},
  418. template_version = #{templateVersion},
  419. template_remark = #{templateRemark},
  420. template_type = #{templateType},
  421. sampling_programme_no = #{samplingProgrammeNo},
  422. inspection_cycle = #{inspectionCycle},
  423. inspection_type_no = #{inspectionTypeNo},
  424. sampling_level_no = #{samplingLevelNo},
  425. AQL = #{aql},
  426. AC = #{ac},
  427. RE = #{re},
  428. default_sampling_quantity = #{defaultSamplingQuantity},
  429. default_sampling_proportion = #{defaultSamplingProportion},
  430. update_date = getDate(),
  431. update_by = #{updateBy}
  432. WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
  433. </update>
  434. <!-- 查询模板里的项目详情 -->
  435. <select id="templateDetailsSearch" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  436. SELECT
  437. a.site,
  438. a.bu_no,
  439. a.template_id,
  440. a.ItemNo,
  441. b.ItemDesc,
  442. a.default_value,
  443. b.ValueType,
  444. b.ValueType_DB,
  445. a.max_value,
  446. a.min_value,
  447. b.ItemRemark,
  448. b.ItemType,
  449. a.object_id,
  450. eo.objectDesc,
  451. b.item_sampling_quantity,
  452. b.sampling_programme_no,
  453. c.sampling_programme_desc,
  454. b.sampling_level_no,
  455. d.sampling_level_desc,
  456. b.default_sampling_proportion,a.order_id
  457. FROM qc_template_detailed a
  458. LEFT JOIN eam_properties_item b ON a.ItemNo = b.ItemNo and a.site = b.site and a.bu_no = b.bu_no
  459. 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
  460. 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
  461. LEFT JOIN eam_object eo ON a.object_id = eo.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  462. WHERE a.template_id = #{templateId} AND b.ItemType = #{itemType} and a.site = #{site} and a.bu_no = #{buNo}
  463. order by order_id,ItemNo
  464. </select>
  465. <!-- 查询模板里是否已存在该项目 -->
  466. <select id="selectItemDetails" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  467. SELECT template_id,
  468. ItemNo,
  469. default_value,
  470. max_value,
  471. min_value
  472. FROM qc_template_detailed
  473. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  474. </select>
  475. <!-- 查询项目的最大最小值 -->
  476. <select id="selectDetail" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  477. SELECT ItemNo,
  478. DefaultValue,
  479. MaxValue,
  480. MinValue
  481. FROM eam_properties_item
  482. WHERE ItemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  483. </select>
  484. <!-- 新增模板的检验项目 -->
  485. <insert id="addItemDetails" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  486. INSERT INTO qc_template_detailed (template_id, ItemNo, default_value, max_value, min_value, site, bu_no,order_id)
  487. VALUES (#{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{site}, #{buNo},#{orderId})
  488. </insert>
  489. <!-- 删除模板的检验项目 -->
  490. <delete id="delItemDetails" >
  491. DELETE FROM qc_template_detailed
  492. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  493. </delete>
  494. <!-- 获取当前模板不包含的项目 -->
  495. <select id="getItemList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  496. SELECT
  497. a.site,
  498. a.bu_no,
  499. a.itemNo,
  500. a.ItemDesc,
  501. a.DefaultValue,
  502. a.MaxValue,
  503. a.MinValue
  504. FROM eam_properties_item a
  505. 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
  506. WHERE a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo} and dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) = #{inspectionTypeName}
  507. </select>
  508. <!-- 查询项目 -->
  509. <select id="getItem" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  510. SELECT
  511. a.site,
  512. a.bu_no,
  513. a.itemNo,
  514. a.ItemDesc,
  515. a.DefaultValue,
  516. a.MaxValue,
  517. a.MinValue
  518. FROM eam_properties_item a
  519. 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
  520. <where>
  521. a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo} and dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) = #{inspectionTypeName}
  522. <if test = "itemNo != null and itemNo != ''">
  523. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  524. </if>
  525. <if test = "itemDesc != null and itemDesc != ''">
  526. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  527. </if>
  528. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  529. AND a.inspection_type_no = #{inspectionTypeNo}
  530. </if>
  531. </where>
  532. </select>
  533. <!-- 删除模板 -->
  534. <delete id="templateDelete" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  535. DELETE FROM qc_template
  536. WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
  537. </delete>
  538. <!-- 删除模板-项目中间表 -->
  539. <delete id="itemItemDelete" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  540. DELETE FROM qc_template_detailed
  541. WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
  542. </delete>
  543. <!-- 搜索所有检验类型 -->
  544. <select id="inspectionTypeSearch" resultType="com.xujie.sys.modules.pms.data.QcInspectionTypeData" parameterType="com.xujie.sys.modules.pms.data.QcInspectionTypeData">
  545. SELECT inspection_type_no,
  546. inspection_type_name
  547. FROM qc_inspection_type
  548. WHERE site = #{site}
  549. </select>
  550. <!-- 搜索所有设备 -->
  551. <select id="objectSearch" resultType="EamObjectData">
  552. SELECT
  553. ObjectID,
  554. ObjectDesc
  555. FROM eam_object
  556. WHERE Active = 'Y' and site = #{site} and bu_no = #{buNo}
  557. </select>
  558. <!-- 导入文件检验 -->
  559. <select id="getItemByItemNo" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  560. SELECT ItemDesc,
  561. ItemType
  562. FROM eam_properties_item
  563. WHERE ItemDesc = #{itemDesc}
  564. AND DefaultValue = #{defaultValue}
  565. AND MaxValue = #{maxValue}
  566. AND MinValue = #{minValue}
  567. AND ItemType = #{itemType}
  568. </select>
  569. <!-- 新增检验项目 -->
  570. <insert id="insertItem" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  571. INSERT INTO eam_properties_item (ItemNo, ItemDesc,DefaultValue,ValueType,ValueType_DB, CreatedDate,CreatedBy,MaxValue, MinValue, ItemRemark,ItemType)
  572. VALUES(#{itemNo},#{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, GetDate(), #{createdBy}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{itemRemark}, #{itemType})
  573. </insert>
  574. <!-- &lt;!&ndash; 获取最大项目编码 &ndash;&gt;-->
  575. <!-- <select id="queryLastItemNo" resultType="string" parameterType="QcItemData">-->
  576. <!-- SELECT top 1 ItemNo-->
  577. <!-- FROM eam_properties_item-->
  578. <!-- WHERE ItemType = #{itemType}-->
  579. <!-- ORDER BY ItemNo Desc-->
  580. <!-- </select>-->
  581. <!-- 根据模板名称查询模板 -->
  582. <select id="selectTemplateByDesc" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  583. SELECT template_id,
  584. template_name,
  585. template_version
  586. FROM qc_template
  587. WHERE template_name = #{templateName}
  588. AND site = #{site}
  589. AND template_version = #{templateVersion}
  590. </select>
  591. <delete id="delTemplateItem" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  592. delete qc_template_detailed
  593. WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
  594. </delete>
  595. <!-- &lt;!&ndash; 修改项目明细的最大最小值 &ndash;&gt;-->
  596. <!-- <insert id="saveItemDetailed">-->
  597. <!-- INSERT INTO qc_template_detailed-->
  598. <!-- (site, bu_no, template_id, ItemNo, default_value, max_value, min_value)-->
  599. <!-- VALUES-->
  600. <!-- <foreach collection="list" item="item" separator=",">-->
  601. <!-- (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.maxValue,jdbcType=DECIMAL}, #{item.minValue,jdbcType=DECIMAL})-->
  602. <!-- </foreach>-->
  603. <!-- </insert>-->
  604. <!-- 修改项目明细的最大最小值 -->
  605. <insert id="saveItemDetailed">
  606. INSERT INTO qc_template_detailed
  607. (site, bu_no, template_id, ItemNo, default_value, max_value, min_value)
  608. VALUES
  609. (#{site}, #{buNo}, #{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL})
  610. </insert>
  611. <!-- 查询项目明细 -->
  612. <select id="selectItem" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  613. SELECT ItemNo,
  614. ItemDesc,
  615. DefaultValue,
  616. ValueType,
  617. ValueType_DB,
  618. MaxValue,
  619. MinValue,
  620. ItemRemark,
  621. ItemType
  622. FROM eam_properties_item
  623. WHERE ItemNo = #{itemNo} AND ItemType = #{itemType}
  624. </select>
  625. <!-- ================================================= 样本量维护 ================================================= -->
  626. <!-- 查询样本量 -->
  627. <select id="samplingQtySearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  628. SELECT
  629. site,
  630. bu_no,
  631. dbo.get_bu_desc(site, bu_no) as buDesc,
  632. sampling_qty_no,
  633. sampling_qty_desc,
  634. sampling_qty,
  635. sampling_qty_remark,
  636. sampling_qty_active,
  637. case when sampling_qty_active = 'Y' then '是' when sampling_qty_active = 'N' then '否' else '' end as samplingQtyActiveDesc,
  638. create_date,
  639. create_by,
  640. dbo.getOperatorDesc(site, create_by) as createByDesc,
  641. update_date,
  642. update_by,
  643. dbo.getOperatorDesc(site, update_by) as updateByDesc
  644. FROM qc_sampling_inspection_qty
  645. <where>
  646. site in (select site from eam_access_site where username = #{query.userName})
  647. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  648. <if test="query.buDesc != null and query.buDesc != ''">
  649. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  650. </if>
  651. <if test="query.samplingQtyNo != null and query.samplingQtyNo != ''">
  652. AND sampling_qty_no LIKE '%' + #{query.samplingQtyNo} + '%'
  653. </if>
  654. <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''">
  655. AND sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc} + '%'
  656. </if>
  657. <if test="query.samplingQty != null">
  658. AND sampling_qty = #{query.samplingQty,jdbcType=DECIMAL}
  659. </if>
  660. <if test="query.samplingQtyActive != null and query.samplingQtyActive != ''">
  661. AND sampling_qty_active = #{query.samplingQtyActive}
  662. </if>
  663. </where>
  664. </select>
  665. <!-- 新增样本量 -->
  666. <insert id="samplingQtySave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  667. 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)
  668. VALUES(#{site}, #{buNo}, #{samplingQtyNo}, #{samplingQty,jdbcType=DECIMAL}, #{samplingQtyRemark}, #{samplingQtyActive}, #{samplingQtyDesc}, getDate(), #{createBy}, getDate(), #{updateBy})
  669. </insert>
  670. <!-- 根据样本量字码查询样本量 -->
  671. <select id="selectSamplingQtyByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  672. SELECT
  673. site,
  674. bu_no,
  675. sampling_qty_no,
  676. sampling_qty_desc,
  677. sampling_qty,
  678. sampling_qty_remark,
  679. sampling_qty_active
  680. FROM qc_sampling_inspection_qty
  681. WHERE sampling_qty_desc = #{samplingQtyDesc} AND site = #{site} and bu_no = #{buNo}
  682. </select>
  683. <!-- 获取最大样本量编码 -->
  684. <select id="queryLastSamplingQtyNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  685. SELECT top 1 sampling_qty_no
  686. FROM qc_sampling_inspection_qty
  687. where site = #{site} and bu_no = #{buNo}
  688. ORDER BY sampling_qty_no Desc
  689. </select>
  690. <!-- 修改样本量 -->
  691. <update id="samplingQtyUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  692. UPDATE qc_sampling_inspection_qty
  693. SET sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  694. sampling_qty_desc = #{samplingQtyDesc},
  695. sampling_qty_remark = #{samplingQtyRemark},
  696. sampling_qty_active = #{samplingQtyActive},
  697. update_date = getDate(),
  698. update_by = #{updateBy}
  699. WHERE sampling_qty_no = #{samplingQtyNo} AND site = #{site} and bu_no = #{buNo}
  700. </update>
  701. <!-- 根据样本量编码查询矩阵 -->
  702. <select id="selectSamplingPlanBySamplingQtyNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  703. SELECT
  704. site,
  705. sampling_plan_no,
  706. sampling_qty_no,
  707. sampling_qty_rank_no,
  708. sampling_level_no,
  709. sampling_plan_active
  710. FROM qc_sampling_inspection_plan
  711. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} and bu_no = #{buNo}
  712. </select>
  713. <!-- 删除样本量 -->
  714. <delete id="samplingQtyDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  715. DELETE FROM qc_sampling_inspection_qty
  716. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} AND sampling_qty_desc = #{samplingQtyDesc} and bu_no = #{buNo}
  717. </delete>
  718. <!-- ================================================= 批量级次维护 ================================================= -->
  719. <!-- 查询批量级次 -->
  720. <select id="samplingQtyRankSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  721. SELECT
  722. site,
  723. bu_no,
  724. dbo.get_bu_desc(site, bu_no) as buDesc,
  725. sampling_qty_rank_no,
  726. sampling_qty_rank_desc,
  727. min_qty,
  728. max_qty,
  729. sampling_qty_rank_active,
  730. case when sampling_qty_rank_active = 'Y' then '是' when sampling_qty_rank_active = 'N' then '否' else '' end as samplingQtyRankActiveDesc,
  731. sampling_qty_rank_Remark,
  732. create_date,
  733. create_by,
  734. dbo.getOperatorDesc(site, create_by) as createByDesc,
  735. update_date,
  736. update_by,
  737. dbo.getOperatorDesc(site, update_by) as updateByDesc
  738. FROM qc_sampling_inspection_qty_rank
  739. <where>
  740. site in (select site from eam_access_site where username = #{query.userName})
  741. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  742. <if test="query.buDesc != null and query.buDesc != ''">
  743. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  744. </if>
  745. <if test="query.samplingQtyRankNo != null and query.samplingQtyRankNo != ''">
  746. AND sampling_qty_rank_no LIKE '%' + #{query.samplingQtyRankNo}+'%'
  747. </if>
  748. <if test="query.samplingQtyRankDesc != null and query.samplingQtyRankDesc != ''">
  749. AND sampling_qty_rank_desc LIKE '%' + #{query.samplingQtyRankDesc}+'%'
  750. </if>
  751. <if test="query.samplingQtyRankActive != null and query.samplingQtyRankActive != ''">
  752. AND sampling_qty_rank_active = #{query.samplingQtyRankActive}
  753. </if>
  754. </where>
  755. </select>
  756. <!-- 根据名称查询批量级次 -->
  757. <select id="selectSamplingQtyRankByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  758. SELECT
  759. site,
  760. bu_no,
  761. sampling_qty_rank_no,
  762. sampling_qty_rank_desc,
  763. min_qty,
  764. max_qty,
  765. sampling_qty_rank_active,
  766. sampling_qty_rank_Remark
  767. FROM qc_sampling_inspection_qty_rank
  768. WHERE sampling_qty_rank_desc = #{samplingQtyRankDesc} AND site = #{site} and bu_no = #{buNo}
  769. </select>
  770. <!-- 获取最大批量级次编码 -->
  771. <select id="queryLastSamplingQtyRankNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  772. SELECT top 1 sampling_qty_rank_no
  773. FROM qc_sampling_inspection_qty_rank
  774. where site = #{site} and bu_no = #{buNo}
  775. ORDER BY sampling_qty_rank_no Desc
  776. </select>
  777. <!-- 新增批量级次 -->
  778. <insert id="samplingQtyRankSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  779. 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)
  780. VALUES(#{site}, #{buNo}, #{samplingQtyRankNo}, #{samplingQtyRankDesc}, #{minQty,jdbcType=DECIMAL}, #{maxQty,jdbcType=DECIMAL}, #{samplingQtyRankRemark}, #{samplingQtyRankActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  781. </insert>
  782. <!-- 根据批量级次编码查询矩阵 -->
  783. <select id="selectSamplingPlanBySamplingQtyRankNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  784. SELECT
  785. site,
  786. bu_no,
  787. sampling_plan_no,
  788. sampling_qty_no,
  789. sampling_qty_rank_no,
  790. sampling_level_no,
  791. sampling_plan_active
  792. FROM qc_sampling_inspection_plan
  793. WHERE site = #{site} AND sampling_qty_rank_no = #{samplingQtyRankNo} and bu_no = #{buNo}
  794. </select>
  795. <!-- 修改批量级次 -->
  796. <update id="samplingQtyRankUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  797. UPDATE qc_sampling_inspection_qty_rank
  798. SET sampling_qty_rank_desc = #{samplingQtyRankDesc},
  799. min_qty = #{minQty,jdbcType=DECIMAL},
  800. max_qty = #{maxQty,jdbcType=DECIMAL},
  801. sampling_qty_rank_Remark = #{samplingQtyRankRemark},
  802. sampling_qty_rank_active = #{samplingQtyRankActive},
  803. update_date = getDate(),
  804. update_by = #{updateBy}
  805. WHERE sampling_qty_rank_no = #{samplingQtyRankNo} AND site = #{site} and bu_no = #{buNo}
  806. </update>
  807. <!-- 删除批量级次 -->
  808. <delete id="samplingQtyRankDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  809. DELETE FROM qc_sampling_inspection_qty_rank
  810. WHERE site = #{site} and bu_no = #{buNo}
  811. AND sampling_qty_rank_no = #{samplingQtyRankNo}
  812. AND sampling_qty_rank_desc = #{samplingQtyRankDesc}
  813. </delete>
  814. <!-- ================================================= 检验等级维护 ================================================= -->
  815. <!-- 查询检验等级 -->
  816. <select id="samplingLevelSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  817. SELECT
  818. site,
  819. bu_no,
  820. dbo.get_bu_desc(site, bu_no) as buDesc,
  821. sampling_level_no,
  822. sampling_level_desc,
  823. sampling_level_remark,
  824. sampling_level_active,
  825. case when sampling_level_active = 'Y' then '是' when sampling_level_active = 'N' then '否' else '' end as samplingLevelActiveDesc,
  826. create_date,
  827. create_by,
  828. dbo.getOperatorDesc(site, create_by) as createByDesc,
  829. update_date,
  830. update_by,
  831. dbo.getOperatorDesc(site, update_by) as updateByDesc
  832. FROM qc_sampling_inspection_level
  833. <where>
  834. site in (select site from eam_access_site where username = #{query.userName})
  835. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  836. <if test="query.buDesc != null and query.buDesc != ''">
  837. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  838. </if>
  839. <if test="query.samplingLevelNo != null and query.samplingLevelNo != ''">
  840. AND sampling_level_no LIKE '%' + #{query.samplingLevelNo}+'%'
  841. </if>
  842. <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''">
  843. AND sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%'
  844. </if>
  845. <if test="query.samplingLevelActive != null and query.samplingLevelActive != ''">
  846. AND sampling_level_active = #{query.samplingLevelActive}
  847. </if>
  848. </where>
  849. </select>
  850. <!-- 根据名称查询检验等级 -->
  851. <select id="selectSamplingLevelByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  852. SELECT
  853. site,
  854. bu_no,
  855. sampling_level_no,
  856. sampling_level_desc,
  857. sampling_level_remark,
  858. sampling_level_active
  859. FROM qc_sampling_inspection_level
  860. WHERE sampling_level_desc = #{samplingLevelDesc} AND site = #{site} and bu_no = #{buNo}
  861. </select>
  862. <!-- 获取最大检验等级编码 -->
  863. <select id="queryLastSamplingLevelNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  864. SELECT top 1 sampling_level_no
  865. FROM qc_sampling_inspection_level
  866. where site = #{site} and bu_no = #{buNo}
  867. ORDER BY sampling_level_no Desc
  868. </select>
  869. <!-- 新增检验等级 -->
  870. <insert id="samplingLevelSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  871. 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)
  872. VALUES (#{site}, #{buNo}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingLevelRemark}, #{samplingLevelActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  873. </insert>
  874. <!-- 根据检验等级编码查询矩阵 -->
  875. <select id="selectSamplingPlanBySamplingLevelNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  876. SELECT
  877. site,
  878. bu_no,
  879. sampling_plan_no,
  880. sampling_qty_no,
  881. sampling_qty_rank_no,
  882. sampling_level_no,
  883. sampling_plan_active
  884. FROM qc_sampling_inspection_plan
  885. WHERE site = #{site} and bu_no = #{buNo}
  886. AND sampling_level_no = #{samplingLevelNo}
  887. </select>
  888. <!-- 修改检验等级 -->
  889. <update id="samplingLevelUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  890. UPDATE qc_sampling_inspection_level
  891. SET sampling_level_desc = #{samplingLevelDesc},
  892. sampling_level_remark = #{samplingLevelRemark},
  893. sampling_level_active = #{samplingLevelActive},
  894. update_date = getDate(),
  895. update_by = #{updateBy}
  896. WHERE sampling_level_no = #{samplingLevelNo}
  897. AND site = #{site} and bu_no = #{buNo}
  898. </update>
  899. <!-- 删除检验等级 -->
  900. <delete id="samplingLevelDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  901. DELETE FROM qc_sampling_inspection_level
  902. WHERE site = #{site} and bu_no = #{buNo}
  903. AND sampling_level_no = #{samplingLevelNo}
  904. AND sampling_level_desc = #{samplingLevelDesc}
  905. </delete>
  906. <!-- ================================================= 物料属性设置维护 ================================================= -->
  907. <!-- 查询物料属性 -->
  908. <select id="qcPartAttributeSearch" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  909. SELECT
  910. qa.site,
  911. qa.bu_no,
  912. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  913. p.part_no as partNo,
  914. p.part_desc,
  915. p.cinv_source_code as cinvSourceCode,
  916. p.sku as sku,
  917. p.FamilyID,
  918. p.invtype as familyName,
  919. p.spec,
  920. p.umid,
  921. qa.supplier_no,
  922. dbo.qc_get_supplier_name(qa.site, qa.supplier_no) as supplierDesc,
  923. qa.attribute_remark,
  924. qa.create_time,
  925. qa.create_by,
  926. dbo.getOperatorDesc(qa.site, qa.create_by) as createByDesc,
  927. qa.attribute_type,
  928. qa.update_date,
  929. qa.update_by,
  930. dbo.getOperatorDesc(qa.site, qa.update_by) as updateByDesc,
  931. qa.exempt_inspection
  932. FROM qc_part_attribute qa
  933. LEFT JOIN part p on qa.attribute_no = p.part_no and qa.site = p.site
  934. <where>
  935. qa.site in (select site from eam_access_site where username = #{query.userName})
  936. and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  937. and qa.attribute_type = #{query.attributeType}
  938. <if test="query.buDesc != null and query.buDesc != ''">
  939. AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc}
  940. </if>
  941. <if test = "query.partNo != null and query.partNo != ''">
  942. AND qa.attribute_no LIKE '%' + #{query.partNo}+'%'
  943. </if>
  944. <if test = "query.partDesc != null and query.partDesc != ''">
  945. AND p.part_desc LIKE '%' + #{query.partDesc}+'%'
  946. </if>
  947. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  948. AND p.cinv_source_code LIKE '%' + #{query.cinvSourceCode}+'%'
  949. </if>
  950. <if test = "query.sku != null and query.sku != ''">
  951. AND p.sku LIKE '%' + #{query.sku}+'%'
  952. </if>
  953. <if test = "query.familyName != null and query.familyName != ''">
  954. AND p.invtype LIKE '%' + #{query.familyName}+'%'
  955. </if>
  956. </where>
  957. </select>
  958. <!-- 查询是否已有该物料属性 -->
  959. <select id="selectPartAttributeByNo" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  960. SELECT
  961. attribute_no,
  962. supplier_no,
  963. attribute_remark,
  964. attribute_type
  965. FROM qc_part_attribute
  966. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  967. </select>
  968. <!-- 新增物料属性 -->
  969. <insert id="qcPartAttributeSave" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  970. INSERT INTO qc_part_attribute (attribute_no, supplier_no, attribute_remark, create_time, create_by, attribute_type, site, exempt_inspection, bu_no)
  971. VALUES(#{partNo}, #{supplierNo}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{exemptInspection}, #{buNo})
  972. </insert>
  973. <!-- 物料属性修改 -->
  974. <update id="qcPartAttributeEdit" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  975. UPDATE qc_part_attribute
  976. SET attribute_remark = #{attributeRemark},
  977. exempt_inspection = #{exemptInspection},
  978. update_date = getDate(),
  979. update_by = #{updateBy}
  980. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  981. </update>
  982. <!-- 删除物料属性 -->
  983. <delete id="qcPartAttributeDelete" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  984. DELETE FROM qc_part_attribute
  985. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo} and attribute_type = #{attributeType}
  986. </delete>
  987. <!-- 删除物料属性模板 -->
  988. <delete id="deletePartAttributeTemplate" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  989. DELETE FROM qc_attribute_template
  990. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo} and attribute_type = #{attributeType}
  991. </delete>
  992. <!-- 查询类别模板 -->
  993. <select id="searchPartAttributeDetails" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  994. SELECT
  995. qat.site,
  996. qat.bu_no,
  997. qpa.attribute_no,
  998. qpa.attribute_type,
  999. qt.template_id,
  1000. qt.template_name,
  1001. qt.template_remark,
  1002. qt.template_version,
  1003. qat.sampling_programme_no,
  1004. qsip.sampling_programme_desc,
  1005. qat.AQL,
  1006. qat.AC,
  1007. qat.RE,
  1008. qt.inspection_type_no,
  1009. qit.inspection_type_name,
  1010. qt.default_sampling_quantity,
  1011. qt.default_sampling_proportion,
  1012. qat.sampling_level_no,
  1013. qsil.sampling_level_desc,
  1014. qat.inspection_cycle,
  1015. qat.operation,
  1016. qat.manufacturer_id,
  1017. dbo.qc_get_supplier_name(qat.site, qat.manufacturer_id) as manufacturerName,
  1018. qat.resource_id
  1019. FROM qc_attribute_template as qat
  1020. 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
  1021. 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
  1022. 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
  1023. LEFT JOIN qc_inspection_type as qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1024. 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
  1025. WHERE qat.site = #{site} and qpa.attribute_type = #{attributeType} and qpa.attribute_no = #{attributeNo} and qat.bu_no = #{buNo}
  1026. </select>
  1027. <!-- 物料属性模板查重 -->
  1028. <select id="searchPartRepeat" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1029. SELECT
  1030. attribute_no,
  1031. template_id
  1032. FROM qc_attribute_template
  1033. WHERE attribute_no = #{attributeNo}
  1034. AND template_id = #{templateId}
  1035. AND attribute_type = #{attributeType}
  1036. AND special_field = #{specialField}
  1037. </select>
  1038. <!-- 新增物料属性模板 -->
  1039. <insert id="savePartAttributeDetails" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1040. INSERT INTO qc_attribute_template
  1041. (attribute_no, template_id, sampling_level_no, inspection_cycle, sampling_programme_no, AQL, AC, RE,
  1042. attribute_type, operation, manufacturer_id, resource_id, site, bu_no, inspection_type_no)
  1043. VALUES
  1044. (#{attributeNo}, #{templateId}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{samplingProgrammeNo}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL},
  1045. #{attributeType}, #{operation}, #{manufacturerID}, #{resourceID}, #{site}, #{buNo}, #{inspectionTypeNo})
  1046. </insert>
  1047. <!-- 可选模板 -->
  1048. <select id="getTemplateList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1049. SELECT
  1050. qt.template_id,
  1051. qt.template_name,
  1052. qit.inspection_type_name
  1053. FROM qc_template as qt
  1054. LEFT JOIN qc_attribute_template as qat ON qat.template_id = qt.template_id and qat.attribute_no = #{attributeNo}
  1055. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no
  1056. <where>
  1057. qt.site = #{site}
  1058. AND qat.attribute_no is null
  1059. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  1060. AND qt.inspection_type_no = #{inspectionTypeNo}
  1061. </if>
  1062. <if test = "templateId != null and templateId != ''">
  1063. AND qt.template_id LIKE '%' + #{templateId}+'%'
  1064. </if>
  1065. <if test = "templateName != null and templateName != ''">
  1066. AND qt.template_name LIKE '%' + #{templateName}+'%'
  1067. </if>
  1068. </where>
  1069. </select>
  1070. <!-- 已有模板 -->
  1071. <select id="getPartTemplateList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1072. SELECT
  1073. qt.template_id,
  1074. qt.template_name,
  1075. qit.inspection_type_name,
  1076. qat.operation,
  1077. qat.manufacturer_id,
  1078. dbo.qc_get_supplier_name(qt.site, qat.manufacturer_id) as manufacturerName,
  1079. qat.resource_id
  1080. FROM qc_attribute_template as qat
  1081. 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
  1082. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1083. WHERE qt.site = #{site} AND qat.attribute_no = #{attributeNo} and qt.bu_no = #{buNo}
  1084. </select>
  1085. <!-- 物料可选模板 -->
  1086. <select id="getTemplateListAll" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1087. SELECT
  1088. qt.template_id,
  1089. qt.template_name,
  1090. qit.inspection_type_name
  1091. FROM qc_template as qt
  1092. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1093. <where>
  1094. qt.site = #{site} and qt.bu_no = #{buNo}
  1095. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  1096. AND qt.inspection_type_no = #{inspectionTypeNo}
  1097. </if>
  1098. <if test = "templateId != null and templateId != ''">
  1099. AND qt.template_id LIKE '%' + #{templateId}+'%'
  1100. </if>
  1101. <if test = "templateName != null and templateName != ''">
  1102. AND qt.template_name LIKE '%' + #{templateName}+'%'
  1103. </if>
  1104. </where>
  1105. </select>
  1106. <!-- 删除物料属性模板 -->
  1107. <delete id="deletePartAttributeDetails" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1108. DELETE FROM qc_attribute_template
  1109. <where>
  1110. site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId} and attribute_type = #{attributeType}
  1111. <if test = "operation != null and operation != ''">
  1112. and operation = #{operation}
  1113. </if>
  1114. <if test = "resourceID != null and resourceID != ''">
  1115. and resource_id = #{resourceID}
  1116. </if>
  1117. <if test = "manufacturerID != null and manufacturerID != ''">
  1118. and manufacturer_id = #{manufacturerID}
  1119. </if>
  1120. </where>
  1121. </delete>
  1122. <!-- 查询模板的基础数据 -->
  1123. <select id="selectTemplateData" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1124. SELECT
  1125. template_id,
  1126. template_name,
  1127. sampling_programme_no,
  1128. sampling_level_no,
  1129. inspection_cycle,
  1130. AQL,
  1131. AC,
  1132. RE,
  1133. inspection_type_no
  1134. FROM qc_template
  1135. WHERE site = #{site} AND template_id = #{templateId} and bu_no = #{buNo}
  1136. </select>
  1137. <!-- 新增物料属性模板详情 -->
  1138. <update id="saveAttributeDetailed" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1139. UPDATE qc_attribute_template
  1140. SET sampling_level_no = #{samplingLevelNo},
  1141. inspection_cycle = #{inspectionCycle,jdbcType=DECIMAL},
  1142. sampling_programme_no = #{samplingProgrammeNo},
  1143. AQL = #{aql,jdbcType=DECIMAL},
  1144. AC = #{ac,jdbcType=DECIMAL},
  1145. RE = #{re,jdbcType=DECIMAL}
  1146. <where>
  1147. site = #{site} and attribute_no = #{attributeNo} AND template_id = #{templateId} AND attribute_type = #{attributeType} and bu_no = #{buNo}
  1148. <if test = "operation != null and operation != ''">
  1149. AND operation = #{operation}
  1150. </if>
  1151. <if test = "resourceID != null and resourceID != ''">
  1152. AND resource_id = #{resourceID}
  1153. </if>
  1154. <if test = "manufacturerID != null and manufacturerID != ''">
  1155. AND manufacturer_id = #{manufacturerID}
  1156. </if>
  1157. </where>
  1158. </update>
  1159. <!-- 更新物料属性修改时间 -->
  1160. <update id="updatePartAttributeTime" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1161. UPDATE qc_part_attribute
  1162. SET update_date = getDate(),
  1163. update_by = #{updateBy}
  1164. WHERE site = #{site} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1165. </update>
  1166. <!-- ================================================= 类别属性设置维护 ================================================= -->
  1167. <!-- 查询类别属性 -->
  1168. <select id="qcFamilyAttributeSearch" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1169. SELECT
  1170. qa.site,
  1171. qa.bu_no,
  1172. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  1173. qa.attribute_no as familyID,
  1174. pf.FamilyName,
  1175. qa.supplier_no,
  1176. qa.attribute_remark,
  1177. qa.create_time,
  1178. qa.create_by,
  1179. qa.update_date,
  1180. qa.update_by,
  1181. qa.attribute_type
  1182. FROM qc_part_attribute as qa
  1183. LEFT JOIN PartFamily as pf on qa.attribute_no = pf.FamilyID and qa.site = pf.site
  1184. <where>
  1185. qa.site in (select site from eam_access_site where username = #{query.userName})
  1186. and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1187. and qa.attribute_type = #{query.attributeType}
  1188. <if test="query.buDesc != null and query.buDesc != ''">
  1189. AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc}
  1190. </if>
  1191. <if test = "query.familyID != null and query.familyID != ''">
  1192. AND qa.attribute_no LIKE '%' + #{query.familyID}+'%'
  1193. </if>
  1194. <if test = "query.familyName != null and query.familyName != ''">
  1195. AND pf.FamilyName LIKE '%' + #{query.familyName}+'%'
  1196. </if>
  1197. </where>
  1198. </select>
  1199. <!-- 新增类别属性 -->
  1200. <insert id="qcFamilyAttributeSave" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1201. INSERT INTO qc_part_attribute (attribute_no, attribute_remark, create_time, create_by, attribute_type, site, bu_no)
  1202. VALUES(#{familyID}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{buNo})
  1203. </insert>
  1204. <!-- 删除分类属性 -->
  1205. <delete id="qcFamilyAttributeDelete" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1206. DELETE FROM qc_part_attribute
  1207. WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1208. </delete>
  1209. <!-- 删除分类属性模板 -->
  1210. <delete id="deleteFamilyAttributeTemplate" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1211. DELETE FROM qc_attribute_template
  1212. WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1213. </delete>
  1214. <!-- ================================================= 抽样方案维护 ================================================= -->
  1215. <!-- 查询类别属性 -->
  1216. <select id="samplingProgrammeSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1217. SELECT
  1218. site,
  1219. bu_no,
  1220. dbo.get_bu_desc(site, bu_no) as buDesc,
  1221. sampling_programme_no,
  1222. sampling_programme_desc,
  1223. sampling_programme_code,
  1224. create_time,
  1225. create_by,
  1226. dbo.getOperatorDesc(site, create_by) as createByDesc,
  1227. update_date,
  1228. update_by,
  1229. dbo.getOperatorDesc(site, update_by) as updateByDesc
  1230. FROM qc_sampling_inspection_programme
  1231. <where>
  1232. site in (select site from eam_access_site where username = #{query.userName})
  1233. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1234. <if test="query.buDesc != null and query.buDesc != ''">
  1235. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  1236. </if>
  1237. <if test = "query.samplingProgrammeNo != null and query.samplingProgrammeNo != ''">
  1238. AND sampling_programme_no LIKE '%' + #{query.samplingProgrammeNo}+'%'
  1239. </if>
  1240. <if test = "query.samplingProgrammeCode != null and query.samplingProgrammeCode != ''">
  1241. AND sampling_programme_code LIKE '%' + #{query.samplingProgrammeCode}+'%'
  1242. </if>
  1243. <if test = "query.samplingProgrammeDesc != null and query.samplingProgrammeDesc != ''">
  1244. AND sampling_programme_desc LIKE '%' + #{query.samplingProgrammeDesc}+'%'
  1245. </if>
  1246. </where>
  1247. </select>
  1248. <!-- 新增抽样方案 -->
  1249. <insert id="samplingProgrammeSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1250. 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)
  1251. VALUES(#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{samplingProgrammeCode}, getDate(), #{createBy}, getDate(), #{updateBy})
  1252. </insert>
  1253. <!-- 删除抽样方案 -->
  1254. <delete id="samplingProgrammeDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1255. DELETE FROM qc_sampling_inspection_programme
  1256. WHERE site = #{site} and bu_no = #{buNo}
  1257. AND sampling_programme_no = #{samplingProgrammeNo}
  1258. </delete>
  1259. <!-- 删除抽样方案中的矩阵 -->
  1260. <delete id="deletePlanByProgrammeNo" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1261. DELETE FROM qc_programme_plan
  1262. WHERE sampling_programme_no = #{samplingProgrammeNo} and site = #{site} and bu_no = #{buNo}
  1263. </delete>
  1264. <!-- 根据名称查询抽样方案 -->
  1265. <select id="selectSamplingProgrammeByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1266. SELECT
  1267. site,
  1268. bu_no,
  1269. sampling_programme_no,
  1270. sampling_programme_desc
  1271. FROM qc_sampling_inspection_programme
  1272. WHERE sampling_programme_desc = #{samplingProgrammeDesc} AND site = #{site} and bu_no = #{buNo}
  1273. </select>
  1274. <!-- 获取最大抽样方案编码 -->
  1275. <select id="queryLastSamplingProgrammeNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1276. SELECT top 1 sampling_programme_no
  1277. FROM qc_sampling_inspection_programme
  1278. where site = #{site} and bu_no = #{buNo}
  1279. ORDER BY sampling_programme_no Desc
  1280. </select>
  1281. <!-- 搜索抽样方案中的矩阵 -->
  1282. <select id="searchSamplingProgrammeDetails" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1283. SELECT
  1284. qpp.site,
  1285. qpp.bu_no,
  1286. qpp.sampling_programme_no,
  1287. qsip.sampling_plan_no,
  1288. qsip.sampling_plan_Desc,
  1289. qsip.sampling_qty_no,
  1290. qsiq.sampling_qty_desc,
  1291. qsiq.sampling_qty,
  1292. qsip.sampling_qty_rank_no,
  1293. qsiqr.sampling_qty_rank_desc,
  1294. qsiqr.min_qty,
  1295. qsiqr.max_qty,
  1296. qsip.sampling_level_no,
  1297. qsil.sampling_level_desc,
  1298. qsip.sampling_plan_active
  1299. FROM qc_programme_plan as qpp
  1300. 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
  1301. 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
  1302. 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
  1303. 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
  1304. WHERE qpp.sampling_programme_no = #{samplingProgrammeNo} and qpp.site = #{site} and qpp.bu_no = #{buNo}
  1305. </select>
  1306. <!-- 获取该方案不包含的矩阵 -->
  1307. <select id="getPlanList" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1308. SELECT
  1309. qip.sampling_plan_no,
  1310. qip.sampling_plan_desc
  1311. FROM qc_sampling_inspection_plan as qip
  1312. 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
  1313. WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no is null
  1314. </select>
  1315. <!-- 获取当前方案所包含的矩阵 -->
  1316. <select id="getProgrammePlanList" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1317. SELECT
  1318. qip.sampling_plan_no,
  1319. qip.sampling_plan_desc
  1320. FROM qc_programme_plan as qpp
  1321. 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
  1322. WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no = #{samplingProgrammeNo}
  1323. </select>
  1324. <!-- 查重 -->
  1325. <select id="searchPlanRepeat" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1326. SELECT
  1327. sampling_plan_no,
  1328. sampling_programme_no
  1329. FROM qc_programme_plan
  1330. WHERE sampling_programme_no = #{samplingProgrammeNo} AND sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
  1331. </select>
  1332. <!-- 新增抽样方案中的矩阵 -->
  1333. <insert id="saveSamplingProgrammeDetails" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1334. INSERT INTO qc_programme_plan (site, bu_no, sampling_programme_no, sampling_plan_no)
  1335. VALUES (#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingPlanNo})
  1336. </insert>
  1337. <!-- 更新抽样方案修改时间 -->
  1338. <update id="updateSamplingInspectionProgrammeDate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1339. UPDATE qc_sampling_inspection_programme
  1340. SET update_date = getDate(),
  1341. update_by = #{updateBy}
  1342. WHERE site = #{site} AND sampling_programme_no = #{samplingProgrammeNo} and bu_no = #{buNo}
  1343. </update>
  1344. <!-- 删除抽样方案中的矩阵 -->
  1345. <delete id="deleteSamplingProgrammeDetails" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1346. DELETE FROM qc_programme_plan
  1347. WHERE sampling_programme_no = #{samplingProgrammeNo} and sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
  1348. </delete>
  1349. <!-- ================================================= FAI检验维护 ================================================= -->
  1350. <!-- 查询FAI基础数据 -->
  1351. <select id="selectFAIBasicData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1352. SELECT
  1353. top 1
  1354. a.orderno as orderNo,
  1355. j.part_no,
  1356. j.part_desc,
  1357. c.operation_desc,
  1358. b.approve_qty as rollQty,
  1359. a.s_resourceid as resourceId,
  1360. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1361. a.itemno as itemNo,
  1362. a.id as ssrId
  1363. FROM soscheduledrouting as a
  1364. LEFT JOIN sfdc as b
  1365. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  1366. select min(sfdc.id)
  1367. from sfdc
  1368. group by sfdc.assjob_seq_no, site
  1369. )
  1370. LEFT JOIN so_routing as c
  1371. ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  1372. LEFT JOIN part j
  1373. ON a.site = j.site and a.part_no = j.part_no
  1374. WHERE a.itemno = '10'
  1375. AND a.id not in (select ssr_id from qc_fai_record)
  1376. AND b.approve_qty is not null
  1377. ORDER BY a.id desc
  1378. </select>
  1379. <!-- 获取该物料属性下维护的iqc -->
  1380. <select id="selectPartAttributeByPartNo" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1381. SELECT
  1382. qat.site,
  1383. qat.bu_no,
  1384. qat.attribute_no,
  1385. qat.template_id,
  1386. qat.sampling_level_no,
  1387. qsil.sampling_level_desc,
  1388. qat.inspection_cycle,
  1389. qat.sampling_programme_no,
  1390. qsip.sampling_programme_desc,
  1391. qat.AQL,
  1392. qat.AC,
  1393. qat.RE,
  1394. qt.default_sampling_quantity,
  1395. qt.default_sampling_proportion
  1396. FROM qc_attribute_template as qat
  1397. 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
  1398. 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
  1399. 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
  1400. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  1401. AND qat.attribute_no = #{partNo}
  1402. AND qat.attribute_type = #{attributeType}
  1403. AND qt.inspection_type_no = #{inspectionTypeNo}
  1404. AND qat.manufacturer_id = #{supplierNo}
  1405. </select>
  1406. <!-- 获取该物料属性下维护的ipqc -->
  1407. <select id="selectPartAttributeByOperationAndResource" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1408. SELECT
  1409. qat.site,
  1410. qat.bu_no,
  1411. qat.attribute_no,
  1412. qat.template_id,
  1413. qat.sampling_level_no,
  1414. qsil.sampling_level_desc,
  1415. qat.inspection_cycle,
  1416. qat.sampling_programme_no,
  1417. qsip.sampling_programme_desc,
  1418. qat.AQL,
  1419. qat.AC,
  1420. qat.RE,
  1421. qt.default_sampling_quantity,
  1422. qt.default_sampling_proportion
  1423. FROM qc_attribute_template as qat
  1424. 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
  1425. 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
  1426. 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
  1427. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  1428. AND qat.attribute_no = #{partNo}
  1429. AND qat.attribute_type = #{attributeType1}
  1430. AND qt.inspection_type_no = #{inspectionTypeNo}
  1431. AND qat.operation = #{operationDesc}
  1432. AND qat.resource_id = #{resourceId}
  1433. </select>
  1434. <!-- 获取模板详情 -->
  1435. <select id="selectTemplate" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1436. SELECT
  1437. qt.site,
  1438. qt.bu_no,
  1439. qt.template_id,
  1440. qt.sampling_level_no,
  1441. qsil.sampling_level_desc,
  1442. qt.inspection_cycle,
  1443. qt.sampling_programme_no,
  1444. qsip.sampling_programme_desc,
  1445. qt.AQL,
  1446. qt.AC,
  1447. qt.RE,
  1448. qt.default_sampling_quantity,
  1449. qt.default_sampling_proportion
  1450. FROM qc_template as qt
  1451. 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
  1452. 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
  1453. WHERE qt.site = #{site} and qt.template_id = #{templateId} and qt.bu_no = #{buNo}
  1454. </select>
  1455. <!-- 新增FAI主记录信息 -->
  1456. <insert id="saveFAIRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1457. 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)
  1458. 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})
  1459. </insert>
  1460. <insert id="saveFAIDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1461. INSERT INTO qc_fai_detailed_record
  1462. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1463. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1464. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  1465. VALUES
  1466. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  1467. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  1468. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  1469. </insert>
  1470. <!-- 新增FAI明细记录信息 -->
  1471. <insert id="saveFAIDetailedRecords">
  1472. INSERT INTO qc_fai_detailed_record
  1473. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1474. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1475. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  1476. VALUES
  1477. <foreach collection="list" item="item" separator=",">
  1478. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  1479. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  1480. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  1481. </foreach>
  1482. </insert>
  1483. <!-- 查询FAI主记录信息 -->
  1484. <select id="qcFAIInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1485. SELECT
  1486. a.inspection_no,
  1487. a.site,
  1488. a.bu_no,
  1489. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1490. a.state,
  1491. a.inspection_result,
  1492. a.task_date,
  1493. a.inspection_type_no,
  1494. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  1495. a.inspection_cycle,
  1496. a.order_no,
  1497. a.operation_desc,
  1498. a.resource_id,
  1499. r.resource_desc,
  1500. a.part_no,
  1501. d.part_desc,
  1502. d.cinv_source_code as cinvSourceCode,
  1503. d.sku as sku,
  1504. d.invdefinetype as invdefinetype,
  1505. a.inspection_remark,
  1506. a.roll_qty,
  1507. a.sampling_qty,
  1508. a.disposal_measures,
  1509. a.disposal_remark,
  1510. a.inspector_date,
  1511. a.inspector_no,
  1512. u.user_display as inspectorName,
  1513. a.ssr_id,
  1514. a.unqualified_qty,
  1515. a.submit_flag,
  1516. a.seq_no,
  1517. a.batch_roll_no,
  1518. a.special_requirements,
  1519. a.work_center_no,
  1520. a.roll_no,
  1521. a.um_id,
  1522. um.UMName as umName,
  1523. a.action_date,
  1524. a.action_by,
  1525. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1526. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1527. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1528. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1529. a.pass_qty,
  1530. a.not_pass_qty,
  1531. a.batch_qualified_qty
  1532. FROM qc_fai_record as a
  1533. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  1534. left join sys_user as u on a.inspector_no = u.username
  1535. left join resource as r on a.site = r.site and a.resource_id = r.resource_id and a.work_center_no = r.work_center_no
  1536. left join UM as um on a.site = um.site and a.um_id = um.UMID
  1537. <where>
  1538. a.site in (select site from eam_access_site where username = #{query.userName})
  1539. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1540. <if test="query.buNo != null and query.buNo != ''">
  1541. AND a.bu_no = #{query.buNo}
  1542. </if>
  1543. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1544. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1545. </if>
  1546. <if test = "query.partNo != null and query.partNo != ''">
  1547. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  1548. </if>
  1549. <if test = "query.partDesc != null and query.partDesc != ''">
  1550. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  1551. </if>
  1552. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1553. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1554. </if>
  1555. <if test = "query.sku != null and query.sku != ''">
  1556. AND d.sku LIKE '%' + #{query.sku} + '%'
  1557. </if>
  1558. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1559. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1560. </if>
  1561. <if test = "query.states != null and query.states.size > 0">
  1562. AND a.state in
  1563. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  1564. #{item}
  1565. </foreach>
  1566. </if>
  1567. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1568. AND a.inspection_result = #{query.inspectionResult}
  1569. </if>
  1570. <if test = "query.orderNo != null and query.orderNo != ''">
  1571. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  1572. </if>
  1573. <if test = "query.seqNo != null and query.seqNo != ''">
  1574. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  1575. </if>
  1576. <if test = "query.operationDesc != null and query.operationDesc != ''">
  1577. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  1578. </if>
  1579. <if test="query.startDate != null">
  1580. AND a.inspector_date >= #{query.startDate}
  1581. </if>
  1582. <if test="query.endDate != null">
  1583. AND #{query.endDate} >= a.inspector_date
  1584. </if>
  1585. <if test="query.startDate2 != null">
  1586. AND a.task_date >= #{query.startDate2}
  1587. </if>
  1588. <if test="query.endDate2 != null">
  1589. AND #{query.endDate2} >= a.task_date
  1590. </if>
  1591. </where>
  1592. ORDER BY
  1593. CASE WHEN a.state = '待检验' THEN 1
  1594. WHEN a.state = '待审核' THEN 2
  1595. WHEN a.state = '已完成' THEN 3
  1596. END, a.task_date desc
  1597. </select>
  1598. <!-- 获取物料的类别编码 -->
  1599. <select id="selectFamilyIdByPartNo" parameterType="string" resultType="string">
  1600. SELECT FamilyID
  1601. FROM part
  1602. WHERE part_no = #{partNo} AND site = #{site}
  1603. </select>
  1604. <!-- FAI明细记录查询 -->
  1605. <select id="faiDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1606. SELECT
  1607. a.site,
  1608. a.bu_no,
  1609. a.inspection_no,
  1610. a.order_no,
  1611. a.template_id,
  1612. a.sampling_level_no,
  1613. a.sampling_level_desc,
  1614. a.sampling_programme_no,
  1615. a.sampling_programme_desc,
  1616. a.AQL,
  1617. a.AC,
  1618. a.RE,
  1619. a.item_no,
  1620. a.item_desc,
  1621. a.object_id,
  1622. a.object_desc,
  1623. a.default_value,
  1624. a.min_value,
  1625. a.max_value,
  1626. a.text_value,
  1627. a.number_value,
  1628. a.value_type_db,
  1629. a.value_type,
  1630. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1631. a.is_submit,
  1632. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1633. a.sampling_qty,
  1634. dbo.qc_get_fai_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1635. c.method_no,
  1636. c.method_name,
  1637. c.method_remark
  1638. FROM qc_fai_detailed_record as a
  1639. 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
  1640. 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
  1641. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1642. order by a.order_id
  1643. </select>
  1644. <!-- 修改FAI主记录信息 -->
  1645. <update id="updateFAIMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1646. UPDATE qc_fai_record
  1647. SET disposal_measures = #{disposalMeasures},
  1648. disposal_remark = #{disposalRemark},
  1649. inspection_result = #{inspectionResult},
  1650. inspector_no = #{inspectorNo},
  1651. state = #{state},
  1652. inspection_remark = #{inspectionRemark},
  1653. inspector_date = getDate(),
  1654. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1655. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1656. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1657. pass_qty = #{passQty,jdbcType=DECIMAL},
  1658. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1659. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  1660. submit_date = getDate()
  1661. WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1662. </update>
  1663. <!-- 修改FAI明细记录信息 -->
  1664. <update id="updateFAIDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1665. UPDATE qc_fai_detailed_record
  1666. SET item_result = #{itemResult},
  1667. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1668. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1669. text_value = #{textValue},
  1670. number_value = #{numberValue,jdbcType=DECIMAL}
  1671. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1672. </update>
  1673. <!-- 修改子明细提交标识 -->
  1674. <update id="updateSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1675. UPDATE qc_fai_sub_detail_record
  1676. SET is_submit = 'Y'
  1677. WHERE inspection_no = #{inspectionNo}
  1678. </update>
  1679. <!-- 删除FAI检验记录 -->
  1680. <delete id="deleteFAIRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1681. DELETE FROM qc_fai_record
  1682. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1683. </delete>
  1684. <!-- 删除FAI明细记录信息 -->
  1685. <delete id="deleteFAIDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1686. DELETE FROM qc_fai_detailed_record
  1687. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1688. </delete>
  1689. <!-- 删除FAI子明细记录信息 -->
  1690. <delete id="deleteFAISubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1691. DELETE FROM qc_fai_sub_detail_record
  1692. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1693. </delete>
  1694. <!-- 修改FAI主记录标识为已提交 -->
  1695. <update id="updateFAIMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1696. UPDATE qc_fai_record
  1697. SET submit_flag = 'Y',
  1698. state = '已完成',
  1699. submit_date = getDate()
  1700. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1701. </update>
  1702. <!-- 修改FAI明细记录标识为已提交 -->
  1703. <update id="updateFAIDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1704. UPDATE qc_fai_detailed_record
  1705. SET is_submit = 'Y'
  1706. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1707. </update>
  1708. <!-- 修改子明细记录标识为已提交 -->
  1709. <update id="updateFAISubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1710. UPDATE qc_fai_sub_detail_record
  1711. SET is_submit = 'Y'
  1712. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1713. </update>
  1714. <!-- 查询FAI检验记录是否已提交 -->
  1715. <select id="checkFAIIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1716. SELECT submit_flag
  1717. FROM qc_fai_record
  1718. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1719. </select>
  1720. <!-- 删除子明细的老数据 -->
  1721. <delete id="delFAISubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  1722. DELETE FROM qc_fai_sub_detail_record
  1723. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1724. </delete>
  1725. <!-- 新增FAI子明细信息 -->
  1726. <insert id="saveFAISubDetailed">
  1727. INSERT INTO qc_fai_sub_detail_record
  1728. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
  1729. VALUES
  1730. <foreach collection="list" item="item" separator=",">
  1731. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  1732. </foreach>
  1733. </insert>
  1734. <!-- 查询FAI的子明细 -->
  1735. <select id="selectFAISubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  1736. SELECT
  1737. site,
  1738. bu_no,
  1739. sub_detail_value,
  1740. sampling_location,
  1741. is_submit,
  1742. sampling_location_b,
  1743. num,
  1744. sub_detail_value_b,
  1745. sub_detail_value_c,
  1746. sub_detail_value_d,
  1747. sub_detail_value_e
  1748. FROM qc_fai_sub_detail_record
  1749. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1750. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1751. AND sub_detail_value ${collectionDataContent}
  1752. </if>
  1753. </select>
  1754. <!-- 获取该项目的子明细值 -->
  1755. <select id="selectFAISubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  1756. SELECT sub_detail_value,
  1757. sampling_location,
  1758. is_submit
  1759. FROM qc_fai_sub_detail_record
  1760. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1761. </select>
  1762. <!-- ================================================= IPQC检验维护 ================================================= -->
  1763. <!-- 查询IPQC基础数据 -->
  1764. <select id="selectIPQCBasicData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1765. SELECT
  1766. top 1
  1767. a.orderno as orderNo,
  1768. j.part_no,
  1769. j.part_desc,
  1770. c.operation_desc,
  1771. b.approve_qty as rollQty,
  1772. a.s_resourceid as resourceId,
  1773. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1774. a.itemno as itemNo,
  1775. a.id as ssrId
  1776. FROM soscheduledrouting as a
  1777. LEFT JOIN sfdc as b
  1778. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  1779. select max(sfdc.id)
  1780. from sfdc
  1781. group by sfdc.assjob_seq_no, site
  1782. )
  1783. LEFT JOIN so_routing as c
  1784. ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  1785. LEFT JOIN part j
  1786. ON a.site = j.site and a.part_no = j.part_no
  1787. LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
  1788. ON a.id = temp.ssr_id
  1789. WHERE b.approve_qty is not null and temp.ssr_id is null
  1790. ORDER BY a.id desc
  1791. </select>
  1792. <select id="qcExec" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="string" statementType="CALLABLE">
  1793. {CALL
  1794. getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
  1795. }
  1796. </select>
  1797. <insert id="saveIPQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1798. INSERT INTO qc_ipqc_detailed_record
  1799. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1800. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1801. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  1802. VALUES
  1803. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  1804. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  1805. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  1806. </insert>
  1807. <!-- 新增IPQC明细记录信息 -->
  1808. <insert id="saveIPQCDetailedRecords">
  1809. INSERT INTO qc_ipqc_detailed_record
  1810. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1811. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1812. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  1813. VALUES
  1814. <foreach collection="list" item="item" separator=",">
  1815. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  1816. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  1817. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  1818. </foreach>
  1819. </insert>
  1820. <!-- 新增IPQC主记录信息 -->
  1821. <insert id="saveIPQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1822. INSERT INTO qc_ipqc_record
  1823. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  1824. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  1825. VALUES
  1826. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  1827. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  1828. </insert>
  1829. <!-- 查询IPQC主记录信息 -->
  1830. <select id="qcIPQCInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1831. SELECT
  1832. a.inspection_no,
  1833. a.site,
  1834. a.bu_no,
  1835. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1836. a.state,
  1837. a.inspection_result,
  1838. a.task_date,
  1839. a.inspection_type_no,
  1840. a.inspection_cycle,
  1841. a.order_no,
  1842. a.operation_desc,
  1843. a.resource_id,
  1844. r.resource_desc,
  1845. a.part_no,
  1846. d.part_desc,
  1847. d.cinv_source_code as cinvSourceCode,
  1848. d.sku as sku,
  1849. d.invdefinetype as invdefinetype,
  1850. a.inspection_remark,
  1851. a.roll_qty,
  1852. a.sampling_qty,
  1853. a.disposal_measures,
  1854. a.disposal_remark,
  1855. a.inspector_date,
  1856. a.inspector_no,
  1857. u.user_display as inspectorName,
  1858. a.ssr_id,
  1859. a.unqualified_qty,
  1860. a.submit_flag,
  1861. a.seq_no,
  1862. a.batch_roll_no,
  1863. a.special_requirements,
  1864. a.work_center_no,
  1865. a.roll_no,
  1866. a.um_id,
  1867. um.UMName as umName,
  1868. a.action_date,
  1869. a.action_by,
  1870. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1871. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1872. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1873. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1874. a.pass_qty,
  1875. a.not_pass_qty,
  1876. a.batch_qualified_qty
  1877. FROM qc_ipqc_record as a
  1878. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  1879. left join sys_user as u on a.inspector_no = u.username
  1880. left join resource as r on a.site = r.site and a.resource_id = r.resource_id and a.work_center_no = r.work_center_no
  1881. left join UM as um on a.site = um.site and a.um_id = um.UMID
  1882. <where>
  1883. a.site in (select site from eam_access_site where username = #{query.userName})
  1884. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1885. <if test="query.buNo != null and query.buNo != ''">
  1886. AND a.bu_no = #{query.buNo}
  1887. </if>
  1888. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1889. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1890. </if>
  1891. <if test = "query.partNo != null and query.partNo != ''">
  1892. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  1893. </if>
  1894. <if test = "query.partDesc != null and query.partDesc != ''">
  1895. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  1896. </if>
  1897. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1898. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1899. </if>
  1900. <if test = "query.sku != null and query.sku != ''">
  1901. AND d.sku LIKE '%' + #{query.sku} + '%'
  1902. </if>
  1903. <if test = "query.states != null and query.states.size > 0">
  1904. AND a.state in
  1905. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  1906. #{item}
  1907. </foreach>
  1908. </if>
  1909. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  1910. AND a.inspection_type_no = #{query.inspectionTypeNo}
  1911. </if>
  1912. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1913. AND a.inspection_result = #{query.inspectionResult}
  1914. </if>
  1915. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1916. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1917. </if>
  1918. <if test = "query.orderNo != null and query.orderNo != ''">
  1919. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  1920. </if>
  1921. <if test = "query.seqNo != null and query.seqNo != ''">
  1922. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  1923. </if>
  1924. <if test = "query.operationDesc != null and query.operationDesc != ''">
  1925. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  1926. </if>
  1927. <if test="query.startDate != null">
  1928. AND a.inspector_date >= #{query.startDate}
  1929. </if>
  1930. <if test="query.endDate != null">
  1931. AND #{query.endDate} >= a.inspector_date
  1932. </if>
  1933. <if test="query.startDate2 != null">
  1934. AND a.task_date >= #{query.startDate2}
  1935. </if>
  1936. <if test="query.endDate2 != null">
  1937. AND #{query.endDate2} >= a.task_date
  1938. </if>
  1939. </where>
  1940. ORDER BY
  1941. CASE WHEN a.state = '待检验' THEN 1
  1942. WHEN a.state = '待审核' THEN 2
  1943. WHEN a.state = '已完成' THEN 3
  1944. END, a.task_date desc
  1945. </select>
  1946. <!-- IPQC明细记录查询 -->
  1947. <select id="ipqcDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1948. SELECT
  1949. a.site,
  1950. a.bu_no,
  1951. a.inspection_no,
  1952. a.order_no,
  1953. a.template_id,
  1954. a.sampling_level_no,
  1955. a.sampling_level_desc,
  1956. a.sampling_programme_no,
  1957. a.sampling_programme_desc,
  1958. a.AQL,
  1959. a.AC,
  1960. a.RE,
  1961. a.item_no,
  1962. a.item_desc,
  1963. a.object_id,
  1964. a.object_desc,
  1965. a.default_value,
  1966. a.min_value,
  1967. a.max_value,
  1968. a.text_value,
  1969. a.number_value,
  1970. a.value_type_db,
  1971. a.value_type,
  1972. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1973. a.is_submit,
  1974. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1975. a.sampling_qty,
  1976. dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1977. c.method_no,
  1978. c.method_name,
  1979. c.method_remark
  1980. FROM qc_ipqc_detailed_record as a
  1981. 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
  1982. 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
  1983. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1984. order by a.order_id
  1985. </select>
  1986. <!-- 删除IPQC检验记录 -->
  1987. <delete id="deleteIPQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1988. DELETE FROM qc_ipqc_record
  1989. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1990. </delete>
  1991. <!-- 删除IPQC明细记录信息 -->
  1992. <delete id="deleteIPQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1993. DELETE FROM qc_ipqc_detailed_record
  1994. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1995. </delete>
  1996. <!-- 删除IPQC子明细记录信息 -->
  1997. <delete id="deleteIPQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1998. DELETE FROM qc_ipqc_sub_detail_record
  1999. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2000. </delete>
  2001. <!-- 修改IPQC主记录信息 -->
  2002. <update id="updateIPQCMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2003. UPDATE qc_ipqc_record
  2004. SET disposal_measures = #{disposalMeasures},
  2005. disposal_remark = #{disposalRemark},
  2006. inspection_result = #{inspectionResult},
  2007. inspector_no = #{inspectorNo},
  2008. state = #{state},
  2009. inspection_remark = #{inspectionRemark},
  2010. inspector_date = getDate(),
  2011. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2012. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2013. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2014. pass_qty = #{passQty,jdbcType=DECIMAL},
  2015. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2016. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  2017. submit_date = getDate()
  2018. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2019. </update>
  2020. <!-- 修改IPQC明细记录信息 -->
  2021. <update id="updateIPQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2022. UPDATE qc_ipqc_detailed_record
  2023. SET item_result = #{itemResult},
  2024. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2025. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2026. text_value = #{textValue},
  2027. number_value = #{numberValue,jdbcType=DECIMAL}
  2028. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2029. </update>
  2030. <!-- 修改IPQC主记录标识为已提交 -->
  2031. <update id="updateIPQCMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2032. UPDATE qc_ipqc_record
  2033. SET submit_flag = 'Y',
  2034. state = '已完成',
  2035. submit_date = getDate()
  2036. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2037. </update>
  2038. <!-- 修改IPQC明细记录标识为已提交 -->
  2039. <update id="updateIPQCDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2040. UPDATE qc_ipqc_detailed_record
  2041. SET is_submit = 'Y'
  2042. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2043. </update>
  2044. <!-- 修改IPQC子明细记录标识为已提交 -->
  2045. <update id="updateIPQCSubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2046. UPDATE qc_ipqc_sub_detail_record
  2047. SET is_submit = 'Y'
  2048. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2049. </update>
  2050. <!-- 删除IPQC子明细的老数据 -->
  2051. <delete id="delIPQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  2052. DELETE FROM qc_ipqc_sub_detail_record
  2053. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2054. </delete>
  2055. <!-- 新增IPQC子明细信息 -->
  2056. <insert id="saveIPQCSubDetailed">
  2057. INSERT INTO qc_ipqc_sub_detail_record
  2058. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
  2059. VALUES
  2060. <foreach collection="list" item="item" separator=",">
  2061. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  2062. </foreach>
  2063. </insert>
  2064. <!-- 查询IPQC的子明细 -->
  2065. <select id="selectIPQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2066. SELECT
  2067. site,
  2068. bu_no,
  2069. sub_detail_value,
  2070. sampling_location,
  2071. is_submit,
  2072. sampling_location_b,
  2073. num,
  2074. sub_detail_value_b,
  2075. sub_detail_value_c,
  2076. sub_detail_value_d,
  2077. sub_detail_value_e
  2078. FROM qc_ipqc_sub_detail_record
  2079. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2080. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2081. AND sub_detail_value ${collectionDataContent}
  2082. </if>
  2083. </select>
  2084. <!-- 查询IPQC检验记录是否已提交 -->
  2085. <select id="checkIPQCIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2086. SELECT submit_flag
  2087. FROM qc_ipqc_record
  2088. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2089. </select>
  2090. <!-- 获取该项目的子明细值 -->
  2091. <select id="selectIPQCSubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2092. SELECT sub_detail_value,
  2093. sampling_location,
  2094. is_submit
  2095. FROM qc_ipqc_sub_detail_record
  2096. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2097. </select>
  2098. <!-- 查询工序列表 -->
  2099. <select id="getOperationList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2100. SELECT
  2101. DISTINCT
  2102. a.seqno as seqNo,
  2103. a.orderno as orderNo,
  2104. j.part_no,
  2105. j.part_desc,
  2106. j.invdefinetype,
  2107. j.sku,
  2108. c.operation_desc as operationDesc,
  2109. a.itemno as operationNo,
  2110. a.s_resourceid as resourceId,
  2111. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  2112. c.work_center_no
  2113. FROM soscheduledrouting as a
  2114. LEFT JOIN so_routing as c ON a.site = c.site and c.order_no = a.orderno and a.itemno = c.item_no
  2115. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2116. WHERE a.site = #{site} and a.seqno = #{seqNo}
  2117. </select>
  2118. <!-- 根据工单号和工序号查出所有数据 -->
  2119. <select id="getResourceList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2120. SELECT
  2121. a.s_resourceid as resourceId,
  2122. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  2123. c.work_center_no
  2124. FROM soscheduledrouting as a
  2125. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2126. LEFT JOIN so_routing as c ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  2127. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2128. WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
  2129. ORDER BY a.id desc
  2130. </select>
  2131. <!-- a.orderno = #{orderNo} and c.operation_desc = #{operationDesc}-->
  2132. <!-- 查询机台名称 -->
  2133. <select id="selectResourceDesc" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2134. SELECT distinct
  2135. resource_desc
  2136. FROM resource
  2137. WHERE site = #{site} and resource_id = #{resourceId}
  2138. </select>
  2139. <!-- 查询物料名称 -->
  2140. <select id="selectPartDesc" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2141. SELECT distinct
  2142. part_desc
  2143. FROM part
  2144. WHERE site = #{site} and part_no = #{partNo}
  2145. </select>
  2146. <!-- ================================================= IQC检验维护 ================================================= -->
  2147. <!-- 查询IQC基础数据 -->
  2148. <select id="selectIQCBasicData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2149. SELECT
  2150. qir.inspection_no,
  2151. qir.state,
  2152. qir.create_date as taskDate,
  2153. qir.roll_no,
  2154. qir.part_no,
  2155. p.part_desc,
  2156. p.cinv_source_code,
  2157. p.sku as sku,
  2158. qir.roll_qty,
  2159. qir.print_flag,
  2160. qir.create_by,
  2161. qir.supplier_no,
  2162. qir.site,
  2163. qir.bu_no,
  2164. qir.po_orderNo,
  2165. qir.po_itemNo,
  2166. qir.roll_count
  2167. FROM qc_iqc_record as qir
  2168. LEFT JOIN part p ON qir.part_no = p.part_no and qir.site = p.site
  2169. WHERE qir.site in (select site from eam_access_site where username = #{userName})
  2170. and (qir.site + '-' + qir.bu_no) in (select * from dbo.query_bu(#{userName}))
  2171. and qir.detail_flag = 'N'
  2172. </select>
  2173. <!-- 新增IQC明细记录信息 -->
  2174. <insert id="saveIQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2175. 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,order_id)
  2176. 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},#{orderId,jdbcType=INTEGER})
  2177. </insert>
  2178. <!-- 修改IQC检验记录 -->
  2179. <update id="updateIQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2180. UPDATE qc_iqc_record
  2181. SET inspection_type_no = #{inspectionTypeNo},
  2182. sampling_qty = #{samplingQty},
  2183. inspection_cycle = #{inspectionCycle},
  2184. part_desc = #{partDesc},
  2185. detail_flag = 'Y',
  2186. state = '未开始',
  2187. action_date = '',
  2188. action_by = ''
  2189. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2190. </update>
  2191. <!-- 查询IQC主记录信息 -->
  2192. <select id="qcIQCInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2193. SELECT
  2194. a.inspection_no,
  2195. a.site,
  2196. a.bu_no,
  2197. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2198. a.state,
  2199. a.inspection_result,
  2200. a.create_date as taskDate,
  2201. a.inspection_type_no,
  2202. a.inspection_cycle,
  2203. a.part_no,
  2204. a.part_desc,
  2205. d.cinv_source_code as cinvSourceCode,
  2206. d.sku,
  2207. d.umid as umId,
  2208. d.invdefinetype as invdefinetype,
  2209. a.inspection_remark,
  2210. a.roll_qty,
  2211. a.sampling_qty,
  2212. a.disposal_measures,
  2213. a.disposal_remark,
  2214. a.inspector_date,
  2215. a.inspector_no,
  2216. u.user_display as inspectorName,
  2217. a.unqualified_quantity,
  2218. a.submit_flag,
  2219. a.roll_no,
  2220. a.supplier_no,
  2221. s.SupplierName as supplierDesc,
  2222. a.po_orderNo,
  2223. a.po_itemNo,
  2224. a.roll_count,
  2225. dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) as orderType,
  2226. a.action_date,
  2227. a.action_by,
  2228. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2229. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2230. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2231. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2232. a.submission_remark,
  2233. a.submission_type,
  2234. a.batch_no,
  2235. a.production_date,
  2236. a.expiration_warning_date,
  2237. a.expiration_date,
  2238. a.pass_qty,
  2239. a.not_pass_qty,
  2240. a.batch_qualified_qty
  2241. FROM qc_iqc_record as a
  2242. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  2243. left join view_Supplier as s on a.site = s.site and a.supplier_no = s.SupplierID
  2244. left join sys_user as u on a.inspector_no = u.username
  2245. <where>
  2246. a.site in (select site from eam_access_site where username = #{query.userName})
  2247. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2248. <if test="query.buNo != null and query.buNo != ''">
  2249. AND a.bu_no = #{query.buNo}
  2250. </if>
  2251. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2252. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2253. </if>
  2254. <if test = "query.states != null and query.states.size > 0">
  2255. AND a.state in
  2256. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2257. #{item}
  2258. </foreach>
  2259. </if>
  2260. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2261. AND a.inspection_result = #{query.inspectionResult}
  2262. </if>
  2263. <if test = "query.partNo != null and query.partNo != ''">
  2264. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2265. </if>
  2266. <if test = "query.partDesc != null and query.partDesc != ''">
  2267. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  2268. </if>
  2269. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2270. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2271. </if>
  2272. <if test = "query.sku != null and query.sku != ''">
  2273. AND d.sku LIKE '%' + #{query.sku} + '%'
  2274. </if>
  2275. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  2276. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  2277. </if>
  2278. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2279. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2280. </if>
  2281. <if test = "query.inspectorName != null and query.inspectorName != ''">
  2282. u.user_display LIKE '%' + #{query.inspectorName} + '%'
  2283. </if>
  2284. <if test="query.startDate != null">
  2285. AND a.inspector_date >= #{query.startDate}
  2286. </if>
  2287. <if test="query.endDate != null">
  2288. AND #{query.endDate} >= a.inspector_date
  2289. </if>
  2290. <if test="query.startDate2 != null">
  2291. AND a.create_date >= #{query.startDate2}
  2292. </if>
  2293. <if test="query.endDate2 != null">
  2294. AND #{query.endDate2} >= a.create_date
  2295. </if>
  2296. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  2297. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  2298. </if>
  2299. <if test = "query.poItemNo != null and query.poItemNo != ''">
  2300. AND a.po_itemNo LIKE '%' + #{query.poItemNo} + '%'
  2301. </if>
  2302. <if test = "query.orderType != null and query.orderType != ''">
  2303. AND dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) = #{query.orderType}
  2304. </if>
  2305. <if test = "query.submissionType != null and query.submissionType != ''">
  2306. AND a.submission_type = #{query.submissionType}
  2307. </if>
  2308. <if test = "query.invdefinetype != null and query.invdefinetype != ''">
  2309. AND d.invdefinetype LIKE '%' + #{query.invdefinetype} + '%'
  2310. </if>
  2311. </where>
  2312. ORDER BY
  2313. CASE WHEN a.state = '待检验' THEN 1
  2314. WHEN a.state = '待审核' THEN 2
  2315. WHEN a.state = '已完成' THEN 3
  2316. END, a.create_date desc
  2317. </select>
  2318. <!-- IQC明细记录查询 -->
  2319. <select id="iqcDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2320. SELECT
  2321. a.site,
  2322. a.bu_no,
  2323. a.inspection_no,
  2324. a.template_id,
  2325. a.sampling_level_no,
  2326. a.sampling_level_desc,
  2327. a.sampling_programme_no,
  2328. a.sampling_programme_desc,
  2329. a.AQL,
  2330. a.AC,
  2331. a.RE,
  2332. a.item_no,
  2333. a.item_desc,
  2334. a.object_id,
  2335. a.object_desc,
  2336. a.default_value,
  2337. a.min_value,
  2338. a.max_value,
  2339. a.text_value,
  2340. a.number_value,
  2341. a.value_type_db,
  2342. a.value_type,
  2343. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2344. a.is_submit,
  2345. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2346. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2347. c.method_no,
  2348. c.method_name,
  2349. c.method_remark,
  2350. a.sampling_qty
  2351. FROM qc_iqc_detailed_record as a
  2352. 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
  2353. 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
  2354. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2355. order by a.order_id
  2356. </select>
  2357. <!-- 查询IQC的子明细 -->
  2358. <select id="selectIQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2359. SELECT
  2360. site,
  2361. bu_no,
  2362. sub_detail_value,
  2363. sampling_location,
  2364. is_submit,
  2365. sampling_location_b,
  2366. num,
  2367. sub_detail_value_b,
  2368. sub_detail_value_c,
  2369. sub_detail_value_d,
  2370. sub_detail_value_e
  2371. FROM qc_iqc_sub_detail_record
  2372. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2373. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2374. AND sub_detail_value ${collectionDataContent}
  2375. </if>
  2376. </select>
  2377. <!-- 获取该项目的子明细值 -->
  2378. <select id="selectIQCSubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2379. SELECT sub_detail_value,
  2380. sampling_location,
  2381. is_submit
  2382. FROM qc_iqc_sub_detail_record
  2383. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2384. </select>
  2385. <!-- 修改IQC主记录信息 -->
  2386. <update id="updateIQCMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2387. UPDATE qc_iqc_record
  2388. SET disposal_measures = #{disposalMeasures},
  2389. disposal_remark = #{disposalRemark},
  2390. inspection_result = #{inspectionResult},
  2391. inspector_no = #{inspectorNo},
  2392. state = #{state},
  2393. inspection_remark = #{inspectionRemark},
  2394. inspector_date = getDate(),
  2395. roll_count = #{rollCount,jdbcType=DECIMAL},
  2396. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2397. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2398. pass_qty = #{passQty,jdbcType=DECIMAL},
  2399. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2400. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  2401. submit_date = getDate()
  2402. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2403. </update>
  2404. <!-- 修改IQC明细记录信息 -->
  2405. <update id="updateIQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2406. UPDATE qc_iqc_detailed_record
  2407. SET item_result = #{itemResult},
  2408. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2409. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2410. text_value = #{textValue},
  2411. number_value = #{numberValue,jdbcType=DECIMAL}
  2412. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2413. </update>
  2414. <!-- 查询该记录明细是否已存在 -->
  2415. <select id="checkIQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2416. SELECT inspection_no,
  2417. template_id
  2418. FROM qc_iqc_detailed_record
  2419. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2420. </select>
  2421. <!-- 查询IQC检验记录是否已提交 -->
  2422. <select id="checkIQCIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2423. SELECT submit_flag
  2424. FROM qc_iqc_record
  2425. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2426. </select>
  2427. <!-- 删除IQC子明细的老数据 -->
  2428. <delete id="delIQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  2429. DELETE FROM qc_iqc_sub_detail_record
  2430. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2431. </delete>
  2432. <!-- 新增IQC子明细信息 -->
  2433. <insert id="saveIQCSubDetailed">
  2434. INSERT INTO qc_iqc_sub_detail_record
  2435. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
  2436. VALUES
  2437. <foreach collection="list" item="item" separator=",">
  2438. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  2439. </foreach>
  2440. </insert>
  2441. <!-- 修改IQC主记录标识为已提交 -->
  2442. <update id="updateIQCMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2443. UPDATE qc_iqc_record
  2444. SET submit_flag = 'Y',
  2445. state = '已完成',
  2446. submit_date = getDate()
  2447. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2448. </update>
  2449. <!-- 修改IQC明细记录标识为已提交 -->
  2450. <update id="updateIQCDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2451. UPDATE qc_iqc_detailed_record
  2452. SET is_submit = 'Y'
  2453. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2454. </update>
  2455. <!-- 修改IQC子明细记录标识为已提交 -->
  2456. <update id="updateIQCSubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2457. UPDATE qc_iqc_sub_detail_record
  2458. SET is_submit = 'Y'
  2459. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2460. </update>
  2461. <!-- 删除IQC检验记录 -->
  2462. <delete id="deleteIQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2463. DELETE FROM qc_iqc_record
  2464. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2465. </delete>
  2466. <!-- 删除IQC明细记录信息 -->
  2467. <delete id="deleteIQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2468. DELETE FROM qc_iqc_detailed_record
  2469. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2470. </delete>
  2471. <!-- 删除IQC子明细记录信息 -->
  2472. <delete id="deleteIQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2473. DELETE FROM qc_iqc_sub_detail_record
  2474. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2475. </delete>
  2476. <!-- 查询文件ID -->
  2477. <select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
  2478. SELECT id, file_name
  2479. FROM sys_oss
  2480. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  2481. </select>
  2482. <!-- 获取工序列表 -->
  2483. <select id="getOperationDescList" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  2484. SELECT distinct
  2485. operation_desc
  2486. FROM so_routing
  2487. <where>
  2488. <if test = "operationDesc != null and operationDesc != ''">
  2489. AND operation_desc LIKE '%' + #{operationDesc} + '%'
  2490. </if>
  2491. </where>
  2492. </select>
  2493. <!-- 获取供应商列表 -->
  2494. <select id="getManufacturerList" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  2495. SELECT
  2496. supplierID as manufacturerID,
  2497. supplierName as manufacturerName
  2498. FROM view_Supplier
  2499. <where>
  2500. site = #{site}
  2501. <if test = "manufacturerID != null and manufacturerID != ''">
  2502. AND supplierID LIKE '%' + #{manufacturerID} + '%'
  2503. </if>
  2504. <if test = "manufacturerName != null and manufacturerName != ''">
  2505. AND supplierName LIKE '%' + #{manufacturerName} + '%'
  2506. </if>
  2507. </where>
  2508. </select>
  2509. <!-- 获取机台列表 -->
  2510. <select id="getAllResourceList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2511. SELECT distinct
  2512. resource_id,
  2513. resource_desc
  2514. FROM resource
  2515. <where>
  2516. site = #{site}
  2517. <if test = "resourceId != null and resourceId != ''">
  2518. AND resource_id LIKE '%' + #{resourceId} + '%'
  2519. </if>
  2520. <if test = "resourceDesc != null and resourceDesc != ''">
  2521. AND resource_desc LIKE '%' + #{resourceDesc} + '%'
  2522. </if>
  2523. </where>
  2524. </select>
  2525. <!-- 获取工单列表 -->
  2526. <select id="getOrderNoList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2527. SELECT DISTINCT
  2528. a.orderno as orderNo
  2529. FROM soscheduledrouting as a
  2530. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2531. LEFT JOIN so_routing as c ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  2532. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2533. <where>
  2534. a.site = #{site}
  2535. AND b.approve_qty is not null
  2536. <if test = "orderNo != null and orderNo != ''">
  2537. AND a.orderno LIKE '%' + #{orderNo} + '%'
  2538. </if>
  2539. </where>
  2540. order by a.orderno DESC
  2541. </select>
  2542. <!-- 查询FQC主记录信息 -->
  2543. <select id="qcFQCInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2544. SELECT
  2545. a.inspection_no,
  2546. a.site,
  2547. a.bu_no,
  2548. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2549. a.state,
  2550. a.inspection_result,
  2551. a.task_date,
  2552. a.inspection_type_no,
  2553. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  2554. a.inspection_cycle,
  2555. a.order_no,
  2556. a.operation_desc,
  2557. a.resource_id,
  2558. r.resource_desc,
  2559. a.part_no,
  2560. d.part_desc,
  2561. d.cinv_source_code as cinvSourceCode,
  2562. d.sku as sku,
  2563. d.invdefinetype as invdefinetype,
  2564. a.inspection_remark,
  2565. a.roll_qty,
  2566. a.sampling_qty,
  2567. a.disposal_measures,
  2568. a.disposal_remark,
  2569. a.inspector_date,
  2570. a.inspector_no,
  2571. u.user_display as inspectorName,
  2572. a.ssr_id,
  2573. a.unqualified_qty,
  2574. a.submit_flag,
  2575. a.seq_no,
  2576. a.batch_roll_no,
  2577. a.special_requirements,
  2578. a.work_center_no,
  2579. a.roll_no,
  2580. a.um_id,
  2581. um.UMName as umName,
  2582. a.action_date,
  2583. a.action_by,
  2584. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2585. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2586. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2587. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2588. a.pass_qty,
  2589. a.not_pass_qty,
  2590. a.batch_qualified_qty
  2591. FROM qc_fqc_record as a
  2592. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  2593. left join sys_user as u on a.inspector_no = u.username
  2594. left join resource as r on a.site = r.site and a.resource_id = r.resource_id and a.work_center_no = r.work_center_no
  2595. left join UM as um on a.site = um.site and a.um_id = um.UMID
  2596. <where>
  2597. a.site in (select site from eam_access_site where username = #{query.userName})
  2598. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2599. <if test="query.buNo != null and query.buNo != ''">
  2600. AND a.bu_no = #{query.buNo}
  2601. </if>
  2602. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2603. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2604. </if>
  2605. <if test = "query.partNo != null and query.partNo != ''">
  2606. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2607. </if>
  2608. <if test = "query.partDesc != null and query.partDesc != ''">
  2609. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  2610. </if>
  2611. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2612. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2613. </if>
  2614. <if test = "query.sku != null and query.sku != ''">
  2615. AND d.sku LIKE '%' + #{query.sku} + '%'
  2616. </if>
  2617. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2618. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2619. </if>
  2620. <if test = "query.states != null and query.states.size > 0">
  2621. AND a.state in
  2622. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2623. #{item}
  2624. </foreach>
  2625. </if>
  2626. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2627. AND a.inspection_result = #{query.inspectionResult}
  2628. </if>
  2629. <if test = "query.orderNo != null and query.orderNo != ''">
  2630. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2631. </if>
  2632. <if test = "query.seqNo != null and query.seqNo != ''">
  2633. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  2634. </if>
  2635. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2636. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2637. </if>
  2638. <if test="query.startDate != null">
  2639. AND a.inspector_date >= #{query.startDate}
  2640. </if>
  2641. <if test="query.endDate != null">
  2642. AND #{query.endDate} >= a.inspector_date
  2643. </if>
  2644. <if test="query.startDate2 != null">
  2645. AND a.task_date >= #{query.startDate2}
  2646. </if>
  2647. <if test="query.endDate2 != null">
  2648. AND #{query.endDate2} >= a.task_date
  2649. </if>
  2650. </where>
  2651. ORDER BY
  2652. CASE WHEN a.state = '待检验' THEN 1
  2653. WHEN a.state = '待审核' THEN 2
  2654. WHEN a.state = '已完成' THEN 3
  2655. END, a.task_date desc
  2656. </select>
  2657. <insert id="saveFQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2658. INSERT INTO qc_fqc_detailed_record
  2659. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2660. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2661. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  2662. VALUES
  2663. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  2664. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  2665. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  2666. </insert>
  2667. <!-- 新增FQC明细记录信息 -->
  2668. <insert id="saveFQCDetailedRecords">
  2669. INSERT INTO qc_fqc_detailed_record
  2670. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2671. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2672. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  2673. VALUES
  2674. <foreach collection="list" item="item" separator=",">
  2675. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  2676. #{item.aql,jdbcType=DECIMAL}, #{item.ac,jdbcType=DECIMAL}, #{item.re,jdbcType=DECIMAL}, #{item.itemNo}, #{item.itemDesc}, #{item.objectId}, #{item.objectDesc}, #{item.defaultValue}, #{item.minValue,jdbcType=DECIMAL},
  2677. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  2678. </foreach>
  2679. </insert>
  2680. <!-- 新增FQC主记录信息 -->
  2681. <insert id="saveFQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2682. INSERT INTO qc_fqc_record
  2683. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  2684. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  2685. VALUES
  2686. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  2687. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  2688. </insert>
  2689. <!-- FQC明细记录查询 -->
  2690. <select id="fqcDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2691. SELECT
  2692. a.site,
  2693. a.bu_no,
  2694. a.inspection_no,
  2695. a.order_no,
  2696. a.template_id,
  2697. a.sampling_level_no,
  2698. a.sampling_level_desc,
  2699. a.sampling_programme_no,
  2700. a.sampling_programme_desc,
  2701. a.AQL,
  2702. a.AC,
  2703. a.RE,
  2704. a.item_no,
  2705. a.item_desc,
  2706. a.object_id,
  2707. a.object_desc,
  2708. a.default_value,
  2709. a.min_value,
  2710. a.max_value,
  2711. a.text_value,
  2712. a.number_value,
  2713. a.value_type_db,
  2714. a.value_type,
  2715. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2716. a.is_submit,
  2717. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2718. a.sampling_qty,
  2719. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2720. c.method_no,
  2721. c.method_name,
  2722. c.method_remark
  2723. FROM qc_fqc_detailed_record as a
  2724. 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
  2725. 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
  2726. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2727. order by a.order_id
  2728. </select>
  2729. <!-- 删除FQC检验记录 -->
  2730. <delete id="deleteFQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2731. DELETE FROM qc_fqc_record
  2732. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2733. </delete>
  2734. <!-- 删除FQC明细记录信息 -->
  2735. <delete id="deleteFQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2736. DELETE FROM qc_fqc_detailed_record
  2737. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2738. </delete>
  2739. <!-- 删除FQC子明细记录信息 -->
  2740. <delete id="deleteFQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2741. DELETE FROM qc_fqc_sub_detail_record
  2742. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2743. </delete>
  2744. <!-- 修改FQC主记录信息 -->
  2745. <update id="updateFQCMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2746. UPDATE qc_fqc_record
  2747. SET disposal_measures = #{disposalMeasures},
  2748. disposal_remark = #{disposalRemark},
  2749. inspection_result = #{inspectionResult},
  2750. inspector_no = #{inspectorNo},
  2751. state = #{state},
  2752. inspection_remark = #{inspectionRemark},
  2753. inspector_date = getDate(),
  2754. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2755. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2756. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2757. pass_qty = #{passQty,jdbcType=DECIMAL},
  2758. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2759. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  2760. submit_date = getDate()
  2761. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2762. </update>
  2763. <!-- 修改FQC明细记录信息 -->
  2764. <update id="updateFQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2765. UPDATE qc_fqc_detailed_record
  2766. SET item_result = #{itemResult},
  2767. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2768. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2769. text_value = #{textValue},
  2770. number_value = #{numberValue,jdbcType=DECIMAL}
  2771. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2772. </update>
  2773. <!-- 修改FQC主记录标识为已提交 -->
  2774. <update id="updateFQCMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2775. UPDATE qc_fqc_record
  2776. SET submit_flag = 'Y',
  2777. state = '已完成',
  2778. submit_date = getDate()
  2779. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2780. </update>
  2781. <!-- 修改FAI明细记录标识为已提交 -->
  2782. <update id="updateFQCDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2783. UPDATE qc_fqc_detailed_record
  2784. SET is_submit = 'Y'
  2785. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2786. </update>
  2787. <!-- 修改子明细记录标识为已提交 -->
  2788. <update id="updateFQCSubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2789. UPDATE qc_fqc_sub_detail_record
  2790. SET is_submit = 'Y'
  2791. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2792. </update>
  2793. <!-- 删除子明细的老数据 -->
  2794. <delete id="delFQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  2795. DELETE FROM qc_fqc_sub_detail_record
  2796. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2797. </delete>
  2798. <!-- 新增子明细信息 -->
  2799. <insert id="saveFQCSubDetailed">
  2800. INSERT INTO qc_fqc_sub_detail_record
  2801. (inspection_no, item_no, sub_detail_value, sampling_location, site, sampling_location_b, bu_no, num, sub_detail_value_b, sub_detail_value_c, sub_detail_value_d, sub_detail_value_e)
  2802. VALUES
  2803. <foreach collection="list" item="item" separator=",">
  2804. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  2805. </foreach>
  2806. </insert>
  2807. <!-- 查询FQC的子明细 -->
  2808. <select id="selectFQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2809. SELECT
  2810. site,
  2811. bu_no,
  2812. sub_detail_value,
  2813. sampling_location,
  2814. is_submit,
  2815. sampling_location_b,
  2816. num,
  2817. sub_detail_value_b,
  2818. sub_detail_value_c,
  2819. sub_detail_value_d,
  2820. sub_detail_value_e
  2821. FROM qc_fqc_sub_detail_record
  2822. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2823. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2824. AND sub_detail_value ${collectionDataContent}
  2825. </if>
  2826. </select>
  2827. <!-- 查询FQC检验记录是否已提交 -->
  2828. <select id="checkFQCIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2829. SELECT submit_flag
  2830. FROM qc_fqc_record
  2831. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2832. </select>
  2833. <!-- 获取该项目的子明细值 -->
  2834. <select id="selectFQCSubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2835. SELECT sub_detail_value,
  2836. sampling_location,
  2837. is_submit
  2838. FROM qc_fqc_sub_detail_record
  2839. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2840. </select>
  2841. <!-- 生成FQC检验单号 -->
  2842. <select id="selectFQCInspectionNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2843. SELECT
  2844. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2845. FROM qc_fqc_record
  2846. WHERE site = #{site} and bu_no = #{buNo}
  2847. </select>
  2848. <!-- 生成IPQC检验单号 -->
  2849. <select id="selectIPQCInspectionNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2850. SELECT
  2851. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  2852. FROM qc_ipqc_record
  2853. WHERE site = #{site} and bu_no = #{buNo}
  2854. </select>
  2855. <!-- 生成FAI检验单号 -->
  2856. <select id="selectFAIInspectionNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2857. SELECT
  2858. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  2859. FROM qc_fai_record
  2860. WHERE site = #{site} and bu_no = #{buNo}
  2861. </select>
  2862. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  2863. <select id="queryDataFromViewPoOrder" resultType="com.xujie.sys.modules.pms.data.PoOrderData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2864. SELECT
  2865. site,
  2866. order_no,
  2867. item_no,
  2868. part_no,
  2869. part_desc,
  2870. spec,
  2871. supplier_id,
  2872. supplier_name,
  2873. order_qty,
  2874. created_date,
  2875. status,
  2876. citem_code,
  2877. citem_class,
  2878. sendto_address,
  2879. order_type
  2880. FROM view_po_order
  2881. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  2882. </select>
  2883. <!-- 向收货任务表里添加数据 -->
  2884. <insert id="saveReceivingTask" parameterType="com.xujie.sys.modules.pms.data.PoOrderData">
  2885. 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, batch_no, production_date, expiration_warning_date, expiration_date)
  2886. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}, #{batchNo}, #{productionDate}, #{expirationWarningDate}, #{expirationDate})
  2887. </insert>
  2888. <!-- 检查动控是否开启 -->
  2889. <select id="queryController" parameterType="com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity" resultType="com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity">
  2890. SELECT
  2891. type,
  2892. base_data,
  2893. base_desc,
  2894. status,
  2895. remark,
  2896. third_type,
  2897. second_type,
  2898. page_control,
  2899. control_style
  2900. FROM sys_scene_dynamic_control_model
  2901. where site = #{site} and control_no = #{controlNo}
  2902. </select>
  2903. <!-- 查询检验模板列表 -->
  2904. <select id="queryTemplateList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  2905. SELECT
  2906. site,
  2907. bu_no,
  2908. template_id as templateId,
  2909. template_name as templateName,
  2910. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  2911. FROM qc_template
  2912. <where>
  2913. site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  2914. <if test = "templateId != null and templateId != ''">
  2915. AND template_id LIKE '%' + #{templateId}+'%'
  2916. </if>
  2917. <if test = "templateName != null and templateName != ''">
  2918. AND template_name LIKE '%' + #{templateName}+'%'
  2919. </if>
  2920. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  2921. AND inspection_type_no = #{inspectionTypeNo}
  2922. </if>
  2923. </where>
  2924. </select>
  2925. <!-- 查询检验模板列表 -->
  2926. <select id="getPartInformation" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2927. select
  2928. part_no,
  2929. part_desc,
  2930. spec,
  2931. sku,
  2932. control_mes,
  2933. DefaultWarehouseID as defaultWarehouseId
  2934. from part
  2935. where site = #{site} and part_no = #{partNo}
  2936. </select>
  2937. <!-- 获取特殊工序列表 -->
  2938. <select id="getSpecialOperationList" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2939. select
  2940. site,
  2941. operation_no,
  2942. operation_desc
  2943. from qc_special_task_operation
  2944. where site = #{site}
  2945. </select>
  2946. <!-- 获取处置措施列表 -->
  2947. <select id="disposalMeasuresSearch" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2948. SELECT
  2949. id,
  2950. disposal_measures
  2951. FROM qc_disposal_measures
  2952. <where>
  2953. <if test = "inspectionTypeNo != '101'">
  2954. inspection_type != 'IPQC'
  2955. </if>
  2956. </where>
  2957. </select>
  2958. <!-- 查询文件路径 -->
  2959. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2960. SELECT
  2961. id,
  2962. url,
  2963. file_name
  2964. FROM sys_oss
  2965. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  2966. </select>
  2967. <!-- 删除图片-->
  2968. <delete id="imageDelete" parameterType="SysOssEntity">
  2969. DELETE FROM sys_oss
  2970. WHERE id = #{id}
  2971. </delete>
  2972. <!-- 模糊查询标签号 -->
  2973. <select id="getRollNo" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2974. SELECT DISTINCT top 3
  2975. a.seqno,
  2976. a.orderno,
  2977. b.roll_no
  2978. FROM soscheduledrouting AS a
  2979. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  2980. WHERE a.site = #{site} and b.roll_no like '%' + #{rollNo} + '%'
  2981. </select>
  2982. <!-- 标签号回车事件 -->
  2983. <select id="rollNoEnter" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2984. SELECT
  2985. a.site,
  2986. a.seqno as seqNo,
  2987. a.orderno as orderNo,
  2988. b.roll_no,
  2989. #{inspectionTypeNo} as inspectionTypeNo
  2990. FROM soscheduledrouting AS a
  2991. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  2992. WHERE a.site = #{site} and b.roll_no = #{rollNo}
  2993. </select>
  2994. <!-- 查询物料列表 -->
  2995. <select id="queryPartList" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2996. SELECT
  2997. site,
  2998. part_no,
  2999. part_desc,
  3000. sku,
  3001. spec
  3002. FROM part
  3003. <where>
  3004. site = #{site}
  3005. <if test = "partNo != null and partNo != ''">
  3006. AND part_no LIKE '%' + #{partNo} + '%'
  3007. </if>
  3008. <if test = "partDesc != null and partDesc != ''">
  3009. AND part_desc LIKE '%' + #{partDesc} + '%'
  3010. </if>
  3011. <if test = "sku != null and sku != ''">
  3012. AND sku LIKE '%' + #{sku} + '%'
  3013. </if>
  3014. </where>
  3015. </select>
  3016. <!-- 查询单位列表 -->
  3017. <select id="umSearch" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3018. SELECT
  3019. site,
  3020. UMID as umId,
  3021. UMName as umName
  3022. FROM UM
  3023. WHERE site = #{site} and active = #{active}
  3024. </select>
  3025. <!-- 查询单位列表 -->
  3026. <select id="checkItem" resultType="com.xujie.sys.modules.pms.data.SubDetailValues" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3027. SELECT
  3028. site,
  3029. bu_no,
  3030. inspection_no,
  3031. item_no,
  3032. value_type_db,
  3033. min_value,
  3034. max_value
  3035. <if test = "flag == 'IPQC'">
  3036. FROM qc_ipqc_detailed_record
  3037. </if>
  3038. <if test = "flag == 'IQC'">
  3039. FROM qc_iqc_detailed_record
  3040. </if>
  3041. <if test = "flag == 'FQC'">
  3042. FROM qc_fqc_detailed_record
  3043. </if>
  3044. <if test = "flag == 'FAI'">
  3045. FROM qc_fai_detailed_record
  3046. </if>
  3047. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  3048. order by order_id
  3049. </select>
  3050. <!-- 查询检验方法列表 -->
  3051. <select id="queryMethodList" resultType="com.xujie.sys.modules.pms.data.QcMethodData" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  3052. SELECT
  3053. site,
  3054. bu_no,
  3055. method_no,
  3056. method_name,
  3057. inspection_type_no,
  3058. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  3059. FROM qc_method
  3060. <where>
  3061. site = #{site} and bu_no = #{buNo}
  3062. <if test = "methodNo != null and methodNo != ''">
  3063. AND method_no LIKE '%' + #{methodNo} + '%'
  3064. </if>
  3065. <if test = "methodName != null and methodName != ''">
  3066. AND method_name LIKE '%' + #{methodName} + '%'
  3067. </if>
  3068. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  3069. AND inspection_type_no = #{inspectionTypeNo}
  3070. </if>
  3071. <if test="inspectionTypeName != null and inspectionTypeName != ''">
  3072. AND dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  3073. </if>
  3074. </where>
  3075. </select>
  3076. <!-- 修改detailFlag字段为N -->
  3077. <update id="updateIQCDetailFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3078. UPDATE qc_iqc_record
  3079. SET detail_flag = 'N'
  3080. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3081. </update>
  3082. <!-- 查询检验方法唯一 -->
  3083. <select id="checkMethodOnlyOne" resultType="com.xujie.sys.modules.pms.data.QcMethodData" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  3084. SELECT
  3085. site,
  3086. bu_no,
  3087. method_no
  3088. FROM qc_method
  3089. <where>
  3090. site = #{site} and bu_no = #{buNo} and method_no = #{methodNo}
  3091. </where>
  3092. </select>
  3093. <!-- 查询检验项目唯一 -->
  3094. <select id="checkItemOnlyOne" resultType="com.xujie.sys.modules.pms.data.QcItemData" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  3095. SELECT
  3096. site,
  3097. bu_no,
  3098. ItemNo,
  3099. ItemDesc
  3100. FROM eam_properties_item
  3101. <where>
  3102. site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ItemType = #{itemType} and inspection_type_no = #{inspectionTypeNo}
  3103. </where>
  3104. </select>
  3105. <!-- 查询检验项目唯一 -->
  3106. <select id="checkTemplateOnlyOne" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  3107. SELECT
  3108. site,
  3109. bu_no,
  3110. template_id,
  3111. template_name
  3112. FROM qc_template
  3113. <where>
  3114. site = #{site} and bu_no = #{buNo} and template_id = #{templateId}
  3115. </where>
  3116. </select>
  3117. <select id="searchSeqInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3118. SELECT DISTINCT
  3119. a.seqno,
  3120. a.orderno,
  3121. J.part_no,
  3122. J.part_desc,
  3123. t.lotsize,
  3124. a.qtyrequired,
  3125. c.operation_desc,
  3126. J.sku,
  3127. sum(roll_qty) as sjzs
  3128. FROM soscheduledrouting AS a
  3129. inner JOIN so_routing AS c ON c.site = a.site AND c.order_no = a.orderno AND a.itemno = c.item_no
  3130. inner JOIN part AS J ON a.site = J.site AND a.part_no = J.part_no
  3131. inner JOIN shoporder AS t ON a.site = t.site AND t.orderno = a.orderno
  3132. left join qc_ipqc_record as r on a.site = r.site and a.seqno = r.seq_no
  3133. WHERE
  3134. a.site = #{query.site} and J.sourceBu = #{query.buNo}
  3135. <if test="query.status != null and query.status != ''">
  3136. AND t.status = #{query.status}
  3137. </if>
  3138. <if test="query.orderNo != null and query.orderNo != ''">
  3139. AND a.orderno LIKE '%' + #{query.orderNo} + '%'
  3140. </if>
  3141. <if test="query.seqNo != null and query.seqNo != ''">
  3142. AND a.seqno LIKE '%' + #{query.seqNo} + '%'
  3143. </if>
  3144. <if test="query.sku != null and query.sku != ''">
  3145. AND j.sku LIKE '%' + #{query.sku} + '%'
  3146. </if>
  3147. <if test="query.partNo != null and query.partNo != ''">
  3148. AND J.part_no LIKE '%' + #{query.partNo} + '%'
  3149. </if>
  3150. <if test="query.partDesc != null and query.partDesc != ''">
  3151. AND J.part_desc LIKE '%' + #{query.partDesc} + '%'
  3152. </if>
  3153. <if test="query.operationDesc != null and query.operationDesc != ''">
  3154. AND c.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  3155. </if>
  3156. group by a.seqno, a.orderno, J.part_no, J.part_desc, t.lotsize, a.qtyrequired, c.operation_desc, J.sku
  3157. </select>
  3158. <select id="searchPartInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3159. select
  3160. part_no,
  3161. part_desc,
  3162. sku,
  3163. cinv_source_code,
  3164. sourceBu
  3165. from
  3166. part
  3167. where
  3168. sourceBu = #{query.buNo}
  3169. <if test="query.partNo != null and query.partNo != ''">
  3170. AND part_no LIKE '%' + #{query.partNo} + '%'
  3171. </if>
  3172. <if test="query.partDesc != null and query.partDesc != ''">
  3173. AND part_desc LIKE '%' + #{query.partDesc} + '%'
  3174. </if>
  3175. <if test="query.sku != null and query.sku != ''">
  3176. AND sku LIKE '%' + #{query.sku} + '%'
  3177. </if>
  3178. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  3179. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  3180. </if>
  3181. </select>
  3182. <select id="getInterfaceTimeData" parameterType="String" resultType="com.xujie.sys.modules.pms.data.InterfaceTimeData">
  3183. SELECT
  3184. id,
  3185. start_time,
  3186. end_time,
  3187. del_flag
  3188. FROM interface_time
  3189. WHERE del_flag = 'N' and site = #{site}
  3190. </select>
  3191. <update id="updateInterfaceTimeData" parameterType="com.xujie.sys.modules.pms.data.InterfaceTimeData">
  3192. UPDATE interface_time
  3193. set
  3194. updated_by = #{updatedBy},
  3195. updated_date = #{updatedDate},
  3196. del_flag = #{delFlag}
  3197. </update>
  3198. <select id="getInterfaceRdStyleData" parameterType="String" resultType="com.xujie.sys.modules.pms.data.RdStyleData">
  3199. SELECT
  3200. crdcode,
  3201. crdname,
  3202. iRdGrade,
  3203. rdtype,
  3204. brdend
  3205. FROM view_custdev_mes_rdstyle
  3206. WHERE crdname = #{crdName}
  3207. </select>
  3208. <insert id="insertHardtagPurchaseInStorageData" parameterType="com.xujie.sys.modules.pms.data.HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
  3209. INSERT INTO purchase_in_storage_count
  3210. (site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
  3211. cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
  3212. values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
  3213. #{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
  3214. </insert>
  3215. <insert id="batchSaveHrdtagTransHeader" parameterType="com.xujie.sys.modules.pms.data.HardtagTransHeaderData">
  3216. insert into TransHeader
  3217. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
  3218. TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
  3219. department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
  3220. values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
  3221. #{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
  3222. #{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
  3223. </insert>
  3224. <insert id="batchSaveHardtagTransDetail" parameterType="com.xujie.sys.modules.pms.data.HardtagTransDetailData">
  3225. INSERT INTO TransDetail
  3226. (TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
  3227. values
  3228. (#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
  3229. </insert>
  3230. <select id="getSendMailAddress" parameterType="String" resultType="com.xujie.sys.modules.pms.data.MailAddressData">
  3231. SELECT
  3232. id,
  3233. site,
  3234. bu_no,
  3235. mail_address,
  3236. send_type,
  3237. del_flag,
  3238. created_by,
  3239. created_date,
  3240. orderref1
  3241. FROM mailAddress
  3242. WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
  3243. <if test="buNo != null and buNo != ''">
  3244. AND bu_no = #{buNo}
  3245. </if>
  3246. </select>
  3247. <select id="getSendMailFromAddress" resultType="com.xujie.sys.modules.pms.data.MailSendAddressData">
  3248. SELECT
  3249. port,
  3250. host,
  3251. username,
  3252. password,
  3253. emailForm,
  3254. timeout,
  3255. personal,
  3256. id
  3257. FROM mailSendAddress
  3258. where delFlag = 'N'
  3259. </select>
  3260. <!-- 新增发送邮件记录 -->
  3261. <insert id="saveSendMailRecord" parameterType="com.xujie.sys.modules.pms.data.SendMailRecord">
  3262. insert into send_mail_record
  3263. (site, bu_no, document_no, sender, recipient, send_date, type)
  3264. values
  3265. (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate(), #{type})
  3266. </insert>
  3267. <select id="orderTypeSearch" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3268. SELECT distinct
  3269. order_type
  3270. FROM view_po_order
  3271. </select>
  3272. <update id="actionIQCInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3273. update qc_iqc_record
  3274. set action_date = getDate(),
  3275. action_by = #{actionBy},
  3276. state = #{state}
  3277. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3278. </update>
  3279. <update id="actionFAIInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3280. update qc_fai_record
  3281. set action_date = getDate(),
  3282. action_by = #{actionBy},
  3283. state = #{state}
  3284. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3285. </update>
  3286. <update id="actionIPQCInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3287. update qc_ipqc_record
  3288. set action_date = getDate(),
  3289. action_by = #{actionBy},
  3290. state = #{state}
  3291. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3292. </update>
  3293. <update id="actionFQCInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3294. update qc_fqc_record
  3295. set action_date = getDate(),
  3296. action_by = #{actionBy},
  3297. state = #{state}
  3298. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3299. </update>
  3300. <insert id="addEquipmentDataAcquisition">
  3301. insert into Equipment_data_acquisition
  3302. (site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
  3303. values
  3304. <foreach collection="list" item="item" separator=",">
  3305. (#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
  3306. </foreach>
  3307. </insert>
  3308. <!-- 新增人员信息 -->
  3309. <insert id="saveOperator" >
  3310. INSERT INTO eam_actual_operator
  3311. (site, order_no, function_type, operator, bu_no)
  3312. VALUES
  3313. <foreach collection="list" item="item" separator=",">
  3314. (#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
  3315. </foreach>
  3316. </insert>
  3317. <!-- 删除之前的人员-->
  3318. <delete id="delOperator" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3319. DELETE FROM eam_actual_operator
  3320. WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
  3321. </delete>
  3322. <select id="getInspectionNo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3323. select distinct
  3324. site,
  3325. bu_no,
  3326. equipment_no,
  3327. inspection_no,
  3328. item_no,
  3329. collection_source,
  3330. collection_method
  3331. from Equipment_data_acquisition
  3332. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3333. </select>
  3334. <select id="getInspectionNoByItem" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3335. select distinct
  3336. site,
  3337. bu_no,
  3338. equipment_no,
  3339. inspection_no,
  3340. item_no,
  3341. collection_source,
  3342. collection_method
  3343. from Equipment_data_acquisition
  3344. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  3345. </select>
  3346. <select id="dataAcquisition" parameterType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3347. select
  3348. id,
  3349. site,
  3350. bu_no,
  3351. #{inspectionNo} as inspectionNo,
  3352. #{itemNo} as itemNo,
  3353. <if test='subDetailValueType == 0'>
  3354. ${collectionSource} as subDetailValue,
  3355. </if>
  3356. <if test='subDetailValueType == 1'>
  3357. ${collectionSource} as subDetailValueB,
  3358. </if>
  3359. <if test='subDetailValueType == 2'>
  3360. ${collectionSource} as subDetailValueC,
  3361. </if>
  3362. <if test='subDetailValueType == 3'>
  3363. ${collectionSource} as subDetailValueD,
  3364. </if>
  3365. <if test='subDetailValueType == 4'>
  3366. ${collectionSource} as subDetailValueE,
  3367. </if>
  3368. num,
  3369. #{collectionSource} as collectionSource,
  3370. #{collectionMethod} as collectionMethod
  3371. from Equipment_data_detail
  3372. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3373. <if test='collectionMethod == "plc"'>
  3374. AND inspection_no = #{inspectionNo}
  3375. </if>
  3376. <if test='collectionMethod == "RS232"'>
  3377. AND (inspection_no is null or inspection_no = '')
  3378. </if>
  3379. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3380. AND ${collectionSource} ${collectionDataContent}
  3381. </if>
  3382. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3383. </select>
  3384. <select id="dataAcquisitionB" parameterType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3385. select
  3386. id,
  3387. site,
  3388. bu_no,
  3389. #{inspectionNo} as inspectionNo,
  3390. #{itemNo} as itemNo,
  3391. ${collectionSource} as subDetailValueB,
  3392. num,
  3393. #{collectionSource} as collectionSource
  3394. from Equipment_data_detail
  3395. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3396. <if test='collectionMethod == "plc"'>
  3397. AND inspection_no = #{inspectionNo}
  3398. </if>
  3399. <if test='collectionMethod == "RS232"'>
  3400. AND (inspection_no is null or inspection_no = '')
  3401. </if>
  3402. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3403. </select>
  3404. <select id="dataAcquisition2" parameterType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData" resultType="SysOssEntity">
  3405. select
  3406. site as orderRef1,
  3407. bu_no as orderRef4,
  3408. #{inspectionNo} as orderRef2,
  3409. #{itemNo} as orderRef3,
  3410. ${collectionSource} as url
  3411. from Equipment_data_detail
  3412. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3413. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3414. </select>
  3415. <select id="getIQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3416. select
  3417. a.site,
  3418. a.bu_no,
  3419. b.collection_condition as equipmentNo,
  3420. #{inspectionNo} as inspectionNo,
  3421. a.item_no,
  3422. b.collection_source,
  3423. #{actionBy} as actionBy,
  3424. b.collection_method
  3425. from qc_iqc_detailed_record as a
  3426. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3427. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
  3428. order by a.order_id
  3429. </select>
  3430. <select id="getFAIDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3431. select
  3432. a.site,
  3433. a.bu_no,
  3434. b.collection_condition as equipmentNo,
  3435. #{inspectionNo} as inspectionNo,
  3436. a.item_no,
  3437. b.collection_source,
  3438. #{actionBy} as actionBy,
  3439. b.collection_method
  3440. from qc_fai_detailed_record as a
  3441. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3442. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
  3443. order by order_id
  3444. </select>
  3445. <select id="getIPQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3446. select
  3447. a.site,
  3448. a.bu_no,
  3449. b.collection_condition as equipmentNo,
  3450. #{inspectionNo} as inspectionNo,
  3451. a.item_no,
  3452. b.collection_source,
  3453. #{actionBy} as actionBy,
  3454. b.collection_method
  3455. from qc_ipqc_detailed_record as a
  3456. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3457. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  3458. order by a.order_id
  3459. </select>
  3460. <select id="getFQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3461. select
  3462. a.site,
  3463. a.bu_no,
  3464. b.collection_condition as equipmentNo,
  3465. #{inspectionNo} as inspectionNo,
  3466. a.item_no,
  3467. b.collection_source,
  3468. #{actionBy} as actionBy,
  3469. b.collection_method
  3470. from qc_fqc_detailed_record as a
  3471. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3472. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
  3473. order by a.order_id
  3474. </select>
  3475. <select id="querySubDetails" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3476. select
  3477. b.site,
  3478. b.bu_no,
  3479. b.inspection_no,
  3480. b.item_no,
  3481. b.default_value,
  3482. b.min_value,
  3483. b.max_value,
  3484. b.value_type_db,
  3485. a.sub_detail_value
  3486. <if test="flag == 'iqc'">
  3487. from qc_iqc_sub_detail_record as a
  3488. left join qc_iqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3489. </if>
  3490. <if test="flag == 'ipqc'">
  3491. from qc_ipqc_sub_detail_record as a
  3492. left join qc_ipqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3493. </if>
  3494. <if test="flag == 'fqc'">
  3495. from qc_fqc_sub_detail_record as a
  3496. left join qc_fqc_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3497. </if>
  3498. <if test="flag == 'fai'">
  3499. from qc_fai_sub_detail_record as a
  3500. left join qc_fai_detailed_record as b on a.site = b.site and a.bu_no = b.bu_no and a.inspection_no = b.inspection_no and a.item_no = b.item_no
  3501. </if>
  3502. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
  3503. order by b.order_id
  3504. </select>
  3505. <insert id="saveFileList">
  3506. INSERT INTO sys_oss
  3507. (url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
  3508. VALUES
  3509. <foreach collection="list" item="item" separator=",">
  3510. (#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
  3511. </foreach>
  3512. </insert>
  3513. <select id="getEquipmentNoList" parameterType="com.xujie.sys.modules.pms.data.EquipmentFolderLocationData" resultType="com.xujie.sys.modules.pms.data.EquipmentFolderLocationData">
  3514. select
  3515. equipment_no
  3516. from Equipment_folder_location
  3517. where site = #{site} and bu_no = #{buNo}
  3518. </select>
  3519. <!-- 获取责任人员列表 -->
  3520. <select id="getResponsibleOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3521. SELECT
  3522. operator_id as adminID,
  3523. operator_name as adminName
  3524. FROM operator
  3525. <where>
  3526. site in (select site from eam_access_site where username = #{userName})
  3527. <if test = "adminID != null and adminID != ''">
  3528. AND operator_id LIKE '%' + #{adminID} + '%'
  3529. </if>
  3530. <if test = "adminName != null and adminName != ''">
  3531. AND operator_name LIKE '%' + #{adminName} + '%'
  3532. </if>
  3533. </where>
  3534. </select>
  3535. <select id="getDataContentList" parameterType="com.xujie.sys.modules.pms.data.QcCollectionDataContentData" resultType="com.xujie.sys.modules.pms.data.QcCollectionDataContentData">
  3536. select
  3537. content_desc
  3538. from qc_collection_data_content
  3539. where site = #{site} and bu_no = #{buNo} and active = 'Y'
  3540. </select>
  3541. <select id="getItemCollectionDataContent" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="string">
  3542. select
  3543. collection_data_content
  3544. from eam_properties_item
  3545. where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
  3546. </select>
  3547. <!-- 获取当前项目不包含的设备 -->
  3548. <select id="getObjectList1" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3549. SELECT
  3550. a.site,
  3551. a.bu_no,
  3552. a.ObjectID,
  3553. a.ObjectDesc
  3554. FROM eam_object as a
  3555. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID and b.ItemNo = #{itemNo}
  3556. where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  3557. </select>
  3558. <!-- 获取当前项目所包含的设备 -->
  3559. <select id="getObjectList2" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3560. SELECT
  3561. a.site,
  3562. a.bu_no,
  3563. a.ObjectID,
  3564. b.ObjectDesc,
  3565. a.default_flag
  3566. FROM qc_item_object a
  3567. LEFT JOIN eam_object b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID
  3568. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
  3569. </select>
  3570. <!-- 获取当前项目不包含的设备 -->
  3571. <select id="getObjectListBy" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3572. SELECT
  3573. a.site,
  3574. a.bu_no,
  3575. a.ObjectID,
  3576. a.ObjectDesc
  3577. FROM eam_object as a
  3578. left join qc_item_object as b on a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID and b.ItemNo = #{itemNo}
  3579. <where>
  3580. a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  3581. <if test = "objectID != null and objectID != ''">
  3582. AND a.ObjectID LIKE '%' + #{objectID} + '%'
  3583. </if>
  3584. <if test = "objectDesc != null and objectDesc != ''">
  3585. AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
  3586. </if>
  3587. </where>
  3588. </select>
  3589. <!-- 新增项目设备 -->
  3590. <insert id="addItemObject">
  3591. INSERT INTO qc_item_object
  3592. (site, bu_no, ItemNo, ObjectID, default_flag)
  3593. VALUES
  3594. <foreach collection="list" item="item" separator=",">
  3595. (#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
  3596. </foreach>
  3597. </insert>
  3598. <delete id="deleteItemObject">
  3599. DELETE FROM qc_item_object
  3600. WHERE
  3601. <foreach collection="list" item="item" separator=" or " index="index">
  3602. (site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
  3603. </foreach>
  3604. </delete>
  3605. <update id="updateItemObject">
  3606. UPDATE qc_item_object
  3607. SET default_flag = #{defaultFlag}
  3608. WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
  3609. </update>
  3610. <select id="getIQCInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3611. select
  3612. a.site,
  3613. a.bu_no,
  3614. a.inspection_no,
  3615. a.item_no,
  3616. a.item_desc,
  3617. b.collection_source,
  3618. b.collection_method
  3619. from qc_iqc_detailed_record as a
  3620. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3621. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '105' and b.collection_flag = 'Y'
  3622. order by a.order_id
  3623. </select>
  3624. <select id="getFAIInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3625. select
  3626. a.site,
  3627. a.bu_no,
  3628. a.inspection_no,
  3629. a.item_no,
  3630. a.item_desc,
  3631. b.collection_source,
  3632. b.collection_method
  3633. from qc_fai_detailed_record as a
  3634. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3635. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '106' and b.collection_flag = 'Y'
  3636. order by a.order_id
  3637. </select>
  3638. <select id="getFQCInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3639. select
  3640. a.site,
  3641. a.bu_no,
  3642. a.inspection_no,
  3643. a.item_no,
  3644. a.item_desc,
  3645. b.collection_source,
  3646. b.collection_method
  3647. from qc_fqc_detailed_record as a
  3648. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3649. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '107' and b.collection_flag = 'Y'
  3650. order by a.order_id
  3651. </select>
  3652. <select id="getIPQCInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3653. select
  3654. a.site,
  3655. a.bu_no,
  3656. a.inspection_no,
  3657. a.item_no,
  3658. a.item_desc,
  3659. b.collection_source,
  3660. b.collection_method
  3661. from qc_ipqc_detailed_record as a
  3662. left join eam_properties_item as b on a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  3663. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and b.ItemType = 'D' and b.inspection_type_no = '101' and b.collection_flag = 'Y'
  3664. order by a.order_id
  3665. </select>
  3666. <delete id="deleteEquipmentDataAcquisition" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3667. delete from Equipment_data_acquisition
  3668. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3669. </delete>
  3670. <select id="getInspectionStandards" parameterType="com.xujie.sys.modules.pms.data.QcInspectionStandardData" resultType="com.xujie.sys.modules.pms.data.QcInspectionStandardData">
  3671. select
  3672. site,
  3673. bu_no,
  3674. template_id,
  3675. item_no,
  3676. default_value,
  3677. min_value,
  3678. max_value,
  3679. condition,
  3680. collection_source,
  3681. seq_no
  3682. from qc_inspection_standards
  3683. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  3684. </select>
  3685. <delete id="deleteInspectionStandard" parameterType="com.xujie.sys.modules.pms.data.QcInspectionStandardData">
  3686. delete from qc_inspection_standards
  3687. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  3688. </delete>
  3689. <delete id="deleteInspectionStandard2" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  3690. delete from qc_inspection_standards
  3691. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  3692. </delete>
  3693. <insert id="saveInspectionStandard">
  3694. INSERT INTO qc_inspection_standards
  3695. (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
  3696. VALUES
  3697. <foreach collection="list" item="item" separator=",">
  3698. (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
  3699. </foreach>
  3700. </insert>
  3701. <select id="getInspectionTemplateDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcInspectionStandardData">
  3702. select
  3703. site,
  3704. bu_no,
  3705. template_id,
  3706. item_no
  3707. <if test="flag == 'iqc'">
  3708. from qc_iqc_detailed_record
  3709. </if>
  3710. <if test="flag == 'ipqc'">
  3711. from qc_ipqc_detailed_record
  3712. </if>
  3713. <if test="flag == 'fqc'">
  3714. from qc_fqc_detailed_record
  3715. </if>
  3716. <if test="flag == 'fai'">
  3717. from qc_fai_detailed_record
  3718. </if>
  3719. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3720. order by order_id
  3721. </select>
  3722. <update id="updateEquipmentDataDetailInspectionNo" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues">getUpItemdata
  3723. update Equipment_data_detail
  3724. set inspection_no = #{inspectionNo}
  3725. where id = #{id}
  3726. </update>
  3727. <delete id="deleteInspectionFiles" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3728. delete sys_oss
  3729. where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo}
  3730. </delete>
  3731. <select id="getUpItemdata" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  3732. select
  3733. top 1
  3734. site,
  3735. bu_no,
  3736. template_id,
  3737. ItemNo,
  3738. order_id
  3739. from qc_template_detailed
  3740. where #{orderId} > order_id
  3741. and site = #{site}
  3742. and bu_no= #{buNo}
  3743. and template_id = #{templateId}
  3744. order by order_id desc
  3745. </select>
  3746. <select id="getDownItemdata" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  3747. select
  3748. top 1
  3749. site,
  3750. bu_no,
  3751. template_id,
  3752. ItemNo,
  3753. order_id
  3754. from qc_template_detailed
  3755. where order_id > #{orderId}
  3756. and site = #{site}
  3757. and bu_no= #{buNo}
  3758. and template_id = #{templateId}
  3759. order by order_id
  3760. </select>
  3761. <update id="updateQcItemOrder">
  3762. update qc_template_detailed
  3763. set order_id=#{orderId}
  3764. where site = #{site}
  3765. and bu_no= #{buNo}
  3766. and template_id = #{templateId}
  3767. and ItemNo = #{itemNo}
  3768. </update>
  3769. <select id="getQCDetailOrderId" resultType="Integer">
  3770. SELECT isnull(max(order_id), 0) + 1
  3771. from qc_template_detailed
  3772. where site = #{site}
  3773. and bu_no= #{buNo}
  3774. and template_id = #{templateId}
  3775. </select>
  3776. <select id="updateQCDetailOrderIdNull">
  3777. UPDATE qc_template_detailed
  3778. SET qc_template_detailed.order_id = oi.rn
  3779. FROM (SELECT
  3780. site,
  3781. bu_no,
  3782. template_id,
  3783. ItemNo,
  3784. ROW_NUMBER() OVER (PARTITION BY site,bu_no,template_id ORDER BY ItemNo) AS rn
  3785. FROM qc_template_detailed
  3786. ) as oi
  3787. where qc_template_detailed.template_id = oi.template_id
  3788. AND qc_template_detailed.ItemNo = oi.ItemNo
  3789. and qc_template_detailed.order_id is null
  3790. </select>
  3791. <select id="selectInfoByInspectionNo" resultType="com.xujie.sys.modules.pms.data.PoOrderRollNoData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3792. select
  3793. site,
  3794. citem_code,
  3795. inspection_no
  3796. from po_order_roll_no
  3797. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  3798. </select>
  3799. <update id="updateIQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3800. UPDATE qc_iqc_record
  3801. SET submit_flag = 'N',
  3802. state = '待检验',
  3803. cancel_check_by = #{updateBy},
  3804. cancel_check_date = getDate()
  3805. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3806. </update>
  3807. <update id="updateIQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3808. UPDATE qc_iqc_detailed_record
  3809. SET is_submit = 'N'
  3810. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3811. </update>
  3812. <update id="updateIQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3813. UPDATE qc_iqc_sub_detail_record
  3814. SET is_submit = 'N'
  3815. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3816. </update>
  3817. <update id="updateFAIMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3818. UPDATE qc_fai_record
  3819. SET submit_flag = 'N',
  3820. state = '待检验',
  3821. cancel_check_by = #{updateBy},
  3822. cancel_check_date = getDate()
  3823. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3824. </update>
  3825. <update id="updateFAIDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3826. UPDATE qc_fai_detailed_record
  3827. SET is_submit = 'N'
  3828. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3829. </update>
  3830. <update id="updateFAISubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3831. UPDATE qc_fai_sub_detail_record
  3832. SET is_submit = 'N'
  3833. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3834. </update>
  3835. <update id="updateIPQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3836. UPDATE qc_ipqc_record
  3837. SET submit_flag = 'N',
  3838. state = '待检验',
  3839. cancel_check_by = #{updateBy},
  3840. cancel_check_date = getDate()
  3841. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3842. </update>
  3843. <update id="updateIPQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3844. UPDATE qc_ipqc_detailed_record
  3845. SET is_submit = 'N'
  3846. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3847. </update>
  3848. <update id="updateIPQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3849. UPDATE qc_ipqc_sub_detail_record
  3850. SET is_submit = 'N'
  3851. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3852. </update>
  3853. <update id="updateFQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3854. UPDATE qc_fqc_record
  3855. SET submit_flag = 'N',
  3856. state = '待检验',
  3857. cancel_check_by = #{updateBy},
  3858. cancel_check_date = getDate()
  3859. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3860. </update>
  3861. <update id="updateFQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3862. UPDATE qc_fqc_detailed_record
  3863. SET is_submit = 'N'
  3864. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3865. </update>
  3866. <update id="updateFQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3867. UPDATE qc_fqc_sub_detail_record
  3868. SET is_submit = 'N'
  3869. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3870. </update>
  3871. <update id="updatePQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3872. UPDATE qc_pqc_record
  3873. SET submit_flag = 'N',
  3874. state = '待检验',
  3875. cancel_check_by = #{updateBy},
  3876. cancel_check_date = getDate()
  3877. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3878. </update>
  3879. <update id="updatePQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3880. UPDATE qc_pqc_detailed_record
  3881. SET is_submit = 'N'
  3882. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3883. </update>
  3884. <update id="updatePQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3885. UPDATE qc_pqc_sub_detail_record
  3886. SET is_submit = 'N'
  3887. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3888. </update>
  3889. <delete id="deleteReceivingTaskByInspectionNo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3890. delete receiving_task
  3891. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  3892. </delete>
  3893. <select id="getQMSTask" resultType="com.xujie.sys.modules.pms.data.QmsTaskData">
  3894. select
  3895. id,
  3896. site,
  3897. bu_no,
  3898. part_no,
  3899. operation_desc,
  3900. s_resourceid,
  3901. qtyrequired,
  3902. create_date,
  3903. create_by,
  3904. inspection_type,
  3905. type,
  3906. order_no,
  3907. seqno,
  3908. template_id,
  3909. um_id,
  3910. work_center_no
  3911. from QMS_soscheduledrouting_TASK
  3912. where ISNULL(delete_flag, '') <![CDATA[<>]]> 'Y'
  3913. </select>
  3914. <update id="updateQMSTaskById">
  3915. UPDATE QMS_soscheduledrouting_TASK
  3916. SET delete_flag = 'Y'
  3917. WHERE id = #{id}
  3918. </update>
  3919. </mapper>