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.

4915 lines
227 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
11 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
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
11 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 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 months ago
3 years ago
3 years ago
3 years ago
3 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
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
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
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1 year ago
3 years ago
3 years ago
3 years ago
3 years ago
4 weeks ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 weeks ago
1 year ago
2 years ago
11 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
11 months 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 = #{itemType} 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. qt.template_sort,
  382. qt.operation_no as operation
  383. FROM qc_template as qt
  384. LEFT JOIN qc_inspection_type as qit on qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  385. 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
  386. 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
  387. <where>
  388. qt.site in (select site from eam_access_site where username = #{query.userName})
  389. and (qt.site + '-' + qt.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  390. <if test="query.buDesc != null and query.buDesc != ''">
  391. AND dbo.get_bu_desc ( qt.site, qt.bu_no ) = #{query.buDesc}
  392. </if>
  393. <if test = "query.templateId != null and query.templateId != ''">
  394. AND qt.template_id LIKE '%' + #{query.templateId}+'%'
  395. </if>
  396. <if test = "query.templateName != null and query.templateName != ''">
  397. AND qt.template_name LIKE '%' + #{query.templateName}+'%'
  398. </if>
  399. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  400. AND qt.inspection_type_no = #{query.inspectionTypeNo}
  401. </if>
  402. <if test = "query.inspectionTypeNo == null or query.inspectionTypeNo == ''">
  403. AND qt.inspection_type_no not in ('GX','***')
  404. </if>
  405. <if test = "query.operation != null and query.operation != ''">
  406. AND qt.operation_no = #{query.operation}
  407. </if>
  408. </where>
  409. order by qt.create_time desc
  410. </select>
  411. <!-- 获得检验模板单号 -->
  412. <select id="getTemplateNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  413. SELECT
  414. Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(template_id,3))),0)+1),3)
  415. FROM qc_template
  416. WHERE site = #{site} and inspection_type_no = #{inspectionTypeNo} and bu_no = #{buNo}
  417. </select>
  418. <!-- 新增模板 -->
  419. <insert id="templateSave" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  420. 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,operation_no,template_sort)
  421. VALUES (#{site}, #{buNo}, #{templateId}, #{templateName},#{templateVersion}, #{templateRemark}, #{templateType}, #{samplingProgrammeNo}, #{inspectionTypeNo}, getDate(), #{createBy}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{aql}, #{ac}, #{re}, #{defaultSamplingQuantity}, #{defaultSamplingProportion}, getDate(), #{updateBy},#{operation},#{templateSort})
  422. </insert>
  423. <!-- 修改模板 -->
  424. <update id="templateUpdate" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  425. UPDATE qc_template
  426. SET template_name = #{templateName},
  427. template_version = #{templateVersion},
  428. template_remark = #{templateRemark},
  429. template_type = #{templateType},
  430. sampling_programme_no = #{samplingProgrammeNo},
  431. inspection_cycle = #{inspectionCycle},
  432. inspection_type_no = #{inspectionTypeNo},
  433. sampling_level_no = #{samplingLevelNo},
  434. AQL = #{aql},
  435. AC = #{ac},
  436. RE = #{re},
  437. default_sampling_quantity = #{defaultSamplingQuantity},
  438. default_sampling_proportion = #{defaultSamplingProportion},
  439. update_date = getDate(),
  440. update_by = #{updateBy}
  441. WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
  442. </update>
  443. <!-- 查询模板里的项目详情 -->
  444. <select id="templateDetailsSearch" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  445. SELECT
  446. a.site,
  447. a.bu_no,
  448. a.template_id,
  449. a.ItemNo,
  450. b.ItemDesc,
  451. a.default_value,
  452. b.ValueType,
  453. b.ValueType_DB,
  454. a.max_value,
  455. a.min_value,
  456. b.ItemRemark,
  457. b.ItemType,
  458. a.object_id,
  459. eo.objectDesc,
  460. b.item_sampling_quantity,
  461. b.sampling_programme_no,
  462. c.sampling_programme_desc,
  463. b.sampling_level_no,
  464. d.sampling_level_desc,
  465. b.default_sampling_proportion,a.order_id
  466. FROM qc_template_detailed a
  467. LEFT JOIN eam_properties_item b ON a.ItemNo = b.ItemNo and a.site = b.site and a.bu_no = b.bu_no
  468. 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
  469. 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
  470. LEFT JOIN eam_object eo ON a.object_id = eo.ObjectID and a.site = b.site and a.bu_no = b.bu_no
  471. WHERE a.template_id = #{templateId} AND b.ItemType = #{itemType} and a.site = #{site} and a.bu_no = #{buNo}
  472. order by order_id,ItemNo
  473. </select>
  474. <!-- 查询模板里是否已存在该项目 -->
  475. <select id="selectItemDetails" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  476. SELECT template_id,
  477. ItemNo,
  478. default_value,
  479. max_value,
  480. min_value
  481. FROM qc_template_detailed
  482. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  483. </select>
  484. <!-- 查询项目的最大最小值 -->
  485. <select id="selectDetail" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  486. SELECT ItemNo,
  487. DefaultValue,
  488. MaxValue,
  489. MinValue
  490. FROM eam_properties_item
  491. WHERE ItemNo = #{itemNo} and ItemType = #{itemType} and site = #{site} and bu_no = #{buNo}
  492. </select>
  493. <!-- 新增模板的检验项目 -->
  494. <insert id="addItemDetails" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  495. INSERT INTO qc_template_detailed (template_id, ItemNo, default_value, max_value, min_value, site, bu_no,order_id)
  496. VALUES (#{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{site}, #{buNo},#{orderId})
  497. </insert>
  498. <!-- 删除模板的检验项目 -->
  499. <delete id="delItemDetails" >
  500. DELETE FROM qc_template_detailed
  501. WHERE template_id = #{templateId} and ItemNo = #{itemNo} and site = #{site} and bu_no = #{buNo}
  502. </delete>
  503. <!-- 获取当前模板不包含的项目 -->
  504. <select id="getItemList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  505. SELECT
  506. a.site,
  507. a.bu_no,
  508. a.itemNo,
  509. a.ItemDesc,
  510. a.DefaultValue,
  511. a.MaxValue,
  512. a.MinValue
  513. FROM eam_properties_item a
  514. 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
  515. 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}
  516. </select>
  517. <!-- 查询项目 -->
  518. <select id="getItem" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  519. SELECT
  520. a.site,
  521. a.bu_no,
  522. a.itemNo,
  523. a.ItemDesc,
  524. a.DefaultValue,
  525. a.MaxValue,
  526. a.MinValue
  527. FROM eam_properties_item a
  528. 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
  529. <where>
  530. 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}
  531. <if test = "itemNo != null and itemNo != ''">
  532. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  533. </if>
  534. <if test = "itemDesc != null and itemDesc != ''">
  535. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  536. </if>
  537. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  538. AND a.inspection_type_no = #{inspectionTypeNo}
  539. </if>
  540. </where>
  541. </select>
  542. <select id="getItem2" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  543. SELECT
  544. a.site,
  545. a.bu_no,
  546. a.itemNo,
  547. a.ItemDesc,
  548. a.DefaultValue,
  549. a.MaxValue,
  550. a.MinValue
  551. FROM eam_properties_item a
  552. 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
  553. <where>
  554. a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo}
  555. <if test = "itemNo != null and itemNo != ''">
  556. AND a.ItemNo LIKE '%' + #{itemNo} + '%'
  557. </if>
  558. <if test = "itemDesc != null and itemDesc != ''">
  559. AND a.ItemDesc LIKE '%' + #{itemDesc} + '%'
  560. </if>
  561. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  562. AND a.inspection_type_no = #{inspectionTypeNo}
  563. </if>
  564. </where>
  565. </select>
  566. <!-- 删除模板 -->
  567. <delete id="templateDelete" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  568. DELETE FROM qc_template
  569. WHERE template_id = #{templateId} AND site = #{site} and bu_no = #{buNo}
  570. </delete>
  571. <!-- 删除模板-项目中间表 -->
  572. <delete id="itemItemDelete" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  573. DELETE FROM qc_template_detailed
  574. WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
  575. </delete>
  576. <!-- 搜索所有检验类型 -->
  577. <select id="inspectionTypeSearch" resultType="com.xujie.sys.modules.pms.data.QcInspectionTypeData" parameterType="com.xujie.sys.modules.pms.data.QcInspectionTypeData">
  578. SELECT inspection_type_no,
  579. inspection_type_name
  580. FROM qc_inspection_type
  581. WHERE site = #{site}
  582. </select>
  583. <!-- 搜索所有设备 -->
  584. <select id="objectSearch" resultType="EamObjectData">
  585. SELECT
  586. ObjectID,
  587. ObjectDesc
  588. FROM eam_object
  589. WHERE Active = 'Y' and site = #{site} and bu_no = #{buNo}
  590. </select>
  591. <!-- 导入文件检验 -->
  592. <select id="getItemByItemNo" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  593. SELECT ItemDesc,
  594. ItemType
  595. FROM eam_properties_item
  596. WHERE ItemDesc = #{itemDesc}
  597. AND DefaultValue = #{defaultValue}
  598. AND MaxValue = #{maxValue}
  599. AND MinValue = #{minValue}
  600. AND ItemType = #{itemType}
  601. </select>
  602. <!-- 新增检验项目 -->
  603. <insert id="insertItem" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesItemData">
  604. INSERT INTO eam_properties_item (ItemNo, ItemDesc,DefaultValue,ValueType,ValueType_DB, CreatedDate,CreatedBy,MaxValue, MinValue, ItemRemark,ItemType)
  605. VALUES(#{itemNo},#{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, GetDate(), #{createdBy}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL}, #{itemRemark}, #{itemType})
  606. </insert>
  607. <!-- &lt;!&ndash; 获取最大项目编码 &ndash;&gt;-->
  608. <!-- <select id="queryLastItemNo" resultType="string" parameterType="QcItemData">-->
  609. <!-- SELECT top 1 ItemNo-->
  610. <!-- FROM eam_properties_item-->
  611. <!-- WHERE ItemType = #{itemType}-->
  612. <!-- ORDER BY ItemNo Desc-->
  613. <!-- </select>-->
  614. <!-- 根据模板名称查询模板 -->
  615. <select id="selectTemplateByDesc" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  616. SELECT template_id,
  617. template_name,
  618. template_version
  619. FROM qc_template
  620. WHERE template_name = #{templateName}
  621. AND site = #{site}
  622. AND template_version = #{templateVersion}
  623. </select>
  624. <delete id="delTemplateItem" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  625. delete qc_template_detailed
  626. WHERE template_id = #{templateId} and site = #{site} and bu_no = #{buNo}
  627. </delete>
  628. <!-- &lt;!&ndash; 修改项目明细的最大最小值 &ndash;&gt;-->
  629. <!-- <insert id="saveItemDetailed">-->
  630. <!-- INSERT INTO qc_template_detailed-->
  631. <!-- (site, bu_no, template_id, ItemNo, default_value, max_value, min_value)-->
  632. <!-- VALUES-->
  633. <!-- <foreach collection="list" item="item" separator=",">-->
  634. <!-- (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.maxValue,jdbcType=DECIMAL}, #{item.minValue,jdbcType=DECIMAL})-->
  635. <!-- </foreach>-->
  636. <!-- </insert>-->
  637. <!-- 修改项目明细的最大最小值 -->
  638. <insert id="saveItemDetailed">
  639. INSERT INTO qc_template_detailed
  640. (site, bu_no, template_id, ItemNo, default_value, max_value, min_value, order_id)
  641. VALUES
  642. (#{site}, #{buNo}, #{templateId}, #{itemNo}, #{defaultValue}, #{maxValue,jdbcType=DECIMAL}, #{minValue,jdbcType=DECIMAL},#{orderId})
  643. </insert>
  644. <!-- 查询项目明细 -->
  645. <select id="selectItem" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  646. SELECT ItemNo,
  647. ItemDesc,
  648. DefaultValue,
  649. ValueType,
  650. ValueType_DB,
  651. MaxValue,
  652. MinValue,
  653. ItemRemark,
  654. ItemType,
  655. site,
  656. bu_no
  657. FROM eam_properties_item
  658. WHERE ItemNo = #{itemNo} AND ItemType = #{itemType} AND bu_no = #{buNo}
  659. </select>
  660. <!-- ================================================= 样本量维护 ================================================= -->
  661. <!-- 查询样本量 -->
  662. <select id="samplingQtySearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  663. SELECT
  664. site,
  665. bu_no,
  666. dbo.get_bu_desc(site, bu_no) as buDesc,
  667. sampling_qty_no,
  668. sampling_qty_desc,
  669. sampling_qty,
  670. sampling_qty_remark,
  671. sampling_qty_active,
  672. case when sampling_qty_active = 'Y' then '是' when sampling_qty_active = 'N' then '否' else '' end as samplingQtyActiveDesc,
  673. create_date,
  674. create_by,
  675. dbo.getOperatorDesc(site, create_by) as createByDesc,
  676. update_date,
  677. update_by,
  678. dbo.getOperatorDesc(site, update_by) as updateByDesc
  679. FROM qc_sampling_inspection_qty
  680. <where>
  681. site in (select site from eam_access_site where username = #{query.userName})
  682. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  683. <if test="query.buDesc != null and query.buDesc != ''">
  684. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  685. </if>
  686. <if test="query.samplingQtyNo != null and query.samplingQtyNo != ''">
  687. AND sampling_qty_no LIKE '%' + #{query.samplingQtyNo} + '%'
  688. </if>
  689. <if test="query.samplingQtyDesc != null and query.samplingQtyDesc != ''">
  690. AND sampling_qty_desc LIKE '%' + #{query.samplingQtyDesc} + '%'
  691. </if>
  692. <if test="query.samplingQty != null">
  693. AND sampling_qty = #{query.samplingQty,jdbcType=DECIMAL}
  694. </if>
  695. <if test="query.samplingQtyActive != null and query.samplingQtyActive != ''">
  696. AND sampling_qty_active = #{query.samplingQtyActive}
  697. </if>
  698. </where>
  699. </select>
  700. <!-- 新增样本量 -->
  701. <insert id="samplingQtySave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  702. 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)
  703. VALUES(#{site}, #{buNo}, #{samplingQtyNo}, #{samplingQty,jdbcType=DECIMAL}, #{samplingQtyRemark}, #{samplingQtyActive}, #{samplingQtyDesc}, getDate(), #{createBy}, getDate(), #{updateBy})
  704. </insert>
  705. <!-- 根据样本量字码查询样本量 -->
  706. <select id="selectSamplingQtyByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  707. SELECT
  708. site,
  709. bu_no,
  710. sampling_qty_no,
  711. sampling_qty_desc,
  712. sampling_qty,
  713. sampling_qty_remark,
  714. sampling_qty_active
  715. FROM qc_sampling_inspection_qty
  716. WHERE sampling_qty_desc = #{samplingQtyDesc} AND site = #{site} and bu_no = #{buNo}
  717. </select>
  718. <!-- 获取最大样本量编码 -->
  719. <select id="queryLastSamplingQtyNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  720. SELECT top 1 sampling_qty_no
  721. FROM qc_sampling_inspection_qty
  722. where site = #{site} and bu_no = #{buNo}
  723. ORDER BY sampling_qty_no Desc
  724. </select>
  725. <!-- 修改样本量 -->
  726. <update id="samplingQtyUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  727. UPDATE qc_sampling_inspection_qty
  728. SET sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  729. sampling_qty_desc = #{samplingQtyDesc},
  730. sampling_qty_remark = #{samplingQtyRemark},
  731. sampling_qty_active = #{samplingQtyActive},
  732. update_date = getDate(),
  733. update_by = #{updateBy}
  734. WHERE sampling_qty_no = #{samplingQtyNo} AND site = #{site} and bu_no = #{buNo}
  735. </update>
  736. <!-- 根据样本量编码查询矩阵 -->
  737. <select id="selectSamplingPlanBySamplingQtyNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  738. SELECT
  739. site,
  740. sampling_plan_no,
  741. sampling_qty_no,
  742. sampling_qty_rank_no,
  743. sampling_level_no,
  744. sampling_plan_active
  745. FROM qc_sampling_inspection_plan
  746. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} and bu_no = #{buNo}
  747. </select>
  748. <!-- 删除样本量 -->
  749. <delete id="samplingQtyDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyData">
  750. DELETE FROM qc_sampling_inspection_qty
  751. WHERE site = #{site} AND sampling_qty_no = #{samplingQtyNo} AND sampling_qty_desc = #{samplingQtyDesc} and bu_no = #{buNo}
  752. </delete>
  753. <!-- ================================================= 批量级次维护 ================================================= -->
  754. <!-- 查询批量级次 -->
  755. <select id="samplingQtyRankSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  756. SELECT
  757. site,
  758. bu_no,
  759. dbo.get_bu_desc(site, bu_no) as buDesc,
  760. sampling_qty_rank_no,
  761. sampling_qty_rank_desc,
  762. min_qty,
  763. max_qty,
  764. sampling_qty_rank_active,
  765. case when sampling_qty_rank_active = 'Y' then '是' when sampling_qty_rank_active = 'N' then '否' else '' end as samplingQtyRankActiveDesc,
  766. sampling_qty_rank_Remark,
  767. create_date,
  768. create_by,
  769. dbo.getOperatorDesc(site, create_by) as createByDesc,
  770. update_date,
  771. update_by,
  772. dbo.getOperatorDesc(site, update_by) as updateByDesc
  773. FROM qc_sampling_inspection_qty_rank
  774. <where>
  775. site in (select site from eam_access_site where username = #{query.userName})
  776. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  777. <if test="query.buDesc != null and query.buDesc != ''">
  778. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  779. </if>
  780. <if test="query.samplingQtyRankNo != null and query.samplingQtyRankNo != ''">
  781. AND sampling_qty_rank_no LIKE '%' + #{query.samplingQtyRankNo}+'%'
  782. </if>
  783. <if test="query.samplingQtyRankDesc != null and query.samplingQtyRankDesc != ''">
  784. AND sampling_qty_rank_desc LIKE '%' + #{query.samplingQtyRankDesc}+'%'
  785. </if>
  786. <if test="query.samplingQtyRankActive != null and query.samplingQtyRankActive != ''">
  787. AND sampling_qty_rank_active = #{query.samplingQtyRankActive}
  788. </if>
  789. </where>
  790. </select>
  791. <!-- 根据名称查询批量级次 -->
  792. <select id="selectSamplingQtyRankByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  793. SELECT
  794. site,
  795. bu_no,
  796. sampling_qty_rank_no,
  797. sampling_qty_rank_desc,
  798. min_qty,
  799. max_qty,
  800. sampling_qty_rank_active,
  801. sampling_qty_rank_Remark
  802. FROM qc_sampling_inspection_qty_rank
  803. WHERE sampling_qty_rank_desc = #{samplingQtyRankDesc} AND site = #{site} and bu_no = #{buNo}
  804. </select>
  805. <!-- 获取最大批量级次编码 -->
  806. <select id="queryLastSamplingQtyRankNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  807. SELECT top 1 sampling_qty_rank_no
  808. FROM qc_sampling_inspection_qty_rank
  809. where site = #{site} and bu_no = #{buNo}
  810. ORDER BY sampling_qty_rank_no Desc
  811. </select>
  812. <!-- 新增批量级次 -->
  813. <insert id="samplingQtyRankSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  814. 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)
  815. VALUES(#{site}, #{buNo}, #{samplingQtyRankNo}, #{samplingQtyRankDesc}, #{minQty,jdbcType=DECIMAL}, #{maxQty,jdbcType=DECIMAL}, #{samplingQtyRankRemark}, #{samplingQtyRankActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  816. </insert>
  817. <!-- 根据批量级次编码查询矩阵 -->
  818. <select id="selectSamplingPlanBySamplingQtyRankNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  819. SELECT
  820. site,
  821. bu_no,
  822. sampling_plan_no,
  823. sampling_qty_no,
  824. sampling_qty_rank_no,
  825. sampling_level_no,
  826. sampling_plan_active
  827. FROM qc_sampling_inspection_plan
  828. WHERE site = #{site} AND sampling_qty_rank_no = #{samplingQtyRankNo} and bu_no = #{buNo}
  829. </select>
  830. <!-- 修改批量级次 -->
  831. <update id="samplingQtyRankUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  832. UPDATE qc_sampling_inspection_qty_rank
  833. SET sampling_qty_rank_desc = #{samplingQtyRankDesc},
  834. min_qty = #{minQty,jdbcType=DECIMAL},
  835. max_qty = #{maxQty,jdbcType=DECIMAL},
  836. sampling_qty_rank_Remark = #{samplingQtyRankRemark},
  837. sampling_qty_rank_active = #{samplingQtyRankActive},
  838. update_date = getDate(),
  839. update_by = #{updateBy}
  840. WHERE sampling_qty_rank_no = #{samplingQtyRankNo} AND site = #{site} and bu_no = #{buNo}
  841. </update>
  842. <!-- 删除批量级次 -->
  843. <delete id="samplingQtyRankDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionQtyRankData">
  844. DELETE FROM qc_sampling_inspection_qty_rank
  845. WHERE site = #{site} and bu_no = #{buNo}
  846. AND sampling_qty_rank_no = #{samplingQtyRankNo}
  847. AND sampling_qty_rank_desc = #{samplingQtyRankDesc}
  848. </delete>
  849. <!-- ================================================= 检验等级维护 ================================================= -->
  850. <!-- 查询检验等级 -->
  851. <select id="samplingLevelSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  852. SELECT
  853. site,
  854. bu_no,
  855. dbo.get_bu_desc(site, bu_no) as buDesc,
  856. sampling_level_no,
  857. sampling_level_desc,
  858. sampling_level_remark,
  859. sampling_level_active,
  860. case when sampling_level_active = 'Y' then '是' when sampling_level_active = 'N' then '否' else '' end as samplingLevelActiveDesc,
  861. create_date,
  862. create_by,
  863. dbo.getOperatorDesc(site, create_by) as createByDesc,
  864. update_date,
  865. update_by,
  866. dbo.getOperatorDesc(site, update_by) as updateByDesc
  867. FROM qc_sampling_inspection_level
  868. <where>
  869. site in (select site from eam_access_site where username = #{query.userName})
  870. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  871. <if test="query.buDesc != null and query.buDesc != ''">
  872. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  873. </if>
  874. <if test="query.samplingLevelNo != null and query.samplingLevelNo != ''">
  875. AND sampling_level_no LIKE '%' + #{query.samplingLevelNo}+'%'
  876. </if>
  877. <if test="query.samplingLevelDesc != null and query.samplingLevelDesc != ''">
  878. AND sampling_level_desc LIKE '%' + #{query.samplingLevelDesc}+'%'
  879. </if>
  880. <if test="query.samplingLevelActive != null and query.samplingLevelActive != ''">
  881. AND sampling_level_active = #{query.samplingLevelActive}
  882. </if>
  883. </where>
  884. </select>
  885. <!-- 根据名称查询检验等级 -->
  886. <select id="selectSamplingLevelByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  887. SELECT
  888. site,
  889. bu_no,
  890. sampling_level_no,
  891. sampling_level_desc,
  892. sampling_level_remark,
  893. sampling_level_active
  894. FROM qc_sampling_inspection_level
  895. WHERE sampling_level_desc = #{samplingLevelDesc} AND site = #{site} and bu_no = #{buNo}
  896. </select>
  897. <!-- 获取最大检验等级编码 -->
  898. <select id="queryLastSamplingLevelNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  899. SELECT top 1 sampling_level_no
  900. FROM qc_sampling_inspection_level
  901. where site = #{site} and bu_no = #{buNo}
  902. ORDER BY sampling_level_no Desc
  903. </select>
  904. <!-- 新增检验等级 -->
  905. <insert id="samplingLevelSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  906. 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)
  907. VALUES (#{site}, #{buNo}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingLevelRemark}, #{samplingLevelActive}, getDate(), #{createBy}, getDate(), #{updateBy})
  908. </insert>
  909. <!-- 根据检验等级编码查询矩阵 -->
  910. <select id="selectSamplingPlanBySamplingLevelNo" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  911. SELECT
  912. site,
  913. bu_no,
  914. sampling_plan_no,
  915. sampling_qty_no,
  916. sampling_qty_rank_no,
  917. sampling_level_no,
  918. sampling_plan_active
  919. FROM qc_sampling_inspection_plan
  920. WHERE site = #{site} and bu_no = #{buNo}
  921. AND sampling_level_no = #{samplingLevelNo}
  922. </select>
  923. <!-- 修改检验等级 -->
  924. <update id="samplingLevelUpdate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  925. UPDATE qc_sampling_inspection_level
  926. SET sampling_level_desc = #{samplingLevelDesc},
  927. sampling_level_remark = #{samplingLevelRemark},
  928. sampling_level_active = #{samplingLevelActive},
  929. update_date = getDate(),
  930. update_by = #{updateBy}
  931. WHERE sampling_level_no = #{samplingLevelNo}
  932. AND site = #{site} and bu_no = #{buNo}
  933. </update>
  934. <!-- 删除检验等级 -->
  935. <delete id="samplingLevelDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionLevelData">
  936. DELETE FROM qc_sampling_inspection_level
  937. WHERE site = #{site} and bu_no = #{buNo}
  938. AND sampling_level_no = #{samplingLevelNo}
  939. AND sampling_level_desc = #{samplingLevelDesc}
  940. </delete>
  941. <!-- ================================================= 物料属性设置维护 ================================================= -->
  942. <!-- 查询物料属性 -->
  943. <select id="qcPartAttributeSearch" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  944. SELECT
  945. qa.site,
  946. qa.bu_no,
  947. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  948. p.part_no as partNo,
  949. p.part_desc,
  950. p.cinv_source_code as cinvSourceCode,
  951. p.sku as sku,
  952. p.FamilyID,
  953. p.invtype as familyName,
  954. p.spec,
  955. p.umid,
  956. qa.supplier_no,
  957. dbo.qc_get_supplier_name(qa.site, qa.supplier_no) as supplierDesc,
  958. qa.attribute_remark,
  959. qa.create_time,
  960. qa.create_by,
  961. dbo.getOperatorDesc(qa.site, qa.create_by) as createByDesc,
  962. qa.attribute_type,
  963. qa.update_date,
  964. qa.update_by,
  965. dbo.getOperatorDesc(qa.site, qa.update_by) as updateByDesc,
  966. qa.exempt_inspection
  967. FROM qc_part_attribute qa
  968. LEFT JOIN part p on qa.attribute_no = p.part_no and qa.site = p.site
  969. <where>
  970. qa.site in (select site from eam_access_site where username = #{query.userName})
  971. and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  972. and qa.attribute_type = #{query.attributeType}
  973. <if test="query.buDesc != null and query.buDesc != ''">
  974. AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc}
  975. </if>
  976. <if test = "query.partNo != null and query.partNo != ''">
  977. AND qa.attribute_no LIKE '%' + #{query.partNo}+'%'
  978. </if>
  979. <if test = "query.partDesc != null and query.partDesc != ''">
  980. AND p.part_desc LIKE '%' + #{query.partDesc}+'%'
  981. </if>
  982. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  983. AND p.cinv_source_code LIKE '%' + #{query.cinvSourceCode}+'%'
  984. </if>
  985. <if test = "query.sku != null and query.sku != ''">
  986. AND p.sku LIKE '%' + #{query.sku}+'%'
  987. </if>
  988. <if test = "query.familyName != null and query.familyName != ''">
  989. AND p.invtype LIKE '%' + #{query.familyName}+'%'
  990. </if>
  991. </where>
  992. </select>
  993. <!-- 查询是否已有该物料属性 -->
  994. <select id="selectPartAttributeByNo" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  995. SELECT
  996. attribute_no,
  997. supplier_no,
  998. attribute_remark,
  999. attribute_type
  1000. FROM qc_part_attribute
  1001. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1002. </select>
  1003. <!-- 新增物料属性 -->
  1004. <insert id="qcPartAttributeSave" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1005. INSERT INTO qc_part_attribute (attribute_no, supplier_no, attribute_remark, create_time, create_by, attribute_type, site, exempt_inspection, bu_no)
  1006. VALUES(#{partNo}, #{supplierNo}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{exemptInspection}, #{buNo})
  1007. </insert>
  1008. <!-- 物料属性修改 -->
  1009. <update id="qcPartAttributeEdit" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1010. UPDATE qc_part_attribute
  1011. SET attribute_remark = #{attributeRemark},
  1012. exempt_inspection = #{exemptInspection},
  1013. update_date = getDate(),
  1014. update_by = #{updateBy}
  1015. WHERE site = #{site} and attribute_no = #{partNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1016. </update>
  1017. <!-- 删除物料属性 -->
  1018. <delete id="qcPartAttributeDelete" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1019. DELETE FROM qc_part_attribute
  1020. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo} and attribute_type = #{attributeType}
  1021. </delete>
  1022. <!-- 删除物料属性模板 -->
  1023. <delete id="deletePartAttributeTemplate" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1024. DELETE FROM qc_attribute_template
  1025. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo} and attribute_type = #{attributeType}
  1026. </delete>
  1027. <!-- 删除物料属性模板检验标准明细 -->
  1028. <delete id="deleteQcAttributeTemplateItemByAttribute" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1029. DELETE FROM qc_attribute_template_item
  1030. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{partNo}
  1031. </delete>
  1032. <!-- 查询类别模板 -->
  1033. <select id="searchPartAttributeDetails" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1034. SELECT
  1035. qat.site,
  1036. qat.bu_no,
  1037. qpa.attribute_no,
  1038. qpa.attribute_type,
  1039. qt.template_id,
  1040. qt.template_name,
  1041. qt.template_remark,
  1042. qt.template_version,
  1043. qat.sampling_programme_no,
  1044. qsip.sampling_programme_desc,
  1045. qat.AQL,
  1046. qat.AC,
  1047. qat.RE,
  1048. qt.inspection_type_no,
  1049. qit.inspection_type_name,
  1050. qt.default_sampling_quantity,
  1051. qt.default_sampling_proportion,
  1052. qat.sampling_level_no,
  1053. qsil.sampling_level_desc,
  1054. qat.inspection_cycle,
  1055. qat.operation,
  1056. qat.manufacturer_id,
  1057. dbo.qc_get_supplier_name(qat.site, qat.manufacturer_id) as manufacturerName,
  1058. qat.resource_id
  1059. FROM qc_attribute_template as qat
  1060. 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
  1061. 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
  1062. 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
  1063. LEFT JOIN qc_inspection_type as qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1064. 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
  1065. <where>
  1066. qat.site = #{site} and qpa.attribute_type = #{attributeType} and qpa.attribute_no = #{attributeNo} and qat.bu_no = #{buNo}
  1067. <if test="inspectionTypeNo !=null and inspectionTypeNo != ''">
  1068. and qt.inspection_type_no = #{inspectionTypeNo}
  1069. </if>
  1070. <if test="operation !=null and operation != ''">
  1071. and qat.operation = #{operation}
  1072. </if>
  1073. </where>
  1074. </select>
  1075. <!-- 物料属性模板查重 -->
  1076. <select id="searchPartRepeat" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1077. SELECT
  1078. attribute_no,
  1079. template_id
  1080. FROM qc_attribute_template
  1081. WHERE attribute_no = #{attributeNo}
  1082. AND template_id = #{templateId}
  1083. AND attribute_type = #{attributeType}
  1084. AND special_field = #{specialField}
  1085. </select>
  1086. <!-- 新增物料属性模板 -->
  1087. <insert id="savePartAttributeDetails" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1088. INSERT INTO qc_attribute_template
  1089. (attribute_no, template_id, sampling_level_no, inspection_cycle, sampling_programme_no, AQL, AC, RE,
  1090. attribute_type, operation, manufacturer_id, resource_id, site, bu_no, inspection_type_no)
  1091. VALUES
  1092. (#{attributeNo}, #{templateId}, #{samplingLevelNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{samplingProgrammeNo}, #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL},
  1093. #{attributeType}, #{operation}, #{manufacturerID}, #{resourceID}, #{site}, #{buNo}, #{inspectionTypeNo})
  1094. </insert>
  1095. <!-- 可选模板 -->
  1096. <select id="getTemplateList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1097. SELECT
  1098. qt.template_id,
  1099. qt.template_name,
  1100. qit.inspection_type_name
  1101. FROM qc_template as qt
  1102. LEFT JOIN qc_attribute_template as qat ON qat.template_id = qt.template_id and qat.attribute_no = #{attributeNo}
  1103. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no
  1104. <where>
  1105. qt.site = #{site}
  1106. AND qat.attribute_no is null
  1107. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  1108. AND qt.inspection_type_no = #{inspectionTypeNo}
  1109. </if>
  1110. <if test = "templateId != null and templateId != ''">
  1111. AND qt.template_id LIKE '%' + #{templateId}+'%'
  1112. </if>
  1113. <if test = "templateName != null and templateName != ''">
  1114. AND qt.template_name LIKE '%' + #{templateName}+'%'
  1115. </if>
  1116. </where>
  1117. </select>
  1118. <!-- 已有模板 -->
  1119. <select id="getPartTemplateList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1120. SELECT
  1121. qt.template_id,
  1122. qt.template_name,
  1123. qit.inspection_type_name,
  1124. qat.operation,
  1125. qat.manufacturer_id,
  1126. dbo.qc_get_supplier_name(qt.site, qat.manufacturer_id) as manufacturerName,
  1127. qat.resource_id
  1128. FROM qc_attribute_template as qat
  1129. 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
  1130. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1131. WHERE qt.site = #{site} AND qat.attribute_no = #{attributeNo} and qt.bu_no = #{buNo}
  1132. </select>
  1133. <!-- 物料模板绑定数量(用于删除模板后判断是否清理检验标准明细) -->
  1134. <select id="countPartAttributeTemplateByTemplateKey" resultType="int" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1135. SELECT COUNT(1)
  1136. FROM qc_attribute_template
  1137. WHERE site = #{site}
  1138. AND bu_no = #{buNo}
  1139. AND attribute_no = #{attributeNo}
  1140. AND template_id = #{templateId}
  1141. AND attribute_type = #{attributeType}
  1142. </select>
  1143. <!-- 物料可选模板 -->
  1144. <select id="getTemplateListAll" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1145. SELECT
  1146. qt.template_id,
  1147. qt.template_name,
  1148. qit.inspection_type_name
  1149. FROM qc_template as qt
  1150. LEFT JOIN qc_inspection_type AS qit ON qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  1151. <where>
  1152. qt.site = #{site} and qt.bu_no = #{buNo}
  1153. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  1154. AND qt.inspection_type_no = #{inspectionTypeNo}
  1155. </if>
  1156. <if test = "templateId != null and templateId != ''">
  1157. AND qt.template_id LIKE '%' + #{templateId}+'%'
  1158. </if>
  1159. <if test = "templateName != null and templateName != ''">
  1160. AND qt.template_name LIKE '%' + #{templateName}+'%'
  1161. </if>
  1162. </where>
  1163. </select>
  1164. <!-- 删除物料属性模板 -->
  1165. <delete id="deletePartAttributeDetails" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1166. DELETE FROM qc_attribute_template
  1167. <where>
  1168. site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId} and attribute_type = #{attributeType}
  1169. <if test = "operation != null and operation != ''">
  1170. and operation = #{operation}
  1171. </if>
  1172. <if test = "resourceID != null and resourceID != ''">
  1173. and resource_id = #{resourceID}
  1174. </if>
  1175. <if test = "manufacturerID != null and manufacturerID != ''">
  1176. and manufacturer_id = #{manufacturerID}
  1177. </if>
  1178. </where>
  1179. </delete>
  1180. <!-- ======================= 物料模板检验标准明细(按“物料+模板”覆盖项目) ======================= -->
  1181. <select id="countQcAttributeTemplateItems" resultType="int" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1182. SELECT COUNT(1)
  1183. FROM qc_attribute_template_item
  1184. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId}
  1185. </select>
  1186. <!-- 明细查询:覆盖表优先;若覆盖表为空则回退模板默认明细 -->
  1187. <select id="qcAttributeTemplateItemDetailsSearch" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1188. SELECT
  1189. d.site,
  1190. d.bu_no,
  1191. d.attributeNo,
  1192. d.templateId,
  1193. d.itemNo,
  1194. d.itemDesc,
  1195. d.objectID,
  1196. d.objectDesc,
  1197. d.valueType,
  1198. d.valueTypeDb,
  1199. d.defaultValue,
  1200. d.maxValue,
  1201. d.minValue,
  1202. d.itemSamplingQuantity,
  1203. d.samplingProgrammeNo,
  1204. d.samplingProgrammeDesc,
  1205. d.samplingLevelNo,
  1206. d.samplingLevelDesc,
  1207. d.defaultSamplingProportion,
  1208. d.orderId
  1209. FROM (
  1210. SELECT
  1211. a.site,
  1212. a.bu_no,
  1213. a.attribute_no as attributeNo,
  1214. a.template_id as templateId,
  1215. a.item_no as itemNo,
  1216. b.ItemDesc as itemDesc,
  1217. td.object_id as objectID,
  1218. eo.objectDesc as objectDesc,
  1219. b.ValueType as valueType,
  1220. b.ValueType_DB as valueTypeDb,
  1221. a.default_value as defaultValue,
  1222. a.max_value as maxValue,
  1223. a.min_value as minValue,
  1224. b.item_sampling_quantity as itemSamplingQuantity,
  1225. b.sampling_programme_no as samplingProgrammeNo,
  1226. sp.sampling_programme_desc as samplingProgrammeDesc,
  1227. b.sampling_level_no as samplingLevelNo,
  1228. sl.sampling_level_desc as samplingLevelDesc,
  1229. b.default_sampling_proportion as defaultSamplingProportion,
  1230. a.order_id as orderId
  1231. FROM qc_attribute_template_item a
  1232. LEFT JOIN eam_properties_item b
  1233. ON a.site = b.site and a.bu_no = b.bu_no and a.item_no = b.ItemNo
  1234. LEFT JOIN qc_template_detailed td
  1235. ON a.site = td.site and a.bu_no = td.bu_no and a.template_id = td.template_id and a.item_no = td.ItemNo
  1236. LEFT JOIN eam_object eo
  1237. ON td.site = eo.site and td.object_id = eo.ObjectID
  1238. LEFT JOIN qc_sampling_inspection_programme sp
  1239. ON b.site = sp.site and b.bu_no = sp.bu_no and b.sampling_programme_no = sp.sampling_programme_no
  1240. LEFT JOIN qc_sampling_inspection_level sl
  1241. ON b.site = sl.site and b.bu_no = sl.bu_no and b.sampling_level_no = sl.sampling_level_no
  1242. WHERE a.site = #{site}
  1243. AND a.bu_no = #{buNo}
  1244. AND a.attribute_no = #{attributeNo}
  1245. AND a.template_id = #{templateId}
  1246. UNION ALL
  1247. SELECT
  1248. t.site,
  1249. t.bu_no,
  1250. #{attributeNo} as attributeNo,
  1251. t.template_id as templateId,
  1252. t.ItemNo as itemNo,
  1253. p.ItemDesc as itemDesc,
  1254. t.object_id as objectID,
  1255. eo.objectDesc as objectDesc,
  1256. p.ValueType as valueType,
  1257. p.ValueType_DB as valueTypeDb,
  1258. t.default_value as defaultValue,
  1259. t.max_value as maxValue,
  1260. t.min_value as minValue,
  1261. p.item_sampling_quantity as itemSamplingQuantity,
  1262. p.sampling_programme_no as samplingProgrammeNo,
  1263. sp.sampling_programme_desc as samplingProgrammeDesc,
  1264. p.sampling_level_no as samplingLevelNo,
  1265. sl.sampling_level_desc as samplingLevelDesc,
  1266. p.default_sampling_proportion as defaultSamplingProportion,
  1267. t.order_id as orderId
  1268. FROM qc_template_detailed t
  1269. LEFT JOIN eam_properties_item p
  1270. ON t.site = p.site and t.bu_no = p.bu_no and t.ItemNo = p.ItemNo
  1271. LEFT JOIN eam_object eo
  1272. ON t.site = eo.site and t.object_id = eo.ObjectID
  1273. LEFT JOIN qc_sampling_inspection_programme sp
  1274. ON p.site = sp.site and p.bu_no = sp.bu_no and p.sampling_programme_no = sp.sampling_programme_no
  1275. LEFT JOIN qc_sampling_inspection_level sl
  1276. ON p.site = sl.site and p.bu_no = sl.bu_no and p.sampling_level_no = sl.sampling_level_no
  1277. WHERE t.site = #{site}
  1278. AND t.bu_no = #{buNo}
  1279. AND t.template_id = #{templateId}
  1280. AND NOT EXISTS (
  1281. SELECT 1
  1282. FROM qc_attribute_template_item z
  1283. WHERE z.site = #{site}
  1284. AND z.bu_no = #{buNo}
  1285. AND z.attribute_no = #{attributeNo}
  1286. AND z.template_id = #{templateId}
  1287. )
  1288. ) d
  1289. ORDER BY d.orderId, d.itemNo
  1290. </select>
  1291. <delete id="qcAttributeTemplateItemDeleteByKey" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1292. DELETE FROM qc_attribute_template_item
  1293. WHERE site = #{site} and bu_no = #{buNo} and attribute_no = #{attributeNo} and template_id = #{templateId}
  1294. </delete>
  1295. <insert id="qcAttributeTemplateItemInsertList">
  1296. INSERT INTO qc_attribute_template_item
  1297. (site, bu_no, attribute_no, template_id, item_no, default_value, max_value, min_value, order_id, create_by, create_time, update_by, update_date)
  1298. VALUES
  1299. <foreach collection="list" item="i" separator=",">
  1300. (#{i.site}, #{i.buNo}, #{i.attributeNo}, #{i.templateId}, #{i.itemNo},
  1301. #{i.defaultValue}, #{i.maxValue}, #{i.minValue}, #{i.orderId},
  1302. #{i.createBy}, getDate(), #{i.updateBy}, getDate())
  1303. </foreach>
  1304. </insert>
  1305. <!-- 按模板明细复制检验项目到物料模板明细表 -->
  1306. <insert id="copyQcTemplateDetailedToAttributeTemplateItem" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1307. INSERT INTO qc_attribute_template_item
  1308. (site, bu_no, attribute_no, template_id, item_no, default_value, max_value, min_value, order_id, create_by, create_time, update_by, update_date)
  1309. SELECT
  1310. t.site,
  1311. t.bu_no,
  1312. #{attributeNo},
  1313. t.template_id,
  1314. t.ItemNo,
  1315. t.default_value,
  1316. t.max_value,
  1317. t.min_value,
  1318. t.order_id,
  1319. #{createBy},
  1320. getDate(),
  1321. #{updateBy},
  1322. getDate()
  1323. FROM qc_template_detailed t
  1324. WHERE t.site = #{site}
  1325. AND t.bu_no = #{buNo}
  1326. AND t.template_id = #{templateId}
  1327. AND NOT EXISTS (
  1328. SELECT 1
  1329. FROM qc_attribute_template_item z
  1330. WHERE z.site = #{site}
  1331. AND z.bu_no = #{buNo}
  1332. AND z.attribute_no = #{attributeNo}
  1333. AND z.template_id = #{templateId}
  1334. AND z.item_no = t.ItemNo
  1335. )
  1336. </insert>
  1337. <!-- 查询模板的基础数据 -->
  1338. <select id="selectTemplateData" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1339. SELECT
  1340. template_id,
  1341. template_name,
  1342. sampling_programme_no,
  1343. sampling_level_no,
  1344. inspection_cycle,
  1345. AQL,
  1346. AC,
  1347. RE,
  1348. inspection_type_no
  1349. FROM qc_template
  1350. WHERE site = #{site} AND template_id = #{templateId} and bu_no = #{buNo}
  1351. </select>
  1352. <!-- 新增物料属性模板详情 -->
  1353. <update id="saveAttributeDetailed" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1354. UPDATE qc_attribute_template
  1355. SET sampling_level_no = #{samplingLevelNo},
  1356. inspection_cycle = #{inspectionCycle,jdbcType=DECIMAL},
  1357. sampling_programme_no = #{samplingProgrammeNo},
  1358. AQL = #{aql,jdbcType=DECIMAL},
  1359. AC = #{ac,jdbcType=DECIMAL},
  1360. RE = #{re,jdbcType=DECIMAL}
  1361. <where>
  1362. site = #{site} and attribute_no = #{attributeNo} AND template_id = #{templateId} AND attribute_type = #{attributeType} and bu_no = #{buNo}
  1363. <if test = "operation != null and operation != ''">
  1364. AND operation = #{operation}
  1365. </if>
  1366. <if test = "resourceID != null and resourceID != ''">
  1367. AND resource_id = #{resourceID}
  1368. </if>
  1369. <if test = "manufacturerID != null and manufacturerID != ''">
  1370. AND manufacturer_id = #{manufacturerID}
  1371. </if>
  1372. </where>
  1373. </update>
  1374. <!-- 更新物料属性修改时间 -->
  1375. <update id="updatePartAttributeTime" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  1376. UPDATE qc_part_attribute
  1377. SET update_date = getDate(),
  1378. update_by = #{updateBy}
  1379. WHERE site = #{site} and attribute_no = #{attributeNo} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1380. </update>
  1381. <!-- ================================================= 类别属性设置维护 ================================================= -->
  1382. <!-- 查询类别属性 -->
  1383. <select id="qcFamilyAttributeSearch" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1384. SELECT
  1385. qa.site,
  1386. qa.bu_no,
  1387. dbo.get_bu_desc(qa.site, qa.bu_no) as buDesc,
  1388. qa.attribute_no as familyID,
  1389. pf.FamilyName,
  1390. qa.supplier_no,
  1391. qa.attribute_remark,
  1392. qa.create_time,
  1393. qa.create_by,
  1394. qa.update_date,
  1395. qa.update_by,
  1396. qa.attribute_type
  1397. FROM qc_part_attribute as qa
  1398. LEFT JOIN PartFamily as pf on qa.attribute_no = pf.FamilyID and qa.site = pf.site
  1399. <where>
  1400. qa.site in (select site from eam_access_site where username = #{query.userName})
  1401. and (qa.site + '-' + qa.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1402. and qa.attribute_type = #{query.attributeType}
  1403. <if test="query.buDesc != null and query.buDesc != ''">
  1404. AND dbo.get_bu_desc ( qa.site, qa.bu_no ) = #{query.buDesc}
  1405. </if>
  1406. <if test = "query.familyID != null and query.familyID != ''">
  1407. AND qa.attribute_no LIKE '%' + #{query.familyID}+'%'
  1408. </if>
  1409. <if test = "query.familyName != null and query.familyName != ''">
  1410. AND pf.FamilyName LIKE '%' + #{query.familyName}+'%'
  1411. </if>
  1412. </where>
  1413. </select>
  1414. <!-- 新增类别属性 -->
  1415. <insert id="qcFamilyAttributeSave" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1416. INSERT INTO qc_part_attribute (attribute_no, attribute_remark, create_time, create_by, attribute_type, site, bu_no)
  1417. VALUES(#{familyID}, #{attributeRemark}, getDate(), #{createBy}, #{attributeType}, #{site}, #{buNo})
  1418. </insert>
  1419. <!-- 删除分类属性 -->
  1420. <delete id="qcFamilyAttributeDelete" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1421. DELETE FROM qc_part_attribute
  1422. WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1423. </delete>
  1424. <!-- 删除分类属性模板 -->
  1425. <delete id="deleteFamilyAttributeTemplate" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  1426. DELETE FROM qc_attribute_template
  1427. WHERE site = #{site} and attribute_no = #{familyID} and attribute_type = #{attributeType} and bu_no = #{buNo}
  1428. </delete>
  1429. <!-- ================================================= 抽样方案维护 ================================================= -->
  1430. <!-- 查询类别属性 -->
  1431. <select id="samplingProgrammeSearch" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1432. SELECT
  1433. site,
  1434. bu_no,
  1435. dbo.get_bu_desc(site, bu_no) as buDesc,
  1436. sampling_programme_no,
  1437. sampling_programme_desc,
  1438. sampling_programme_code,
  1439. create_time,
  1440. create_by,
  1441. dbo.getOperatorDesc(site, create_by) as createByDesc,
  1442. update_date,
  1443. update_by,
  1444. dbo.getOperatorDesc(site, update_by) as updateByDesc
  1445. FROM qc_sampling_inspection_programme
  1446. <where>
  1447. site in (select site from eam_access_site where username = #{query.userName})
  1448. and (site + '-' + bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1449. <if test="query.buDesc != null and query.buDesc != ''">
  1450. AND dbo.get_bu_desc ( site, bu_no ) = #{query.buDesc}
  1451. </if>
  1452. <if test = "query.samplingProgrammeNo != null and query.samplingProgrammeNo != ''">
  1453. AND sampling_programme_no LIKE '%' + #{query.samplingProgrammeNo}+'%'
  1454. </if>
  1455. <if test = "query.samplingProgrammeCode != null and query.samplingProgrammeCode != ''">
  1456. AND sampling_programme_code LIKE '%' + #{query.samplingProgrammeCode}+'%'
  1457. </if>
  1458. <if test = "query.samplingProgrammeDesc != null and query.samplingProgrammeDesc != ''">
  1459. AND sampling_programme_desc LIKE '%' + #{query.samplingProgrammeDesc}+'%'
  1460. </if>
  1461. </where>
  1462. </select>
  1463. <!-- 新增抽样方案 -->
  1464. <insert id="samplingProgrammeSave" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1465. 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)
  1466. VALUES(#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingProgrammeDesc}, #{samplingProgrammeCode}, getDate(), #{createBy}, getDate(), #{updateBy})
  1467. </insert>
  1468. <!-- 删除抽样方案 -->
  1469. <delete id="samplingProgrammeDelete" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1470. DELETE FROM qc_sampling_inspection_programme
  1471. WHERE site = #{site} and bu_no = #{buNo}
  1472. AND sampling_programme_no = #{samplingProgrammeNo}
  1473. </delete>
  1474. <!-- 删除抽样方案中的矩阵 -->
  1475. <delete id="deletePlanByProgrammeNo" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1476. DELETE FROM qc_programme_plan
  1477. WHERE sampling_programme_no = #{samplingProgrammeNo} and site = #{site} and bu_no = #{buNo}
  1478. </delete>
  1479. <!-- 根据名称查询抽样方案 -->
  1480. <select id="selectSamplingProgrammeByDesc" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1481. SELECT
  1482. site,
  1483. bu_no,
  1484. sampling_programme_no,
  1485. sampling_programme_desc
  1486. FROM qc_sampling_inspection_programme
  1487. WHERE sampling_programme_desc = #{samplingProgrammeDesc} AND site = #{site} and bu_no = #{buNo}
  1488. </select>
  1489. <!-- 获取最大抽样方案编码 -->
  1490. <select id="queryLastSamplingProgrammeNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1491. SELECT top 1 sampling_programme_no
  1492. FROM qc_sampling_inspection_programme
  1493. where site = #{site} and bu_no = #{buNo}
  1494. ORDER BY sampling_programme_no Desc
  1495. </select>
  1496. <!-- 搜索抽样方案中的矩阵 -->
  1497. <select id="searchSamplingProgrammeDetails" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1498. SELECT
  1499. qpp.site,
  1500. qpp.bu_no,
  1501. qpp.sampling_programme_no,
  1502. qsip.sampling_plan_no,
  1503. qsip.sampling_plan_Desc,
  1504. qsip.sampling_qty_no,
  1505. qsiq.sampling_qty_desc,
  1506. qsiq.sampling_qty,
  1507. qsip.sampling_qty_rank_no,
  1508. qsiqr.sampling_qty_rank_desc,
  1509. qsiqr.min_qty,
  1510. qsiqr.max_qty,
  1511. qsip.sampling_level_no,
  1512. qsil.sampling_level_desc,
  1513. qsip.sampling_plan_active
  1514. FROM qc_programme_plan as qpp
  1515. 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
  1516. 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
  1517. 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
  1518. 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
  1519. WHERE qpp.sampling_programme_no = #{samplingProgrammeNo} and qpp.site = #{site} and qpp.bu_no = #{buNo}
  1520. </select>
  1521. <!-- 获取该方案不包含的矩阵 -->
  1522. <select id="getPlanList" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1523. SELECT
  1524. qip.sampling_plan_no,
  1525. qip.sampling_plan_desc
  1526. FROM qc_sampling_inspection_plan as qip
  1527. 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
  1528. WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no is null
  1529. </select>
  1530. <!-- 获取当前方案所包含的矩阵 -->
  1531. <select id="getProgrammePlanList" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1532. SELECT
  1533. qip.sampling_plan_no,
  1534. qip.sampling_plan_desc
  1535. FROM qc_programme_plan as qpp
  1536. 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
  1537. WHERE qip.site = #{site} and qip.bu_no = #{buNo} AND qpp.sampling_programme_no = #{samplingProgrammeNo}
  1538. </select>
  1539. <!-- 查重 -->
  1540. <select id="searchPlanRepeat" resultType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1541. SELECT
  1542. sampling_plan_no,
  1543. sampling_programme_no
  1544. FROM qc_programme_plan
  1545. WHERE sampling_programme_no = #{samplingProgrammeNo} AND sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
  1546. </select>
  1547. <!-- 新增抽样方案中的矩阵 -->
  1548. <insert id="saveSamplingProgrammeDetails" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1549. INSERT INTO qc_programme_plan (site, bu_no, sampling_programme_no, sampling_plan_no)
  1550. VALUES (#{site}, #{buNo}, #{samplingProgrammeNo}, #{samplingPlanNo})
  1551. </insert>
  1552. <!-- 更新抽样方案修改时间 -->
  1553. <update id="updateSamplingInspectionProgrammeDate" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1554. UPDATE qc_sampling_inspection_programme
  1555. SET update_date = getDate(),
  1556. update_by = #{updateBy}
  1557. WHERE site = #{site} AND sampling_programme_no = #{samplingProgrammeNo} and bu_no = #{buNo}
  1558. </update>
  1559. <!-- 删除抽样方案中的矩阵 -->
  1560. <delete id="deleteSamplingProgrammeDetails" parameterType="com.xujie.sys.modules.pms.data.QcSamplingInspectionProgrammeData">
  1561. DELETE FROM qc_programme_plan
  1562. WHERE sampling_programme_no = #{samplingProgrammeNo} and sampling_plan_no = #{samplingPlanNo} and site = #{site} and bu_no = #{buNo}
  1563. </delete>
  1564. <!-- ================================================= FAI检验维护 ================================================= -->
  1565. <!-- 查询FAI基础数据 -->
  1566. <select id="selectFAIBasicData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1567. SELECT
  1568. top 1
  1569. a.orderno as orderNo,
  1570. j.part_no,
  1571. j.part_desc,
  1572. c.operation_desc,
  1573. b.approve_qty as rollQty,
  1574. a.s_resourceid as resourceId,
  1575. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1576. a.itemno as itemNo,
  1577. a.id as ssrId
  1578. FROM soscheduledrouting as a
  1579. LEFT JOIN sfdc as b
  1580. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  1581. select min(sfdc.id)
  1582. from sfdc
  1583. group by sfdc.assjob_seq_no, site
  1584. )
  1585. LEFT JOIN so_routing as c
  1586. ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  1587. LEFT JOIN part j
  1588. ON a.site = j.site and a.part_no = j.part_no
  1589. WHERE a.itemno = '10'
  1590. AND a.id not in (select ssr_id from qc_fai_record)
  1591. AND b.approve_qty is not null
  1592. ORDER BY a.id desc
  1593. </select>
  1594. <!-- 获取该物料属性下维护的iqc -->
  1595. <select id="selectPartAttributeByPartNo" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1596. SELECT
  1597. qat.site,
  1598. qat.bu_no,
  1599. qat.attribute_no,
  1600. qat.template_id,
  1601. qat.sampling_level_no,
  1602. qsil.sampling_level_desc,
  1603. qat.inspection_cycle,
  1604. qat.sampling_programme_no,
  1605. qsip.sampling_programme_desc,
  1606. qat.AQL,
  1607. qat.AC,
  1608. qat.RE,
  1609. qt.default_sampling_quantity,
  1610. qt.default_sampling_proportion
  1611. FROM qc_attribute_template as qat
  1612. 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
  1613. 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
  1614. 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
  1615. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  1616. AND qat.attribute_no = #{partNo}
  1617. AND qat.attribute_type = #{attributeType}
  1618. AND qt.inspection_type_no = #{inspectionTypeNo}
  1619. AND qat.manufacturer_id = #{supplierNo}
  1620. </select>
  1621. <!-- 获取该物料属性下维护的ipqc -->
  1622. <select id="selectPartAttributeByOperationAndResource" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1623. SELECT
  1624. qat.site,
  1625. qat.bu_no,
  1626. qat.attribute_no,
  1627. qat.template_id,
  1628. qat.sampling_level_no,
  1629. qsil.sampling_level_desc,
  1630. qat.inspection_cycle,
  1631. qat.sampling_programme_no,
  1632. qsip.sampling_programme_desc,
  1633. qat.AQL,
  1634. qat.AC,
  1635. qat.RE,
  1636. qt.default_sampling_quantity,
  1637. qt.default_sampling_proportion
  1638. FROM qc_attribute_template as qat
  1639. 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
  1640. 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
  1641. 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
  1642. WHERE qat.site = #{site} and qat.bu_no = #{buNo}
  1643. AND qat.attribute_no = #{partNo}
  1644. AND qat.attribute_type = #{attributeType1}
  1645. AND qt.inspection_type_no = #{inspectionTypeNo}
  1646. AND qat.operation = #{operationDesc}
  1647. AND qat.resource_id = #{resourceId}
  1648. </select>
  1649. <!-- 获取模板详情 -->
  1650. <select id="selectTemplate" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1651. SELECT
  1652. qt.site,
  1653. qt.bu_no,
  1654. qt.template_id,
  1655. qt.sampling_level_no,
  1656. qsil.sampling_level_desc,
  1657. qt.inspection_cycle,
  1658. qt.sampling_programme_no,
  1659. qsip.sampling_programme_desc,
  1660. qt.AQL,
  1661. qt.AC,
  1662. qt.RE,
  1663. qt.default_sampling_quantity,
  1664. qt.default_sampling_proportion
  1665. FROM qc_template as qt
  1666. 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
  1667. 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
  1668. WHERE qt.site = #{site} and qt.template_id = #{templateId} and qt.bu_no = #{buNo}
  1669. </select>
  1670. <!-- 新增FAI主记录信息 -->
  1671. <insert id="saveFAIRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1672. 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)
  1673. 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})
  1674. </insert>
  1675. <insert id="saveFAIDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1676. INSERT INTO qc_fai_detailed_record
  1677. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1678. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1679. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  1680. VALUES
  1681. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  1682. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  1683. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  1684. </insert>
  1685. <!-- 新增FAI明细记录信息 -->
  1686. <insert id="saveFAIDetailedRecords">
  1687. INSERT INTO qc_fai_detailed_record
  1688. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  1689. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  1690. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  1691. VALUES
  1692. <foreach collection="list" item="item" separator=",">
  1693. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  1694. #{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},
  1695. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  1696. </foreach>
  1697. </insert>
  1698. <!-- 查询FAI主记录信息 -->
  1699. <select id="qcFAIInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1700. SELECT
  1701. a.inspection_no,
  1702. a.site,
  1703. a.bu_no,
  1704. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  1705. a.state,
  1706. a.inspection_result,
  1707. a.task_date,
  1708. a.inspection_type_no,
  1709. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  1710. a.inspection_cycle,
  1711. a.order_no,
  1712. a.operation_desc,
  1713. a.resource_id,
  1714. r.resource_desc,
  1715. a.part_no,
  1716. d.part_desc,
  1717. d.cinv_source_code as cinvSourceCode,
  1718. d.sku as sku,
  1719. d.invdefinetype as invdefinetype,
  1720. a.inspection_remark,
  1721. a.roll_qty,
  1722. a.sampling_qty,
  1723. a.disposal_measures,
  1724. a.disposal_remark,
  1725. a.inspector_date,
  1726. a.inspector_no,
  1727. u.user_display as inspectorName,
  1728. a.ssr_id,
  1729. a.unqualified_qty,
  1730. a.submit_flag,
  1731. a.seq_no,
  1732. a.batch_roll_no,
  1733. a.special_requirements,
  1734. a.work_center_no,
  1735. a.roll_no,
  1736. a.um_id,
  1737. um.UMName as umName,
  1738. a.action_date,
  1739. a.action_by,
  1740. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  1741. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  1742. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  1743. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  1744. a.pass_qty,
  1745. a.not_pass_qty,
  1746. a.batch_qualified_qty
  1747. FROM qc_fai_record as a
  1748. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  1749. left join sys_user as u on a.inspector_no = u.username
  1750. 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
  1751. left join UM as um on a.site = um.site and a.um_id = um.UMID
  1752. <where>
  1753. a.site in (select site from eam_access_site where username = #{query.userName})
  1754. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  1755. <if test="query.buNo != null and query.buNo != ''">
  1756. AND a.bu_no = #{query.buNo}
  1757. </if>
  1758. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  1759. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  1760. </if>
  1761. <if test = "query.partNo != null and query.partNo != ''">
  1762. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  1763. </if>
  1764. <if test = "query.partDesc != null and query.partDesc != ''">
  1765. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  1766. </if>
  1767. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  1768. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  1769. </if>
  1770. <if test = "query.sku != null and query.sku != ''">
  1771. AND d.sku LIKE '%' + #{query.sku} + '%'
  1772. </if>
  1773. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  1774. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  1775. </if>
  1776. <if test = "query.states != null and query.states.size > 0">
  1777. AND a.state in
  1778. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  1779. #{item}
  1780. </foreach>
  1781. </if>
  1782. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  1783. AND a.inspection_result = #{query.inspectionResult}
  1784. </if>
  1785. <if test = "query.orderNo != null and query.orderNo != ''">
  1786. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  1787. </if>
  1788. <if test = "query.seqNo != null and query.seqNo != ''">
  1789. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  1790. </if>
  1791. <if test = "query.operationDesc != null and query.operationDesc != ''">
  1792. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  1793. </if>
  1794. <if test="query.startDate != null">
  1795. AND a.inspector_date >= #{query.startDate}
  1796. </if>
  1797. <if test="query.endDate != null">
  1798. AND #{query.endDate} >= a.inspector_date
  1799. </if>
  1800. <if test="query.startDate2 != null">
  1801. AND a.task_date >= #{query.startDate2}
  1802. </if>
  1803. <if test="query.endDate2 != null">
  1804. AND #{query.endDate2} >= a.task_date
  1805. </if>
  1806. </where>
  1807. ORDER BY
  1808. CASE WHEN a.state = '待检验' THEN 1
  1809. WHEN a.state = '待审核' THEN 2
  1810. WHEN a.state = '已完成' THEN 3
  1811. END, a.task_date desc
  1812. </select>
  1813. <!-- 获取物料的类别编码 -->
  1814. <select id="selectFamilyIdByPartNo" parameterType="string" resultType="string">
  1815. SELECT FamilyID
  1816. FROM part
  1817. WHERE part_no = #{partNo} AND site = #{site}
  1818. </select>
  1819. <!-- FAI明细记录查询 -->
  1820. <select id="faiDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1821. SELECT
  1822. a.site,
  1823. a.bu_no,
  1824. a.inspection_no,
  1825. a.order_no,
  1826. a.template_id,
  1827. a.sampling_level_no,
  1828. a.sampling_level_desc,
  1829. a.sampling_programme_no,
  1830. a.sampling_programme_desc,
  1831. a.AQL,
  1832. a.AC,
  1833. a.RE,
  1834. a.item_no,
  1835. a.item_desc,
  1836. a.object_id,
  1837. a.object_desc,
  1838. a.default_value,
  1839. a.min_value,
  1840. a.max_value,
  1841. a.text_value,
  1842. a.number_value,
  1843. a.value_type_db,
  1844. a.value_type,
  1845. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  1846. a.is_submit,
  1847. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  1848. a.sampling_qty,
  1849. dbo.qc_get_fai_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  1850. c.method_no,
  1851. c.method_name,
  1852. c.method_remark
  1853. FROM qc_fai_detailed_record as a
  1854. 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
  1855. 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
  1856. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  1857. order by a.order_id
  1858. </select>
  1859. <!-- 修改FAI主记录信息 -->
  1860. <update id="updateFAIMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1861. UPDATE qc_fai_record
  1862. SET disposal_measures = #{disposalMeasures},
  1863. disposal_remark = #{disposalRemark},
  1864. inspection_result = #{inspectionResult},
  1865. inspector_no = #{inspectorNo},
  1866. state = #{state},
  1867. inspection_remark = #{inspectionRemark},
  1868. inspector_date = getDate(),
  1869. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1870. roll_qty = #{rollQty,jdbcType=DECIMAL},
  1871. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  1872. pass_qty = #{passQty,jdbcType=DECIMAL},
  1873. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  1874. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  1875. submit_date = getDate()
  1876. WHERE site = #{site} AND inspection_no = #{inspectionNo} and bu_no = #{buNo}
  1877. </update>
  1878. <!-- 修改FAI明细记录信息 -->
  1879. <update id="updateFAIDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1880. UPDATE qc_fai_detailed_record
  1881. SET item_result = #{itemResult},
  1882. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  1883. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  1884. text_value = #{textValue},
  1885. number_value = #{numberValue,jdbcType=DECIMAL}
  1886. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1887. </update>
  1888. <!-- 修改子明细提交标识 -->
  1889. <update id="updateSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1890. UPDATE qc_fai_sub_detail_record
  1891. SET is_submit = 'Y'
  1892. WHERE inspection_no = #{inspectionNo}
  1893. </update>
  1894. <!-- 删除FAI检验记录 -->
  1895. <delete id="deleteFAIRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1896. DELETE FROM qc_fai_record
  1897. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1898. </delete>
  1899. <!-- 删除FAI明细记录信息 -->
  1900. <delete id="deleteFAIDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1901. DELETE FROM qc_fai_detailed_record
  1902. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1903. </delete>
  1904. <!-- 删除FAI子明细记录信息 -->
  1905. <delete id="deleteFAISubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1906. DELETE FROM qc_fai_sub_detail_record
  1907. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1908. </delete>
  1909. <!-- 修改FAI主记录标识为已提交 -->
  1910. <update id="updateFAIMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1911. UPDATE qc_fai_record
  1912. SET submit_flag = 'Y',
  1913. state = '已完成',
  1914. submit_date = getDate()
  1915. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1916. </update>
  1917. <!-- 修改FAI明细记录标识为已提交 -->
  1918. <update id="updateFAIDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1919. UPDATE qc_fai_detailed_record
  1920. SET is_submit = 'Y'
  1921. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1922. </update>
  1923. <!-- 修改子明细记录标识为已提交 -->
  1924. <update id="updateFAISubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1925. UPDATE qc_fai_sub_detail_record
  1926. SET is_submit = 'Y'
  1927. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1928. </update>
  1929. <!-- 查询FAI检验记录是否已提交 -->
  1930. <select id="checkFAIIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1931. SELECT submit_flag
  1932. FROM qc_fai_record
  1933. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  1934. </select>
  1935. <!-- 删除子明细的老数据 -->
  1936. <delete id="delFAISubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  1937. DELETE FROM qc_fai_sub_detail_record
  1938. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1939. </delete>
  1940. <!-- 新增FAI子明细信息 -->
  1941. <insert id="saveFAISubDetailed">
  1942. INSERT INTO qc_fai_sub_detail_record
  1943. (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)
  1944. VALUES
  1945. <foreach collection="list" item="item" separator=",">
  1946. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  1947. </foreach>
  1948. </insert>
  1949. <!-- 查询FAI的子明细 -->
  1950. <select id="selectFAISubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  1951. SELECT
  1952. site,
  1953. bu_no,
  1954. sub_detail_value,
  1955. sampling_location,
  1956. is_submit,
  1957. sampling_location_b,
  1958. num,
  1959. sub_detail_value_b,
  1960. sub_detail_value_c,
  1961. sub_detail_value_d,
  1962. sub_detail_value_e
  1963. FROM qc_fai_sub_detail_record
  1964. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  1965. <if test = "collectionDataContent != null and collectionDataContent != ''">
  1966. AND sub_detail_value ${collectionDataContent}
  1967. </if>
  1968. </select>
  1969. <!-- 获取该项目的子明细值 -->
  1970. <select id="selectFAISubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  1971. SELECT sub_detail_value,
  1972. sampling_location,
  1973. is_submit
  1974. FROM qc_fai_sub_detail_record
  1975. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  1976. </select>
  1977. <!-- ================================================= IPQC检验维护 ================================================= -->
  1978. <!-- 查询IPQC基础数据 -->
  1979. <select id="selectIPQCBasicData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  1980. SELECT
  1981. top 1
  1982. a.orderno as orderNo,
  1983. j.part_no,
  1984. j.part_desc,
  1985. c.operation_desc,
  1986. b.approve_qty as rollQty,
  1987. a.s_resourceid as resourceId,
  1988. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  1989. a.itemno as itemNo,
  1990. a.id as ssrId
  1991. FROM soscheduledrouting as a
  1992. LEFT JOIN sfdc as b
  1993. ON a.site = b.site and a.seqno = b.assjob_seq_no and b.id in (
  1994. select max(sfdc.id)
  1995. from sfdc
  1996. group by sfdc.assjob_seq_no, site
  1997. )
  1998. LEFT JOIN so_routing as c
  1999. ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  2000. LEFT JOIN part j
  2001. ON a.site = j.site and a.part_no = j.part_no
  2002. LEFT JOIN (select ssr_id from qc_ipqc_record where check_type = '末件检') as temp
  2003. ON a.id = temp.ssr_id
  2004. WHERE b.approve_qty is not null and temp.ssr_id is null
  2005. ORDER BY a.id desc
  2006. </select>
  2007. <select id="qcExec" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="string" statementType="CALLABLE">
  2008. {CALL
  2009. getIpqcRecord(#{site,mode=IN,jdbcType=VARCHAR})
  2010. }
  2011. </select>
  2012. <insert id="saveIPQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2013. INSERT INTO qc_ipqc_detailed_record
  2014. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2015. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2016. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  2017. VALUES
  2018. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  2019. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  2020. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  2021. </insert>
  2022. <!-- 新增IPQC明细记录信息 -->
  2023. <insert id="saveIPQCDetailedRecords">
  2024. INSERT INTO qc_ipqc_detailed_record
  2025. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2026. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2027. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  2028. VALUES
  2029. <foreach collection="list" item="item" separator=",">
  2030. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  2031. #{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},
  2032. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  2033. </foreach>
  2034. </insert>
  2035. <!-- 新增IPQC主记录信息 -->
  2036. <insert id="saveIPQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2037. INSERT INTO qc_ipqc_record
  2038. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  2039. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  2040. VALUES
  2041. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  2042. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  2043. </insert>
  2044. <!-- 查询IPQC主记录信息 -->
  2045. <select id="qcIPQCInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2046. SELECT
  2047. a.inspection_no,
  2048. a.site,
  2049. a.bu_no,
  2050. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2051. a.state,
  2052. a.inspection_result,
  2053. a.task_date,
  2054. a.inspection_type_no,
  2055. a.inspection_cycle,
  2056. a.order_no,
  2057. a.operation_desc,
  2058. a.resource_id,
  2059. r.resource_desc,
  2060. a.part_no,
  2061. d.part_desc,
  2062. d.cinv_source_code as cinvSourceCode,
  2063. d.sku as sku,
  2064. d.invdefinetype as invdefinetype,
  2065. a.inspection_remark,
  2066. a.roll_qty,
  2067. a.sampling_qty,
  2068. a.disposal_measures,
  2069. a.disposal_remark,
  2070. a.inspector_date,
  2071. a.inspector_no,
  2072. u.user_display as inspectorName,
  2073. a.ssr_id,
  2074. a.unqualified_qty,
  2075. a.submit_flag,
  2076. a.seq_no,
  2077. a.batch_roll_no,
  2078. a.special_requirements,
  2079. a.work_center_no,
  2080. a.roll_no,
  2081. a.um_id,
  2082. um.UMName as umName,
  2083. a.action_date,
  2084. a.action_by,
  2085. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2086. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2087. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2088. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2089. a.pass_qty,
  2090. a.not_pass_qty,
  2091. a.batch_qualified_qty,
  2092. isnull(a.work_file_read, 'N') as workFileRead,
  2093. CASE WHEN (
  2094. EXISTS (SELECT 1 FROM sys_oss o WHERE o.order_ref1 = a.site AND o.order_ref2 = a.part_no AND o.order_ref4 = a.bu_no)
  2095. OR EXISTS (
  2096. SELECT 1
  2097. FROM dbo.getSOP_RootPartList(a.site, a.part_no) p
  2098. INNER JOIN part_sop s ON p.partNo = s.part_no AND p.site = a.site
  2099. WHERE ((s.sop_type <![CDATA[<>]]> 'TPI') OR (s.sop_type = 'TPI' AND GETDATE() >= s.phase_in_date AND s.phase_out_date >= DATEADD(DAY, -1, GETDATE()) AND s.part_no = a.part_no))
  2100. AND s.sop_status = N'下达'
  2101. )
  2102. ) THEN 'Y' ELSE 'N' END as hasWorkFile
  2103. FROM qc_ipqc_record as a
  2104. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  2105. left join sys_user as u on a.inspector_no = u.username
  2106. 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
  2107. left join UM as um on a.site = um.site and a.um_id = um.UMID
  2108. <where>
  2109. a.site in (select site from eam_access_site where username = #{query.userName})
  2110. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2111. <if test="query.buNo != null and query.buNo != ''">
  2112. AND a.bu_no = #{query.buNo}
  2113. </if>
  2114. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2115. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2116. </if>
  2117. <if test = "query.partNo != null and query.partNo != ''">
  2118. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2119. </if>
  2120. <if test = "query.partDesc != null and query.partDesc != ''">
  2121. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  2122. </if>
  2123. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2124. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2125. </if>
  2126. <if test = "query.sku != null and query.sku != ''">
  2127. AND d.sku LIKE '%' + #{query.sku} + '%'
  2128. </if>
  2129. <if test = "query.states != null and query.states.size > 0">
  2130. AND a.state in
  2131. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2132. #{item}
  2133. </foreach>
  2134. </if>
  2135. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  2136. AND a.inspection_type_no = #{query.inspectionTypeNo}
  2137. </if>
  2138. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2139. AND a.inspection_result = #{query.inspectionResult}
  2140. </if>
  2141. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2142. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2143. </if>
  2144. <if test = "query.orderNo != null and query.orderNo != ''">
  2145. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2146. </if>
  2147. <if test = "query.seqNo != null and query.seqNo != ''">
  2148. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  2149. </if>
  2150. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2151. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2152. </if>
  2153. <if test="query.startDate != null">
  2154. AND a.inspector_date >= #{query.startDate}
  2155. </if>
  2156. <if test="query.endDate != null">
  2157. AND #{query.endDate} >= a.inspector_date
  2158. </if>
  2159. <if test="query.startDate2 != null">
  2160. AND a.task_date >= #{query.startDate2}
  2161. </if>
  2162. <if test="query.endDate2 != null">
  2163. AND #{query.endDate2} >= a.task_date
  2164. </if>
  2165. </where>
  2166. ORDER BY
  2167. CASE WHEN a.state = '待检验' THEN 1
  2168. WHEN a.state = '待审核' THEN 2
  2169. WHEN a.state = '已完成' THEN 3
  2170. END, a.task_date desc
  2171. </select>
  2172. <!-- IPQC明细记录查询 -->
  2173. <select id="ipqcDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2174. SELECT
  2175. a.site,
  2176. a.bu_no,
  2177. a.inspection_no,
  2178. a.order_no,
  2179. a.template_id,
  2180. a.sampling_level_no,
  2181. a.sampling_level_desc,
  2182. a.sampling_programme_no,
  2183. a.sampling_programme_desc,
  2184. a.AQL,
  2185. a.AC,
  2186. a.RE,
  2187. a.item_no,
  2188. a.item_desc,
  2189. a.object_id,
  2190. a.object_desc,
  2191. a.default_value,
  2192. a.min_value,
  2193. a.max_value,
  2194. a.text_value,
  2195. a.number_value,
  2196. a.value_type_db,
  2197. a.value_type,
  2198. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2199. a.is_submit,
  2200. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2201. a.sampling_qty,
  2202. dbo.qc_get_ipqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2203. c.method_no,
  2204. c.method_name,
  2205. c.method_remark
  2206. FROM qc_ipqc_detailed_record as a
  2207. 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
  2208. 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
  2209. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2210. order by a.order_id
  2211. </select>
  2212. <!-- 删除IPQC检验记录 -->
  2213. <delete id="deleteIPQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2214. DELETE FROM qc_ipqc_record
  2215. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2216. </delete>
  2217. <!-- 删除IPQC明细记录信息 -->
  2218. <delete id="deleteIPQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2219. DELETE FROM qc_ipqc_detailed_record
  2220. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2221. </delete>
  2222. <!-- 删除IPQC子明细记录信息 -->
  2223. <delete id="deleteIPQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2224. DELETE FROM qc_ipqc_sub_detail_record
  2225. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2226. </delete>
  2227. <!-- 修改IPQC主记录信息 -->
  2228. <update id="updateIPQCMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2229. UPDATE qc_ipqc_record
  2230. SET disposal_measures = #{disposalMeasures},
  2231. disposal_remark = #{disposalRemark},
  2232. inspection_result = #{inspectionResult},
  2233. inspector_no = #{inspectorNo},
  2234. state = #{state},
  2235. inspection_remark = #{inspectionRemark},
  2236. inspector_date = getDate(),
  2237. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2238. roll_qty = #{rollQty,jdbcType=DECIMAL},
  2239. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2240. pass_qty = #{passQty,jdbcType=DECIMAL},
  2241. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2242. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  2243. submit_date = getDate()
  2244. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2245. </update>
  2246. <!-- 修改IPQC明细记录信息 -->
  2247. <update id="updateIPQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2248. UPDATE qc_ipqc_detailed_record
  2249. SET item_result = #{itemResult},
  2250. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2251. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2252. text_value = #{textValue},
  2253. number_value = #{numberValue,jdbcType=DECIMAL}
  2254. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2255. </update>
  2256. <!-- 标记IPQC工作文件已阅读 -->
  2257. <update id="updateIPQCWorkFileRead" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2258. UPDATE qc_ipqc_record
  2259. SET work_file_read = 'Y'
  2260. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  2261. AND isnull(work_file_read, 'N') <![CDATA[<>]]> 'Y'
  2262. </update>
  2263. <!-- 修改IPQC主记录标识为已提交 -->
  2264. <update id="updateIPQCMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2265. UPDATE qc_ipqc_record
  2266. SET submit_flag = 'Y',
  2267. state = '已完成',
  2268. submit_date = getDate()
  2269. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2270. </update>
  2271. <!-- 修改IPQC明细记录标识为已提交 -->
  2272. <update id="updateIPQCDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2273. UPDATE qc_ipqc_detailed_record
  2274. SET is_submit = 'Y'
  2275. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2276. </update>
  2277. <!-- 修改IPQC子明细记录标识为已提交 -->
  2278. <update id="updateIPQCSubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2279. UPDATE qc_ipqc_sub_detail_record
  2280. SET is_submit = 'Y'
  2281. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2282. </update>
  2283. <!-- 删除IPQC子明细的老数据 -->
  2284. <delete id="delIPQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  2285. DELETE FROM qc_ipqc_sub_detail_record
  2286. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2287. </delete>
  2288. <!-- 新增IPQC子明细信息 -->
  2289. <insert id="saveIPQCSubDetailed">
  2290. INSERT INTO qc_ipqc_sub_detail_record
  2291. (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)
  2292. VALUES
  2293. <foreach collection="list" item="item" separator=",">
  2294. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  2295. </foreach>
  2296. </insert>
  2297. <!-- 查询IPQC的子明细 -->
  2298. <select id="selectIPQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2299. SELECT
  2300. site,
  2301. bu_no,
  2302. sub_detail_value,
  2303. sampling_location,
  2304. is_submit,
  2305. sampling_location_b,
  2306. num,
  2307. sub_detail_value_b,
  2308. sub_detail_value_c,
  2309. sub_detail_value_d,
  2310. sub_detail_value_e
  2311. FROM qc_ipqc_sub_detail_record
  2312. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2313. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2314. AND sub_detail_value ${collectionDataContent}
  2315. </if>
  2316. </select>
  2317. <!-- 查询IPQC检验记录是否已提交 -->
  2318. <select id="checkIPQCIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2319. SELECT submit_flag
  2320. FROM qc_ipqc_record
  2321. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2322. </select>
  2323. <!-- 获取该项目的子明细值 -->
  2324. <select id="selectIPQCSubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2325. SELECT sub_detail_value,
  2326. sampling_location,
  2327. is_submit
  2328. FROM qc_ipqc_sub_detail_record
  2329. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2330. </select>
  2331. <!-- 查询工序列表 -->
  2332. <select id="getOperationList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2333. SELECT
  2334. DISTINCT
  2335. a.seqno as seqNo,
  2336. a.orderno as orderNo,
  2337. j.part_no,
  2338. j.part_desc,
  2339. j.invdefinetype,
  2340. j.sku,
  2341. c.operation_desc as operationDesc,
  2342. a.itemno as operationNo,
  2343. a.s_resourceid as resourceId,
  2344. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  2345. c.work_center_no
  2346. FROM soscheduledrouting as a
  2347. LEFT JOIN so_routing as c ON a.site = c.site and c.order_no = a.orderno and a.itemno = c.item_no
  2348. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2349. WHERE a.site = #{site} and a.seqno = #{seqNo}
  2350. </select>
  2351. <!-- 根据工单号和工序号查出所有数据 -->
  2352. <select id="getResourceList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2353. SELECT
  2354. a.s_resourceid as resourceId,
  2355. DBO.getResourceDesc(a.site, a.s_resourceid) as resourceDesc,
  2356. c.work_center_no
  2357. FROM soscheduledrouting as a
  2358. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2359. LEFT JOIN so_routing as c ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  2360. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2361. WHERE a.site = #{site} and b.approve_qty is not null and a.seqno = #{seqNo}
  2362. ORDER BY a.id desc
  2363. </select>
  2364. <!-- a.orderno = #{orderNo} and c.operation_desc = #{operationDesc}-->
  2365. <!-- 查询机台名称 -->
  2366. <select id="selectResourceDesc" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2367. SELECT distinct
  2368. resource_desc
  2369. FROM resource
  2370. WHERE site = #{site} and resource_id = #{resourceId}
  2371. </select>
  2372. <!-- 查询物料名称 -->
  2373. <select id="selectPartDesc" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2374. SELECT distinct
  2375. part_desc
  2376. FROM part
  2377. WHERE site = #{site} and part_no = #{partNo}
  2378. </select>
  2379. <!-- ================================================= IQC检验维护 ================================================= -->
  2380. <!-- 查询IQC基础数据 -->
  2381. <select id="selectIQCBasicData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2382. SELECT
  2383. qir.inspection_no,
  2384. qir.state,
  2385. qir.create_date as taskDate,
  2386. qir.roll_no,
  2387. qir.part_no,
  2388. p.part_desc,
  2389. p.cinv_source_code,
  2390. p.sku as sku,
  2391. qir.roll_qty,
  2392. qir.print_flag,
  2393. qir.create_by,
  2394. qir.supplier_no,
  2395. qir.site,
  2396. qir.bu_no,
  2397. qir.po_orderNo,
  2398. qir.po_itemNo,
  2399. qir.roll_count
  2400. FROM qc_iqc_record as qir
  2401. LEFT JOIN part p ON qir.part_no = p.part_no and qir.site = p.site
  2402. WHERE qir.site in (select site from eam_access_site where username = #{userName})
  2403. and (qir.site + '-' + qir.bu_no) in (select * from dbo.query_bu(#{userName}))
  2404. and qir.detail_flag = 'N'
  2405. </select>
  2406. <!-- 新增IQC明细记录信息 -->
  2407. <insert id="saveIQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2408. 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)
  2409. 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})
  2410. </insert>
  2411. <!-- 修改IQC检验记录 -->
  2412. <update id="updateIQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2413. UPDATE qc_iqc_record
  2414. SET inspection_type_no = #{inspectionTypeNo},
  2415. sampling_qty = #{samplingQty},
  2416. inspection_cycle = #{inspectionCycle},
  2417. part_no = #{partNo},
  2418. supplier_no = #{supplierNo},
  2419. part_desc = #{partDesc},
  2420. detail_flag = 'Y',
  2421. state = '未开始',
  2422. action_date = null,
  2423. action_by = ''
  2424. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2425. </update>
  2426. <!-- 查询IQC主记录信息 -->
  2427. <select id="qcIQCInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2428. SELECT
  2429. a.inspection_no,
  2430. a.site,
  2431. a.bu_no,
  2432. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2433. a.state,
  2434. a.inspection_result,
  2435. a.create_date as taskDate,
  2436. a.inspection_type_no,
  2437. a.inspection_cycle,
  2438. a.part_no,
  2439. a.part_desc,
  2440. d.cinv_source_code as cinvSourceCode,
  2441. d.sku,
  2442. d.umid as umId,
  2443. d.invdefinetype as invdefinetype,
  2444. a.inspection_remark,
  2445. a.roll_qty,
  2446. a.sampling_qty,
  2447. a.disposal_measures,
  2448. a.disposal_remark,
  2449. a.inspector_date,
  2450. a.inspector_no,
  2451. u.user_display as inspectorName,
  2452. a.unqualified_quantity,
  2453. a.submit_flag,
  2454. a.roll_no,
  2455. a.supplier_no,
  2456. s.SupplierName as supplierDesc,
  2457. a.po_orderNo,
  2458. a.po_itemNo,
  2459. a.roll_count,
  2460. dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) as orderType,
  2461. a.action_date,
  2462. a.action_by,
  2463. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2464. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2465. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2466. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2467. a.submission_remark,
  2468. a.submission_type,
  2469. a.batch_no,
  2470. a.production_date,
  2471. a.expiration_warning_date,
  2472. a.expiration_date,
  2473. a.cancel_check_date,
  2474. a.submit_date,
  2475. a.pass_qty,
  2476. a.not_pass_qty,
  2477. a.batch_qualified_qty
  2478. FROM qc_iqc_record as a
  2479. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  2480. left join view_Supplier as s on a.site = s.site and a.supplier_no = s.SupplierID
  2481. left join sys_user as u on a.inspector_no = u.username
  2482. <where>
  2483. a.site in (select site from eam_access_site where username = #{query.userName})
  2484. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2485. <if test="query.buNo != null and query.buNo != ''">
  2486. AND a.bu_no = #{query.buNo}
  2487. </if>
  2488. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2489. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2490. </if>
  2491. <if test = "query.states != null and query.states.size > 0">
  2492. AND a.state in
  2493. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2494. #{item}
  2495. </foreach>
  2496. </if>
  2497. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2498. AND a.inspection_result = #{query.inspectionResult}
  2499. </if>
  2500. <if test = "query.partNo != null and query.partNo != ''">
  2501. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2502. </if>
  2503. <if test = "query.partDesc != null and query.partDesc != ''">
  2504. AND a.part_desc LIKE '%' + #{query.partDesc} + '%'
  2505. </if>
  2506. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2507. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2508. </if>
  2509. <if test = "query.sku != null and query.sku != ''">
  2510. AND d.sku LIKE '%' + #{query.sku} + '%'
  2511. </if>
  2512. <if test = "query.supplierDesc != null and query.supplierDesc != ''">
  2513. AND s.SupplierName LIKE '%' + #{query.supplierDesc} + '%'
  2514. </if>
  2515. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2516. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2517. </if>
  2518. <if test = "query.inspectorName != null and query.inspectorName != ''">
  2519. u.user_display LIKE '%' + #{query.inspectorName} + '%'
  2520. </if>
  2521. <if test="query.startDate != null">
  2522. AND a.inspector_date >= #{query.startDate}
  2523. </if>
  2524. <if test="query.endDate != null">
  2525. AND #{query.endDate} >= a.inspector_date
  2526. </if>
  2527. <if test="query.startDate2 != null">
  2528. AND a.create_date >= #{query.startDate2}
  2529. </if>
  2530. <if test="query.endDate2 != null">
  2531. AND #{query.endDate2} >= a.create_date
  2532. </if>
  2533. <if test = "query.poOrderNo != null and query.poOrderNo != ''">
  2534. AND a.po_orderNo LIKE '%' + #{query.poOrderNo} + '%'
  2535. </if>
  2536. <if test = "query.poItemNo != null and query.poItemNo != ''">
  2537. AND a.po_itemNo LIKE '%' + #{query.poItemNo} + '%'
  2538. </if>
  2539. <if test = "query.orderType != null and query.orderType != ''">
  2540. AND dbo.qc_get_order_type(a.site, a.po_orderNo, a.po_itemNo) = #{query.orderType}
  2541. </if>
  2542. <if test = "query.submissionType != null and query.submissionType != ''">
  2543. AND a.submission_type = #{query.submissionType}
  2544. </if>
  2545. <if test = "query.invdefinetype != null and query.invdefinetype != ''">
  2546. AND d.invdefinetype LIKE '%' + #{query.invdefinetype} + '%'
  2547. </if>
  2548. </where>
  2549. ORDER BY
  2550. CASE WHEN a.state = '待检验' THEN 1
  2551. WHEN a.state = '待审核' THEN 2
  2552. WHEN a.state = '已完成' THEN 3
  2553. END, a.create_date desc
  2554. </select>
  2555. <!-- IQC明细记录查询 -->
  2556. <select id="iqcDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2557. SELECT
  2558. a.site,
  2559. a.bu_no,
  2560. a.inspection_no,
  2561. a.template_id,
  2562. a.sampling_level_no,
  2563. a.sampling_level_desc,
  2564. a.sampling_programme_no,
  2565. a.sampling_programme_desc,
  2566. a.AQL,
  2567. a.AC,
  2568. a.RE,
  2569. a.item_no,
  2570. a.item_desc,
  2571. a.object_id,
  2572. a.object_desc,
  2573. a.default_value,
  2574. a.min_value,
  2575. a.max_value,
  2576. a.text_value,
  2577. a.number_value,
  2578. a.value_type_db,
  2579. a.value_type,
  2580. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2581. a.is_submit,
  2582. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2583. dbo.qc_get_iqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2584. c.method_no,
  2585. c.method_name,
  2586. c.method_remark,
  2587. a.sampling_qty
  2588. FROM qc_iqc_detailed_record as a
  2589. 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
  2590. 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
  2591. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2592. order by a.order_id
  2593. </select>
  2594. <!-- 查询IQC的子明细 -->
  2595. <select id="selectIQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2596. SELECT
  2597. site,
  2598. bu_no,
  2599. sub_detail_value,
  2600. sampling_location,
  2601. is_submit,
  2602. sampling_location_b,
  2603. num,
  2604. sub_detail_value_b,
  2605. sub_detail_value_c,
  2606. sub_detail_value_d,
  2607. sub_detail_value_e
  2608. FROM qc_iqc_sub_detail_record
  2609. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2610. <if test = "collectionDataContent != null and collectionDataContent != ''">
  2611. AND sub_detail_value ${collectionDataContent}
  2612. </if>
  2613. </select>
  2614. <!-- 获取该项目的子明细值 -->
  2615. <select id="selectIQCSubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  2616. SELECT sub_detail_value,
  2617. sampling_location,
  2618. is_submit
  2619. FROM qc_iqc_sub_detail_record
  2620. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  2621. </select>
  2622. <!-- 修改IQC主记录信息 -->
  2623. <update id="updateIQCMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2624. UPDATE qc_iqc_record
  2625. SET disposal_measures = #{disposalMeasures},
  2626. disposal_remark = #{disposalRemark},
  2627. inspection_result = #{inspectionResult},
  2628. inspector_no = #{inspectorNo},
  2629. state = #{state},
  2630. inspection_remark = #{inspectionRemark},
  2631. inspector_date = getDate(),
  2632. roll_count = #{rollCount,jdbcType=DECIMAL},
  2633. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2634. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  2635. pass_qty = #{passQty,jdbcType=DECIMAL},
  2636. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  2637. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  2638. submit_date = getDate()
  2639. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2640. </update>
  2641. <!-- 修改IQC明细记录信息 -->
  2642. <update id="updateIQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2643. UPDATE qc_iqc_detailed_record
  2644. SET item_result = #{itemResult},
  2645. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  2646. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  2647. text_value = #{textValue},
  2648. number_value = #{numberValue,jdbcType=DECIMAL}
  2649. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2650. </update>
  2651. <!-- 查询该记录明细是否已存在 -->
  2652. <select id="checkIQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2653. SELECT inspection_no,
  2654. template_id
  2655. FROM qc_iqc_detailed_record
  2656. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2657. </select>
  2658. <!-- 查询IQC检验记录是否已提交 -->
  2659. <select id="checkIQCIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2660. SELECT submit_flag
  2661. FROM qc_iqc_record
  2662. WHERE inspection_no = #{inspectionNo} and site = #{site}
  2663. </select>
  2664. <!-- 删除IQC子明细的老数据 -->
  2665. <delete id="delIQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  2666. DELETE FROM qc_iqc_sub_detail_record
  2667. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  2668. </delete>
  2669. <!-- 新增IQC子明细信息 -->
  2670. <insert id="saveIQCSubDetailed">
  2671. INSERT INTO qc_iqc_sub_detail_record
  2672. (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)
  2673. VALUES
  2674. <foreach collection="list" item="item" separator=",">
  2675. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  2676. </foreach>
  2677. </insert>
  2678. <!-- 修改IQC主记录标识为已提交 -->
  2679. <update id="updateIQCMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2680. UPDATE qc_iqc_record
  2681. SET submit_flag = 'Y',
  2682. state = '已完成',
  2683. submit_date = getDate()
  2684. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2685. </update>
  2686. <!-- 修改IQC明细记录标识为已提交 -->
  2687. <update id="updateIQCDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2688. UPDATE qc_iqc_detailed_record
  2689. SET is_submit = 'Y'
  2690. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2691. </update>
  2692. <!-- 修改IQC子明细记录标识为已提交 -->
  2693. <update id="updateIQCSubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2694. UPDATE qc_iqc_sub_detail_record
  2695. SET is_submit = 'Y'
  2696. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2697. </update>
  2698. <!-- 删除IQC检验记录 -->
  2699. <delete id="deleteIQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2700. DELETE FROM qc_iqc_record
  2701. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2702. </delete>
  2703. <!-- 删除IQC明细记录信息 -->
  2704. <delete id="deleteIQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2705. DELETE FROM qc_iqc_detailed_record
  2706. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2707. </delete>
  2708. <!-- 删除IQC子明细记录信息 -->
  2709. <delete id="deleteIQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2710. DELETE FROM qc_iqc_sub_detail_record
  2711. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  2712. </delete>
  2713. <!-- 查询文件ID -->
  2714. <select id="queryFileId" parameterType="SysOssEntity" resultType="SysOssEntity">
  2715. SELECT id, file_name
  2716. FROM sys_oss
  2717. WHERE order_ref1 = #{orderRef1} and order_ref2 = #{orderRef2}
  2718. </select>
  2719. <!-- 获取工序列表 -->
  2720. <select id="getOperationDescList" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  2721. SELECT distinct
  2722. operation_desc
  2723. FROM so_routing
  2724. <where>
  2725. <if test = "operationDesc != null and operationDesc != ''">
  2726. AND operation_desc LIKE '%' + #{operationDesc} + '%'
  2727. </if>
  2728. </where>
  2729. </select>
  2730. <!-- 获取供应商列表 -->
  2731. <select id="getManufacturerList" parameterType="com.xujie.sys.modules.pms.data.QcPartAttributeData" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  2732. SELECT
  2733. supplierID as manufacturerID,
  2734. supplierName as manufacturerName
  2735. FROM view_Supplier
  2736. <where>
  2737. site = #{site}
  2738. <if test = "manufacturerID != null and manufacturerID != ''">
  2739. AND supplierID LIKE '%' + #{manufacturerID} + '%'
  2740. </if>
  2741. <if test = "manufacturerName != null and manufacturerName != ''">
  2742. AND supplierName LIKE '%' + #{manufacturerName} + '%'
  2743. </if>
  2744. </where>
  2745. </select>
  2746. <!-- 获取机台列表 -->
  2747. <select id="getAllResourceList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2748. SELECT distinct
  2749. resource_id,
  2750. resource_desc
  2751. FROM resource
  2752. <where>
  2753. site = #{site}
  2754. <if test = "resourceId != null and resourceId != ''">
  2755. AND resource_id LIKE '%' + #{resourceId} + '%'
  2756. </if>
  2757. <if test = "resourceDesc != null and resourceDesc != ''">
  2758. AND resource_desc LIKE '%' + #{resourceDesc} + '%'
  2759. </if>
  2760. </where>
  2761. </select>
  2762. <!-- 获取工单列表 -->
  2763. <select id="getOrderNoList" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2764. SELECT DISTINCT
  2765. a.orderno as orderNo
  2766. FROM soscheduledrouting as a
  2767. LEFT JOIN sfdc as b ON a.site = b.site and a.seqno = b.assjob_seq_no
  2768. LEFT JOIN so_routing as c ON c.site = a.site and c.order_no = a.orderno and a.itemno = c.item_no
  2769. LEFT JOIN part j ON a.site = j.site and a.part_no = j.part_no
  2770. <where>
  2771. a.site = #{site}
  2772. AND b.approve_qty is not null
  2773. <if test = "orderNo != null and orderNo != ''">
  2774. AND a.orderno LIKE '%' + #{orderNo} + '%'
  2775. </if>
  2776. </where>
  2777. order by a.orderno DESC
  2778. </select>
  2779. <!-- 查询FQC主记录信息 -->
  2780. <select id="qcFQCInspectionSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2781. SELECT
  2782. a.inspection_no,
  2783. a.site,
  2784. a.bu_no,
  2785. dbo.get_bu_desc(a.site, a.bu_no) as buDesc,
  2786. a.state,
  2787. a.inspection_result,
  2788. a.task_date,
  2789. a.inspection_type_no,
  2790. dbo.qc_get_inspection_type_name(a.site, a.inspection_type_no) as inspectionTypeName,
  2791. a.inspection_cycle,
  2792. a.order_no,
  2793. a.operation_desc,
  2794. a.resource_id,
  2795. r.resource_desc,
  2796. a.part_no,
  2797. d.part_desc,
  2798. d.cinv_source_code as cinvSourceCode,
  2799. d.sku as sku,
  2800. d.invdefinetype as invdefinetype,
  2801. a.inspection_remark,
  2802. a.roll_qty,
  2803. a.sampling_qty,
  2804. a.disposal_measures,
  2805. a.disposal_remark,
  2806. a.inspector_date,
  2807. a.inspector_no,
  2808. u.user_display as inspectorName,
  2809. a.ssr_id,
  2810. a.unqualified_qty,
  2811. a.submit_flag,
  2812. a.seq_no,
  2813. a.batch_roll_no,
  2814. a.special_requirements,
  2815. a.work_center_no,
  2816. a.roll_no,
  2817. a.um_id,
  2818. um.UMName as umName,
  2819. a.action_date,
  2820. a.action_by,
  2821. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operator,
  2822. isnull(dbo.joint_name(a.site, a.bu_no, a.inspection_no, 'coordination'), '') as operatorName,
  2823. isnull(dbo.joint_id(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePerson,
  2824. isnull(dbo.joint_name2(a.site, a.bu_no, a.inspection_no, 'responsible'), '') as responsiblePersonName,
  2825. a.pass_qty,
  2826. a.not_pass_qty,
  2827. a.batch_qualified_qty,
  2828. isnull(a.work_file_read, 'N') as workFileRead,
  2829. CASE WHEN (
  2830. EXISTS (SELECT 1 FROM sys_oss o WHERE o.order_ref1 = a.site AND o.order_ref2 = a.part_no AND o.order_ref4 = a.bu_no)
  2831. OR EXISTS (
  2832. SELECT 1
  2833. FROM dbo.getSOP_RootPartList(a.site, a.part_no) p
  2834. INNER JOIN part_sop s ON p.partNo = s.part_no AND p.site = a.site
  2835. WHERE ((s.sop_type <![CDATA[<>]]> 'TPI') OR (s.sop_type = 'TPI' AND GETDATE() >= s.phase_in_date AND s.phase_out_date >= DATEADD(DAY, -1, GETDATE()) AND s.part_no = a.part_no))
  2836. AND s.sop_status = N'下达'
  2837. )
  2838. ) THEN 'Y' ELSE 'N' END as hasWorkFile
  2839. FROM qc_fqc_record as a
  2840. left join part as d on a.site = d.site and a.bu_no = d.sourceBu and a.part_no = d.part_no
  2841. left join sys_user as u on a.inspector_no = u.username
  2842. 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
  2843. left join UM as um on a.site = um.site and a.um_id = um.UMID
  2844. <where>
  2845. a.site in (select site from eam_access_site where username = #{query.userName})
  2846. and (a.site + '-' + a.bu_no) in (select * from dbo.query_bu(#{query.userName}))
  2847. <if test="query.buNo != null and query.buNo != ''">
  2848. AND a.bu_no = #{query.buNo}
  2849. </if>
  2850. <if test = "query.inspectionNo != null and query.inspectionNo != ''">
  2851. AND a.inspection_no LIKE '%' + #{query.inspectionNo} + '%'
  2852. </if>
  2853. <if test = "query.partNo != null and query.partNo != ''">
  2854. AND a.part_no LIKE '%' + #{query.partNo} + '%'
  2855. </if>
  2856. <if test = "query.partDesc != null and query.partDesc != ''">
  2857. AND d.part_desc LIKE '%' + #{query.partDesc} + '%'
  2858. </if>
  2859. <if test = "query.cinvSourceCode != null and query.cinvSourceCode != ''">
  2860. AND d.cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  2861. </if>
  2862. <if test = "query.sku != null and query.sku != ''">
  2863. AND d.sku LIKE '%' + #{query.sku} + '%'
  2864. </if>
  2865. <if test = "query.disposalMeasures != null and query.disposalMeasures != ''">
  2866. AND a.disposal_measures LIKE '%' + #{query.disposalMeasures} + '%'
  2867. </if>
  2868. <if test = "query.states != null and query.states.size > 0">
  2869. AND a.state in
  2870. <foreach item="item" collection="query.states" open="(" separator="," close=")">
  2871. #{item}
  2872. </foreach>
  2873. </if>
  2874. <if test = "query.inspectionResult != null and query.inspectionResult != ''">
  2875. AND a.inspection_result = #{query.inspectionResult}
  2876. </if>
  2877. <if test = "query.orderNo != null and query.orderNo != ''">
  2878. AND a.order_no LIKE '%' + #{query.orderNo} + '%'
  2879. </if>
  2880. <if test = "query.seqNo != null and query.seqNo != ''">
  2881. AND a.seq_no LIKE '%' + #{query.seqNo} + '%'
  2882. </if>
  2883. <if test = "query.operationDesc != null and query.operationDesc != ''">
  2884. AND a.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  2885. </if>
  2886. <if test="query.startDate != null">
  2887. AND a.inspector_date >= #{query.startDate}
  2888. </if>
  2889. <if test="query.endDate != null">
  2890. AND #{query.endDate} >= a.inspector_date
  2891. </if>
  2892. <if test="query.startDate2 != null">
  2893. AND a.task_date >= #{query.startDate2}
  2894. </if>
  2895. <if test="query.endDate2 != null">
  2896. AND #{query.endDate2} >= a.task_date
  2897. </if>
  2898. </where>
  2899. ORDER BY
  2900. CASE WHEN a.state = '待检验' THEN 1
  2901. WHEN a.state = '待审核' THEN 2
  2902. WHEN a.state = '已完成' THEN 3
  2903. END, a.task_date desc
  2904. </select>
  2905. <insert id="saveFQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2906. INSERT INTO qc_fqc_detailed_record
  2907. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2908. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2909. max_value, value_type_db, value_type, site, sampling_qty, bu_no,order_id)
  2910. VALUES
  2911. (#{inspectionNo}, #{orderNo}, #{templateId}, #{samplingLevelNo}, #{samplingLevelDesc}, #{samplingProgrammeNo}, #{samplingProgrammeDesc},
  2912. #{aql,jdbcType=DECIMAL}, #{ac,jdbcType=DECIMAL}, #{re,jdbcType=DECIMAL}, #{itemNo}, #{itemDesc}, #{objectId}, #{objectDesc}, #{defaultValue}, #{minValue,jdbcType=DECIMAL},
  2913. #{maxValue,jdbcType=DECIMAL}, #{valueTypeDb}, #{valueType}, #{site}, #{samplingQty,jdbcType=DECIMAL}, #{buNo},#{orderId,jdbcType=INTEGER})
  2914. </insert>
  2915. <!-- 新增FQC明细记录信息 -->
  2916. <insert id="saveFQCDetailedRecords">
  2917. INSERT INTO qc_fqc_detailed_record
  2918. (inspection_no, order_no, template_id, sampling_level_no, sampling_level_desc, sampling_programme_no, sampling_programme_desc,
  2919. AQL, AC, RE, item_no, item_desc, object_id, object_desc, default_value, min_value,
  2920. max_value, value_type_db, value_type, site, sampling_qty, bu_no, order_id)
  2921. VALUES
  2922. <foreach collection="list" item="item" separator=",">
  2923. (#{item.inspectionNo}, #{item.orderNo}, #{item.templateId}, #{item.samplingLevelNo}, #{item.samplingLevelDesc}, #{item.samplingProgrammeNo}, #{item.samplingProgrammeDesc},
  2924. #{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},
  2925. #{item.maxValue,jdbcType=DECIMAL}, #{item.valueTypeDb}, #{item.valueType}, #{item.site}, #{item.samplingQty,jdbcType=DECIMAL}, #{item.buNo}, #{item.orderId})
  2926. </foreach>
  2927. </insert>
  2928. <!-- 新增FQC主记录信息 -->
  2929. <insert id="saveFQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2930. INSERT INTO qc_fqc_record
  2931. (inspection_no, site, bu_no, state, task_date, inspection_type_no, inspection_cycle, order_no, operation_desc, resource_id,
  2932. part_no, roll_qty, sampling_qty, ssr_id, seq_no, batch_roll_no, special_requirements, work_center_no, roll_no, um_id)
  2933. VALUES
  2934. (#{inspectionNo}, #{site}, #{buNo}, #{state}, getDate(), #{inspectionTypeNo}, #{inspectionCycle,jdbcType=DECIMAL}, #{orderNo}, #{operationDesc}, #{resourceId},
  2935. #{partNo}, #{rollQty}, #{samplingQty,jdbcType=DECIMAL}, #{ssrId}, #{seqNo}, #{batchRollNo}, #{specialRequirements}, #{workCenterNo}, #{rollNo}, #{umId})
  2936. </insert>
  2937. <!-- FQC明细记录查询 -->
  2938. <select id="fqcDetailSearch" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2939. SELECT
  2940. a.site,
  2941. a.bu_no,
  2942. a.inspection_no,
  2943. a.order_no,
  2944. a.template_id,
  2945. a.sampling_level_no,
  2946. a.sampling_level_desc,
  2947. a.sampling_programme_no,
  2948. a.sampling_programme_desc,
  2949. a.AQL,
  2950. a.AC,
  2951. a.RE,
  2952. a.item_no,
  2953. a.item_desc,
  2954. a.object_id,
  2955. a.object_desc,
  2956. a.default_value,
  2957. a.min_value,
  2958. a.max_value,
  2959. a.text_value,
  2960. a.number_value,
  2961. a.value_type_db,
  2962. a.value_type,
  2963. case when a.item_result = '' or a.item_result is null then 'Y' else a.item_result end as itemResult,
  2964. a.is_submit,
  2965. isnull(a.unqualified_quantity,0) as unqualifiedQuantity,
  2966. a.sampling_qty,
  2967. dbo.qc_get_fqc_sub_record_num(a.site, a.bu_no, a.inspection_no, a.item_no) as subDetailRecordNum,
  2968. c.method_no,
  2969. c.method_name,
  2970. c.method_remark
  2971. FROM qc_fqc_detailed_record as a
  2972. 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
  2973. 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
  2974. WHERE a.inspection_no = #{inspectionNo} and a.site = #{site} and a.bu_no = #{buNo}
  2975. order by a.order_id
  2976. </select>
  2977. <!-- 删除FQC检验记录 -->
  2978. <delete id="deleteFQCRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2979. DELETE FROM qc_fqc_record
  2980. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2981. </delete>
  2982. <!-- 删除FQC明细记录信息 -->
  2983. <delete id="deleteFQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2984. DELETE FROM qc_fqc_detailed_record
  2985. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2986. </delete>
  2987. <!-- 删除FQC子明细记录信息 -->
  2988. <delete id="deleteFQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2989. DELETE FROM qc_fqc_sub_detail_record
  2990. WHERE site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  2991. </delete>
  2992. <!-- 修改FQC主记录信息 -->
  2993. <update id="updateFQCMasterRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  2994. UPDATE qc_fqc_record
  2995. SET disposal_measures = #{disposalMeasures},
  2996. disposal_remark = #{disposalRemark},
  2997. inspection_result = #{inspectionResult},
  2998. inspector_no = #{inspectorNo},
  2999. state = #{state},
  3000. inspection_remark = #{inspectionRemark},
  3001. inspector_date = getDate(),
  3002. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  3003. roll_qty = #{rollQty,jdbcType=DECIMAL},
  3004. unqualified_qty = #{unqualifiedQty,jdbcType=DECIMAL},
  3005. pass_qty = #{passQty,jdbcType=DECIMAL},
  3006. not_pass_qty = #{notPassQty,jdbcType=DECIMAL},
  3007. batch_qualified_qty = #{batchQualifiedQty,jdbcType=DECIMAL},
  3008. submit_date = getDate()
  3009. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  3010. </update>
  3011. <!-- 修改FQC明细记录信息 -->
  3012. <update id="updateFQCDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3013. UPDATE qc_fqc_detailed_record
  3014. SET item_result = #{itemResult},
  3015. unqualified_quantity = #{unqualifiedQuantity,jdbcType=DECIMAL},
  3016. sampling_qty = #{samplingQty,jdbcType=DECIMAL},
  3017. text_value = #{textValue},
  3018. number_value = #{numberValue,jdbcType=DECIMAL}
  3019. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  3020. </update>
  3021. <!-- 标记FQC工作文件已阅读 -->
  3022. <update id="updateFQCWorkFileRead" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3023. UPDATE qc_fqc_record
  3024. SET work_file_read = 'Y'
  3025. WHERE site = #{site} and inspection_no = #{inspectionNo} and bu_no = #{buNo}
  3026. AND isnull(work_file_read, 'N') <![CDATA[<>]]> 'Y'
  3027. </update>
  3028. <!-- 修改FQC主记录标识为已提交 -->
  3029. <update id="updateFQCMasterSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3030. UPDATE qc_fqc_record
  3031. SET submit_flag = 'Y',
  3032. state = '已完成',
  3033. submit_date = getDate()
  3034. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3035. </update>
  3036. <!-- 修改FAI明细记录标识为已提交 -->
  3037. <update id="updateFQCDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3038. UPDATE qc_fqc_detailed_record
  3039. SET is_submit = 'Y'
  3040. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3041. </update>
  3042. <!-- 修改子明细记录标识为已提交 -->
  3043. <update id="updateFQCSubDetailSubmitFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3044. UPDATE qc_fqc_sub_detail_record
  3045. SET is_submit = 'Y'
  3046. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3047. </update>
  3048. <!-- 删除子明细的老数据 -->
  3049. <delete id="delFQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.QcSubDetailInformationData">
  3050. DELETE FROM qc_fqc_sub_detail_record
  3051. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  3052. </delete>
  3053. <!-- 新增子明细信息 -->
  3054. <insert id="saveFQCSubDetailed">
  3055. INSERT INTO qc_fqc_sub_detail_record
  3056. (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)
  3057. VALUES
  3058. <foreach collection="list" item="item" separator=",">
  3059. (#{item.inspectionNo}, #{item.itemNo}, #{item.subDetailValue}, #{item.samplingLocation}, #{item.site}, #{item.samplingLocationB}, #{item.buNo}, #{item.num}, #{item.subDetailValueB}, #{item.subDetailValueC}, #{item.subDetailValueD}, #{item.subDetailValueE})
  3060. </foreach>
  3061. </insert>
  3062. <!-- 查询FQC的子明细 -->
  3063. <select id="selectFQCSubDetailedRecord" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3064. SELECT
  3065. site,
  3066. bu_no,
  3067. sub_detail_value,
  3068. sampling_location,
  3069. is_submit,
  3070. sampling_location_b,
  3071. num,
  3072. sub_detail_value_b,
  3073. sub_detail_value_c,
  3074. sub_detail_value_d,
  3075. sub_detail_value_e
  3076. FROM qc_fqc_sub_detail_record
  3077. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site} and bu_no = #{buNo}
  3078. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3079. AND sub_detail_value ${collectionDataContent}
  3080. </if>
  3081. </select>
  3082. <!-- 查询FQC检验记录是否已提交 -->
  3083. <select id="checkFQCIsSubmit" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3084. SELECT submit_flag
  3085. FROM qc_fqc_record
  3086. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3087. </select>
  3088. <!-- 获取该项目的子明细值 -->
  3089. <select id="selectFQCSubDetailValue" parameterType="string" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3090. SELECT sub_detail_value,
  3091. sampling_location,
  3092. is_submit
  3093. FROM qc_fqc_sub_detail_record
  3094. WHERE inspection_no = #{inspectionNo} and item_no = #{itemNo} and site = #{site}
  3095. </select>
  3096. <!-- 生成FQC检验单号 -->
  3097. <select id="selectFQCInspectionNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3098. SELECT
  3099. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  3100. FROM qc_fqc_record
  3101. WHERE site = #{site} and bu_no = #{buNo}
  3102. </select>
  3103. <!-- 生成IPQC检验单号 -->
  3104. <select id="selectIPQCInspectionNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3105. SELECT
  3106. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,5,10))),0)+1),8)
  3107. FROM qc_ipqc_record
  3108. WHERE site = #{site} and bu_no = #{buNo}
  3109. </select>
  3110. <!-- 生成FAI检验单号 -->
  3111. <select id="selectFAIInspectionNo" resultType="string" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3112. SELECT
  3113. Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(inspection_no,4,10))),0)+1),8)
  3114. FROM qc_fai_record
  3115. WHERE site = #{site} and bu_no = #{buNo}
  3116. </select>
  3117. <!-- 根据 site、po_orderNo、po_itemNo 从 view_po_order 中查出数据 -->
  3118. <select id="queryDataFromViewPoOrder" resultType="com.xujie.sys.modules.pms.data.PoOrderData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3119. SELECT
  3120. site,
  3121. order_no,
  3122. item_no,
  3123. part_no,
  3124. part_desc,
  3125. spec,
  3126. supplier_id,
  3127. supplier_name,
  3128. order_qty,
  3129. created_date,
  3130. status,
  3131. citem_code,
  3132. citem_class,
  3133. sendto_address,
  3134. order_type
  3135. FROM view_po_order
  3136. WHERE site = #{site} and order_no = #{poOrderNo} and item_no = #{poItemNo}
  3137. </select>
  3138. <!-- 向收货任务表里添加数据 -->
  3139. <insert id="saveReceivingTask" parameterType="com.xujie.sys.modules.pms.data.PoOrderData">
  3140. 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)
  3141. VALUES (#{site}, #{orderNo}, #{itemNo}, #{partNo}, #{partDesc}, #{spec}, #{supplierId}, #{supplierName}, #{orderQty}, getDate(), #{status}, #{citemCode}, #{citemClass}, #{sendtoAddress}, #{orderType}, #{inspectionNo}, #{batchNo}, #{productionDate}, #{expirationWarningDate}, #{expirationDate})
  3142. </insert>
  3143. <!-- 检查动控是否开启 -->
  3144. <select id="queryController" parameterType="com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity" resultType="com.xujie.sys.modules.sys.entity.SysSceneDynamicControlModelEntity">
  3145. SELECT
  3146. type,
  3147. base_data,
  3148. base_desc,
  3149. status,
  3150. remark,
  3151. third_type,
  3152. second_type,
  3153. page_control,
  3154. control_style
  3155. FROM sys_scene_dynamic_control_model
  3156. where site = #{site} and control_no = #{controlNo}
  3157. </select>
  3158. <!-- 查询检验模板列表 -->
  3159. <select id="queryTemplateList" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  3160. SELECT
  3161. site,
  3162. bu_no,
  3163. template_id as templateId,
  3164. template_name as templateName,
  3165. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  3166. FROM qc_template
  3167. <where>
  3168. site = #{site} and bu_no = #{buNo} and dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  3169. <if test = "templateId != null and templateId != ''">
  3170. AND template_id LIKE '%' + #{templateId}+'%'
  3171. </if>
  3172. <if test = "templateName != null and templateName != ''">
  3173. AND template_name LIKE '%' + #{templateName}+'%'
  3174. </if>
  3175. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  3176. AND inspection_type_no = #{inspectionTypeNo}
  3177. </if>
  3178. </where>
  3179. </select>
  3180. <!-- 查询检验模板列表 -->
  3181. <select id="getPartInformation" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3182. select
  3183. part_no,
  3184. part_desc,
  3185. spec,
  3186. sku,
  3187. control_mes,
  3188. DefaultWarehouseID as defaultWarehouseId
  3189. from part
  3190. where site = #{site} and part_no = #{partNo}
  3191. </select>
  3192. <!-- 获取特殊工序列表 -->
  3193. <select id="getSpecialOperationList" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3194. select
  3195. site,
  3196. operation_no,
  3197. operation_desc
  3198. from qc_special_task_operation
  3199. where site = #{site}
  3200. </select>
  3201. <select id="getSpecialOperationList2" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3202. select distinct site , routing_item_no as operation_no,item_desc as operation_desc from routing_detail
  3203. <where>
  3204. <if test = "site != null and site != ''">
  3205. site = #{site}
  3206. </if>
  3207. </where>
  3208. </select>
  3209. <!-- 获取处置措施列表 -->
  3210. <select id="disposalMeasuresSearch" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3211. SELECT
  3212. id,
  3213. disposal_measures
  3214. FROM qc_disposal_measures
  3215. <where>
  3216. <if test = "inspectionTypeNo != '101'">
  3217. inspection_type != 'IPQC'
  3218. </if>
  3219. </where>
  3220. </select>
  3221. <!-- 查询文件路径 -->
  3222. <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3223. SELECT
  3224. id,
  3225. url,
  3226. file_name
  3227. FROM sys_oss
  3228. WHERE order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref3 = #{itemNo} and order_ref4 = #{buNo}
  3229. </select>
  3230. <!-- 删除图片-->
  3231. <delete id="imageDelete" parameterType="SysOssEntity">
  3232. DELETE FROM sys_oss
  3233. WHERE id = #{id}
  3234. </delete>
  3235. <!-- 模糊查询标签号 -->
  3236. <select id="getRollNo" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3237. SELECT DISTINCT top 3
  3238. a.seqno,
  3239. a.orderno,
  3240. b.roll_no
  3241. FROM soscheduledrouting AS a
  3242. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  3243. WHERE a.site = #{site} and b.roll_no like '%' + #{rollNo} + '%'
  3244. </select>
  3245. <!-- 标签号回车事件 -->
  3246. <select id="rollNoEnter" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3247. SELECT
  3248. a.site,
  3249. a.seqno as seqNo,
  3250. a.orderno as orderNo,
  3251. b.roll_no,
  3252. #{inspectionTypeNo} as inspectionTypeNo
  3253. FROM soscheduledrouting AS a
  3254. LEFT JOIN sfdc_rolls AS b ON a.site = b.site AND a.seqno = b.createdops_seqno
  3255. WHERE a.site = #{site} and b.roll_no = #{rollNo}
  3256. </select>
  3257. <!-- 查询物料列表 -->
  3258. <select id="queryPartList" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3259. SELECT
  3260. site,
  3261. part_no,
  3262. part_desc,
  3263. sku,
  3264. spec
  3265. FROM part
  3266. <where>
  3267. site = #{site}
  3268. <if test = "partNo != null and partNo != ''">
  3269. AND part_no LIKE '%' + #{partNo} + '%'
  3270. </if>
  3271. <if test = "partDesc != null and partDesc != ''">
  3272. AND part_desc LIKE '%' + #{partDesc} + '%'
  3273. </if>
  3274. <if test = "sku != null and sku != ''">
  3275. AND sku LIKE '%' + #{sku} + '%'
  3276. </if>
  3277. </where>
  3278. </select>
  3279. <!-- 查询单位列表 -->
  3280. <select id="umSearch" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3281. SELECT
  3282. site,
  3283. UMID as umId,
  3284. UMName as umName
  3285. FROM UM
  3286. WHERE site = #{site} and active = #{active}
  3287. </select>
  3288. <!-- 查询单位列表 -->
  3289. <select id="checkItem" resultType="com.xujie.sys.modules.pms.data.SubDetailValues" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3290. SELECT
  3291. site,
  3292. bu_no,
  3293. inspection_no,
  3294. item_no,
  3295. value_type_db,
  3296. min_value,
  3297. max_value
  3298. <if test = "flag == 'IPQC'">
  3299. FROM qc_ipqc_detailed_record
  3300. </if>
  3301. <if test = "flag == 'IQC'">
  3302. FROM qc_iqc_detailed_record
  3303. </if>
  3304. <if test = "flag == 'FQC'">
  3305. FROM qc_fqc_detailed_record
  3306. </if>
  3307. <if test = "flag == 'FAI'">
  3308. FROM qc_fai_detailed_record
  3309. </if>
  3310. WHERE site = #{site} and inspection_no = #{inspectionNo} and item_no = #{itemNo} and bu_no = #{buNo}
  3311. order by order_id
  3312. </select>
  3313. <!-- 查询检验方法列表 -->
  3314. <select id="queryMethodList" resultType="com.xujie.sys.modules.pms.data.QcMethodData" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  3315. SELECT
  3316. site,
  3317. bu_no,
  3318. method_no,
  3319. method_name,
  3320. inspection_type_no,
  3321. dbo.qc_get_inspection_type_name(site, inspection_type_no) as inspectionTypeName
  3322. FROM qc_method
  3323. <where>
  3324. site = #{site} and bu_no = #{buNo}
  3325. <if test = "methodNo != null and methodNo != ''">
  3326. AND method_no LIKE '%' + #{methodNo} + '%'
  3327. </if>
  3328. <if test = "methodName != null and methodName != ''">
  3329. AND method_name LIKE '%' + #{methodName} + '%'
  3330. </if>
  3331. <if test = "inspectionTypeNo != null and inspectionTypeNo != ''">
  3332. AND inspection_type_no = #{inspectionTypeNo}
  3333. </if>
  3334. <if test="inspectionTypeName != null and inspectionTypeName != ''">
  3335. AND dbo.qc_get_inspection_type_name(site, inspection_type_no) = #{inspectionTypeName}
  3336. </if>
  3337. </where>
  3338. </select>
  3339. <!-- 修改detailFlag字段为N -->
  3340. <update id="updateIQCDetailFlag" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3341. UPDATE qc_iqc_record
  3342. SET detail_flag = 'N'
  3343. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  3344. </update>
  3345. <!-- 查询检验方法唯一 -->
  3346. <select id="checkMethodOnlyOne" resultType="com.xujie.sys.modules.pms.data.QcMethodData" parameterType="com.xujie.sys.modules.pms.data.QcMethodData">
  3347. SELECT
  3348. site,
  3349. bu_no,
  3350. method_no
  3351. FROM qc_method
  3352. <where>
  3353. site = #{site} and bu_no = #{buNo} and method_no = #{methodNo}
  3354. </where>
  3355. </select>
  3356. <!-- 查询检验项目唯一 -->
  3357. <select id="checkItemOnlyOne" resultType="com.xujie.sys.modules.pms.data.QcItemData" parameterType="com.xujie.sys.modules.pms.data.QcItemData">
  3358. SELECT
  3359. site,
  3360. bu_no,
  3361. ItemNo,
  3362. ItemDesc
  3363. FROM eam_properties_item
  3364. <where>
  3365. site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ItemType = #{itemType} and inspection_type_no = #{inspectionTypeNo}
  3366. </where>
  3367. </select>
  3368. <!-- 查询检验项目唯一 -->
  3369. <select id="checkTemplateOnlyOne" resultType="com.xujie.sys.modules.pms.data.QcTemplateData" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  3370. SELECT
  3371. site,
  3372. bu_no,
  3373. template_id,
  3374. template_name
  3375. FROM qc_template
  3376. <where>
  3377. site = #{site} and bu_no = #{buNo} and template_id = #{templateId}
  3378. </where>
  3379. </select>
  3380. <select id="searchSeqInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3381. SELECT DISTINCT
  3382. a.seqno,
  3383. a.orderno,
  3384. J.part_no,
  3385. J.part_desc,
  3386. t.lotsize,
  3387. a.qtyrequired,
  3388. c.operation_desc,
  3389. J.sku,
  3390. sum(roll_qty) as sjzs
  3391. FROM soscheduledrouting AS a
  3392. inner JOIN so_routing AS c ON c.site = a.site AND c.order_no = a.orderno AND a.itemno = c.item_no
  3393. inner JOIN part AS J ON a.site = J.site AND a.part_no = J.part_no
  3394. inner JOIN shoporder AS t ON a.site = t.site AND t.orderno = a.orderno
  3395. left join qc_ipqc_record as r on a.site = r.site and a.seqno = r.seq_no
  3396. WHERE
  3397. a.site = #{query.site} and J.sourceBu = #{query.buNo}
  3398. <if test="query.status != null and query.status != ''">
  3399. AND t.status = #{query.status}
  3400. </if>
  3401. <if test="query.orderNo != null and query.orderNo != ''">
  3402. AND a.orderno LIKE '%' + #{query.orderNo} + '%'
  3403. </if>
  3404. <if test="query.seqNo != null and query.seqNo != ''">
  3405. AND a.seqno LIKE '%' + #{query.seqNo} + '%'
  3406. </if>
  3407. <if test="query.sku != null and query.sku != ''">
  3408. AND j.sku LIKE '%' + #{query.sku} + '%'
  3409. </if>
  3410. <if test="query.partNo != null and query.partNo != ''">
  3411. AND J.part_no LIKE '%' + #{query.partNo} + '%'
  3412. </if>
  3413. <if test="query.partDesc != null and query.partDesc != ''">
  3414. AND J.part_desc LIKE '%' + #{query.partDesc} + '%'
  3415. </if>
  3416. <if test="query.operationDesc != null and query.operationDesc != ''">
  3417. AND c.operation_desc LIKE '%' + #{query.operationDesc} + '%'
  3418. </if>
  3419. group by a.seqno, a.orderno, J.part_no, J.part_desc, t.lotsize, a.qtyrequired, c.operation_desc, J.sku
  3420. </select>
  3421. <select id="searchPartInfo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3422. select
  3423. part_no,
  3424. part_desc,
  3425. sku,
  3426. cinv_source_code,
  3427. sourceBu
  3428. from
  3429. part
  3430. where
  3431. sourceBu = #{query.buNo}
  3432. <if test="query.partNo != null and query.partNo != ''">
  3433. AND part_no LIKE '%' + #{query.partNo} + '%'
  3434. </if>
  3435. <if test="query.partDesc != null and query.partDesc != ''">
  3436. AND part_desc LIKE '%' + #{query.partDesc} + '%'
  3437. </if>
  3438. <if test="query.sku != null and query.sku != ''">
  3439. AND sku LIKE '%' + #{query.sku} + '%'
  3440. </if>
  3441. <if test="query.cinvSourceCode != null and query.cinvSourceCode != ''">
  3442. AND cinv_source_code LIKE '%' + #{query.cinvSourceCode} + '%'
  3443. </if>
  3444. </select>
  3445. <select id="getInterfaceTimeData" parameterType="String" resultType="com.xujie.sys.modules.pms.data.InterfaceTimeData">
  3446. SELECT
  3447. id,
  3448. start_time,
  3449. end_time,
  3450. del_flag
  3451. FROM interface_time
  3452. WHERE del_flag = 'N' and site = #{site}
  3453. </select>
  3454. <update id="updateInterfaceTimeData" parameterType="com.xujie.sys.modules.pms.data.InterfaceTimeData">
  3455. UPDATE interface_time
  3456. set
  3457. updated_by = #{updatedBy},
  3458. updated_date = #{updatedDate},
  3459. del_flag = #{delFlag}
  3460. </update>
  3461. <select id="getInterfaceRdStyleData" parameterType="String" resultType="com.xujie.sys.modules.pms.data.RdStyleData">
  3462. SELECT
  3463. crdcode,
  3464. crdname,
  3465. iRdGrade,
  3466. rdtype,
  3467. brdend
  3468. FROM view_custdev_mes_rdstyle
  3469. WHERE crdname = #{crdName}
  3470. </select>
  3471. <insert id="insertHardtagPurchaseInStorageData" parameterType="com.xujie.sys.modules.pms.data.HardtagPurchaseInStorageCountData" useGeneratedKeys="true" keyProperty="id">
  3472. INSERT INTO purchase_in_storage_count
  3473. (site, trans_no, created_date, created_by, erp_flag, toacc, logindate, cordercode, cdepcode, cwhcode, crdcode, coutcode, ddate, bredvouch,
  3474. cmemo, verify, irowno, cinvcode, iquantity, citemcode, erp_remark, trans_date, csource, trans_type)
  3475. values (#{site}, #{transNo}, #{createdDate}, #{createdBy}, #{erpFlag}, #{toacc}, #{logindate}, #{cordercode}, #{cdepcode}, #{cwhcode}, #{crdcode}, #{coutcode}, #{ddate}, #{bredvouch},
  3476. #{cmemo}, #{verify}, #{irowno}, #{cinvcode}, #{iquantity}, #{citemcode}, #{erpRemark}, #{transDate}, #{csource}, #{transType})
  3477. </insert>
  3478. <insert id="batchSaveHrdtagTransHeader" parameterType="com.xujie.sys.modules.pms.data.HardtagTransHeaderData">
  3479. insert into TransHeader
  3480. (TransNo, Site, WarehouseID, TransDate, TransType_DB, TransType, UserName, Receiver, TransYear, TransMonth, PartnerID, PartnerType, AuthorizeFlag, AuthorizeDate, Authorizor, TransferFlag, TransferDate,
  3481. TransferGuys, VoucherDate, ProjectID, EnterDate, Remark, UseLocation, OrderRef1, LinkOrderFlag, DelAddID, Status, ProjectName, PartnerName, erp_warehouse_id, ERP,
  3482. department_no, picking_status, scan_type, inCategory, pmProject, remarks, item_no_mat, remark3, location_id, count_id)
  3483. values (#{TransNo}, #{Site}, #{WarehouseID}, #{TransDate}, #{TransTypeDB}, #{TransType}, #{UserName}, #{Receiver}, #{TransYear}, #{TransMonth}, #{PartnerID}, #{PartnerType}, #{AuthorizeFlag}, #{AuthorizeDate}, #{Authorizor}, #{TransferFlag}, #{TransferDate},
  3484. #{TransferGuys}, #{VoucherDate}, #{ProjectID}, #{EnterDate}, #{Remark}, #{UseLocation}, #{OrderRef1}, #{LinkOrderFlag}, #{DelAddID}, #{Status}, #{ProjectName}, #{PartnerName}, #{erpWarehouseId}, #{ERP},
  3485. #{departmentNo}, #{pickingStatus}, #{scanType}, #{inCategory}, #{pmProject}, #{remarks}, #{itemNoMat}, #{remark3}, #{locationId}, #{countId})
  3486. </insert>
  3487. <insert id="batchSaveHardtagTransDetail" parameterType="com.xujie.sys.modules.pms.data.HardtagTransDetailData">
  3488. INSERT INTO TransDetail
  3489. (TransNo, Site, PartNo, LocationID, TransQty, Direction, OrderRef1, ItemNo, OrderRef2, OrderRef3, OrderRef5, Remark, citem_code)
  3490. values
  3491. (#{TransNo}, #{Site}, #{PartNo}, #{LocationID}, #{TransQty}, #{Direction}, #{OrderRef1}, #{ItemNo}, #{OrderRef2}, #{OrderRef3}, #{OrderRef5}, #{Remark}, #{citemCode})
  3492. </insert>
  3493. <select id="getSendMailAddress" parameterType="String" resultType="com.xujie.sys.modules.pms.data.MailAddressData">
  3494. SELECT
  3495. id,
  3496. site,
  3497. bu_no,
  3498. mail_address,
  3499. send_type,
  3500. del_flag,
  3501. created_by,
  3502. created_date,
  3503. orderref1
  3504. FROM mailAddress
  3505. WHERE site = #{site} and send_type = #{type} and del_flag = 'N'
  3506. <if test="buNo != null and buNo != ''">
  3507. AND bu_no = #{buNo}
  3508. </if>
  3509. </select>
  3510. <select id="getSendMailFromAddress" resultType="com.xujie.sys.modules.pms.data.MailSendAddressData">
  3511. SELECT
  3512. port,
  3513. host,
  3514. username,
  3515. password,
  3516. emailForm,
  3517. timeout,
  3518. personal,
  3519. id
  3520. FROM mailSendAddress
  3521. where delFlag = 'N'
  3522. </select>
  3523. <!-- 新增发送邮件记录 -->
  3524. <insert id="saveSendMailRecord" parameterType="com.xujie.sys.modules.pms.data.SendMailRecord">
  3525. insert into send_mail_record
  3526. (site, bu_no, document_no, sender, recipient, send_date, type)
  3527. values
  3528. (#{site}, #{buNo}, #{documentNo}, #{sender}, #{recipient}, getDate(), #{type})
  3529. </insert>
  3530. <select id="orderTypeSearch" resultType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3531. SELECT distinct
  3532. order_type
  3533. FROM view_po_order
  3534. </select>
  3535. <update id="actionIQCInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3536. update qc_iqc_record
  3537. set action_date = getDate(),
  3538. action_by = #{actionBy},
  3539. state = #{state}
  3540. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3541. </update>
  3542. <update id="actionFAIInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3543. update qc_fai_record
  3544. set action_date = getDate(),
  3545. action_by = #{actionBy},
  3546. state = #{state}
  3547. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3548. </update>
  3549. <update id="actionIPQCInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3550. update qc_ipqc_record
  3551. set action_date = getDate(),
  3552. action_by = #{actionBy},
  3553. state = #{state}
  3554. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3555. </update>
  3556. <update id="actionFQCInspection" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3557. update qc_fqc_record
  3558. set action_date = getDate(),
  3559. action_by = #{actionBy},
  3560. state = #{state}
  3561. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3562. </update>
  3563. <insert id="addEquipmentDataAcquisition">
  3564. insert into Equipment_data_acquisition
  3565. (site, bu_no, equipment_no, inspection_no, create_date, create_by, item_no, collection_source, collection_method)
  3566. values
  3567. <foreach collection="list" item="item" separator=",">
  3568. (#{item.site}, #{item.buNo}, #{item.equipmentNo}, #{item.inspectionNo}, getDate(), #{item.actionBy}, #{item.itemNo}, #{item.collectionSource}, #{item.collectionMethod})
  3569. </foreach>
  3570. </insert>
  3571. <!-- 新增人员信息 -->
  3572. <insert id="saveOperator" >
  3573. INSERT INTO eam_actual_operator
  3574. (site, order_no, function_type, operator, bu_no)
  3575. VALUES
  3576. <foreach collection="list" item="item" separator=",">
  3577. (#{item.site}, #{item.orderNo}, #{item.functionType}, #{item.operator}, #{item.buNo})
  3578. </foreach>
  3579. </insert>
  3580. <!-- 删除之前的人员-->
  3581. <delete id="delOperator" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  3582. DELETE FROM eam_actual_operator
  3583. WHERE site = #{site} and order_no = #{inspectionNo} and bu_no = #{buNo}
  3584. </delete>
  3585. <select id="getInspectionNo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3586. select distinct
  3587. site,
  3588. bu_no,
  3589. equipment_no,
  3590. inspection_no,
  3591. item_no,
  3592. collection_source,
  3593. collection_method
  3594. from Equipment_data_acquisition
  3595. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  3596. </select>
  3597. <select id="getInspectionNoByItem" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3598. select distinct
  3599. site,
  3600. bu_no,
  3601. equipment_no,
  3602. inspection_no,
  3603. item_no,
  3604. collection_source,
  3605. collection_method
  3606. from Equipment_data_acquisition
  3607. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  3608. </select>
  3609. <select id="dataAcquisition" parameterType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3610. select
  3611. id,
  3612. site,
  3613. bu_no,
  3614. #{inspectionNo} as inspectionNo,
  3615. #{itemNo} as itemNo,
  3616. <if test='subDetailValueType == 0'>
  3617. ${collectionSource} as subDetailValue,
  3618. </if>
  3619. <if test='subDetailValueType == 1'>
  3620. ${collectionSource} as subDetailValueB,
  3621. </if>
  3622. <if test='subDetailValueType == 2'>
  3623. ${collectionSource} as subDetailValueC,
  3624. </if>
  3625. <if test='subDetailValueType == 3'>
  3626. ${collectionSource} as subDetailValueD,
  3627. </if>
  3628. <if test='subDetailValueType == 4'>
  3629. ${collectionSource} as subDetailValueE,
  3630. </if>
  3631. num,
  3632. #{collectionSource} as collectionSource,
  3633. #{collectionMethod} as collectionMethod
  3634. from Equipment_data_detail
  3635. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3636. <if test='collectionMethod == "plc"'>
  3637. AND inspection_no = #{inspectionNo}
  3638. </if>
  3639. <if test='collectionMethod == "RS232"'>
  3640. AND (inspection_no is null or inspection_no = '')
  3641. </if>
  3642. <if test = "collectionDataContent != null and collectionDataContent != ''">
  3643. AND ${collectionSource} ${collectionDataContent}
  3644. </if>
  3645. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3646. </select>
  3647. <select id="dataAcquisitionB" parameterType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3648. select
  3649. id,
  3650. site,
  3651. bu_no,
  3652. #{inspectionNo} as inspectionNo,
  3653. #{itemNo} as itemNo,
  3654. ${collectionSource} as subDetailValueB,
  3655. num,
  3656. #{collectionSource} as collectionSource
  3657. from Equipment_data_detail
  3658. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3659. <if test='collectionMethod == "plc"'>
  3660. AND inspection_no = #{inspectionNo}
  3661. </if>
  3662. <if test='collectionMethod == "RS232"'>
  3663. AND (inspection_no is null or inspection_no = '')
  3664. </if>
  3665. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3666. </select>
  3667. <select id="dataAcquisition2" parameterType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData" resultType="SysOssEntity">
  3668. select
  3669. site as orderRef1,
  3670. bu_no as orderRef4,
  3671. #{inspectionNo} as orderRef2,
  3672. #{itemNo} as orderRef3,
  3673. ${collectionSource} as url
  3674. from Equipment_data_detail
  3675. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo} and ${collectionSource} is not null and ${collectionSource} <![CDATA[<>]]> ''
  3676. and batch_no = (select MAX(batch_no) from Equipment_data_detail where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo})
  3677. </select>
  3678. <select id="getIQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3679. select
  3680. a.site,
  3681. a.bu_no,
  3682. b.collection_condition as equipmentNo,
  3683. #{inspectionNo} as inspectionNo,
  3684. a.item_no,
  3685. b.collection_source,
  3686. #{actionBy} as actionBy,
  3687. b.collection_method
  3688. from qc_iqc_detailed_record as a
  3689. 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
  3690. 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'
  3691. order by a.order_id
  3692. </select>
  3693. <select id="getFAIDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3694. select
  3695. a.site,
  3696. a.bu_no,
  3697. b.collection_condition as equipmentNo,
  3698. #{inspectionNo} as inspectionNo,
  3699. a.item_no,
  3700. b.collection_source,
  3701. #{actionBy} as actionBy,
  3702. b.collection_method
  3703. from qc_fai_detailed_record as a
  3704. 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
  3705. 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'
  3706. order by order_id
  3707. </select>
  3708. <select id="getIPQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3709. select
  3710. a.site,
  3711. a.bu_no,
  3712. b.collection_condition as equipmentNo,
  3713. #{inspectionNo} as inspectionNo,
  3714. a.item_no,
  3715. b.collection_source,
  3716. #{actionBy} as actionBy,
  3717. b.collection_method
  3718. from qc_ipqc_detailed_record as a
  3719. 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
  3720. 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'
  3721. order by a.order_id
  3722. </select>
  3723. <select id="getFQCDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.EquipmentDataAcquisitionData">
  3724. select
  3725. a.site,
  3726. a.bu_no,
  3727. b.collection_condition as equipmentNo,
  3728. #{inspectionNo} as inspectionNo,
  3729. a.item_no,
  3730. b.collection_source,
  3731. #{actionBy} as actionBy,
  3732. b.collection_method
  3733. from qc_fqc_detailed_record as a
  3734. 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
  3735. 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'
  3736. order by a.order_id
  3737. </select>
  3738. <select id="querySubDetails" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.SubDetailValues">
  3739. select
  3740. b.site,
  3741. b.bu_no,
  3742. b.inspection_no,
  3743. b.item_no,
  3744. b.default_value,
  3745. b.min_value,
  3746. b.max_value,
  3747. b.value_type_db,
  3748. a.sub_detail_value
  3749. <if test="flag == 'iqc'">
  3750. from qc_iqc_sub_detail_record as a
  3751. 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
  3752. </if>
  3753. <if test="flag == 'ipqc'">
  3754. from qc_ipqc_sub_detail_record as a
  3755. 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
  3756. </if>
  3757. <if test="flag == 'fqc'">
  3758. from qc_fqc_sub_detail_record as a
  3759. 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
  3760. </if>
  3761. <if test="flag == 'fai'">
  3762. from qc_fai_sub_detail_record as a
  3763. 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
  3764. </if>
  3765. where a.site = #{site} and a.bu_no = #{buNo} and a.inspection_no = #{inspectionNo} and a.item_no = #{itemNo}
  3766. order by b.order_id
  3767. </select>
  3768. <insert id="saveFileList">
  3769. INSERT INTO sys_oss
  3770. (url, create_date, file_name, new_file_name, order_ref1, order_ref2, order_ref3, order_ref4)
  3771. VALUES
  3772. <foreach collection="list" item="item" separator=",">
  3773. (#{item.url}, getDate(), #{item.fileName}, #{item.newFileName}, #{item.orderRef1}, #{item.orderRef2}, #{item.orderRef3}, #{item.orderRef4})
  3774. </foreach>
  3775. </insert>
  3776. <select id="getEquipmentNoList" parameterType="com.xujie.sys.modules.pms.data.EquipmentFolderLocationData" resultType="com.xujie.sys.modules.pms.data.EquipmentFolderLocationData">
  3777. select
  3778. equipment_no
  3779. from Equipment_folder_location
  3780. where site = #{site} and bu_no = #{buNo}
  3781. </select>
  3782. <!-- 获取责任人员列表 -->
  3783. <select id="getResponsibleOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3784. SELECT DISTINCT
  3785. a.user_id,
  3786. a.username as adminID,
  3787. a.email,
  3788. a.mobile as phone,
  3789. a.user_display as adminName,
  3790. dbo.get_bu_desc(c.site,c.bu_no) as buDesc,
  3791. d.role_id,
  3792. e.role_name
  3793. FROM sys_user as a
  3794. LEFT JOIN eam_access_site as b on a.username = b.username
  3795. LEFT JOIN AccessBu as c on b.username = c.username and b.site = c.site
  3796. LEFT JOIN sys_user_role as d on a.user_id = d.user_id
  3797. LEFT JOIN sys_role as e on d.role_id = e.role_id
  3798. <where>
  3799. b.site = #{site} and c.bu_no = #{buNo}
  3800. <if test = "adminID != null and adminID != ''">
  3801. AND a.username LIKE '%' + #{adminID} + '%'
  3802. </if>
  3803. <if test = "adminName != null and adminName != ''">
  3804. AND a.user_display LIKE '%' + #{adminName} + '%'
  3805. </if>
  3806. <if test = "roleId != null and roleId != ''">
  3807. AND d.role_id = #{roleId}
  3808. </if>
  3809. </where>
  3810. </select>
  3811. <!-- 04-MHM 责任人:operator 表 + users(排除 admin、仓管角色43) -->
  3812. <select id="getMhmResponsibleOperatorList" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3813. SELECT DISTINCT userId, adminID, adminName, departmentName, roleId, roleName FROM (
  3814. SELECT
  3815. NULL as userId,
  3816. o.operator_id as adminID,
  3817. o.operator_name as adminName,
  3818. NULL as departmentName,
  3819. NULL as roleId,
  3820. N'操作员' as roleName
  3821. FROM operator o
  3822. <where>
  3823. (o.active = 'Y' OR o.active IS NULL)
  3824. AND LOWER(o.operator_id) &lt;&gt; 'admin'
  3825. <if test="site != null and site != ''">
  3826. AND o.site = #{site}
  3827. </if>
  3828. <if test="adminID != null and adminID != ''">
  3829. AND o.operator_id LIKE '%' + #{adminID} + '%'
  3830. </if>
  3831. <if test="adminName != null and adminName != ''">
  3832. AND o.operator_name LIKE '%' + #{adminName} + '%'
  3833. </if>
  3834. </where>
  3835. UNION ALL
  3836. SELECT
  3837. u.id as userId,
  3838. u.username as adminID,
  3839. u.display as adminName,
  3840. u.department as departmentName,
  3841. NULL as roleId,
  3842. NULL as roleName
  3843. FROM users u
  3844. <where>
  3845. (u.active = 'Y' OR u.active IS NULL)
  3846. AND LOWER(u.username) &lt;&gt; 'admin'
  3847. AND NOT EXISTS (SELECT 1 FROM user_role ur2 WHERE ur2.user_id = u.id AND ur2.role_id = 43)
  3848. <if test="site != null and site != ''">
  3849. AND u.site = #{site}
  3850. </if>
  3851. <if test="adminID != null and adminID != ''">
  3852. AND u.username LIKE '%' + #{adminID} + '%'
  3853. </if>
  3854. <if test="adminName != null and adminName != ''">
  3855. AND u.display LIKE '%' + #{adminName} + '%'
  3856. </if>
  3857. </where>
  3858. ) t
  3859. ORDER BY adminID
  3860. </select>
  3861. <select id="getMhmResponsibleRoleList" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  3862. SELECT id as roleId, name as roleName
  3863. FROM role
  3864. WHERE id IN (7, 8)
  3865. ORDER BY id
  3866. </select>
  3867. <!-- 04-MHM 协同人员:按职位名称 -->
  3868. <select id="getMhmOperatorListByRoleName" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3869. SELECT DISTINCT
  3870. u.id as userId,
  3871. u.username as adminID,
  3872. u.display as adminName,
  3873. u.department as departmentName,
  3874. ur.role_id as roleId,
  3875. r.name as roleName
  3876. FROM users u
  3877. INNER JOIN user_role ur ON u.id = ur.user_id
  3878. INNER JOIN role r ON ur.role_id = r.id
  3879. <where>
  3880. r.name = #{roleName}
  3881. AND (u.active = 'Y' OR u.active IS NULL)
  3882. <if test="site != null and site != ''">
  3883. AND u.site = #{site}
  3884. </if>
  3885. <if test="adminID != null and adminID != ''">
  3886. AND u.username LIKE '%' + #{adminID} + '%'
  3887. </if>
  3888. <if test="adminName != null and adminName != ''">
  3889. AND u.display LIKE '%' + #{adminName} + '%'
  3890. </if>
  3891. <if test="roleId != null and roleId != ''">
  3892. AND ur.role_id = #{roleId}
  3893. </if>
  3894. </where>
  3895. ORDER BY u.username
  3896. </select>
  3897. <select id="getMhmRoleByName" resultType="com.xujie.sys.modules.pms.data.EamAdminData" parameterType="com.xujie.sys.modules.pms.data.EamAdminData">
  3898. SELECT id as roleId, name as roleName
  3899. FROM role
  3900. WHERE name = #{roleName}
  3901. </select>
  3902. <select id="getDataContentList" parameterType="com.xujie.sys.modules.pms.data.QcCollectionDataContentData" resultType="com.xujie.sys.modules.pms.data.QcCollectionDataContentData">
  3903. select
  3904. content_desc
  3905. from qc_collection_data_content
  3906. where site = #{site} and bu_no = #{buNo} and active = 'Y'
  3907. </select>
  3908. <select id="getItemCollectionDataContent" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues" resultType="string">
  3909. select
  3910. collection_data_content
  3911. from eam_properties_item
  3912. where site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo}
  3913. </select>
  3914. <!-- 获取当前项目不包含的设备 -->
  3915. <select id="getObjectList1" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3916. SELECT
  3917. a.site,
  3918. a.bu_no,
  3919. a.ObjectID,
  3920. a.ObjectDesc
  3921. FROM eam_object as a
  3922. 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}
  3923. where a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  3924. </select>
  3925. <!-- 获取当前项目所包含的设备 -->
  3926. <select id="getObjectList2" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3927. SELECT
  3928. a.site,
  3929. a.bu_no,
  3930. a.ObjectID,
  3931. b.ObjectDesc,
  3932. a.default_flag
  3933. FROM qc_item_object a
  3934. LEFT JOIN eam_object b ON a.site = b.site and a.bu_no = b.bu_no and a.ObjectID = b.ObjectID
  3935. WHERE a.site = #{site} and a.bu_no = #{buNo} and a.ItemNo = #{itemNo}
  3936. </select>
  3937. <!-- 获取当前项目不包含的设备 -->
  3938. <select id="getObjectListBy" resultType="com.xujie.sys.modules.pms.data.EamObjectInData" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3939. SELECT
  3940. a.site,
  3941. a.bu_no,
  3942. a.ObjectID,
  3943. a.ObjectDesc
  3944. FROM eam_object as a
  3945. 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}
  3946. <where>
  3947. a.site = #{site} and a.bu_no = #{buNo} and b.ItemNo is null and a.active = 'Y'
  3948. <if test = "objectID != null and objectID != ''">
  3949. AND a.ObjectID LIKE '%' + #{objectID} + '%'
  3950. </if>
  3951. <if test = "objectDesc != null and objectDesc != ''">
  3952. AND a.ObjectDesc LIKE '%' + #{objectDesc} + '%'
  3953. </if>
  3954. </where>
  3955. </select>
  3956. <!-- 新增项目设备 -->
  3957. <insert id="addItemObject">
  3958. INSERT INTO qc_item_object
  3959. (site, bu_no, ItemNo, ObjectID, default_flag)
  3960. VALUES
  3961. <foreach collection="list" item="item" separator=",">
  3962. (#{item.site}, #{item.buNo}, #{item.itemNo}, #{item.objectID}, #{item.defaultFlag})
  3963. </foreach>
  3964. </insert>
  3965. <delete id="deleteItemObject">
  3966. DELETE FROM qc_item_object
  3967. WHERE
  3968. <foreach collection="list" item="item" separator=" or " index="index">
  3969. (site = #{item.site} and bu_no = #{item.buNo} and ItemNo = #{item.itemNo} and ObjectID = #{item.objectID})
  3970. </foreach>
  3971. </delete>
  3972. <update id="updateItemObject">
  3973. UPDATE qc_item_object
  3974. SET default_flag = #{defaultFlag}
  3975. WHERE site = #{site} and bu_no = #{buNo} and ItemNo = #{itemNo} and ObjectID = #{objectID}
  3976. </update>
  3977. <select id="getIQCInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3978. select
  3979. a.site,
  3980. a.bu_no,
  3981. a.inspection_no,
  3982. a.item_no,
  3983. a.item_desc,
  3984. b.collection_source,
  3985. b.collection_method
  3986. from qc_iqc_detailed_record as a
  3987. 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
  3988. 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'
  3989. order by a.order_id
  3990. </select>
  3991. <select id="getFAIInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  3992. select
  3993. a.site,
  3994. a.bu_no,
  3995. a.inspection_no,
  3996. a.item_no,
  3997. a.item_desc,
  3998. b.collection_source,
  3999. b.collection_method
  4000. from qc_fai_detailed_record as a
  4001. 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
  4002. 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'
  4003. order by a.order_id
  4004. </select>
  4005. <select id="getFQCInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  4006. select
  4007. a.site,
  4008. a.bu_no,
  4009. a.inspection_no,
  4010. a.item_no,
  4011. a.item_desc,
  4012. b.collection_source,
  4013. b.collection_method
  4014. from qc_fqc_detailed_record as a
  4015. 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
  4016. 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'
  4017. order by a.order_id
  4018. </select>
  4019. <select id="getIPQCInspectionDetail" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData">
  4020. select
  4021. a.site,
  4022. a.bu_no,
  4023. a.inspection_no,
  4024. a.item_no,
  4025. a.item_desc,
  4026. b.collection_source,
  4027. b.collection_method
  4028. from qc_ipqc_detailed_record as a
  4029. 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
  4030. 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'
  4031. order by a.order_id
  4032. </select>
  4033. <delete id="deleteEquipmentDataAcquisition" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4034. delete from Equipment_data_acquisition
  4035. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4036. </delete>
  4037. <select id="getInspectionStandards" parameterType="com.xujie.sys.modules.pms.data.QcInspectionStandardData" resultType="com.xujie.sys.modules.pms.data.QcInspectionStandardData">
  4038. select
  4039. site,
  4040. bu_no,
  4041. template_id,
  4042. item_no,
  4043. default_value,
  4044. min_value,
  4045. max_value,
  4046. condition,
  4047. collection_source,
  4048. seq_no
  4049. from qc_inspection_standards
  4050. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4051. </select>
  4052. <delete id="deleteInspectionStandard" parameterType="com.xujie.sys.modules.pms.data.QcInspectionStandardData">
  4053. delete from qc_inspection_standards
  4054. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4055. </delete>
  4056. <delete id="deleteInspectionStandard2" parameterType="com.xujie.sys.modules.pms.data.QcTemplateData">
  4057. delete from qc_inspection_standards
  4058. where site = #{site} and bu_no = #{buNo} and template_id = #{templateId} and item_no = #{itemNo}
  4059. </delete>
  4060. <insert id="saveInspectionStandard">
  4061. INSERT INTO qc_inspection_standards
  4062. (site, bu_no, template_id, item_no, default_value, min_value, max_value, condition, collection_source, seq_no)
  4063. VALUES
  4064. <foreach collection="list" item="item" separator=",">
  4065. (#{item.site}, #{item.buNo}, #{item.templateId}, #{item.itemNo}, #{item.defaultValue}, #{item.minValue}, #{item.maxValue}, #{item.condition}, #{item.collectionSource}, #{item.seqNo})
  4066. </foreach>
  4067. </insert>
  4068. <insert id="saveEquipmentFolderLocationList">
  4069. insert into Equipment_folder_location
  4070. (folder_path,equipment_no,site,bu_no,file_no,backup_folder_path,IP,suffix,equipment_desc,backup_photo_path,batch_date,port,register_address,
  4071. register_num,register_num_columntype,register_address_inspection,register_num_inspection,register_num_inspection_columntype,unit_id,
  4072. excel_compare_fields_x,excel_compare_fields_y,initial_line,data_row,skip_line,cutting_symbol,transparent_flag,Formula_calculation,
  4073. Formula,Group_calculation,regexp,repair_type,buzzer,create_by,create_time)
  4074. values (#{folderPath}, #{equipmentNo}, #{site}, #{buNo}, #{fileNo}, #{backupFolderPath}, #{IP}, #{suffix}, #{equipmentDesc}, #{backupPhotoPath}, #{batchDate}, #{port}, #{registerAddress},
  4075. #{registerNum}, #{registerNumColumntype}, #{registerAddressInspection}, #{registerNumInspection}, #{registerNumInspectionColumntype}, #{unitId},
  4076. #{excelCompareFieldsX}, #{excelCompareFieldsY}, #{initialLine}, #{dataRow}, #{skipLine}, #{cuttingSymbol}, #{transparentFlag}, #{formulaCalculation},
  4077. #{formula}, #{groupCalculation}, #{regexp}, #{repairType}, #{buzzer}, #{createBy}, getDate())
  4078. </insert>
  4079. <insert id="saveProductPartData">
  4080. insert into product_part(site,buNo,partNo,productDesc,sku,spec,roll,remark,createBy,createTime)
  4081. values(#{site},#{buNo},#{partNo},#{productDesc},#{sku},#{spec},#{roll},#{remark},#{createBy},GETDATE())
  4082. </insert>
  4083. <select id="getInspectionTemplateDetail" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData" resultType="com.xujie.sys.modules.pms.data.QcInspectionStandardData">
  4084. select
  4085. site,
  4086. bu_no,
  4087. template_id,
  4088. item_no
  4089. <if test="flag == 'iqc'">
  4090. from qc_iqc_detailed_record
  4091. </if>
  4092. <if test="flag == 'ipqc'">
  4093. from qc_ipqc_detailed_record
  4094. </if>
  4095. <if test="flag == 'fqc'">
  4096. from qc_fqc_detailed_record
  4097. </if>
  4098. <if test="flag == 'fai'">
  4099. from qc_fai_detailed_record
  4100. </if>
  4101. where site = #{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo}
  4102. order by order_id
  4103. </select>
  4104. <update id="updateEquipmentDataDetailInspectionNo" parameterType="com.xujie.sys.modules.pms.data.SubDetailValues">
  4105. update Equipment_data_detail
  4106. set inspection_no = #{inspectionNo}
  4107. where id = #{id}
  4108. </update>
  4109. <delete id="deleteInspectionFiles" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4110. delete sys_oss
  4111. where order_ref1 = #{site} and order_ref2 = #{inspectionNo} and order_ref4 = #{buNo}
  4112. </delete>
  4113. <select id="getUpItemdata" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  4114. select
  4115. top 1
  4116. site,
  4117. bu_no,
  4118. template_id,
  4119. ItemNo,
  4120. order_id
  4121. from qc_template_detailed
  4122. where #{orderId} > order_id
  4123. and site = #{site}
  4124. and bu_no= #{buNo}
  4125. and template_id = #{templateId}
  4126. order by order_id desc
  4127. </select>
  4128. <select id="getDownItemdata" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  4129. select
  4130. top 1
  4131. site,
  4132. bu_no,
  4133. template_id,
  4134. ItemNo,
  4135. order_id
  4136. from qc_template_detailed
  4137. where order_id > #{orderId}
  4138. and site = #{site}
  4139. and bu_no= #{buNo}
  4140. and template_id = #{templateId}
  4141. order by order_id
  4142. </select>
  4143. <update id="updateQcItemOrder">
  4144. update qc_template_detailed
  4145. set order_id=#{orderId}
  4146. where site = #{site}
  4147. and bu_no= #{buNo}
  4148. and template_id = #{templateId}
  4149. and ItemNo = #{itemNo}
  4150. </update>
  4151. <select id="getQCDetailOrderId" resultType="Integer">
  4152. SELECT isnull(max(order_id), 0) + 1
  4153. from qc_template_detailed
  4154. where site = #{site}
  4155. and bu_no= #{buNo}
  4156. and template_id = #{templateId}
  4157. </select>
  4158. <select id="updateQCDetailOrderIdNull">
  4159. UPDATE qc_template_detailed
  4160. SET qc_template_detailed.order_id = oi.rn
  4161. FROM (SELECT
  4162. site,
  4163. bu_no,
  4164. template_id,
  4165. ItemNo,
  4166. ROW_NUMBER() OVER (PARTITION BY site,bu_no,template_id ORDER BY ItemNo) AS rn
  4167. FROM qc_template_detailed
  4168. ) as oi
  4169. where qc_template_detailed.template_id = oi.template_id
  4170. AND qc_template_detailed.ItemNo = oi.ItemNo
  4171. and qc_template_detailed.order_id is null
  4172. </select>
  4173. <select id="selectInfoByInspectionNo" resultType="com.xujie.sys.modules.pms.data.PoOrderRollNoData" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4174. select
  4175. site,
  4176. citem_code,
  4177. inspection_no
  4178. from po_order_roll_no
  4179. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  4180. </select>
  4181. <update id="updateIQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4182. UPDATE qc_iqc_record
  4183. SET submit_flag = 'N',
  4184. state = '待检验',
  4185. cancel_check_by = #{updateBy},
  4186. cancel_check_date = getDate()
  4187. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4188. </update>
  4189. <update id="updateIQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4190. UPDATE qc_iqc_detailed_record
  4191. SET is_submit = 'N'
  4192. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4193. </update>
  4194. <update id="updateIQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4195. UPDATE qc_iqc_sub_detail_record
  4196. SET is_submit = 'N'
  4197. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4198. </update>
  4199. <update id="updateFAIMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4200. UPDATE qc_fai_record
  4201. SET submit_flag = 'N',
  4202. state = '待检验',
  4203. cancel_check_by = #{updateBy},
  4204. cancel_check_date = getDate()
  4205. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4206. </update>
  4207. <update id="updateFAIDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4208. UPDATE qc_fai_detailed_record
  4209. SET is_submit = 'N'
  4210. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4211. </update>
  4212. <update id="updateFAISubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4213. UPDATE qc_fai_sub_detail_record
  4214. SET is_submit = 'N'
  4215. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4216. </update>
  4217. <update id="updateIPQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4218. UPDATE qc_ipqc_record
  4219. SET submit_flag = 'N',
  4220. state = '待检验',
  4221. cancel_check_by = #{updateBy},
  4222. cancel_check_date = getDate()
  4223. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4224. </update>
  4225. <update id="updateIPQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4226. UPDATE qc_ipqc_detailed_record
  4227. SET is_submit = 'N'
  4228. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4229. </update>
  4230. <update id="updateIPQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4231. UPDATE qc_ipqc_sub_detail_record
  4232. SET is_submit = 'N'
  4233. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4234. </update>
  4235. <update id="updateFQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4236. UPDATE qc_fqc_record
  4237. SET submit_flag = 'N',
  4238. state = '待检验',
  4239. cancel_check_by = #{updateBy},
  4240. cancel_check_date = getDate()
  4241. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4242. </update>
  4243. <update id="updateFQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4244. UPDATE qc_fqc_detailed_record
  4245. SET is_submit = 'N'
  4246. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4247. </update>
  4248. <update id="updateFQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4249. UPDATE qc_fqc_sub_detail_record
  4250. SET is_submit = 'N'
  4251. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4252. </update>
  4253. <update id="updatePQCMasterSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4254. UPDATE qc_pqc_record
  4255. SET submit_flag = 'N',
  4256. state = '待检验',
  4257. cancel_check_by = #{updateBy},
  4258. cancel_check_date = getDate()
  4259. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4260. </update>
  4261. <update id="updatePQCDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4262. UPDATE qc_pqc_detailed_record
  4263. SET is_submit = 'N'
  4264. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4265. </update>
  4266. <update id="updatePQCSubDetailSubmitFlag2" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4267. UPDATE qc_pqc_sub_detail_record
  4268. SET is_submit = 'N'
  4269. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4270. </update>
  4271. <delete id="deleteReceivingTaskByInspectionNo" parameterType="com.xujie.sys.modules.pms.data.QcFAIRecordData">
  4272. delete receiving_task
  4273. where site = #{site} and citem_code = #{buNo} and inspection_no = #{inspectionNo}
  4274. </delete>
  4275. <delete id="deleteEquipmentFolderLocationList">
  4276. delete from Equipment_folder_location
  4277. where id = #{id}
  4278. </delete>
  4279. <delete id="deleteProductPartList">
  4280. delete from product_part where id = #{id}
  4281. </delete>
  4282. <select id="getQMSTask" resultType="com.xujie.sys.modules.pms.data.QmsTaskData">
  4283. select
  4284. id,
  4285. site,
  4286. bu_no,
  4287. part_no,
  4288. operation_desc,
  4289. s_resourceid,
  4290. qtyrequired,
  4291. create_date,
  4292. create_by,
  4293. inspection_type,
  4294. type,
  4295. order_no,
  4296. seqno,
  4297. template_id,
  4298. um_id,
  4299. work_center_no
  4300. from QMS_soscheduledrouting_TASK
  4301. where ISNULL(delete_flag, '') <![CDATA[<>]]> 'Y'
  4302. </select>
  4303. <select id="getSuffixList" resultType="java.lang.String">
  4304. select distinct suffix from Equipment_folder_location
  4305. </select>
  4306. <select id="checkEquipmentFolderLocation" resultType="java.lang.Integer">
  4307. select count(1)
  4308. from Equipment_folder_location
  4309. where site = #{site} and bu_no = #{buNo} and equipment_no = #{equipmentNo}
  4310. </select>
  4311. <update id="updateQMSTaskById">
  4312. UPDATE QMS_soscheduledrouting_TASK
  4313. SET delete_flag = 'Y'
  4314. WHERE id = #{id}
  4315. </update>
  4316. <select id="queryEquipmentFolderLocationList"
  4317. resultType="com.xujie.sys.modules.pms.data.QCEquipmentFolderLocation">
  4318. select efl.*,
  4319. dbo.get_bu_desc(efl.site, efl.bu_no) as buDesc
  4320. from Equipment_folder_location efl
  4321. <where>
  4322. <if test="params.site != null and params.site != ''">
  4323. and efl.site = #{params.site}
  4324. </if>
  4325. <if test="params.buNo != null and params.buNo != ''">
  4326. and efl.bu_no = #{params.buNo}
  4327. </if>
  4328. <if test="params.equipmentNo != null and params.equipmentNo != ''">
  4329. and efl.equipment_no like '%'+ #{params.equipmentNo} +'%'
  4330. </if>
  4331. <if test="params.equipmentDesc != null and params.equipmentDesc != ''">
  4332. and efl.equipment_desc like '%'+ #{params.equipmentDesc} +'%'
  4333. </if>
  4334. <if test="params.IP != null and params.IP != ''">
  4335. and efl.IP like '%'+ #{params.IP} +'%'
  4336. </if>
  4337. <if test="params.suffix != null and params.suffix != ''">
  4338. and efl.suffix like '%'+ #{params.suffix} +'%'
  4339. </if>
  4340. </where>
  4341. </select>
  4342. <select id="getPqcOperationDescList" resultType="com.xujie.sys.modules.pms.data.QcPartAttributeData">
  4343. select qro.description as operationDesc
  4344. from operation_resource a
  4345. left join qc_pqc_record_operation qro on a.operation = qro.code
  4346. GROUP BY qro.description
  4347. </select>
  4348. <select id="queryTemplateSortList" resultType="com.xujie.sys.modules.pms.entity.QmsDataDictionaryData">
  4349. select code,description from qms_data_dictionary where type = #{type}
  4350. </select>
  4351. <select id="getItemList2" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  4352. SELECT
  4353. a.site,
  4354. a.bu_no,
  4355. a.itemNo,
  4356. a.ItemDesc,
  4357. a.DefaultValue,
  4358. a.MaxValue,
  4359. a.MinValue
  4360. FROM eam_properties_item a
  4361. 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
  4362. WHERE a.ItemType = #{itemType} and a.site = #{site} and b.template_id is null and a.bu_no = #{buNo}
  4363. </select>
  4364. <select id="qcLcItemSearch" resultType="com.xujie.sys.modules.pms.data.QcItemData">
  4365. SELECT
  4366. epi.site,
  4367. epi.bu_no,
  4368. dbo.get_bu_desc(epi.site, epi.bu_no) as buDesc,
  4369. epi.ItemNo,
  4370. epi.ItemDesc,
  4371. epi.DefaultValue,
  4372. epi.ValueType,
  4373. epi.ValueType_DB as valueTypeDb,
  4374. epi.ValueChooseFlag,
  4375. epi.CreatedDate,
  4376. epi.CreatedBy,
  4377. dbo.getOperatorDesc(epi.site, epi.CreatedBy) as createdByDesc,
  4378. epi.MaxValue,
  4379. epi.MinValue,
  4380. epi.ItemRemark,
  4381. epi.ItemType,
  4382. epi.update_date,
  4383. epi.update_by,
  4384. dbo.getOperatorDesc(epi.site, epi.update_by) as updateByDesc,
  4385. qm.method_no,
  4386. qm.method_name,
  4387. qm.method_remark,
  4388. epi.inspection_type_no,
  4389. qit.inspection_type_name,
  4390. epi.item_sampling_quantity,
  4391. epi.sampling_programme_no,
  4392. qsip.sampling_programme_desc,
  4393. epi.sampling_level_no,
  4394. qsil.sampling_level_desc,
  4395. epi.default_sampling_proportion,
  4396. epi.collection_flag,
  4397. epi.collection_source,
  4398. epi.collection_method,
  4399. CASE WHEN epi.collection_method = 'plc' THEN 'PLC'
  4400. WHEN epi.collection_method = 'file' THEN '文件'
  4401. WHEN epi.collection_method = 'image' THEN '图片'
  4402. else '' end as collectionMethodDesc,
  4403. epi.collection_condition,
  4404. epi.collection_data_content
  4405. FROM eam_properties_item as epi
  4406. LEFT JOIN qc_method_item as qmi on epi.ItemNo = qmi.ItemNo and epi.site = qmi.site and epi.bu_no = qmi.bu_no
  4407. 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
  4408. LEFT JOIN qc_inspection_type as qit on qit.inspection_type_no = epi.inspection_type_no and qit.site = epi.site
  4409. 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
  4410. 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
  4411. <where>
  4412. epi.site = '***' and epi.bu_no = '***' and epi.ItemType = '***'
  4413. <if test="query.buDesc != null and query.buDesc != ''">
  4414. AND dbo.get_bu_desc ( epi.site, epi.bu_no ) = #{query.buDesc}
  4415. </if>
  4416. <if test="query.itemDesc != null and query.itemDesc != ''">
  4417. AND epi.ItemDesc LIKE '%' + #{query.itemDesc} +'%'
  4418. </if>
  4419. <if test="query.itemNo != null and query.itemNo != ''">
  4420. AND epi.ItemNo LIKE '%' + #{query.itemNo} +'%'
  4421. </if>
  4422. <if test="query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  4423. AND epi.inspection_type_no = #{query.inspectionTypeNo}
  4424. </if>
  4425. </where>
  4426. </select>
  4427. <select id="templateSearch2" resultType="com.xujie.sys.modules.pms.data.QcTemplateData">
  4428. SELECT
  4429. qt.site,
  4430. qt.bu_no,
  4431. dbo.get_bu_desc(qt.site, qt.bu_no) as buDesc,
  4432. qt.template_id,
  4433. qt.template_name,
  4434. qt.template_remark,
  4435. qt.template_type,
  4436. qt.template_version,
  4437. qt.sampling_programme_no,
  4438. qsip.sampling_programme_Desc,
  4439. qt.inspection_type_no,
  4440. qit.inspection_type_name,
  4441. qt.sampling_level_no,
  4442. qsil.sampling_level_desc,
  4443. qt.inspection_cycle,
  4444. qt.create_time,
  4445. qt.create_by,
  4446. dbo.getOperatorDesc(qt.site, qt.create_by) as createByDesc,
  4447. qt.update_date,
  4448. qt.update_by,
  4449. dbo.getOperatorDesc(qt.site, qt.update_by) as updateByDesc,
  4450. qt.AQL,
  4451. qt.AC,
  4452. qt.RE,
  4453. qt.default_sampling_quantity,
  4454. qt.default_sampling_proportion,
  4455. qt.template_sort,
  4456. qt.operation_no as operation
  4457. FROM qc_template as qt
  4458. LEFT JOIN qc_inspection_type as qit on qt.inspection_type_no = qit.inspection_type_no and qt.site = qit.site
  4459. 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
  4460. 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
  4461. <where>
  4462. qt.site = '***' and qt.bu_no = '***' and qt.inspection_type_no = '***'
  4463. <if test = "query.templateId != null and query.templateId != ''">
  4464. AND qt.template_id LIKE '%' + #{query.templateId}+'%'
  4465. </if>
  4466. <if test = "query.templateName != null and query.templateName != ''">
  4467. AND qt.template_name LIKE '%' + #{query.templateName}+'%'
  4468. </if>
  4469. <if test = "query.inspectionTypeNo != null and query.inspectionTypeNo != ''">
  4470. AND qt.inspection_type_no = #{query.inspectionTypeNo}
  4471. </if>
  4472. <if test = "query.operation != null and query.operation != ''">
  4473. AND qt.operation_no = #{query.operation}
  4474. </if>
  4475. </where>
  4476. order by qt.create_time desc
  4477. </select>
  4478. <select id="queryProductPartList" resultType="com.xujie.sys.modules.pms.data.ProductPartData">
  4479. select *,
  4480. dbo.get_bu_desc(site,buNo) as buDesc
  4481. from product_part
  4482. <where>
  4483. <if test=" bu != null and bu != '' ">
  4484. and site+'_'+buNo = #{bu}
  4485. </if>
  4486. <if test=" partNo != null and partNo != '' ">
  4487. and partNo = #{partNo}
  4488. </if>
  4489. <if test=" sku != null and sku != '' ">
  4490. and sku like '%'+#{sku}+'%'
  4491. </if>
  4492. <if test=" productDesc != null and productDesc != '' ">
  4493. and productDesc like '%'+ #{productDesc}+'%'
  4494. </if>
  4495. </where>
  4496. </select>
  4497. <select id="selectPartData" resultType="com.xujie.sys.modules.orderIssure.entity.PartData">
  4498. select part_desc,sku from part where site = #{site} and part_no = #{partNo}
  4499. </select>
  4500. <select id="getButtonsPermission1" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  4501. SELECT username as adminID,user_display as adminName
  4502. from sys_user a
  4503. LEFT JOIN sys_user_role b on a.user_id = b.user_id
  4504. LEFT JOIN sys_role c on b.role_id = c.role_id
  4505. where c.role_name = '成品物料模块-全部按钮权限'
  4506. </select>
  4507. <select id="getButtonsPermission2" resultType="com.xujie.sys.modules.pms.data.EamAdminData">
  4508. SELECT username as adminID,user_display as adminName
  4509. from sys_user a
  4510. LEFT JOIN sys_user_role b on a.user_id = b.user_id
  4511. LEFT JOIN sys_role c on b.role_id = c.role_id
  4512. where c.role_name = '成品物料模块-查询导出权限'
  4513. </select>
  4514. <select id="selectProductPartCount" resultType="com.xujie.sys.modules.pms.data.ProductPartData">
  4515. select * from product_part where site = #{site} and partNo = #{partNo}
  4516. </select>
  4517. <select id="getQcIpqcSubDetailRecordCount" resultType="java.lang.Integer">
  4518. select count(*) from qc_ipqc_sub_detail_record where site =#{site} and bu_no = #{buNo} and inspection_no = #{inspectionNo} and item_no = #{itemNo}
  4519. </select>
  4520. <update id="updateEquipmentFolderLocation">
  4521. UPDATE Equipment_folder_location
  4522. SET
  4523. folder_path = #{folderPath},
  4524. equipment_no = #{equipmentNo},
  4525. bu_no = #{buNo},
  4526. file_no = #{fileNo},
  4527. backup_folder_path = #{backupFolderPath},
  4528. IP = #{IP},
  4529. suffix = #{suffix},
  4530. equipment_desc = #{equipmentDesc},
  4531. backup_photo_path = #{backupPhotoPath},
  4532. batch_date = #{batchDate},
  4533. port = #{port},
  4534. register_address = #{registerAddress},
  4535. register_num = #{registerNum},
  4536. register_num_columntype = #{registerNumColumntype},
  4537. register_address_inspection = #{registerAddressInspection},
  4538. register_num_inspection = #{registerNumInspection},
  4539. register_num_inspection_columntype = #{registerNumInspectionColumntype},
  4540. unit_id = #{unitId},
  4541. excel_compare_fields_x = #{excelCompareFieldsX},
  4542. excel_compare_fields_y = #{excelCompareFieldsY},
  4543. initial_line = #{initialLine},
  4544. data_row = #{dataRow},
  4545. skip_line = #{skipLine},
  4546. cutting_symbol = #{cuttingSymbol},
  4547. transparent_flag = #{transparentFlag},
  4548. Formula_calculation = #{formulaCalculation},
  4549. Formula = #{formula},
  4550. Group_calculation = #{groupCalculation},
  4551. regexp = #{regexp},
  4552. repair_type = #{repairType},
  4553. buzzer = #{buzzer},
  4554. update_by = #{updateBy},
  4555. update_time = getDate()
  4556. WHERE id = #{id}
  4557. </update>
  4558. <update id="updatePQCMasterSubmitFlag">
  4559. UPDATE qc_pqc_record
  4560. SET submit_flag = 'Y',
  4561. state = '已完成',
  4562. submit_date = getDate()
  4563. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4564. </update>
  4565. <update id="updatePQCDetailSubmitFlag">
  4566. UPDATE qc_pqc_detailed_record
  4567. SET is_submit = 'Y'
  4568. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4569. </update>
  4570. <update id="updatePQCSubDetailSubmitFlag">
  4571. UPDATE qc_pqc_sub_detail_record
  4572. SET is_submit = 'Y'
  4573. WHERE inspection_no = #{inspectionNo} and site = #{site} and bu_no = #{buNo}
  4574. </update>
  4575. <update id="updateProductPartData">
  4576. update product_part set productDesc = #{productDesc},roll = #{roll},remark = #{remark} where id = #{id}
  4577. </update>
  4578. </mapper>