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.

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