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.

4146 lines
192 KiB

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