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.

2068 lines
90 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
4 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
4 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
2 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months 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.gaotao.modules.schedule.mapper.ScheduleMapper">
  4. <update id="closeOrOpenProduceOrder">
  5. Update SOScheduledRouting
  6. Set ClosedFlag=#{closedFlag}
  7. , Closedby=#{username}
  8. , ClosedDate=#{closedDate}
  9. Where Site = #{site}
  10. and OrderNo = #{orderNo}
  11. and ItemNo = #{itemNo}
  12. and SeqNo = #{seqNo}
  13. </update>
  14. <update id="pauseOrReopenProduceOrder">
  15. Update SOScheduledRouting
  16. Set ParkFlag=#{parkFlag}
  17. Where Site = #{site}
  18. and OrderNo = #{orderNo}
  19. and ItemNo = #{itemNo}
  20. and SeqNo = #{seqNo}
  21. </update>
  22. <update id="costRollUpProduceOrder">
  23. Update ShopOrder
  24. Set CostRollUpFlag= #{costRollUpFlag}
  25. Where Site = #{site}
  26. and OrderNo = #{orderNo}
  27. </update>
  28. <update id="manualProduceOrder">
  29. Update ShopOrder
  30. Set ManualFlag=#{manualFlag}
  31. Where Site = #{site}
  32. and OrderNo = #{orderNo}
  33. </update>
  34. <update id="repairSOFlagProduceOrder">
  35. Update ShopOrder
  36. Set RepairSOFlag=#{repairSOFlag}
  37. Where Site = #{site}
  38. and OrderNo = #{orderNo}
  39. </update>
  40. <!--查询加工中心机台的信息-->
  41. <select id="getResourceLIst" parameterType="SearchScheduleData" resultType="ResourceOutData">
  42. SELECT wcr.Site site, wcr.WorkCenterNo workCenterNo, wcr.ResourceID resourceId, wcr.ResourceDesc resourceDEsc,
  43. wcr.Efficiency efficiency,
  44. wcr.Utilization utilization, wcr.Active active, wcr.Remark Remark, wcr.CreatedDate createdDate, wcr.CalendarID
  45. calendarId, wcr.VirturlFlag virturlFlag
  46. FROM WorkCenterResource wcr
  47. <where>
  48. wcr.Site = site
  49. <if test="workCenterNo != null and workCenterNo != ''">
  50. AND wcr.WorkCenterNo= #{workCenterNo}
  51. </if>
  52. <if test="resourceId != null and resourceId != ''">
  53. AND wcr.ResourceID = #{resourceId}
  54. </if>
  55. </where>
  56. </select>
  57. <!--查询机台+排产日期的休息信息-->
  58. <select id="getResourceRestList" parameterType="SearchScheduleData" resultType="ShiftInfoData">
  59. Select top 10 ScheduleDate shiftDate, CONVERT(Varchar(200), (Case when ExceptDuration1<![CDATA[ <> ]]>0 then
  60. CONVERT(Varchar(10),Convert(float,ExceptTime1)) + '/' + CONVERT(Varchar(10),Convert(float,ExceptDuration1)) else
  61. '' end)
  62. +' ; '+
  63. (Case when ExceptDuration2<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime2)) + '/' +
  64. CONVERT(Varchar(10),Convert(float,ExceptDuration2)) else '' end)
  65. +' ; '+
  66. (Case when ExceptDuration3<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime3)) + '/' +
  67. CONVERT(Varchar(10),Convert(float,ExceptDuration3)) else '' end)
  68. +' ; '+
  69. (Case when ExceptDuration4<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime4)) + '/' +
  70. CONVERT(Varchar(10),Convert(float,ExceptDuration4)) else '' end)
  71. +' ; '+
  72. (Case when ExceptDuration5<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime5)) + '/' +
  73. CONVERT(Varchar(10),Convert(float,ExceptDuration5)) else '' end)
  74. +' ; '+
  75. (Case when ExceptDuration6<![CDATA[ <> ]]>0 then CONVERT(Varchar(10),Convert(float,ExceptTime6)) + '/' +
  76. CONVERT(Varchar(10),Convert(float,ExceptDuration6)) else '' end)
  77. ) as shiftInfo from Calendar_Exception cde
  78. <where>
  79. AND cde.Site = #{site}
  80. AND cde.CalendarID = #{calendarId}
  81. AND cde.ScheduleDate <![CDATA[ >= ]]> #{scheduleDate}
  82. </where>
  83. </select>
  84. <!--按照条件查询工单的数据-->
  85. <select id="getShopOrderList" parameterType="SearchScheduleData" resultType="ShopOrderOutData">
  86. Select T.Site site, T.OrderNo orderNo, T.ItemNo itemNo, T.OperationDesc itemDesc, T.PartNo partNo,
  87. P.PartDescription partDesc, P.Spec spec,
  88. D.LotSize lotSize, T.QtyReported qtyReported, D.NeedDate needDate, T.PreItemNo PreItemNo, S1.OperationDesc
  89. PreItemDesc, S1.ScheduledFlag preScheduledFlag,
  90. T.NextItemNo nextItemNo, S2.OperationDesc nextItemDesc, S2.ScheduledFlag nextScheduledFlag, D.CustomerID
  91. customerId, P.ConfigurationTemplateID customerName,
  92. D.EnterDate enterDate, dbo.Get_SOOpsScheduleAvailResource(T.Site,T.OrderNo,T.WorkCenterNo,T.ItemNo)
  93. availResource, T.WorkCenterNo workCenterNo,
  94. T.MachRunFactor machRunFactor, T.MachSetupTime machSetupTime, T.FactorUnit factorUnit, T.ScheduledFlag
  95. scheduledFlag, D.RoutingRevNo routingRevNo,
  96. T.QtyScheduled qtyScheduled,(round(T.QtyRequired,3) - Round(T.QtyScheduled,3)) qtyToSchedule,
  97. Isnull(S1.QtyScheduled,0.0) qtyScheduledPreOps,
  98. dbo.getScheduleToPlanTime(D.LotSize, T.MachSetupTime, T.MachRunFactor, T.FactorUnit, t.Efficiency)
  99. scheduleToPlanTime,
  100. D.OriSOOrderNo oriSOOrderNo, P.Remark custPartNo, 1*t.Efficiency efficiency, D.CostRollUpFlag costRollUpFlag,
  101. isnull(S1.QtyApprove,0.0) qtyApprovedPreOps,
  102. d.ManualFlag manualFlag, d.RepairSOFlag repairSOFlag
  103. from SORouting as T
  104. Left Join ShopOrder as D On T.Site=D.Site and T.OrderNo=D.OrderNo
  105. Left Join Part as P On T.Site=P.Site and T.PartNo=P.PartNo
  106. Left Join SORouting as S1 On T.Site=S1.Site and T.OrderNo=S1.OrderNo and T.PreItemNo=S1.ItemNo
  107. Left Join SORouting as S2 On T.Site=S2.Site and T.OrderNo=S2.OrderNo and T.NextItemNo=S2.ItemNo
  108. <where>
  109. Round(T.QtyScheduled,3) <![CDATA[ < ]]> round(T.QtyRequired,3) and T.ClosedFlag = 'N'
  110. <if test="username != null and username != ''">
  111. and T.site in (Select Site from AccessSite where upper(UserID)=#{username})
  112. </if>
  113. and T.OrderNo<![CDATA[ <> ]]>'9999' and isnull(D.Status,'')<![CDATA[ <> ]]>'已取消' and isnull(D.Status,'')
  114. <![CDATA[ <> ]]>'已计划'
  115. and isnull(D.Status,'')<![CDATA[ <> ]]>'已关闭'
  116. <if test="enterTime1 != null">
  117. and D.EnterDate<![CDATA[ >= ]]> #{enterTime1}
  118. </if>
  119. <if test="enterTime2 != null">
  120. and D.EnterDate-1<![CDATA[<]]> #{enterTime2}
  121. </if>
  122. <if test="needTime1 != null">
  123. and D.NeedDate<![CDATA[ >= ]]>#{needTime1}
  124. </if>
  125. <if test="needTime2 != null">
  126. and D.NeedDate<![CDATA[ <= ]]>#{needTime2}
  127. </if>
  128. <if test="site != null and site != ''">
  129. AND T.Site like '%' + #{site} + '%'
  130. </if>
  131. <if test="partNo != null and partNo != ''">
  132. AND T.PartNo like '%' + #{partNo} + '%'
  133. </if>
  134. AND Rtrim(T.WorkCenterNo) like '%' + #{workCenterNo} + '%'
  135. <if test="scheduledFlag != null and scheduledFlag != ''">
  136. AND Isnull(S1.ScheduledFlag, 'Y') = #{scheduledFlag}
  137. </if>
  138. <if test='preScheduledFlag != null and preScheduledFlag == "Y"'>
  139. and Isnull(S1.ScheduledFlag,'Y') = 'Y'
  140. </if>
  141. AND dbo.Get_SOOpsScheduleAvailResource(T.Site,T.OrderNo,T.WorkCenterNo,T.ItemNo) like '%' + #{resourceId} +
  142. '(%'
  143. </where>
  144. /*设置排序规则*/
  145. <if test="sortField == null || sortField == ''">
  146. Order by D.NeedDate
  147. </if>
  148. <if test="sortField != null and sortField == 'needDate'">
  149. Order by D.NeedDate
  150. </if>
  151. <if test="sortField != null and sortField == 'orderNo'">
  152. Order by T.OrderNo
  153. </if>
  154. <if test="sortField != null and sortField == 'partNo'">
  155. Order by T.PartNo
  156. </if>
  157. </select>
  158. <!--按照条件查询工单的数据-->
  159. <select id="getOrderScheduleList" parameterType="SearchScheduleData" resultType="ScheduleData">
  160. select
  161. T.Site site,
  162. T.OrderNo orderNo,
  163. T.ItemNo itemNo,
  164. S.OperationDesc itemDesc,
  165. S.PartNo partNo,
  166. P.PartDescription partDesc,
  167. P.Spec spec,
  168. T.QtyRequired qtyRequired,
  169. T.QtyReported qtyReported,
  170. (T.QtyRequired - T.QtyReported) as qtyToReport,
  171. D.NeedDate needDate,
  172. S.PreItemNo preItemNo,
  173. S1.OperationDesc preItemDesc,
  174. S1.ScheduledFlag preScheduledFlag,
  175. S.NextItemNo nextItemNo,
  176. S2.OperationDesc nextItemDesc,
  177. S2.ScheduledFlag nextScheduledFlag,
  178. D.CustomerID customerId,
  179. dbo.Get_CustomerDesc (D.Site, D.CustomerID) customerName,
  180. D.EnterDate enterDate,
  181. dbo.Get_SOOpsScheduleAvailResource (
  182. T.Site,
  183. S.OrderNo,
  184. T.S_WorkCenterNo,
  185. T.ItemNo
  186. ) availResource,
  187. T.S_WorkCenterNo workCenterNo,
  188. S.MachRunFactor machRunFactor,
  189. S.MachSetupTime machSetupTime,
  190. S.FactorUnit factorUnit,
  191. T.ClosedFlag closedFlag,
  192. E.S_ScheduledSeqNo scheduledSeqNo,
  193. T.PlanStartTime planStartTime,
  194. T.PlanFinishTime planFinishTime,
  195. T.S_ResourceID resourceId,
  196. T.TimeRequired timeRequired,
  197. T.SeqNo seqNo,
  198. T.SelectedFlag selectedFlag,
  199. T.SourceFlag sourceFlag,
  200. S1.QtyScheduled qtyScheduledPreOps,
  201. T.ParkFlag parkFlag,
  202. T.TimeRequired_Original timeRequiredOriginal,
  203. T.QtyRequired_Original qtyRequiredOriginal,
  204. S1.PlanStartTime preOpsPlanStartTime,
  205. S1.PlanFinishTime preOpsPlanFinishTime,
  206. T.Remark remark,
  207. D.OriSOOrderNo oriSOOrderNo,
  208. P.Remark custPartNo,
  209. T.Efficiency eficiency,
  210. (Case when dbo.Get_SOOpsJobEstFinishDate(T.Site,T.OrderNo,T.ItemNo,T.SeqNo)<![CDATA[ <= ]]>T.PlanFinishTime then
  211. 0.0
  212. else round((convert(float,dbo.Get_SOOpsJobEstFinishDate(T.Site,T.OrderNo,T.ItemNo,T.SeqNo)) -
  213. convert(float,T.PlanFinishTime)) * 24,2) end) delayHours,
  214. dbo.Get_SOSchedule_RecordIdentity(T.Site,T.PlanStartTime,T.PlanFinishTime,D.NeedDate,S1.PlanStartTime,S1.PlanFinishTime) mergeStatusCon,
  215. T.mat_issueflag costRollUpFlag,
  216. dbo.getCurrentScheduleColorStyle(T.QtyReported, T.QtyRequired, T.PlanFinishTime, T.ClosedFlag) colorStyle
  217. from SOScheduledList as E,SOScheduledRouting as T
  218. Left Join ShopOrder as D On T.Site=D.Site and T.OrderNo=D.OrderNo
  219. ,SORouting as S
  220. Left Join Part as P On S.Site=P.Site and S.PartNo=P.PartNo
  221. Left Join SORouting as S1 On S.Site=S1.Site and S.OrderNo=S1.OrderNo and S.PreItemNo=S1.ItemNo
  222. Left Join SORouting as S2 On S.Site=S2.Site and S.OrderNo=S2.OrderNo and S.NextItemNo=S2.ItemNo
  223. <where>
  224. T.Site=S.Site and T.OrderNo=S.OrderNo and T.ItemNo=S.ItemNo and E.Site=T.Site and E.LinkedSeqNo=T.SeqNo
  225. <if test="site != null and site != ''">
  226. AND E.Site like '%' + #{site} + '%'
  227. </if>
  228. AND RTrim(T.S_WorkCenterNo) like #{workCenterNo} AND T.S_WorkCenterNo <![CDATA[<>]]> 'FQC'
  229. AND RTrim(E.ResourceID) like '%' + #{resourceId} + '%'
  230. </where>
  231. Order by E.S_ScheduledSeqNo
  232. </select>
  233. <!--查询-待生产工单-->
  234. <select id="getProduceScheduleData" parameterType="SearchScheduleData" resultType="ScheduleData">
  235. <if test='exportFlag != null and exportFlag == "N"'>
  236. Select TOP 200 T.Site site, T.OrderNo orderNo, T.ItemNo itemNo, D.OperationDesc itemDesc, D.PartNo partNo,
  237. </if>
  238. <if test='exportFlag != null and exportFlag == "Y"'>
  239. Select T.Site site, T.OrderNo orderNo, T.ItemNo itemNo, D.OperationDesc itemDesc, D.PartNo partNo,
  240. </if>
  241. P.PartDescription partDesc,
  242. P.Spec spec,
  243. T.SeqNo seqNo,
  244. T.QtyRequired qtyRequired,
  245. T.QtyReported qtyReported,
  246. (T.QtyRequired - T.QtyReported) as qtyToReport,
  247. T.QtyApprove qtyApprove,
  248. ROUND(T.TimeRequired, 3) timeRequired,
  249. T.TimeReported timeReported,
  250. T.PlanStartTime planStartTime,
  251. T.PlanFinishTime planFinishTime,
  252. T.BarcodeID barcodeId,
  253. T.Remark remark,
  254. T.Crewsize crewSize,
  255. T.ClosedFlag closedFlag,
  256. T.QtyScrapt qtyScrapt,
  257. T.OutWorkFlag outWorkFlag,
  258. T.S_ScheduledDate scheduledDate,
  259. T.S_ResourceID resourceId,
  260. dbo.getWorkCenterResourceDesc(T.Site, t.S_WorkCenterNo, T.S_ResourceID) resourceDesc,
  261. T.serial_number serialNumber,
  262. T.S_ShiftNo shiftNo,
  263. D.MachSetupTime machSetupTime,
  264. D.MachRunFactor machRunFactor,
  265. D.FactorUnit factorUnit,
  266. D.Efficiency efficiency,
  267. D.NextItemNo nextItemNo,
  268. dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.NextItemNo) nextItemDesc,
  269. D.PreItemNo preItemNo,
  270. dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.PreItemNo) preItemDesc,
  271. SO.NeedDate needDate,
  272. T.ParkFlag parkFlag,
  273. dbo.Get_SOOpsPreResourceInfo(T.Site, T.OrderNo, T.ItemNo) preResourceInfo,
  274. dbo.Get_SOOpsPreQtyFinished(T.Site, T.OrderNo, T.ItemNo) preQtyFinished,
  275. P.ConfigurationTemplateID customerName,
  276. P.Remark custPartNo,
  277. t.S_WorkCenterNo workCenterNo,
  278. dbo.Get_WorkCenterDesc(T.Site, T.S_WorkCenterNo) workCenterDesc,
  279. T.QtyRequired_Original qtyRequiredOriginal,
  280. SO.orderType,
  281. T.ClosedBy closedBy,
  282. T.ClosedDate closedDate,
  283. T.mat_issueflag matIssueFlag,
  284. T.plate_issueflag plateIssueFlag,
  285. T.tool_issueflag toolIssueFlag,
  286. so.bu_no buNo
  287. from SOScheduledRouting as T
  288. Left Join SOScheduledList as E on E.Site=T.Site and E.LinkedSeqNo=T.SeqNo and T.S_ResourceID = E.ResourceID,
  289. SORouting as D,Part as P,ShopOrder as SO
  290. <where>
  291. T.Site=D.Site and T.OrderNo=D.OrderNo and T.ItemNo=D.ItemNo and D.Site=P.Site and D.PartNo=P.PartNo
  292. and T.site in (Select Site from AccessSite where upper(UserID)=#{username})
  293. and T.Site=SO.Site and T.OrderNo=SO.OrderNo and T.OrderNo<![CDATA[ <> ]]>'9999'
  294. <if test="site != null and site != ''">
  295. AND T.Site like '%' + #{site} + '%'
  296. </if>
  297. <if test="planStartTime1 != null">
  298. and T.PlanStartTime<![CDATA[ >= ]]> #{planStartTime1}
  299. </if>
  300. <if test="planStartTime2 != null">
  301. and T.PlanStartTime<![CDATA[ <= ]]> #{planStartTime2}
  302. </if>
  303. <if test="resourceId != null and resourceId != ''">
  304. AND T.S_ResourceID = #{resourceId}
  305. </if>
  306. <if test="orderNo != null and orderNo != ''">
  307. AND T.OrderNo like '%' + #{orderNo} + '%'
  308. </if>
  309. <if test="seqNo != null and seqNo != ''">
  310. AND T.SeqNo like '%' + #{seqNo} + '%'
  311. </if>
  312. <if test='closedFlag != null and closedFlag == "N"'>
  313. and T.ClosedFlag = #{closedFlag}
  314. </if>
  315. </where>
  316. Order by SO.bu_no, T.S_ResourceID, ISNULL(T.serial_number, 999999) asc
  317. </select>
  318. <!--查询操作员信息列表-->
  319. <select id="getOperatorList" parameterType="OperatorOutData" resultType="com.gaotao.modules.shopOrder.entity.OperatorData">
  320. SELECT
  321. op.Site site,
  322. op.OperatorID operatorId,
  323. op.OperatorName operatorName,
  324. op.Active status
  325. FROM Operator op
  326. <where>
  327. op.Site IN (SELECT Site FROM AccessSite WHERE UPPER(UserID) = #{username})
  328. <if test="site != null and site != ''">
  329. AND op.Site = #{site}
  330. </if>
  331. <if test="operatorId != null and operatorId != ''">
  332. AND op.OperatorID like '%' + #{operatorId} + '%'
  333. </if>
  334. <if test="operatorName != null and operatorName != ''">
  335. AND op.OperatorName like '%' + #{operatorName} + '%'
  336. </if>
  337. <if test="status != null and status != ''">
  338. AND op.Active = #{status}
  339. </if>
  340. </where>
  341. </select>
  342. <!--查询操作员信息-->
  343. <select id="getOperatorData" parameterType="OperatorOutData" resultType="OperatorOutData">
  344. SELECT op.Site site, op.OperatorID operatorId, op.OperatorName operatorName, op.Active status
  345. FROM Operator op
  346. <where>
  347. op.Site IN (SELECT Site FROM AccessSite WHERE UPPER(UserID) = #{username})
  348. <if test="site != null and site != ''">
  349. AND op.Site = #{site}
  350. </if>
  351. <if test="operatorId != null and operatorId != ''">
  352. AND op.OperatorID = #{operatorId}
  353. </if>
  354. <if test="operatorName != null and operatorName != ''">
  355. AND op.OperatorName = #{operatorName}
  356. </if>
  357. </where>
  358. </select>
  359. <!--获取操作员列表-->
  360. <select id="getOperatorList2" parameterType="java.util.Map" resultType="java.util.Map">
  361. SELECT
  362. id,
  363. site,
  364. order_no AS orderNo,
  365. item_no AS itemNo,
  366. seq_no AS seqNo,
  367. roll_no AS rollNo,
  368. created_by AS createdBy,
  369. created_date AS createdDate,
  370. operator,
  371. (SELECT OperatorName FROM Operator WHERE OperatorID = sol.operator AND Site = sol.site) AS operatorName,
  372. is_on_duty AS isOnDuty,
  373. on_duty_time AS onDutyTime,
  374. off_duty_time AS offDutyTime,
  375. batch_no AS batchNo,
  376. remark
  377. FROM sfdc_operator_list sol
  378. <where>
  379. <if test="site != null and site != ''">
  380. AND site = #{site}
  381. </if>
  382. <if test="orderNo != null and orderNo != ''">
  383. AND order_no = #{orderNo}
  384. </if>
  385. <if test="itemNo != null">
  386. AND item_no = #{itemNo}
  387. </if>
  388. <if test="seqNo != null and seqNo != ''">
  389. AND seq_no = #{seqNo}
  390. </if>
  391. <if test="isOnDuty != null and isOnDuty != ''">
  392. AND is_on_duty = #{isOnDuty}
  393. </if>
  394. </where>
  395. ORDER BY on_duty_time DESC
  396. </select>
  397. <!--添加操作员上岗-->
  398. <insert id="addOperatorOnDuty" parameterType="java.util.Map">
  399. INSERT INTO sfdc_operator_list (
  400. site,
  401. order_no,
  402. item_no,
  403. seq_no,
  404. roll_no,
  405. created_by,
  406. created_date,
  407. operator,
  408. is_on_duty,
  409. on_duty_time,
  410. batch_no,
  411. remark
  412. ) VALUES (
  413. #{site},
  414. #{orderNo},
  415. #{itemNo},
  416. #{seqNo},
  417. #{rollNo},
  418. #{createdBy},
  419. #{createdDate},
  420. #{operator},
  421. #{isOnDuty},
  422. #{onDutyTime},
  423. #{batchNo},
  424. #{remark}
  425. )
  426. </insert>
  427. <!--操作员下岗-->
  428. <update id="removeOperatorOnDuty" parameterType="java.util.Map">
  429. UPDATE sfdc_operator_list
  430. SET is_on_duty = #{isOnDuty},
  431. off_duty_time = #{offDutyTime}
  432. <where>
  433. <if test="id != null">
  434. AND id = #{id}
  435. </if>
  436. <if test="site != null and site != ''">
  437. AND site = #{site}
  438. </if>
  439. <if test="orderNo != null and orderNo != ''">
  440. AND order_no = #{orderNo}
  441. </if>
  442. <if test="itemNo != null">
  443. AND item_no = #{itemNo}
  444. </if>
  445. <if test="seqNo != null and seqNo != ''">
  446. AND seq_no = #{seqNo}
  447. </if>
  448. <if test="operator != null and operator != ''">
  449. AND operator = #{operator}
  450. </if>
  451. </where>
  452. </update>
  453. <!--删除操作员数据-->
  454. <delete id="deleteOperatorData" parameterType="java.util.Map">
  455. DELETE FROM sfdc_operator_list
  456. <where>
  457. <if test="id != null">
  458. AND id = #{id}
  459. </if>
  460. <if test="site != null and site != ''">
  461. AND site = #{site}
  462. </if>
  463. <if test="orderNo != null and orderNo != ''">
  464. AND order_no = #{orderNo}
  465. </if>
  466. <if test="itemNo != null">
  467. AND item_no = #{itemNo}
  468. </if>
  469. <if test="seqNo != null and seqNo != ''">
  470. AND seq_no = #{seqNo}
  471. </if>
  472. <if test="operator != null and operator != ''">
  473. AND operator = #{operator}
  474. </if>
  475. </where>
  476. </delete>
  477. <!--更新操作员时间-->
  478. <update id="updateOperatorTime" parameterType="java.util.Map">
  479. UPDATE sfdc_operator_list
  480. SET
  481. on_duty_time = #{onDutyTime},
  482. off_duty_time = #{offDutyTime}
  483. <where>
  484. <if test="id != null">
  485. AND id = #{id}
  486. </if>
  487. <if test="site != null and site != ''">
  488. AND site = #{site}
  489. </if>
  490. <if test="orderNo != null and orderNo != ''">
  491. AND order_no = #{orderNo}
  492. </if>
  493. <if test="itemNo != null">
  494. AND item_no = #{itemNo}
  495. </if>
  496. <if test="seqNo != null and seqNo != ''">
  497. AND seq_no = #{seqNo}
  498. </if>
  499. <if test="operator != null and operator != ''">
  500. AND operator = #{operator}
  501. </if>
  502. </where>
  503. </update>
  504. <!--更新派工单MRB信息-->
  505. <update id="updateScheduleMrbInfo" parameterType="java.util.Map">
  506. UPDATE SOScheduledRouting
  507. SET
  508. mrb = #{mrb},
  509. mrb_inspection_report = #{mrbInspectionReport},
  510. mrb_remark = #{mrbRemark}
  511. WHERE
  512. Site = #{site}
  513. AND OrderNo = #{orderNo}
  514. AND ItemNo = #{itemNo}
  515. AND SeqNo = #{seqNo}
  516. </update>
  517. <!--查询派工单MRB信息-->
  518. <select id="getScheduleMrbInfo" parameterType="java.util.Map" resultType="java.util.Map">
  519. SELECT
  520. mrb,
  521. mrb_inspection_report AS mrbInspectionReport,
  522. mrb_remark AS mrbRemark
  523. FROM SOScheduledRouting
  524. WHERE
  525. Site = #{site}
  526. AND OrderNo = #{orderNo}
  527. AND ItemNo = #{itemNo}
  528. AND SeqNo = #{seqNo}
  529. </select>
  530. <!--只更新操作员上岗时间-->
  531. <update id="updateOnDutyTime" parameterType="java.util.Map">
  532. UPDATE sfdc_operator_list
  533. SET on_duty_time = #{onDutyTime}
  534. <where>
  535. <if test="id != null">
  536. AND id = #{id}
  537. </if>
  538. <if test="site != null and site != ''">
  539. AND site = #{site}
  540. </if>
  541. <if test="orderNo != null and orderNo != ''">
  542. AND order_no = #{orderNo}
  543. </if>
  544. <if test="itemNo != null">
  545. AND item_no = #{itemNo}
  546. </if>
  547. <if test="seqNo != null and seqNo != ''">
  548. AND seq_no = #{seqNo}
  549. </if>
  550. <if test="operator != null and operator != ''">
  551. AND operator = #{operator}
  552. </if>
  553. </where>
  554. </update>
  555. <!--按照派工单号查询派工单的数据-->
  556. <select id="getScheduleDataBySeqNo" parameterType="java.lang.String" resultType="ScheduleData">
  557. Select
  558. T.Site site,
  559. T.OrderNo orderNo,
  560. T.ItemNo itemNo,
  561. D.OperationDesc itemDesc,
  562. D.PartNo partNo,
  563. P.PartDescription partDesc,
  564. P.Spec spec,
  565. SO.bu_no buNo,
  566. T.SeqNo seqNo,
  567. T.QtyRequired qtyRequired,
  568. T.QtyReported qtyReported,
  569. (SELECT SUM(RollQty) FROM SFDC_Rolls S WHERE s.Site = T.SITE AND s.VirtualNewRollFlag ='N' and s.RollType ='下道流转') qtyApprove,
  570. ROUND(T.TimeRequired, 3) timeRequired,
  571. T.TimeReported timeReported,
  572. T.PlanStartTime planStartTime,
  573. T.PlanFinishTime planFinishTime,
  574. T.BarcodeID as barcodeId,
  575. T.Remark remark,
  576. T.Crewsize crewSize,
  577. T.ClosedFlag closedFlag,
  578. T.QtyScrapt qtyScrapt,
  579. T.OutWorkFlag outWorkFlag,
  580. T.S_ScheduledDate scheduledDate,
  581. t.S_WorkCenterNo workCenterNo,
  582. T.S_ResourceID resourceId,
  583. dbo.getWorkCenterResourceDesc(T.Site, t.S_WorkCenterNo, T.S_ResourceID) resourceDesc,
  584. E.S_ScheduledSeqNo scheduledSeqNo,
  585. T.S_ShiftNo shiftNo,
  586. D.MachSetupTime machSetupTime,
  587. D.MachRunFactor machRunFactor,
  588. D.FactorUnit factorUnit,
  589. D.Efficiency efficiency,
  590. D.NextItemNo nextItemNo,
  591. dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.NextItemNo) nextItemDesc,
  592. D.PreItemNo preItemNo,
  593. dbo.Get_SOOpsDescription(T.Site,T.OrderNo,D.PreItemNo) preItemDesc,
  594. SO.NeedDate needDate,
  595. T.ParkFlag parkFlag,
  596. P.ConfigurationTemplateID customerName,
  597. P.Remark custPartNo,
  598. t.S_WorkCenterNo workCenterNo,
  599. dbo.Get_WorkCenterDesc(T.Site, T.S_WorkCenterNo) workCenterDesc,
  600. T.QtyRequired_Original qtyRequiredOriginal,
  601. T.ClosedBy closedBy,
  602. T.ClosedDate closedDate,
  603. SO.CostRollUpFlag costRollUpFlag,
  604. SO.RepairSOFlag repairSOFlag,
  605. SO.ManualFlag manualFlag,
  606. T.row_count,
  607. T.roll_count,
  608. T.carrier_no,
  609. d.production_qty,
  610. d.total_roll_qty,
  611. d.total_per_volume,
  612. d.Remark as soRemark,
  613. SO.batch_no as batchNo,
  614. (SELECT count(1) FROM SFDC_Rolls S WHERE s.Site = T.SITE AND s.VirtualNewRollFlag ='N' and s.RollType ='下道流转') as productionRollQty
  615. from SOScheduledRouting as T
  616. Left Join SOScheduledList as E on E.Site = T.Site and E.LinkedSeqNo = T.SeqNo,
  617. SORouting as D, Part as P, ShopOrder as SO
  618. <where>
  619. T.Site=D.Site and T.OrderNo=D.OrderNo and T.ItemNo=D.ItemNo and D.Site=P.Site and D.PartNo=P.PartNo
  620. and T.Site=SO.Site and T.OrderNo=SO.OrderNo and T.OrderNo<![CDATA[ <> ]]>'9999'
  621. AND T.SeqNo = #{seqNo}
  622. </where>
  623. </select>
  624. <!--获取当前的上机卷信息-->
  625. <select id="getCurrentRollOpsBySeqNo" parameterType="BaseRollData" resultType="SfdcRollOpsData">
  626. SELECT TOP 1 sro.Site site, sro.OrderNo orderNo, sro.RollNo rollNo, sro.ItemNo itemNo, sro.SeqNo seqNo,
  627. sro.ScanedBy scanedBy, sro.ScanedDate scanedDate,
  628. sro.StartProdFlag startProdFlag, sro.FirstSetupBy firstSetupBy, sro.FirstSetupDate firstSetupDate,
  629. sro.LatestSetupBy latestSetupBy,
  630. sro.LatestSetupDate latestSetupDate, sro.FirstEndSetupBy firstEndSetupBy, sro.FirstEndSetupDate
  631. firstEndSetupDate, sro.LatestEndSetupBy latestEndSetupBy,
  632. sro.LatestEndSetupDate latestEndSetupDate, sro.FirstProdBy firstProdBy, sro.FirstProdDate firstProdDate,
  633. sro.LatestProdBy latestProdBy,
  634. sro.LatestProdDate latestProdDate, sro.FirstEndProdBy firstEndProdBy, sro.FirstEndProdDate firstEndProdDate,
  635. sro.LatestEndProdBy latestEndProdBy,
  636. sro.LatestEndProdDate latestEndProdDate, sro.FinishedDate finishedDate, sro.FinishedBy finishedBy,
  637. sro.FinishedFlag finishedFlag, sro.PauseFlag pauseFlag,
  638. sro.Remark remark, sro.QtyReported qtyReported, sro.QtyDefected qtyDefected, sro.ReportedFlag reportedFlag
  639. FROM SFDC_RollOps sro
  640. <where>
  641. sro.Site = #{site} AND sro.SeqNo = #{seqNo}
  642. AND sro.FinishedFlag <![CDATA[<>]]> 'Y' AND sro.PauseFlag <![CDATA[<>]]> 'Y'
  643. </where>
  644. </select>
  645. <!--查询派工单的时间记录信息-->
  646. <select id="getSfdcTimeByCon" parameterType="SearchScheduleData" resultType="SfdcTimeData">
  647. SELECT sth.Site site, sth.OrderNo orderNo,sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
  648. sth.RollNo rollNo,
  649. sth.EventTime eventTime, sth.Enteredby enteredby, sth.EventDesc eventDesc, sth.DowntimeCode downtimeCode,
  650. sth.TillTime tillTime,
  651. sth.TillEnteredTime tillEnteredTime, sth.TillEnteredBy tillEnteredBy, sth.CompletedFlag completedFlag,
  652. ROUND(sth.TotalTime, 3) totalTime,
  653. sth.DowntimePhaseIn downtimePhaseIn
  654. FROM SFDC_TimeHist sth
  655. <where>
  656. <if test="site != null and site != ''">
  657. AND sth.Site = #{site}
  658. </if>
  659. <if test="orderNo != null and orderNo != ''">
  660. AND sth.OrderNo = #{orderNo}
  661. </if>
  662. <if test="itemNo != null and itemNo != ''">
  663. AND sth.ItemNo = #{itemNo}
  664. </if>
  665. <if test="seqNo != null and seqNo != ''">
  666. AND sth.SeqNo = #{seqNo}
  667. </if>
  668. <if test="rollNo != null and rollNo != ''">
  669. AND sth.RollNo = #{rollNo}
  670. </if>
  671. </where>
  672. ORDER BY sth.HistSeqNo DESC
  673. </select>
  674. <!--查询工单工序的刀具信息-->
  675. <select id="getOrderToolByCon" parameterType="SearchScheduleData" resultType="ToolInstanceData">
  676. SELECT st.Site site, st.OrderNo orderNo, st.ItemNo itemNo, st.ToolID toolId, th.ToolDescription toolDesc,
  677. th.Spec spec,
  678. st.ToolQty toolQty, th.UMID umid, th.FamilyID familyId, dbo.Get_PartFamilyDesc (st.Site, th.FamilyID)
  679. familyName,
  680. th.Active active, st.Remark remark, st.CreateDate createdDate, st.CreatedBy createdBy
  681. FROM SOTool st
  682. LEFT JOIN ToolHeader th ON st.Site = th.Site AND st.ToolID = th.ToolID
  683. <where>
  684. st.Site = th.Site AND st.ToolID = th.ToolID
  685. <if test="site != null and site != ''">
  686. AND st.Site = #{site}
  687. </if>
  688. <if test="orderNo != null and orderNo != ''">
  689. AND st.OrderNo = #{orderNo}
  690. </if>
  691. <if test="itemNo != null and itemNo != ''">
  692. AND st.ItemNo = #{itemNo}
  693. </if>
  694. </where>
  695. ORDER BY st.ItemNo
  696. </select>
  697. <!--查询派工单的工具记录信息-->
  698. <select id="getSfdcToolByCon" parameterType="SearchScheduleData" resultType="SfdcToolData">
  699. SELECT sth.Site site, sth.OrderNo orderNo, sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
  700. sth.RollNo rollNo,
  701. sth.ReportDate reportedDate, sth.Reportedby reportedby, sth.ToolInstanceID toolInstanceID, sth.StartDate
  702. startDate,
  703. sth.FinishDate finishedDate, sth.FinishFlag finishedFlag, sth.Remark remark, sth.StartFromRollNo
  704. startFromRollNo, sth.FinishQty finishQty
  705. FROM SFDC_ToolingHist sth
  706. <where>
  707. <if test="site != null and site != ''">
  708. AND sth.Site = #{site}
  709. </if>
  710. <if test="orderNo != null and orderNo != ''">
  711. AND sth.OrderNo = #{orderNo}
  712. </if>
  713. <if test="itemNo != null and itemNo != ''">
  714. AND sth.ItemNo = #{itemNo}
  715. </if>
  716. <if test="seqNo != null and seqNo != ''">
  717. AND sth.SeqNo = #{seqNo}
  718. </if>
  719. <if test="rollNo != null and rollNo != ''">
  720. AND sth.RollNo = #{rollNo}
  721. </if>
  722. </where>
  723. ORDER BY sth.HistSeqNo DESC
  724. </select>
  725. <!--获取关联的客户ID-->
  726. <select id="getReferenceCustomerId" parameterType="java.lang.String" resultType="java.lang.String">
  727. SELECT ISNULL(ReferenceCustomerID, '') referenceCustomerID
  728. FROM Site
  729. WHERE SiteID = #{site}
  730. </select>
  731. <!--查询工单的bom信息-->
  732. <select id="getOrderBomByCon" parameterType="SearchScheduleData" resultType="OrderBomData">
  733. SELECT
  734. vss.Site site,
  735. vss.OrderNo orderNo,
  736. vss.ItemNo itemNo,
  737. vss.ComponentPartNo componentPartNo,
  738. P.PartDescription partDesc,
  739. P.Spec partSpec,
  740. U.UMName partUm,
  741. vss.QtyAssembly qtyAssembly,
  742. vss.QtyFixedScrapt qtyFixedScrapt,
  743. vss.ScraptFactor scraptFactor,
  744. vss.Remark remark,
  745. vss.QtyRequired qtyRequired,
  746. vss.QtyIssue qtyIssue,
  747. vss.IssueDate issueDate,
  748. vss.QtyReserved qtyReserved,
  749. vss.MatGroup matGroup,
  750. vss.RMType_DB rmTypeDb,
  751. ISNULL(vss.qtyReturn, 0) as qtyReturn,
  752. CAST (
  753. ROUND(CASE WHEN ISNULL(vss.QtyIssue, 0) > ISNULL(vss.qtyRequired, 0) THEN
  754. ISNULL(vss.QtyIssue, 0) - ISNULL(vss.qtyRequired, 0) ELSE 0 END, 6) AS DECIMAL (18, 6)
  755. ) AS theoryQtyReturn
  756. FROM dbo.view_SAP_SOBOM vss
  757. LEFT JOIN Part P ON vss.Site = P.Site AND vss.ComponentPartNo = P.PartNo
  758. LEFT JOIN UM U ON P.Site = U.Site AND P.UMID = U.UMID
  759. <where>
  760. vss.Site = P.Site AND vss.ComponentPartNo = P.PartNo
  761. <if test="site != null and site != ''">
  762. AND vss.Site = #{site}
  763. </if>
  764. <if test="orderNo != null and orderNo != ''">
  765. AND vss.OrderNo = #{orderNo}
  766. </if>
  767. </where>
  768. ORDER BY vss.ItemNo ASC
  769. </select>
  770. <!-- 更新工单BOM备注 -->
  771. <update id="updateOrderBomRemark">
  772. UPDATE SOBOM
  773. SET Remark = #{remark}
  774. WHERE Site = #{site}
  775. AND OrderNo = #{orderNo}
  776. AND ItemNo = #{itemNo}
  777. </update>
  778. <!--查询派工单时的材料记录信息-->
  779. <select id="getSfdcMaterialByCon" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
  780. SELECT
  781. smh.Site site,
  782. smh.OrderNo orderNo,
  783. smh.ItemNo itemNo,
  784. smh.SeqNo seqNo,
  785. smh.HistSeqNo histSeqNo,
  786. smh.RollNo rollNo,
  787. smh.ReportDate reportDate,
  788. smh.Reportedby reportedby,
  789. smh.RMRollNo rmRollNo,
  790. smh.PartNo partNo,
  791. smh.Remark remark,
  792. smh.StartDate startDate,
  793. smh.FinishDate finishedDate,
  794. smh.FinishFlag finishedFlag,
  795. case when smh.FinishFlag = 'Y' then '是' else '否' end as finishedFlagDesc,
  796. smh.HistType histType,
  797. smh.TransGeneratedFlag transGeneratedFlag,
  798. smh.OriginalRMRollNo originalRMRollNo,
  799. smh.UnissueFlag unissueFlag,
  800. case when smh.UnissueFlag = 'Y' then '是' else '否' end as unissueFlagDesc,
  801. ROUND(smh.TransQty, 3) transQty,
  802. ROUND(smh.NetIssueQty, 3) netIssueQty,
  803. smh.OriginalHistSeqNo originalHistSeqNo,
  804. smh.StartFromRollNo startFromRollNo,
  805. smh.KeyRMFlag keyRMFlag,
  806. case when smh.KeyRMFlag = 'Y' then '是' else '否' end as keyRMFlagDesc,
  807. smh.SAPBOMItemNo sAPBOMItemNo,
  808. smh.Setupflag setupflag,
  809. case when smh.Setupflag = 'Y' then '是' else '否' end as setupFlagDesc,
  810. B.PartDescription AS partDesc, --新增字段:物料名称,放到物料编码下面
  811. B.Spec AS Spec ,--新增字段,放到物料名称下面
  812. I.batch_no as batchNo
  813. FROM SFDC_MaterialHist smh WITH(NOLOCK)
  814. LEFT JOIN Part B WITH(NOLOCK) ON smh.Site = B.Site AND smh.PartNo = B.PartNo
  815. LEFT JOIN inventory_stock I ON SMH.Site = I.Site AND SMH.RMRollNo = I.roll_no
  816. <where>
  817. <if test="site != null and site != ''">
  818. AND smh.Site = #{site}
  819. </if>
  820. <if test="orderNo != null and orderNo != ''">
  821. AND smh.OrderNo = #{orderNo}
  822. </if>
  823. <if test="itemNo != null and itemNo != ''">
  824. AND smh.ItemNo = #{itemNo}
  825. </if>
  826. <if test="seqNo != null and seqNo != ''">
  827. AND smh.SeqNo = #{seqNo}
  828. </if>
  829. <if test="rollNo != null and rollNo != ''">
  830. AND smh.RollNo = #{rollNo}
  831. </if>
  832. <if test="finishedFlag != null and finishedFlag != ''">
  833. AND smh.FinishFlag = #{finishedFlag}
  834. </if>
  835. <if test="keyRMFlag != null and keyRMFlag != ''">
  836. AND smh.KeyRMFlag = #{keyRMFlag}
  837. </if>
  838. <if test="histType != null and histType != ''">
  839. AND smh.HistType = #{histType}
  840. </if>
  841. <if test="bomItemNo != null and bomItemNo > -1">
  842. AND smh.SAPBOMItemNo = #{bomItemNo}
  843. </if>
  844. <if test="histSeqNo != null and histSeqNo > 0">
  845. AND smh.HistSeqNo = #{histSeqNo}
  846. </if>
  847. </where>
  848. ORDER BY (CASE WHEN smh.FinishFlag = 'N' THEN 1 ELSE 999 END ) ASC, smh.HistSeqNo DESC
  849. </select>
  850. <!--按照条件查询上机卷记录-->
  851. <select id="getSfdcRollOpsByCon" parameterType="SearchScheduleData" resultType="SfdcRollOpsData">
  852. SELECT sro.Site site, sro.OrderNo orderNo, sro.RollNo rollNo, sro.ItemNo itemNo, sro.SeqNo seqNo, sro.ScanedBy
  853. scanedBy, sro.ScanedDate scanedDate,
  854. sro.StartProdFlag startProdFlag, sro.FirstSetupBy firstSetupBy, sro.FirstSetupDate firstSetupDate,
  855. sro.LatestSetupBy latestSetupBy,
  856. sro.LatestSetupDate latestSetupDate, sro.FirstEndSetupBy firstEndSetupBy, sro.FirstEndSetupDate
  857. firstEndSetupDate, sro.LatestEndSetupBy latestEndSetupBy,
  858. sro.LatestEndSetupDate latestEndSetupDate, sro.FirstProdBy firstProdBy, sro.FirstProdDate firstProdDate,
  859. sro.LatestProdBy latestProdBy,
  860. sro.LatestProdDate latestProdDate, sro.FirstEndProdBy firstEndProdBy, sro.FirstEndProdDate firstEndProdDate,
  861. sro.LatestEndProdBy latestEndProdBy,
  862. sro.LatestEndProdDate latestEndProdDate, sro.FinishedDate finishedDate, sro.FinishedBy finishedBy,
  863. sro.FinishedFlag finishedFlag, sro.PauseFlag pauseFlag,
  864. sro.Remark remark, sro.QtyReported qtyReported, sro.QtyDefected qtyDefected, sro.ReportedFlag reportedFlag
  865. FROM SFDC_RollOps sro
  866. <where>
  867. <if test="site != null and site != ''">
  868. AND sro.Site = #{site}
  869. </if>
  870. <if test="orderNo != null and orderNo != ''">
  871. AND sro.OrderNo = #{orderNo}
  872. </if>
  873. <if test="itemNo != null and itemNo != ''">
  874. AND sro.ItemNo = #{itemNo}
  875. </if>
  876. <if test="seqNo != null and seqNo != ''">
  877. AND sro.SeqNo = #{seqNo}
  878. </if>
  879. <if test="rollNo != null and rollNo != ''">
  880. AND sro.RollNo = #{rollNo}
  881. </if>
  882. </where>
  883. ORDER BY sro.RollNo DESC
  884. </select>
  885. <!--查询派工单的不良信息记录-->
  886. <select id="getSfdcDefectByCon" parameterType="SearchScheduleData" resultType="SfdcDefectData">
  887. SELECT sdh.Site site, sdh.OrderNo orderNo, sdh.ItemNo itemNo, sdh.SeqNo seqNo, sdh.HistSeqNo histSeqNo,
  888. sdh.RollNo rollNo,
  889. sdh.ReportDate reportedDate, sdh.Reportedby reportedBy, sdh.DefectCode defectCode, sdh.DefectQty defectQty,
  890. sdh.Remark remark,
  891. (SELECT idc.DefectDesc FROM InspectionDefectCode idc WHERE idc.Site = sdh.Site AND idc.DefectCode =
  892. sdh.DefectCode) defectDesc
  893. FROM SFDC_DefectHist sdh
  894. <where>
  895. <if test="site != null and site != ''">
  896. AND sdh.Site = #{site}
  897. </if>
  898. <if test="orderNo != null and orderNo != ''">
  899. AND sdh.OrderNo = #{orderNo}
  900. </if>
  901. <if test="itemNo != null and itemNo != ''">
  902. AND sdh.ItemNo = #{itemNo}
  903. </if>
  904. <if test="seqNo != null and seqNo != ''">
  905. AND sdh.SeqNo = #{seqNo}
  906. </if>
  907. <if test="rollNo != null and rollNo != ''">
  908. AND sdh.RollNo = #{rollNo}
  909. </if>
  910. </where>
  911. ORDER BY sdh.HistSeqNo DESC
  912. </select>
  913. <!--查询派工单的下机卷信息-->
  914. <select id="getSfdcRollByCon" parameterType="SearchScheduleData" resultType="SfdcRollData">
  915. SELECT
  916. sfr.Site site,
  917. sfr.OrderNo orderNo,
  918. sfr.RollNo rollNo,
  919. sfr.CreatedDate createdDate,
  920. sfr.Createdby createdby,
  921. sfr.CurrentOpsItemNo currentOpsItemNo,
  922. sfr.LastFinishedOpsItemNo lastFinishedOpsItemNo,
  923. sfr.FinishedDate finishedDate,
  924. sfr.FinishedFlag finishedFlag,
  925. sfr.OnLineFlag onLineFlag,
  926. sfr.PauseFlag pauseFlag,
  927. sfr.OriRollNo oriRollNo,
  928. sfr.StartOpsItemNo startOpsItemNo,
  929. sfr.RollType rollType,
  930. sfr.CreatedOpsItemNo createdOpsItemNo,
  931. sfr.CreatedOpsSeqNo createdOpsSeqNo,
  932. sfr.RollQty rollQty,
  933. sfr.FirstLevelRollNo firstLevelRollNo,
  934. sfr.VirtualRollFlag virtualRollFlag,
  935. SUM(B.good_qty) AS goodQty,
  936. SUM(B.defect_qty) AS defectQty,
  937. SUM(B.total_qty) AS totalQty,
  938. CASE WHEN SUM(B.total_qty) = 0 THEN CAST(0 AS DECIMAL(18, 2)) ELSE CAST( ROUND( CAST(SUM(B.good_qty) AS DECIMAL(20, 6)) / SUM(B.total_qty) * 100, 2) AS DECIMAL(18, 2) ) END AS yieldRate
  939. FROM
  940. SFDC_Rolls sfr
  941. LEFT JOIN ProductionReport B ON sfr.Site = B.site
  942. AND sfr.OrderNo = B.order_no
  943. AND sfr.CreatedOpsSeqNo = B.seq_no
  944. AND sfr.RollNo = B.roll_no
  945. <where>
  946. ISNULL(virtualNewRollFlag, 'Y') = 'N' and sfr.RollType = '下道流转'
  947. <if test="site != null and site != ''">
  948. AND sfr.Site = #{site}
  949. </if>
  950. <if test="orderNo != null and orderNo != ''">
  951. AND sfr.OrderNo = #{orderNo}
  952. </if>
  953. <if test="itemNo != null and itemNo != ''">
  954. AND sfr.CreatedOpsItemNo = #{itemNo}
  955. </if>
  956. <if test="seqNo != null and seqNo != ''">
  957. AND sfr.CreatedOpsSeqNo = #{seqNo}
  958. </if>
  959. <if test="rollNo != null and rollNo != ''">
  960. AND sfr.RollNo = #{rollNo}
  961. </if>
  962. </where>
  963. GROUP BY sfr.Site,sfr.OrderNo,sfr.RollNo,sfr.CreatedDate,sfr.Createdby,sfr.CurrentOpsItemNo,sfr.LastFinishedOpsItemNo,sfr.FinishedDate,sfr.FinishedFlag,sfr.OnLineFlag,sfr.PauseFlag,sfr.OriRollNo,sfr.StartOpsItemNo,sfr.RollType,sfr.CreatedOpsItemNo,sfr.CreatedOpsSeqNo,sfr.RollQty,sfr.FirstLevelRollNo,sfr.VirtualRollFlag
  964. ORDER BY sfr.RollNo
  965. </select>
  966. <!--查询报工数据-->
  967. <select id="getSfdcDataByCon" parameterType="SearchScheduleData" resultType="SfdcData">
  968. SELECT SUM (ApproveQty) approveQty, SUM (ReportQty - ApproveQty) defectQty, SUM (ReportedManfTime)
  969. reportedManfTime,
  970. SUM (Downtime) downtime
  971. FROM SFDC
  972. <where>
  973. <if test="site != null and site != ''">
  974. AND Site = #{site}
  975. </if>
  976. <if test="orderNo != null and orderNo != ''">
  977. AND OrderNo = #{orderNo}
  978. </if>
  979. <if test="itemNo != null and itemNo != ''">
  980. AND ItemNo = #{itemNo}
  981. </if>
  982. <if test="seqNo != null and seqNo != ''">
  983. AND AssJobSeqNo = #{seqNo}
  984. </if>
  985. <if test="rollNo != null and rollNo != ''">
  986. AND RollNo = #{rollNo}
  987. </if>
  988. </where>
  989. </select>
  990. <!--查询sfdc_roll表的数据-->
  991. <select id="getSfdcRollReportedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
  992. SELECT SUM(RollQty) reportedQty FROM SFDC_Rolls sfr
  993. <where>
  994. <if test="site != null and site != ''">
  995. AND sfr.Site = #{site}
  996. </if>
  997. <if test="orderNo != null and orderNo != ''">
  998. AND sfr.OrderNo = #{orderNo}
  999. </if>
  1000. <if test="itemNo != null and itemNo != ''">
  1001. AND sfr.CreatedOpsItemNo = #{itemNo}
  1002. </if>
  1003. <if test="seqNo != null and seqNo != ''">
  1004. AND sfr.CreatedOpsSeqNo = #{seqNo}
  1005. </if>
  1006. <if test="rollNo != null and rollNo != ''">
  1007. AND sfr.OriRollNo = #{rollNo}
  1008. </if>
  1009. <choose>
  1010. <when test='switchKey != null and switchKey == "V"'>
  1011. AND sfr.VirtualRollFlag<![CDATA[<>]]>'Y'
  1012. </when>
  1013. <when test='switchKey != null and switchKey == "VC"'>
  1014. AND NOT(sfr.VirtualRollFlag='N' AND sfr.CombineFlag='Y')
  1015. </when>
  1016. </choose>
  1017. AND sfr.RollType_DB<![CDATA[<>]]>'C'
  1018. </where>
  1019. </select>
  1020. <!--统计是否报工过-->
  1021. <select id="countSfdcRollByRollNo" parameterType="SearchScheduleData" resultType="java.lang.Integer">
  1022. SELECT COUNT(1) FROM SFDC_Rolls sfr
  1023. <where>
  1024. <if test="site != null and site != ''">
  1025. AND sfr.Site = #{site}
  1026. </if>
  1027. <if test="orderNo != null and orderNo != ''">
  1028. AND sfr.OrderNo = #{orderNo}
  1029. </if>
  1030. <if test="itemNo != null and itemNo != ''">
  1031. AND sfr.CreatedOpsItemNo = #{itemNo}
  1032. </if>
  1033. <if test="seqNo != null and seqNo != ''">
  1034. AND sfr.CreatedOpsSeqNo = #{seqNo}
  1035. </if>
  1036. <if test="rollNo != null and rollNo != ''">
  1037. AND sfr.OriRollNo = #{rollNo}
  1038. </if>
  1039. AND sfr.RollType_DB<![CDATA[<>]]>'C'
  1040. </where>
  1041. </select>
  1042. <!--查询sfdcdefect的数据-->
  1043. <select id="getSfdcDefectDefectedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
  1044. SELECT SUM(sfd.DefectQty) defectQty FROM SFDC_DefectHist sfd
  1045. <where>
  1046. <if test="site != null and site != ''">
  1047. AND sfd.Site = #{site}
  1048. </if>
  1049. <if test="orderNo != null and orderNo != ''">
  1050. AND sfd.OrderNo = #{orderNo}
  1051. </if>
  1052. <if test="itemNo != null and itemNo != ''">
  1053. AND sfd.ItemNo = #{itemNo}
  1054. </if>
  1055. <if test="seqNo != null and seqNo != ''">
  1056. AND sfd.SeqNo = #{seqNo}
  1057. </if>
  1058. <if test="rollNo != null and rollNo != ''">
  1059. AND sfd.RollNo = #{rollNo}
  1060. </if>
  1061. </where>
  1062. </select>
  1063. <!--查询sfdc_time_hist的数据-->
  1064. <select id="countSfdcTimeQty" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1065. SELECT Round(SUM(CASE WHEN EventType='P' AND sfd.EventDesc='开始调机'
  1066. THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
  1067. END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
  1068. ELSE 0.0 END), 2) totalSetupTime
  1069. , Round(SUM(CASE WHEN EventType='D' AND sfd.DowntimePhaseIn='调机'
  1070. THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
  1071. END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
  1072. ELSE 0.0 END), 2) totalDowntimeTimeSetup
  1073. , Round(SUM(CASE WHEN EventType='P' AND sfd.EventDesc='开始生产'
  1074. THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
  1075. END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
  1076. ELSE 0.0 END), 2) totalProdTime
  1077. , Round(SUM(CASE WHEN EventType='D' AND sfd.DowntimePhaseIn='生产'
  1078. THEN ISNULL(((CONVERT(FLOAT,CONVERT(datetime,(CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()
  1079. END))) - CONVERT(FLOAT,EventTime)) * 24),0.0)
  1080. ELSE 0.0 END), 2) totalDowntimeTimeProd
  1081. ,SUM(CASE WHEN CompletedFlag='N' THEN 1.0 ELSE 0.0 END) unCloseLeft
  1082. FROM SFDC_TimeHist sfd
  1083. <where>
  1084. <if test="site != null and site != ''">
  1085. AND sfd.Site = #{site}
  1086. </if>
  1087. <if test="orderNo != null and orderNo != ''">
  1088. AND sfd.OrderNo = #{orderNo}
  1089. </if>
  1090. <if test="itemNo != null and itemNo != ''">
  1091. AND sfd.ItemNo = #{itemNo}
  1092. </if>
  1093. <if test="seqNo != null and seqNo != ''">
  1094. AND sfd.SeqNo = #{seqNo}
  1095. </if>
  1096. <if test="rollNo != null and rollNo != ''">
  1097. AND sfd.RollNo = #{rollNo}
  1098. </if>
  1099. </where>
  1100. </select>
  1101. <!--查询sfdc_time_hist的数据-->
  1102. <select id="getSfdcTimeMaxAndMinTime" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1103. SELECT MIN(sfd.EventTime) eventTime, COUNT(1) sl, ROUND(SUM(TotalTime), 2) totalTime,
  1104. MAX((CASE WHEN sfd.CompletedFlag='Y' THEN sfd.TillTime ELSE getdate()END)) tillTime
  1105. FROM SFDC_TimeHist sfd
  1106. <where>
  1107. <if test="site != null and site != ''">
  1108. AND sfd.Site = #{site}
  1109. </if>
  1110. <if test="orderNo != null and orderNo != ''">
  1111. AND sfd.OrderNo = #{orderNo}
  1112. </if>
  1113. <if test="itemNo != null and itemNo != ''">
  1114. AND sfd.ItemNo = #{itemNo}
  1115. </if>
  1116. <if test="seqNo != null and seqNo != ''">
  1117. AND sfd.SeqNo = #{seqNo}
  1118. </if>
  1119. <if test="rollNo != null and rollNo != ''">
  1120. AND sfd.RollNo = #{rollNo}
  1121. </if>
  1122. AND sfd.EventType='P'
  1123. </where>
  1124. </select>
  1125. <!--查询sfdc_rollops表的数据-->
  1126. <select id="getSfdcRollOpsReportedQty" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1127. SELECT sfo.QtyReported approvedQty, ISNULL((SELECT SUM(DefectQty) FROM SFDC_DefectHist sfd
  1128. WHERE sfo.Site = sfd.Site AND sfo.OrderNo = sfd.OrderNo AND sfo.ItemNo = sfd.ItemNo AND sfo.SeqNo = sfd.SeqNo
  1129. AND sfo.RollNo = sfd.RollNo), 0) defectedQty
  1130. FROM SFDC_RollOps sfo
  1131. <where>
  1132. <if test="site != null and site != ''">
  1133. AND sfo.Site = #{site}
  1134. </if>
  1135. <if test="orderNo != null and orderNo != ''">
  1136. AND sfo.OrderNo = #{orderNo}
  1137. </if>
  1138. <if test="itemNo != null and itemNo != ''">
  1139. AND sfo.ItemNo = #{itemNo}
  1140. </if>
  1141. <if test="seqNo != null and seqNo != ''">
  1142. AND sfo.SeqNo = #{seqNo}
  1143. </if>
  1144. <if test="rollNo != null and rollNo != ''">
  1145. AND sfo.RollNo = #{rollNo}
  1146. </if>
  1147. </where>
  1148. </select>
  1149. <!--查询派工单的班次信息数据-->
  1150. <select id="getScheduleShiftData" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1151. Select WR.ResourceID resourceId,
  1152. CE.ScheduleDate scheduledDate,
  1153. CES.ShiftNo shiftNo,
  1154. CES.ShiftDesc shiftDesc,
  1155. (CONVERT(Decimal(20, 6), CE.ScheduleDate) + CONVERT(Decimal(20, 6), CES.StartTime / 24.0)) startTime,
  1156. (CONVERT(Decimal(20, 6), CE.ScheduleDate) + CONVERT(Decimal(20, 6), CES.EndTime / 24.0) +
  1157. (case when CES.EndTime <![CDATA[<]]> CES.StartTime then 1.0 else 0.0 end)) endTime,
  1158. (CONVERT(Decimal(20, 6), Convert(datetime, #{currentTime}))) curTime
  1159. from WorkCenterResource as WR
  1160. , Calendar_Exception as CE
  1161. , Calendar_Exception_Shift CES
  1162. where WR.Site = CE.Site
  1163. and WR.CalendarID = CE.CalendarID
  1164. and CE.Site = CES.Site
  1165. and CE.CalendarID = CES.CalendarID
  1166. and CE.ScheduleDate = CES.ScheduleDate
  1167. and WR.Site = '1'
  1168. and WR.ResourceID = #{resourceId}
  1169. and CONVERT(Decimal(20, 6), CE.ScheduleDate)<![CDATA[ >=]]>
  1170. Convert(Decimal(20, 6), Convert(datetime, #{currentDate})) - 1
  1171. and CONVERT(Decimal(20, 6), CE.ScheduleDate)<![CDATA[ <=]]>
  1172. Convert(Decimal(20, 6), Convert(datetime, #{currentDate})) + 1
  1173. Order by CE.ScheduleDate, CES.StartTime
  1174. </select>
  1175. <!--查询sfdc的时间数据-->
  1176. <select id="getSfdcTimeData" parameterType="SearchScheduleData" resultType="java.util.Map">
  1177. SELECT MAX(finishtime) finishTime, SUM(ReportedSetupTime) reportedSetupTime, SUM(ReportedManfTime)
  1178. reportedManfTime,
  1179. SUM(Downtime) downTime, SUM(ReportedSetupDowntime) reportedSetupDowntime, SUM(ReportedManfDowntime)
  1180. reportedManfDowntime
  1181. FROM SFDC
  1182. <where>
  1183. <if test="site != null and site != ''">
  1184. AND Site = #{site}
  1185. </if>
  1186. <if test="orderNo != null and orderNo != ''">
  1187. AND OrderNo = #{orderNo}
  1188. </if>
  1189. <if test="itemNo != null and itemNo != ''">
  1190. AND ItemNo = #{itemNo}
  1191. </if>
  1192. AND AssJobSeqNo = #{seqNo} AND RollNo = #{rollNo} AND InAdvanceflag='Y'
  1193. </where>
  1194. </select>
  1195. <select id="getSfdcMaterialByRollNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
  1196. SELECT smh.Site site, smh.OrderNo orderNo, smh.ItemNo itemNo, smh.SeqNo seqNo, smh.HistSeqNo histSeqNo,
  1197. smh.RollNo rollNo, smh.ReportDate reportDate,
  1198. smh.Reportedby reportedby, smh.RMRollNo rmRollNo, smh.PartNo partNo, smh.Remark remark, smh.StartDate startDate,
  1199. smh.FinishDate finishedDate,
  1200. smh.FinishFlag finishedFlag, smh.HistType histType, smh.TransGeneratedFlag transGeneratedFlag,
  1201. smh.OriginalRMRollNo originalRMRollNo,
  1202. smh.UnissueFlag unissueFlag, ROUND(smh.TransQty, 3) transQty, ROUND(smh.NetIssueQty, 3) netIssueQty,
  1203. smh.OriginalHistSeqNo originalHistSeqNo,
  1204. smh.StartFromRollNo startFromRollNo, smh.KeyRMFlag keyRMFlag, smh.SAPBOMItemNo sAPBOMItemNo, smh.Setupflag
  1205. setupflag
  1206. FROM SFDC_MaterialHist smh
  1207. <where>
  1208. <if test="site != null and site != ''">
  1209. AND smh.Site = #{site}
  1210. </if>
  1211. <if test="orderNo != null and orderNo != ''">
  1212. AND smh.OrderNo = #{orderNo}
  1213. </if>
  1214. <if test="itemNo != null and itemNo != ''">
  1215. AND smh.ItemNo = #{itemNo}
  1216. </if>
  1217. <if test="seqNo != null and seqNo != ''">
  1218. AND smh.SeqNo = #{seqNo}
  1219. </if>
  1220. <if test="rollNo != null and rollNo != ''">
  1221. AND smh.RollNo = #{rollNo}
  1222. </if>
  1223. <if test="finishedFlag != null and finishedFlag != ''">
  1224. AND smh.FinishFlag = #{finishedFlag}
  1225. </if>
  1226. <if test="keyRMFlag != null and keyRMFlag != ''">
  1227. AND smh.KeyRMFlag = #{keyRMFlag}
  1228. </if>
  1229. <if test="histType != null and histType != ''">
  1230. AND smh.HistType = #{histType}
  1231. </if>
  1232. </where>
  1233. ORDER BY smh.HistSeqNo DESC
  1234. </select>
  1235. <!--检查派工单是否关闭-->
  1236. <select id="checkScheduleStatus" parameterType="SearchScheduleData" resultType="java.lang.Integer">
  1237. SELECT COUNT(1) FROM SOScheduledRouting ssr
  1238. <where>
  1239. <if test="site != null and site != ''">
  1240. AND ssr.Site = #{site}
  1241. </if>
  1242. <if test="orderNo != null and orderNo != ''">
  1243. AND ssr.OrderNo = #{orderNo}
  1244. </if>
  1245. <if test="itemNo != null and itemNo != ''">
  1246. AND ssr.ItemNo = #{itemNo}
  1247. </if>
  1248. <if test="seqNo != null and seqNo != ''">
  1249. AND ssr.SeqNo = #{seqNo}
  1250. </if>
  1251. <if test="closedFlag != null and closedFlag != ''">
  1252. AND ssr.ClosedFlag = #{closedFlag}
  1253. </if>
  1254. </where>
  1255. </select>
  1256. <!--获取rollId和normalRollId-->
  1257. <select id="getRollIdAndNormalRollIdByCon" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1258. SELECT MAX(RollID) rollId, MAX(NormalRollID) normalRollId FROM SFDC_Rolls ssr
  1259. <where>
  1260. <if test="site != null and site != ''">
  1261. AND ssr.Site = #{site}
  1262. </if>
  1263. <if test="orderNo != null and orderNo != ''">
  1264. AND ssr.OrderNo = #{orderNo}
  1265. </if>
  1266. </where>
  1267. </select>
  1268. <!--插入sfdcRolls的数据-->
  1269. <insert id="insertSfdcRolls" parameterType="SfdcRollData">
  1270. INSERT INTO SFDC_Rolls(Site, OrderNo, RollID, RollNo, CreatedDate, Createdby, CreatedOpsItemNo, CreatedOpsSeqNo,
  1271. CurrentOpsItemNo, LastFinishedOpsItemNo, FinishedDate,
  1272. FinishedFlag, OnLineFlag, PauseFlag, OriRollNo, Remark, StartOpsItemNo, RollType,
  1273. RollType_DB, RollQty, FirstLevelRollNo, FGRollFlag, FGRollID,
  1274. NormalRollID, CombineFlag, VirtualRollFlag, VirtualLinkRollNo, CQCPassFlag,
  1275. CQCInspectedFlag, CQCNeedInspectFlag)
  1276. VALUES (#{site}, #{orderNo}, #{rollId}, #{rollNo}, #{createdDate}, #{createdBy}, #{createdOpsItemNo},
  1277. #{createdOpsSeqNo}, #{currentOpsItemNo}, #{lastFinishedOpsItemNo}, #{finishedDate},
  1278. #{finishedFlag}, #{onLineFlag}, #{pauseFlag}, #{oriRollNo}, #{remark}, #{startOpsItemNo}, #{rollType},
  1279. #{rollTypeDb}, #{rollQty}, #{firstLevelRollNo}, #{fgRollFlag}, #{fgRollId},
  1280. #{normalRollId}, #{combineFlag}, #{virtualRollFlag}, #{virtualLinkRollNo}, #{cqcPassFlag},
  1281. #{cqcInspectedFlag}, #{cqcNeedInspectFlag})
  1282. </insert>
  1283. <!--插入sfdcRollOps的数据-->
  1284. <insert id="insertSfdcRollOps" parameterType="SfdcRollData">
  1285. INSERT INTO SFDC_RollOps(Site, OrderNo, RollNo, ItemNo, SeqNo, StartProdFlag, FinishedFlag, PauseFlag,
  1286. ScanedBy, ScanedDate, Remark, QtyReported, QtyDefected, ReportedFlag)
  1287. VALUES (#{site}, #{orderNo}, #{rollNo}, #{itemNo}, #{seqNo}, #{startProdFlag}, #{finishedFlag}, #{pauseFlag},
  1288. #{scanedBy}, #{scanedDate}, #{remark}, #{qtyReported}, #{qtyDefected}, #{reportedFlag})
  1289. </insert>
  1290. <!--根据条件或者材料卷数据-->
  1291. <select id="getCRollInfoByRollNo" parameterType="SearchScheduleData" resultType="CRollInfoOutData">
  1292. SELECT cri.rollno rollNo,
  1293. cri.partno partNo,
  1294. part.PartDescription partDesc,
  1295. cri.rolltype rollType,
  1296. cri.rolltype_db rollTypeDb,
  1297. status status,
  1298. cri.status_db statusDb,
  1299. cri.rollqty rollQty,
  1300. cri.site,
  1301. cri.SourceType orderRefType,
  1302. cri.orderref1 orderRef1,
  1303. cri.orderref2 orderRef2,
  1304. cri.orderref3 orderRef3,
  1305. cri.frozenflag frozenFlag
  1306. FROM C_RollInfo cri
  1307. LEFT JOIN Part part ON part.Site = cri.site AND part.PartNo = cri.partno
  1308. WHERE cri.site = #{site}
  1309. AND cri.rollno = #{rmRollNo}
  1310. </select>
  1311. <!--根据条件或者材料卷数据-->
  1312. <select id="getInventoryStockByRollNo" parameterType="SearchScheduleData" resultType="CRollInfoOutData">
  1313. SELECT cri.roll_no rollNo,
  1314. cri.part_no partNo,
  1315. part.PartDescription partDesc,
  1316. '合格卷' rollType,
  1317. '0' rollTypeDb,
  1318. status status,
  1319. cri.status_tb statusDb,
  1320. cri.qty_on_hand rollQty,
  1321. cri.site,
  1322. cri.orderref0 orderRefType,
  1323. cri.orderref1 orderRef1,
  1324. cri.orderref2 orderRef2,
  1325. cri.orderref3 orderRef3,
  1326. case when cri.status='冻结' then 'Y' else 'N' end frozenFlag
  1327. FROM inventory_stock cri
  1328. inner JOIN Part part ON part.Site = cri.site AND part.PartNo = cri.part_no
  1329. WHERE cri.site = #{site}
  1330. AND cri.roll_no = #{rmRollNo}
  1331. </select>
  1332. <!--根据工单和物料自动获取bom行数据-->
  1333. <select id="getBomItemNosByPartNo" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1334. SELECT Site site,
  1335. OrderNo orderNo,
  1336. CONVERT(INT, ItemNo) itemNo,
  1337. ComponentPartNo partNo,
  1338. dbo.Get_PartDesc(Site, ComponentPartNo) partDesc,
  1339. QtyAssembly qtyAssembly,
  1340. QtyFixedScrapt qtyFixedScrapt,
  1341. ScraptFactor scraptFactor,
  1342. Remark remark,
  1343. QtyRequired qtyRequired,
  1344. QtyIssue qtyIssue,
  1345. CONVERT(VARCHAR(20), IssueDate, 120) issueDate,
  1346. QtyReserved qtyReserved,
  1347. MatGroup matGroup,
  1348. QtyNotified qtyNotified,
  1349. RMType_DB rmTypeDb,
  1350. IssueType issueType
  1351. FROM dbo.view_SAP_SOBOM vss
  1352. WHERE vss.Site = #{site}
  1353. AND vss.OrderNo = #{orderNo}
  1354. AND vss.ComponentPartNo = #{rmPartNo}
  1355. </select>
  1356. <!--查询材料的上机卷记录数据-->
  1357. <select id="getBomItemNosByPartNo" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1358. SELECT OrderNo + '/' + CONVERT(VARCHAR(20), ItemNo) + '/' + CONVERT(VARCHAR(20), SeqNo) orderInfo
  1359. FROM SFDC_MaterialHist
  1360. WHERE Site = #{site}
  1361. AND RMRollNo = #{rmPartNo}
  1362. </select>
  1363. <!--查询派工单时的材料记录信息-->
  1364. <select id="getSfdcMaterialByBomItemNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
  1365. SELECT smh.Site site, smh.OrderNo orderNo, smh.ItemNo itemNo, smh.SeqNo seqNo, smh.HistSeqNo histSeqNo,
  1366. smh.RollNo rollNo, smh.ReportDate reportDate,
  1367. smh.Reportedby reportedby, smh.RMRollNo rmRollNo, smh.PartNo partNo, smh.Remark remark, smh.StartDate startDate,
  1368. smh.FinishDate finishedDate,
  1369. smh.FinishFlag finishedFlag, smh.HistType histType, smh.TransGeneratedFlag transGeneratedFlag,
  1370. smh.OriginalRMRollNo originalRMRollNo,
  1371. smh.UnissueFlag unissueFlag, ROUND(smh.TransQty, 3) transQty, ROUND(smh.NetIssueQty, 3) netIssueQty,
  1372. smh.OriginalHistSeqNo originalHistSeqNo,
  1373. smh.StartFromRollNo startFromRollNo, smh.KeyRMFlag keyRMFlag, smh.SAPBOMItemNo sAPBOMItemNo, smh.Setupflag
  1374. setupflag
  1375. FROM SFDC_MaterialHist smh
  1376. <where>
  1377. <if test="site != null and site != ''">
  1378. AND smh.Site = #{site}
  1379. </if>
  1380. <if test="orderNo != null and orderNo != ''">
  1381. AND smh.OrderNo = #{orderNo}
  1382. </if>
  1383. <if test="itemNo != null and itemNo > 0">
  1384. AND smh.ItemNo = #{itemNo}
  1385. </if>
  1386. <if test="seqNo != null and seqNo != ''">
  1387. AND smh.SeqNo = #{seqNo}
  1388. </if>
  1389. <if test="bomItemNo != null and bomItemNo > -1">
  1390. AND smh.SAPBOMItemNo = #{bomItemNo}
  1391. </if>
  1392. </where>
  1393. ORDER BY smh.HistSeqNo DESC
  1394. </select>
  1395. <!--查询派工单时的材料记录信息-->
  1396. <select id="getSfdcMaterialByBomItemNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
  1397. SELECT COUNT(1) FROM SFDC_MaterialHist smh
  1398. <where>
  1399. <if test="site != null and site != ''">
  1400. AND smh.Site = #{site}
  1401. </if>
  1402. <if test="orderNo != null and orderNo != ''">
  1403. AND smh.OrderNo = #{orderNo}
  1404. </if>
  1405. <if test="itemNo != null and itemNo > 0">
  1406. AND smh.ItemNo = #{itemNo}
  1407. </if>
  1408. <if test="seqNo != null and seqNo != ''">
  1409. AND smh.SeqNo = #{seqNo}
  1410. </if>
  1411. <if test="rollNo != null and rollNo != ''">
  1412. AND smh.RollNo = #{rollNo}
  1413. </if>
  1414. <if test="rmPartNo != null and rmPartNo != ''">
  1415. AND smh.PartNo = #{rmPartNo}
  1416. </if>
  1417. <if test="finishedFlag != null and finishedFlag != ''">
  1418. AND smh.FinishFlag = #{finishedFlag}
  1419. </if>
  1420. <if test="histType != null and histType != ''">
  1421. AND smh.HistType = #{histType}
  1422. </if>
  1423. </where>
  1424. ORDER BY smh.HistSeqNo DESC
  1425. </select>
  1426. <!--查询派工单的不良记录-->
  1427. <select id="getScheduleDefectHist" parameterType="SearchScheduleData" resultType="SfdcDefectData">
  1428. SELECT sdh.Site site, sdh.OrderNo orderNo, sdh.ItemNo itemNo, sdh.SeqNo seqNo, sdh.HistSeqNo histSeqNo,
  1429. sdh.RollNo rollNo,
  1430. sdh.ReportDate reportedDate, sdh.Reportedby reportedBy, sdh.DefectCode defectCode, sdh.DefectQty defectQty,
  1431. sdh.Remark remark,
  1432. (SELECT idc.DefectDesc FROM InspectionDefectCode idc WHERE idc.Site = sdh.Site AND idc.DefectCode =
  1433. sdh.DefectCode) defectDesc
  1434. FROM SFDC_DefectHist sdh
  1435. <where>
  1436. <if test="site != null and site != ''">
  1437. AND sdh.Site = #{site}
  1438. </if>
  1439. <if test="orderNo != null and orderNo != ''">
  1440. AND sdh.OrderNo = #{orderNo}
  1441. </if>
  1442. <if test="itemNo != null and itemNo != ''">
  1443. AND sdh.ItemNo = #{itemNo}
  1444. </if>
  1445. <if test="seqNo != null and seqNo != ''">
  1446. AND sdh.SeqNo = #{seqNo}
  1447. </if>
  1448. </where>
  1449. ORDER BY sdh.HistSeqNo DESC
  1450. </select>
  1451. <!--查询派工单的不良记录-->
  1452. <select id="countToolUsedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
  1453. SELECT SUM(FinishQty)
  1454. FROM SFDC_ToolingHist sth
  1455. WHERE sth.Site = #{site}
  1456. AND sth.OrderNo = #{orderNo}
  1457. AND sth.ItemNo = #{itemNo}
  1458. AND sth.SeqNo = #{seqNo}
  1459. AND sth.RollNo <![CDATA[<>]]> #{rollNo}
  1460. AND sth.ToolInstanceID = #{oriToolInstanceId}
  1461. </select>
  1462. <!--查询派工单的时间记录信息-->
  1463. <select id="getSfdcTimeHistBySeqNo" parameterType="SearchScheduleData" resultType="SfdcTimeData">
  1464. SELECT sth.Site site, sth.OrderNo orderNo,sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
  1465. sth.RollNo rollNo,
  1466. sth.EventTime eventTime, sth.Enteredby enteredby, sth.EventDesc eventDesc, sth.DowntimeCode downtimeCode,
  1467. sth.TillTime tillTime,
  1468. sth.TillEnteredTime tillEnteredTime, sth.TillEnteredBy tillEnteredBy, sth.CompletedFlag completedFlag,
  1469. ROUND(sth.TotalTime, 3) totalTime,
  1470. sth.DowntimePhaseIn downtimePhaseIn
  1471. FROM SFDC_TimeHist sth
  1472. <where>
  1473. <if test="site != null and site != ''">
  1474. AND sth.Site = #{site}
  1475. </if>
  1476. <if test="orderNo != null and orderNo != ''">
  1477. AND sth.OrderNo = #{orderNo}
  1478. </if>
  1479. <if test="itemNo != null and itemNo != ''">
  1480. AND sth.ItemNo = #{itemNo}
  1481. </if>
  1482. <if test="seqNo != null and seqNo != ''">
  1483. AND sth.SeqNo = #{seqNo}
  1484. </if>
  1485. <if test='showNoFinishedTimeFlag != null and showNoFinishedTimeFlag != "" and showNoFinishedTimeFlag == "Y"'>
  1486. AND sth.CompletedFlag = 'N'
  1487. </if>
  1488. </where>
  1489. ORDER BY sth.HistSeqNo DESC
  1490. </select>
  1491. <!--查询派工单的工具记录信息-->
  1492. <select id="getSfdcToolHistBySeqNo" parameterType="SearchScheduleData" resultType="SfdcToolData">
  1493. SELECT sth.Site site, sth.OrderNo orderNo, sth.ItemNo itemNo, sth.SeqNo seqNo, sth.HistSeqNo histSeqNo,
  1494. sth.RollNo rollNo,
  1495. sth.ReportDate reportedDate, sth.Reportedby reportedby, sth.ToolInstanceID toolInstanceID, sth.StartDate
  1496. startDate,
  1497. sth.FinishDate finishedDate, sth.FinishFlag finishedFlag, sth.Remark remark, sth.StartFromRollNo
  1498. startFromRollNo, sth.FinishQty finishQty
  1499. FROM SFDC_ToolingHist sth
  1500. <where>
  1501. <if test="site != null and site != ''">
  1502. AND sth.Site = #{site}
  1503. </if>
  1504. <if test="orderNo != null and orderNo != ''">
  1505. AND sth.OrderNo = #{orderNo}
  1506. </if>
  1507. <if test="itemNo != null and itemNo != ''">
  1508. AND sth.ItemNo = #{itemNo}
  1509. </if>
  1510. <if test="seqNo != null and seqNo != ''">
  1511. AND sth.SeqNo = #{seqNo}
  1512. </if>
  1513. <if test='showNoFinishedToolFlag != null and showNoFinishedToolFlag != "" and showNoFinishedToolFlag == "Y"'>
  1514. AND sth.FinishFlag = 'N'
  1515. </if>
  1516. </where>
  1517. ORDER BY sth.HistSeqNo DESC
  1518. </select>
  1519. <!--查询派工单时的材料记录信息-->
  1520. <select id="getSfdcMaterialHistBySeqNo" parameterType="SearchScheduleData" resultType="SfdcMaterialData">
  1521. SELECT smh.Site site, smh.OrderNo orderNo, smh.ItemNo itemNo, smh.SeqNo seqNo, smh.HistSeqNo histSeqNo,
  1522. smh.RollNo rollNo, smh.ReportDate reportDate,
  1523. smh.Reportedby reportedby, smh.RMRollNo rmRollNo, smh.PartNo partNo, smh.Remark remark, smh.StartDate startDate,
  1524. smh.FinishDate finishedDate,
  1525. smh.FinishFlag finishedFlag, smh.HistType histType, smh.TransGeneratedFlag transGeneratedFlag,
  1526. smh.OriginalRMRollNo originalRMRollNo,
  1527. smh.UnissueFlag unissueFlag, ROUND(smh.TransQty, 3) transQty, ROUND(smh.NetIssueQty, 3) netIssueQty,
  1528. smh.OriginalHistSeqNo originalHistSeqNo,
  1529. smh.StartFromRollNo startFromRollNo, smh.KeyRMFlag keyRMFlag, smh.SAPBOMItemNo sAPBOMItemNo, smh.Setupflag
  1530. setupflag
  1531. FROM SFDC_MaterialHist smh
  1532. <where>
  1533. <if test="site != null and site != ''">
  1534. AND smh.Site = #{site}
  1535. </if>
  1536. <if test="orderNo != null and orderNo != ''">
  1537. AND smh.OrderNo = #{orderNo}
  1538. </if>
  1539. <if test="itemNo != null and itemNo != ''">
  1540. AND smh.ItemNo = #{itemNo}
  1541. </if>
  1542. <if test="seqNo != null and seqNo != ''">
  1543. AND smh.SeqNo = #{seqNo}
  1544. </if>
  1545. <if test='showNoFinishedMaterialFlag != null and showNoFinishedMaterialFlag != "" and showNoFinishedMaterialFlag == "Y"'>
  1546. AND smh.FinishFlag = 'N'
  1547. </if>
  1548. </where>
  1549. ORDER BY smh.HistSeqNo DESC
  1550. </select>
  1551. <!--获取当前加工中心机台对应的calendarId-->
  1552. <select id="getCalendarId" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1553. SELECT wcr.CalendarID calendarId,
  1554. (SELECT cd.CalendarDesc
  1555. FROM Calendar cd
  1556. WHERE wcr.Site = cd.Site
  1557. AND wcr.CalendarID = cd.CalendarID) calendarDesc,
  1558. Efficiency efficiency
  1559. FROM WorkCenterResource wcr
  1560. WHERE wcr.Site = #{site}
  1561. AND wcr.WorkCenterNo = #{workCenterNo}
  1562. AND wcr.ResourceID = #{resourceId}
  1563. </select>
  1564. <!--获取班次选择的数据-->
  1565. <select id="getScheduleShiftWithSelect" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1566. SELECT WR.ResourceID resourceId,
  1567. CONVERT(VARCHAR(10), CE.ScheduleDate, 120) scheduleDate,
  1568. CES.ShiftNo shiftNo,
  1569. CES.ShiftDesc shiftDesc,
  1570. CONVERT(VARCHAR(5), CES.StartExactTime, 108) startTime,
  1571. CONVERT(VARCHAR(5), CES.EndExactTime, 108) endTime,
  1572. (CASE WHEN CES.EndTime <![CDATA[<]]> CES.StartTime THEN 'Y' ELSE 'N' END) nextDayFlag
  1573. FROM WorkCenterResource WR,
  1574. Calendar_Exception CE,
  1575. Calendar_Exception_Shift CES
  1576. WHERE WR.Site = CE.Site
  1577. and WR.CalendarID = CE.CalendarID
  1578. AND CE.Site = CES.Site
  1579. and CE.CalendarID = CES.CalendarID
  1580. and CE.ScheduleDate = CES.ScheduleDate
  1581. AND WR.Site = #{site}
  1582. AND WR.ResourceID = #{resourceId}
  1583. AND CONVERT(DECIMAL(20, 6), CE.ScheduleDate)<![CDATA[ >=]]>
  1584. CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{scheduledDate})) - 1
  1585. AND CONVERT(DECIMAL(20, 6), CE.ScheduleDate)<![CDATA[ <=]]>
  1586. CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{scheduledDate})) + 1
  1587. AND (CONVERT(DECIMAL(20, 6), CE.ScheduleDate) + CONVERT(DECIMAL(20, 6), CES.StartTime / 24.0)) <![CDATA[<=]]>
  1588. (CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{scheduledDate})) +
  1589. (CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{reportedTime})) -
  1590. floor(CONVERT(DECIMAL(20, 6), CONVERT(datetime, #{reportedTime})))))
  1591. ORDER BY CE.ScheduleDate, CES.Starttime
  1592. </select>
  1593. <select id="searchFqcSfdcRolls" resultType="com.gaotao.modules.schedule.data.SfdcRollData">
  1594. SELECT sfr.Site site, sfr.OrderNo orderNo, sfr.RollNo rollNo, sfr.CreatedDate createdDate, sfr.Createdby
  1595. createdby, sfr.CurrentOpsItemNo currentOpsItemNo,
  1596. sfr.LastFinishedOpsItemNo lastFinishedOpsItemNo, sfr.FinishedDate finishedDate, sfr.FinishedFlag finishedFlag,
  1597. sfr.OnLineFlag onLineFlag,
  1598. sfr.PauseFlag pauseFlag, sfr.OriRollNo oriRollNo, sfr.StartOpsItemNo startOpsItemNo, sfr.RollType rollType,
  1599. sfr.CreatedOpsItemNo createdOpsItemNo,
  1600. sfr.CreatedOpsSeqNo createdOpsSeqNo, sfr.RollQty rollQty, sfr.FirstLevelRollNo firstLevelRollNo,
  1601. sfr.VirtualRollFlag virtualRollFlag
  1602. FROM SFDC_Rolls sfr
  1603. <where>
  1604. sfr.Site= #{site}
  1605. and sfr.OrderNo=#{orderNo}
  1606. and sfr.StartOpsItemNo <![CDATA[ <= ]]> #{itemNo}
  1607. and sfr.CQCPassFlag='N'
  1608. and sfr.FinishedFlag='N'
  1609. and sfr.CQCInspectedFlag='Y'
  1610. <if test=" rollNo != null and rollNo != ''">
  1611. and sfr.RollNo like '%' + #{rollNo} + '%'
  1612. </if>
  1613. </where>
  1614. </select>
  1615. <select id="getReworkSfdcRollByCon" resultType="com.gaotao.modules.schedule.data.SfdcRollData">
  1616. SELECT sfr.Site site, sfr.OrderNo orderNo, sfr.RollNo rollNo, sfr.CreatedDate createdDate, sfr.Createdby
  1617. createdby, sfr.CurrentOpsItemNo currentOpsItemNo,
  1618. sfr.LastFinishedOpsItemNo lastFinishedOpsItemNo, sfr.FinishedDate finishedDate, sfr.FinishedFlag finishedFlag,
  1619. sfr.OnLineFlag onLineFlag,
  1620. sfr.PauseFlag pauseFlag, sfr.OriRollNo oriRollNo, sfr.StartOpsItemNo startOpsItemNo, sfr.RollType rollType,
  1621. sfr.CreatedOpsItemNo createdOpsItemNo,
  1622. sfr.CreatedOpsSeqNo createdOpsSeqNo, sfr.RollQty rollQty, sfr.FirstLevelRollNo firstLevelRollNo,
  1623. sfr.VirtualRollFlag virtualRollFlag,
  1624. sfr.CombineFlag combineFlag
  1625. FROM SFDC_Rolls sfr
  1626. <where>
  1627. <if test="site != null and site != ''">
  1628. AND sfr.Site = #{site}
  1629. </if>
  1630. <if test="orderNo != null and orderNo != ''">
  1631. AND sfr.OrderNo = #{orderNo}
  1632. </if>
  1633. <if test="itemNo != null and itemNo != ''">
  1634. AND sfr.CreatedOpsItemNo = #{itemNo}
  1635. </if>
  1636. <if test="seqNo != null and seqNo != ''">
  1637. AND sfr.CreatedOpsSeqNo = #{seqNo}
  1638. </if>
  1639. <if test="rollNo != null and rollNo != ''">
  1640. AND sfr.RollNo = #{rollNo}
  1641. </if>
  1642. </where>
  1643. Union all
  1644. Select
  1645. T.Site,T.OrderNo,D.RollNo,D.CreatedDate,D.Createdby,D.CurrentOpsItemNo,D.LastFinishedOpsItemNo,D.FinishedDate,D.FinishedFlag
  1646. ,D.OnLineFlag,D.PauseFlag,D.OriRollNo,D.StartOpsItemNo,D.RollType,D.CreatedOpsItemNo,D.CreatedOpsSeqNo,D.RollQty,D.FirstLevelRollNo
  1647. ,D.FGRollFlag,D.CombineFlag
  1648. from SFDC_RollOps as T,SFDC_Rolls as D
  1649. Where T.Site=D.Site and T.OrderNo=D.OrderNo and T.RollNo=D.RollNo
  1650. and T.Site=#{site}
  1651. and T.OrderNo=#{orderNo}
  1652. and T.ItemNo=#{itemNo}
  1653. and T.SeqNo=#{seqNo}
  1654. and T.Remark='直接送检'
  1655. ORDER BY sfr.RollNo
  1656. </select>
  1657. <select id="reportCheck" resultType="java.lang.Integer">
  1658. Select count(1)
  1659. from SOScheduledRouting as T
  1660. Where Site = #{site}
  1661. and S_ResourceID = #{resourceId}
  1662. and S_WorkCenterNo = #{workCenterNo}
  1663. and SeqNo != #{seqNo}
  1664. and ClosedFlag = 'N'
  1665. and StartProdFlag = 'Y'
  1666. and (
  1667. (case
  1668. when exists(select 1
  1669. from SFDC_MaterialHist as T1
  1670. where T1.Site = T.Site
  1671. and T1.OrderNo = T.OrderNo
  1672. and T1.ItemNo = T.ItemNo
  1673. and T1.SeqNo = T.SeqNo
  1674. and T1.FinishFlag = 'N'
  1675. )
  1676. then 1
  1677. else 0 end
  1678. )
  1679. +
  1680. (case
  1681. when exists(select 1
  1682. from SFDC_ToolingHist as T2
  1683. where T2.Site = T.Site
  1684. and T2.OrderNo = T.OrderNo
  1685. and T2.ItemNo = T.ItemNo
  1686. and T2.SeqNo = T.SeqNo
  1687. and T2.FinishFlag = 'N'
  1688. )
  1689. then 1
  1690. else 0 end
  1691. )
  1692. +
  1693. (case
  1694. when exists(select 1
  1695. from SFDC_TimeHist as T3
  1696. where T3.Site = T.Site
  1697. and T3.OrderNo = T.OrderNo
  1698. and T3.ItemNo = T.ItemNo
  1699. and T3.SeqNo = T.SeqNo
  1700. and T3.CompletedFlag = 'N'
  1701. )
  1702. then 1
  1703. else 0 end
  1704. )
  1705. +
  1706. (case
  1707. when exists(select 1
  1708. from SFDC_RollOps as T4
  1709. where T4.Site = T.Site
  1710. and T4.OrderNo = T.OrderNo
  1711. and T4.ItemNo = T.ItemNo
  1712. and T4.SeqNo = T.SeqNo
  1713. and T4.FinishedFlag = 'N'
  1714. )
  1715. then 1
  1716. else 0 end
  1717. )
  1718. ) > 0
  1719. </select>
  1720. <select id="getUserSpecialSecurity" resultType="java.lang.String">
  1721. select dbo.Get_User_Special_Security(#{username}, #{sNo})
  1722. </select>
  1723. <insert id="saveSfdcDefect" parameterType="SfdcDefectData">
  1724. INSERT INTO SFDC_DefectHist(Site, OrderNo, ItemNo, SeqNo, HistSeqNo, ReportDate, Reportedby, DefectCode,
  1725. DefectQty, RollNo)
  1726. VALUES (#{site}, #{orderNo}, #{itemNo}, #{seqNo}, #{histSeqNo}, #{reportedDate}, #{reportedBy}, #{defectCode},
  1727. #{defectQty}, #{rollNo})
  1728. </insert>
  1729. <insert id="saveSfdcDefectList">
  1730. INSERT INTO
  1731. SFDC_DefectHist(Site,OrderNo,ItemNo,SeqNo,HistSeqNo,ReportDate,Reportedby,DefectCode,DefectQty,RollNo)
  1732. VALUES
  1733. <foreach collection="list" separator="," item="item">
  1734. ( #{item.site},#{item.orderNo},#{item.itemNo},#{item.seqNo},#{item.histSeqNo}
  1735. ,#{item.reportedDate},#{item.reportedBy},#{item.defectCode},#{item.defectQty},#{item.rollNo} )
  1736. </foreach>
  1737. </insert>
  1738. <insert id="insertShopOrderChangeHist">
  1739. Insert into ShopOrderChangeHist(Site, OrderNo, CreateDate, Fieldname, FieldCaption, OldValue, NewValue, UserID,
  1740. RecordType, Remark)
  1741. Values (#{site}, #{orderNo}, getdate(), '*', '*', '*', '*', #{username}, '更改', #{orderChangeStatus})
  1742. </insert>
  1743. <select id="getSORoutingPreviousOperationItemNo" resultType="java.lang.Integer">
  1744. select dbo.Get_SORouting_PreviousOperationItemNo(#{site}, #{orderNo}, #{itemNo})
  1745. </select>
  1746. <select id="getShopOrderType" resultType="java.lang.String">
  1747. Select OrderType as order_type
  1748. from ShopOrder
  1749. where Site = #{site}
  1750. and OrderNo = #{orderNo}
  1751. </select>
  1752. <!--查询分切工单的物料信息-->
  1753. <select id="getSplitOrderParts" parameterType="SearchScheduleData" resultType="java.util.HashMap">
  1754. SELECT vss.Site site,
  1755. vss.SAPOrderNo sapOrderNo,
  1756. vss.OrderNo orderNo,
  1757. vss.OrderItemNo bomItemNo,
  1758. vss.PartNo partNo,
  1759. vss.PartDescription partDesc,
  1760. vss.Quantity orderQty
  1761. FROM view_sap_slitting_partlist vss
  1762. WHERE vss.Site = #{site}
  1763. AND vss.OrderNo = #{orderNo}
  1764. </select>
  1765. <!--统计C_RollInfo是否报工过-->
  1766. <select id="countCRollByRollNo" parameterType="SearchScheduleData" resultType="java.lang.Integer">
  1767. SELECT COUNT(1) FROM C_RollInfo cri
  1768. <where>
  1769. cri.Site = #{site} AND cri.OrderRef1 = #{orderNo} AND cri.OriginalRollNo = #{rollNo}
  1770. </where>
  1771. </select>
  1772. <!--统计C_RollInfo表的报工数据-->
  1773. <select id="getCRollReportedQty" parameterType="SearchScheduleData" resultType="java.lang.Float">
  1774. SELECT SUM(ISNULL(cri.RollQty, 0)) FROM C_RollInfo cri
  1775. <where>
  1776. cri.Site = #{site} AND cri.OrderRef1 = #{orderNo} AND cri.OriginalRollNo = #{rollNo}
  1777. </where>
  1778. </select>
  1779. <!--修改派工单的排料标记-->
  1780. <update id="updateSoScheduledRoutingMatIssueFlag" parameterType="SearchScheduleData">
  1781. UPDATE SOScheduledRouting
  1782. SET mat_issueflag = #{matIssueFlag}
  1783. WHERE Site = #{site}
  1784. AND OrderNo = #{orderNo}
  1785. AND SeqNo = #{seqNo}
  1786. </update>
  1787. <!--修改派工单的网版标记-->
  1788. <update id="updateSoScheduledRoutingPlateIssueFlag" parameterType="SearchScheduleData">
  1789. UPDATE SOScheduledRouting
  1790. SET plate_issueflag = #{plateIssueFlag}
  1791. WHERE Site = #{site}
  1792. AND OrderNo = #{orderNo}
  1793. AND SeqNo = #{seqNo}
  1794. </update>
  1795. <!--修改派工单的刀模标记-->
  1796. <update id="updateSoScheduledRoutingToolIssueFlag" parameterType="SearchScheduleData">
  1797. UPDATE SOScheduledRouting
  1798. SET tool_issueflag = #{toolIssueFlag}
  1799. WHERE Site = #{site}
  1800. AND OrderNo = #{orderNo}
  1801. AND SeqNo = #{seqNo}
  1802. </update>
  1803. <update id="updateSOScheduledRouting">
  1804. Update SOScheduledRouting
  1805. Set ClosedFlag='Y'
  1806. , Closedby=#{userId}
  1807. , ClosedDate=getdate()
  1808. Where Site = #{site}
  1809. and OrderNo = #{orderNo}
  1810. and ItemNo = #{itemNo}
  1811. and SeqNo = #{seqNo}
  1812. </update>
  1813. <!-- 更新派工单的备注 -->
  1814. <update id="updateSOScheduledRoutingRemark">
  1815. UPDATE SOScheduledRouting
  1816. SET Remark = #{remark}
  1817. WHERE Site = #{site}
  1818. AND OrderNo = #{orderNo}
  1819. AND ItemNo = #{itemNo}
  1820. AND SeqNo = #{seqNo}
  1821. </update>
  1822. <select id="checkKeyMart" resultType="java.lang.String">
  1823. Select Isnull(RMType_DB, '') as RMType_DB
  1824. From dbo.view_SAP_SOBOM as B
  1825. Where B.Site = #{site}
  1826. and B.OrderNo = #{orderNo}
  1827. and B.ItemNo = #{bomItemNo}
  1828. </select>
  1829. <select id="sumProductionCapacity" resultType="java.lang.Double">
  1830. SELECT
  1831. sum (dbo.getScheduleToPlanTime ( D.LotSize, T.MachSetupTime, T.MachRunFactor, T.FactorUnit, t.Efficiency ))
  1832. scheduleToPlanTime
  1833. FROM
  1834. SORouting AS T
  1835. LEFT JOIN ShopOrder AS D ON T.Site= D.Site
  1836. AND T.OrderNo= D.OrderNo
  1837. <where>
  1838. Round(T.QtyScheduled,3) <![CDATA[ < ]]> round(T.QtyRequired,3) and T.ClosedFlag = 'N' AND T.WorkCenterNo
  1839. <![CDATA[<>]]> 'FQC'
  1840. <if test="username != null and username != ''">
  1841. and T.site in (Select Site from AccessSite where upper(UserID)=#{username})
  1842. </if>
  1843. and T.OrderNo<![CDATA[ <> ]]>'9999' and isnull(D.Status,'')<![CDATA[ <> ]]>'已取消' and isnull(D.Status,'')
  1844. <![CDATA[ <> ]]>'已计划'
  1845. and isnull(D.Status,'')<![CDATA[ <> ]]>'已关闭'
  1846. <if test="enterTime1 != null">
  1847. and D.EnterDate<![CDATA[ >= ]]> #{enterTime1}
  1848. </if>
  1849. <if test="enterTime2 != null">
  1850. and D.EnterDate-1 <![CDATA[<]]> #{enterTime2}
  1851. </if>
  1852. <if test="needTime1 != null">
  1853. and D.NeedDate<![CDATA[ >= ]]>#{needTime1}
  1854. </if>
  1855. <if test="needTime2 != null">
  1856. and D.NeedDate<![CDATA[ <= ]]>#{needTime2}
  1857. </if>
  1858. <if test="site != null and site != ''">
  1859. AND T.Site like '%' + #{site} + '%'
  1860. </if>
  1861. <if test="partNo != null and partNo != ''">
  1862. AND T.PartNo like '%' + #{partNo} + '%'
  1863. </if>
  1864. AND T.WorkCenterNo = #{workCenterNo}
  1865. <if test="scheduledFlag != null and scheduledFlag != ''">
  1866. AND Isnull(S1.ScheduledFlag, 'Y') = #{scheduledFlag}
  1867. </if>
  1868. </where>
  1869. </select>
  1870. <select id="getBomItemNosByKeyPartNo" resultType="java.util.Map">
  1871. SELECT Site site,
  1872. OrderNo orderNo,
  1873. CONVERT(INT, ItemNo) itemNo,
  1874. ComponentPartNo partNo,
  1875. QtyAssembly qtyAssembly,
  1876. QtyFixedScrapt qtyFixedScrapt,
  1877. ScraptFactor scraptFactor,
  1878. Remark remark,
  1879. QtyRequired qtyRequired,
  1880. QtyIssue qtyIssue,
  1881. CONVERT(VARCHAR(20), IssueDate, 120) issueDate,
  1882. QtyReserved qtyReserved,
  1883. MatGroup matGroup,
  1884. QtyNotified qtyNotified,
  1885. RMType_DB rmTypeDb,
  1886. IssueType issueType
  1887. FROM dbo.view_SAP_SOBOM vss
  1888. WHERE vss.Site = #{site}
  1889. AND vss.RMType_DB = 'key Mart'
  1890. AND vss.OrderNo = #{orderNo}
  1891. AND vss.ComponentPartNo = #{rmPartNo}
  1892. </select>
  1893. <select id="deleteSfdcDefect" resultType="java.util.Map">
  1894. exec dbo.RemoveSfdcDefect #{site},#{orderNo},#{itemNo},#{seqNo},#{rollNo},#{histSeqNo}
  1895. </select>
  1896. <select id="deleteSfdcTimeHist" resultType="java.util.Map">
  1897. exec dbo.RemoveSfdcTimeHist #{site},#{orderNo},#{itemNo},#{seqNo},#{rollNo},#{histSeqNo}
  1898. </select>
  1899. <select id="deleteSfdcMaterialHist" resultType="java.util.Map">
  1900. exec dbo.RemoveSfdcMaterialHist #{site},#{orderNo},#{itemNo},#{seqNo},#{rollNo},#{histSeqNo},#{histType}
  1901. </select>
  1902. <!-- 获取固定载具列表 -->
  1903. <select id="getFixedCarrierList" resultType="map">
  1904. SELECT
  1905. site,
  1906. bu_no AS buNo,
  1907. carrier_no AS carrierNo,
  1908. carrier_type_code AS carrierTypeCode,
  1909. carrier_type_name AS carrierTypeName,
  1910. specification,
  1911. asset_no AS assetNo,
  1912. dimensions,
  1913. max_weight AS maxWeight,
  1914. expected_life_cycles AS expectedLifeCycles,
  1915. expected_life_days AS expectedLifeDays,
  1916. status,
  1917. current_location AS currentLocation,
  1918. last_used_time AS lastUsedTime,
  1919. total_usage_count AS totalUsageCount,
  1920. purchase_date AS purchaseDate,
  1921. create_by AS createBy,
  1922. create_date AS createDate,
  1923. remark,
  1924. available_qty AS availableQty
  1925. FROM fixed_carrier
  1926. WHERE site = #{site} and status = 1
  1927. <if test="carrierNo != null and carrierNo != ''">
  1928. AND carrier_no LIKE '%' + #{carrierNo} + '%'
  1929. </if>
  1930. <if test="carrierTypeName != null and carrierTypeName != ''">
  1931. AND carrier_type_name LIKE '%' + #{carrierTypeName} + '%'
  1932. </if>
  1933. <if test="specification != null and specification != ''">
  1934. AND specification LIKE '%' + #{specification} + '%'
  1935. </if>
  1936. ORDER BY carrier_no
  1937. </select>
  1938. <!-- 批量更新固定载具可用数量 -->
  1939. <update id="updateFixedCarrierBatch">
  1940. <foreach collection="list" item="item" separator=";">
  1941. UPDATE fixed_carrier
  1942. SET available_qty = #{item.availableQty}
  1943. WHERE site = #{item.site}
  1944. AND carrier_no = #{item.carrierNo}
  1945. </foreach>
  1946. </update>
  1947. <!-- 查询工单的订单备注信息 -->
  1948. <select id="getOrderNotesByOrderNo" parameterType="SearchScheduleData" resultType="java.util.Map">
  1949. SELECT TOP 1
  1950. B.orderref01 AS orderNotes -- 订单备注信息
  1951. FROM ShopOrder A
  1952. LEFT JOIN outbound_notification_detail B
  1953. ON A.Site = B.site
  1954. AND A.bu_no = B.bu_no
  1955. AND A.batch_no = B.related_order_no
  1956. WHERE A.Site = #{site}
  1957. AND A.OrderNo like '%' + #{batchNo} +'%'
  1958. </select>
  1959. <!-- 扫描获取新卷数量 -->
  1960. <select id="getNewRollQtyByScan" resultType="java.lang.Float">
  1961. SELECT RollQty as rollQty
  1962. FROM SFDC_Rolls
  1963. WHERE site = #{site}
  1964. AND RollNo = #{rollNo}
  1965. </select>
  1966. <!-- 调用存储过程 sfdcRollsOpsReportExecute 用于打开材料卷 -->
  1967. <select id="callSfdcRollsOpsReportExecute" resultType="java.util.Map" statementType="CALLABLE">
  1968. exec sfdcRollsOpsReportExecute
  1969. #{site},
  1970. #{seqNo},
  1971. #{rollNo},
  1972. #{histSeqNo},
  1973. #{type},
  1974. #{userId}
  1975. </select>
  1976. <!-- 调用存储过程 UspUpdateProductionStatus:暂停生产/继续生产(写入 SFDC_TimeHist 并更新 ParkFlag) -->
  1977. <select id="updateProductionStatus" resultType="java.util.Map">
  1978. exec dbo.UspUpdateProductionStatus
  1979. #{site},
  1980. #{orderNo},
  1981. #{seqNo},
  1982. #{itemNo},
  1983. #{rollNo},
  1984. #{currentTime},
  1985. #{operatorId},
  1986. #{parkFlag}
  1987. </select>
  1988. </mapper>