斯瑞奇mes后端
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.

655 lines
32 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
  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.srq.modules.schedule.dao.ScheduleMapper">
  4. <select id="getShopOrderRoutingData" resultType="com.srq.modules.schedule.entity.ShopOrderRoutingData">
  5. SELECT so.Site,so.OrderNo ,so.NeedDate,so.Status,so.LotSize,so.PartNo,sr.ItemNo,sr.OperationDesc,
  6. sr.WorkCenterNo,p.PartDesc,isnull(sl.QtyScheduled,0) QtyScheduled,isnull(sl.QtyReported,0) QtyReported,
  7. so.EnterDate
  8. FROM view_ShopOrder so
  9. LEFT JOIN view_SORouting sr on so.site=sr.Site and so.OrderNo=sr.OrderNo
  10. left join view_Part p on so.site=P.Site and so.PartNo=p.PartNo
  11. left join so_schedule_list sl on sl.Site=so.Site and sl.OrderNo=so.OrderNo and sr.ItemNo=sl.ItemNo
  12. <where>
  13. and so.site=#{site}
  14. <if test="startDate1 != null">
  15. and so.EnterDate>=#{startDate1}
  16. </if>
  17. <if test="endDate1 != null">
  18. and #{endDate1}>=so.EnterDate
  19. </if>
  20. <if test="startDate2 != null">
  21. and so.NeedDate>=#{startDate2}
  22. </if>
  23. <if test="endDate2 != null">
  24. and #{endDate2}>=so.NeedDate
  25. </if>
  26. <if test="itemNo != null">
  27. and sr.itemNo=#{itemNo}
  28. </if>
  29. <if test="status != null and status != ''">
  30. and so.status in ${status}
  31. </if>
  32. <if test="partNo != null and partNo != ''">
  33. and so.partNo like #{partNo}
  34. </if>
  35. <if test="planStatus != null and planStatus != ''">
  36. and ${planStatus}
  37. </if>
  38. <if test="workCenterNo != null and workCenterNo != ''">
  39. and sr.WorkCenterNo like #{workCenterNo}
  40. </if>
  41. </where>
  42. order by so.NeedDate,so.EnterDate
  43. </select>
  44. <select id="getWorkCenterOperatorList" resultType="com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData">
  45. SELECT a.OperatorID,a.OperatorName,a.Site
  46. FROM Operator a left join operator_work_center b on a.site=b.site and a.OperatorID=b.OperatorID
  47. where b.WorkCenterNo =#{workCenterNo} and a.site=#{site}
  48. and a.active='Y'
  49. </select>
  50. <select id="getAvailableResourceList" resultType="com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData">
  51. SELECT site,WorkCenterNo,ResourceID,ResourceDesc
  52. FROM WorkCenterResource
  53. where WorkCenterNo =#{workCenterNo} and site=#{site}
  54. and active='Y'
  55. </select>
  56. <select id="checkScheduleQty" resultType="ScheduleCheckData">
  57. Select a.orderNo, a.lotSize as Qty,isnull(b.QtyScheduled,0) scheduledQty,a.lotSize -isnull(b.QtyScheduled,0) as canScheduledQty
  58. from view_ShopOrder a left join so_schedule_list b on a.site=b.site and a.orderNo=b.orderNo and b.itemNo=#{itemNo}
  59. where a.Site=#{site} and a.OrderNo=#{orderNo}
  60. </select>
  61. <select id="checkScheduleList" resultType="ScheduleCheckData">
  62. Select QtyScheduled from so_schedule_list where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo}
  63. </select>
  64. <insert id="saveScheduleList">
  65. insert into so_schedule_list(Site,OrderNo,ItemNo,QtyScheduled,QtyReported,PartNo,QtyApprove,TimeReported) values (#{site},#{orderNo},#{itemNo},0,0,#{partNo},0,0)
  66. </insert>
  67. <select id="getDataSequence" resultType="integer">
  68. select seqNo from DataSequence where SeqType= 'A'
  69. </select>
  70. <update id="updateDataSequence">
  71. update DataSequence set seqNo=seqNo+1 where SeqType= 'A'
  72. </update>
  73. <insert id="saveSchedule">
  74. Insert into soscheduledrouting(Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime
  75. ,BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ShiftNo,S_WorkCenterNo
  76. ,SelectedFlag,SourceFlag,ParkFlag,TimeRequired_Original,QtyRequired_Original
  77. ,StartProdFlag,CancelledProdFlag,Efficiency,EnteredDate,operatorId,partNo,operation_desc)
  78. values(#{site},#{orderNo},#{itemNo},#{seqNo},#{scheduleQty},0,0,null,0,#{scheduleDate},#{scheduleDate}
  79. ,'*','',1,'N',0,'N',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo}
  80. ,'N','N','N',null,null
  81. ,'N','N',#{efficiency},GETDATE(),#{operatorId},#{partNo},#{operationDesc})
  82. </insert>
  83. <update id="updateScheduleListQty">
  84. update so_schedule_list set QtyScheduled=QtyScheduled+#{sumQty} where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo}
  85. </update>
  86. <select id="getSOScheduleRoutingData" resultType="SOScheduledRoutingOutData">
  87. select Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,
  88. BarcodeID,Remark,Crewsize,ClosedFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  89. S_WorkCenterNo, EnteredDate,operatorId,partNo,dbo.Get_PartDesc(Site,partNo) as partDesc,
  90. dbo.Get_OperatorDesc(Site,operatorId) as operatorName,dbo.Get_ItemDesc(site,OrderNo) as itemDesc,
  91. circulation_seqNo,circulation_qty from SOScheduledRouting
  92. <where>
  93. <if test="site != null and site != ''">
  94. AND site = #{site}
  95. </if>
  96. <if test="orderNo != null and orderNo != ''">
  97. AND OrderNo LIKE #{orderNo}
  98. </if>
  99. <if test="seqNo != null and seqNo != ''">
  100. AND seqNo = #{seqNo}
  101. </if>
  102. <if test="partNo != null and partNo != ''">
  103. AND PartNo LIKE #{partNo}
  104. </if>
  105. <if test="sWorkCenterNo != null and sWorkCenterNo != ''">
  106. AND S_WorkCenterNo LIKE #{sWorkCenterNo}
  107. </if>
  108. <if test="itemNo != null and itemNo != ''">
  109. and ItemNo = #{itemNo}
  110. </if>
  111. <if test="closedFlag != null and closedFlag != ''">
  112. and ClosedFlag = #{closedFlag}
  113. </if>
  114. <if test="startDate != null ">
  115. and S_ScheduledDate >= #{startDate}
  116. </if>
  117. <if test="endDate != null ">
  118. and #{endDate} >= S_ScheduledDate
  119. </if>
  120. <if test="reportFlag != null and reportFlag != ''">
  121. and ${reportFlag}
  122. </if>
  123. <if test="operatorName != null and operatorName != ''">
  124. and dbo.Get_OperatorDesc(Site,operatorId) like #{operatorName}
  125. </if>
  126. <if test="sResourceID != null and sResourceID != ''">
  127. and S_ResourceID like #{sResourceID}
  128. </if>
  129. <if test="sShiftNo != null and sShiftNo != ''">
  130. and S_ShiftNo = #{sShiftNo}
  131. </if>
  132. </where>
  133. order by S_ScheduledDate
  134. </select>
  135. <select id="checkCloseOrOpen" resultType="SOScheduledRoutingOutData">
  136. select Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,ClosedFlag,circulation_seqNo from SOScheduledRouting
  137. where seqNo=#{seqNo} AND site = #{site} and QtyRequired>QtyReported
  138. </select>
  139. <update id="updateClosedFlag">
  140. update SOScheduledRouting set closedFlag=#{closedFlag} where seqNo=#{seqNo} AND site = #{site}
  141. </update>
  142. <select id="getOldSOScheduledRoutingOutData" resultType="SOScheduledRoutingOutData">
  143. select Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime,
  144. BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  145. S_WorkCenterNo,ParkFlag,TimeRequired_Original,QtyRequired_Original,QtyReturntoSchedule,StartProdFlag,CancelledProdFlag,
  146. Efficiency,EnteredDate,SelectedFlag,SourceFlag,Closedby,ClosedDate,VirtualResourceFlag,mat_issueflag,plate_issueflag,
  147. tool_issueflag,operatorId,partNo,circulation_seqNo,circulation_qty from SOScheduledRouting where
  148. site=#{site} and seqNo=#{seqNo}
  149. </select>
  150. <update id="closeOldSchedule">
  151. update SOScheduledRouting set ClosedFlag='Y',circulation_seqNo=#{newSeqNo},circulation_qty=#{circulationQty} where site=#{site} and seqNo=#{oldSeqNo}
  152. </update>
  153. <insert id="saveCirculationSchedule" >
  154. INSERT into SOScheduledRouting (Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime,
  155. BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  156. S_WorkCenterNo,ParkFlag,TimeRequired_Original,QtyRequired_Original,QtyReturntoSchedule,StartProdFlag,CancelledProdFlag,
  157. Efficiency,EnteredDate,SelectedFlag,SourceFlag,Closedby,ClosedDate,VirtualResourceFlag,mat_issueflag,plate_issueflag,
  158. tool_issueflag,operatorId,partNo) values
  159. (#{site},#{orderNo},#{itemNo},#{seqNo},#{qtyRequired},0,0,0,0,#{planStartTime},#{planFinishTime},
  160. #{barcodeID},#{remark},#{crewsize},'N',0,'N',#{sScheduledDate},#{sResourceID},#{sScheduledSeqNo},#{sShiftNo},
  161. #{sWorkCenterNo},#{parkFlag},#{timeRequiredOriginal},#{qtyRequiredOriginal},null,'N','N',
  162. 0,GetDate(),'N','N',NULL,NULL,NULL,'N','N','N',#{operatorId},#{partNo}
  163. )
  164. </insert>
  165. <select id="scanSeqNo" resultType="SOScheduledRoutingOutData">
  166. select a.Site,a.OrderNo,a.ItemNo,a.SeqNo,a.QtyRequired,a.ClosedFlag,a.S_ScheduledDate,a.S_ScheduledSeqNo,a.S_ShiftNo,S_WorkCenterNo sWorkCenterNo,
  167. a.ParkFlag,a.operatorId ,isnull(b.partDesc,0) +'/'+ isnull(b.spec,0) as partDesc ,a.partNo,c.operatorName from SOScheduledRouting a
  168. left join view_part b on a.site=b.site and a.partNo=b.partNo
  169. left join Operator c on a.site=c.site and a.operatorId=c.operatorID
  170. where a.site=#{site} and a.seqNo=#{seqNo}
  171. </select>
  172. <insert id="saveSfdcOperatorList">
  173. insert into sfdc_operator_list (site,order_no,item_no,seq_no,roll_no,batch_no,defult_operator,total_operator,
  174. work_center_no,created_by,created_date,type,remark)values
  175. (#{site},#{orderNo},#{itemNo},#{seqNo},'*',#{batchNo},#{defultOperator},#{totalOperator},#{workCenterNo}
  176. ,#{createdBy},GetDate(),'派工单',#{remark})
  177. </insert>
  178. <insert id="saveDefectList">
  179. insert into SFDC_DefectHist (Site,OrderNo,ItemNo,SeqNo,HistSeqNo,ReportDate,Reportedby,DefectCode,DefectQty,Remark,RollNo,DefectDesc)
  180. values(#{site},#{orderNo},#{itemNo},#{seqNo},#{histSeqNo},GetDate(),#{reportedby},#{defectCode},#{defectQty},#{remark},'*',#{defectDesc})
  181. </insert>
  182. <select id="getSfdcList" resultType="com.srq.modules.schedule.entity.SfdcCancel">
  183. select a.site,a.OrderNo,a.ItemNo ,a.SeqNo,a.WorkCenterNo,a.ReportDate,a.OperatorID,a.ReportQty,a.ApproveQty,a.ReportedManfTime,
  184. a.AssJobSeqNo,a.ResourceID,a.BatchNo,b.S_ShiftNo ShiftNo,b.partNo,b.operation_desc,c.OperatorName,d.ShiftDesc,e.ResourceDesc,Reverseflag
  185. from sfdc a LEFT JOIN SOScheduledRouting b on a.Site=b.Site and a.AssJobSeqNo=b.SeqNo
  186. left join Operator c on a.site=b.site and a.OperatorID=c.OperatorID LEFT JOIN Calendar_DateType_Shift d on a.Site=d.Site and b.S_ShiftNo=d.ShiftNo
  187. left join WorkCenterResource e on a.Site=e.Site and a.ResourceID =e.ResourceID and a.WorkCenterNo=e.WorkCenterNo
  188. <where>
  189. AND a.site=#{site}
  190. <if test="orderNo != null and orderNo != ''">
  191. and a.OrderNo like #{orderNo}
  192. </if>
  193. <if test="workCenterNo != null and workCenterNo != ''">
  194. and a.WorkCenterNo like #{workCenterNo}
  195. </if>
  196. <if test="partNo != null and partNo != ''">
  197. and b.partNo like #{partNo}
  198. </if>
  199. <if test="itemNo != null and itemNo != ''">
  200. and a.ItemNo = #{itemNo}
  201. </if>
  202. <if test="operatorName != null and operatorName != ''">
  203. and c.OperatorName like #{operatorName}
  204. </if>
  205. <if test="resourceId != null and resourceId != ''">
  206. and a.ResourceID = #{resourceId}
  207. </if>
  208. <if test="shiftNo != null and shiftNo != ''">
  209. and b.S_ShiftNo = #{shiftNo}
  210. </if>
  211. <if test="startDate != null ">
  212. and ReportDate >= #{startDate}
  213. </if>
  214. <if test="endDate != null ">
  215. and #{endDate} >= ReportDate
  216. </if>
  217. </where>
  218. order by a.ReportDate desc
  219. </select>
  220. <select id="getSfdcOperatorList" resultType="OperatorData">
  221. SELECT b.OperatorID,b.OperatorName
  222. FROM sfdc_operator_list a LEFT JOIN Operator b on a.site=b.Site and a.defult_operator=b.OperatorID
  223. where a.site= #{site} and a.order_no=#{orderNo} and a.item_no=#{itemNo} and a.seq_no=#{seqNo}
  224. </select>
  225. <select id="getSfdcDefectList" resultType="com.srq.modules.base.entity.SfdcDefectHist">
  226. select Site,OrderNo,ItemNo,SeqNo,HistSeqNo,ReportDate,Reportedby,DefectCode,DefectQty,DefectDesc
  227. from SFDC_DefectHist where site = #{site} and OrderNo=#{orderNo} and ItemNo=#{itemNo} and SeqNo=#{seqNo}
  228. </select>
  229. <select id="checkAccessSite" resultType="com.srq.modules.base.entity.AccessSiteData">
  230. select Site,userID from AccessSite where site=#{site} and userID=#{username}
  231. </select>
  232. <insert id="addAccessSite">
  233. insert into AccessSite(UserID,Site) values (#{userID},#{site})
  234. </insert>
  235. <select id="scheduleFormOperator" resultType="SOScheduledRoutingOutData">
  236. select site,PartNo,partDesc,sum( QtyRequired)-sum(isnull(circulation_qty,0)) QtyRequired,
  237. sum(QtyReported) QtyReported,sum(QtyApprove) QtyApprove,operatorId,operatorName
  238. from (
  239. select Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,
  240. BarcodeID,Remark,Crewsize,ClosedFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  241. S_WorkCenterNo, EnteredDate,operatorId,partNo,dbo.Get_PartDesc(Site,partNo) as partDesc,
  242. dbo.Get_OperatorDesc(Site,operatorId) as operatorName,dbo.Get_ItemDesc(site,OrderNo) as itemDesc,
  243. circulation_seqNo,circulation_qty from SOScheduledRouting
  244. <where>
  245. AND site = #{site}
  246. <if test="orderNo != null and orderNo != ''">
  247. AND OrderNo LIKE #{orderNo}
  248. </if>
  249. <!-- <if test="seqNo != null and seqNo != ''">-->
  250. <!-- AND seqNo = #{seqNo}-->
  251. <!-- </if>-->
  252. <if test="partNo != null and partNo != ''">
  253. AND PartNo LIKE #{partNo}
  254. </if>
  255. <if test="sWorkCenterNo != null and sWorkCenterNo != ''">
  256. AND S_WorkCenterNo LIKE #{sWorkCenterNo}
  257. </if>
  258. <if test="itemNo != null and itemNo != ''">
  259. and ItemNo = #{itemNo}
  260. </if>
  261. <!-- <if test="closedFlag != null and closedFlag != ''">-->
  262. <!-- and ClosedFlag = #{closedFlag}-->
  263. <!-- </if>-->
  264. <if test="startDate != null ">
  265. and S_ScheduledDate >= #{startDate}
  266. </if>
  267. <if test="endDate != null ">
  268. and #{endDate} >= S_ScheduledDate
  269. </if>
  270. <!-- <if test="reportFlag != null and reportFlag != ''">-->
  271. <!-- and ${reportFlag}-->
  272. <!-- </if>-->
  273. <if test="operatorName != null and operatorName != ''">
  274. and dbo.Get_OperatorDesc(Site,operatorId) like #{operatorName}
  275. </if>
  276. <if test="sResourceID != null and sResourceID != ''">
  277. and S_ResourceID like #{sResourceID}
  278. </if>
  279. <if test="sShiftNo != null and sShiftNo != ''">
  280. and S_ShiftNo = #{sShiftNo}
  281. </if>
  282. </where>
  283. ) a
  284. GROUP BY site,PartNo,partDesc,operatorId,operatorName
  285. order by operatorId,PartNo
  286. </select>
  287. <select id="sfdcOperator" resultType="com.srq.modules.schedule.entity.SfdcCancel">
  288. SELECT OperatorID ,OperatorName,partDesc,partNo,sum(ReportQty) reportQty,sum(ApproveQty) ApproveQty,sum(ReportedManfTime) ReportedManfTime
  289. from
  290. (
  291. select c.OperatorID,c.OperatorName,dbo.Get_PartDesc(b.Site,d.partNo) partDesc, d.partNo,b.ReportQty,b.ApproveQty,b.ReportedManfTime
  292. from sfdc_operator_list a LEFT JOIN sfdc b on a.site=b.Site and a.order_no=order_no and a.item_no=b.ItemNo and a.seq_no=b.SeqNo
  293. left join Operator c on a.site=c.Site and a.defult_operator=c.OperatorID
  294. LEFT JOIN SOScheduledRouting d on b.Site=d.Site and b.AssJobSeqNo=d.SeqNo
  295. <where>
  296. AND b.site=#{site}
  297. <if test="orderNo != null and orderNo != ''">
  298. and b.OrderNo like #{orderNo}
  299. </if>
  300. <if test="workCenterNo != null and workCenterNo != ''">
  301. and b.WorkCenterNo like #{workCenterNo}
  302. </if>
  303. <if test="partNo != null and partNo != ''">
  304. and d.partNo like #{partNo}
  305. </if>
  306. <if test="itemNo != null and itemNo != ''">
  307. and b.ItemNo = #{itemNo}
  308. </if>
  309. <if test="operatorName != null and operatorName != ''">
  310. and c.OperatorName like #{operatorName}
  311. </if>
  312. <if test="resourceId != null and resourceId != ''">
  313. and b.ResourceID = #{resourceId}
  314. </if>
  315. <if test="shiftNo != null and shiftNo != ''">
  316. and d.S_ShiftNo = #{shiftNo}
  317. </if>
  318. <if test="startDate != null ">
  319. and ReportDate >= #{startDate}
  320. </if>
  321. <if test="endDate != null ">
  322. and #{endDate} >= ReportDate
  323. </if>
  324. </where>
  325. ) d
  326. group by OperatorID ,OperatorName,partDesc,partNo order by OperatorID,partNo
  327. </select>
  328. <select id="sfdcResource" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  329. SELECT ResourceID ,ResourceDesc,partDesc,partNo,sum(ReportQty) reportQty,sum(ApproveQty) ApproveQty,sum(ReportedManfTime) ReportedManfTime
  330. from
  331. (
  332. select a.ResourceID ,e.ResourceDesc ,b.partNo,dbo.Get_PartDesc(b.Site,b.partNo) partDesc,reportQty,ApproveQty,ReportedManfTime
  333. from sfdc a LEFT JOIN SOScheduledRouting b on a.Site=b.Site and a.AssJobSeqNo=b.SeqNo
  334. left join WorkCenterResource e on a.Site=e.Site and a.ResourceID =e.ResourceID and a.WorkCenterNo=e.WorkCenterNo
  335. <where>
  336. AND a.site=#{site}
  337. <if test="orderNo != null and orderNo != ''">
  338. and a.OrderNo like #{orderNo}
  339. </if>
  340. <if test="workCenterNo != null and workCenterNo != ''">
  341. and a.WorkCenterNo like #{workCenterNo}
  342. </if>
  343. <if test="partNo != null and partNo != ''">
  344. and b.partNo like #{partNo}
  345. </if>
  346. <if test="itemNo != null and itemNo != ''">
  347. and a.ItemNo = #{itemNo}
  348. </if>
  349. <if test="resourceId != null and resourceId != ''">
  350. and a.ResourceID = #{resourceId}
  351. </if>
  352. <if test="shiftNo != null and shiftNo != ''">
  353. and b.S_ShiftNo = #{shiftNo}
  354. </if>
  355. <if test="startDate != null ">
  356. and ReportDate >= #{startDate}
  357. </if>
  358. <if test="endDate != null ">
  359. and #{endDate} >= ReportDate
  360. </if>
  361. </where>
  362. ) d
  363. group by ResourceID ,ResourceDesc,partDesc,partNo order by ResourceID ,partNo
  364. </select>
  365. <select id="sfdcWorkCenter" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  366. SELECT WorkCenterNo,partDesc,partNo,sum(ReportQty) reportQty,sum(ApproveQty) ApproveQty,sum(ReportedManfTime) ReportedManfTime
  367. from
  368. (
  369. select a.WorkCenterNo ,b.partNo,dbo.Get_PartDesc(b.Site,b.partNo) partDesc,reportQty,ApproveQty,ReportedManfTime
  370. from sfdc a LEFT JOIN SOScheduledRouting b on a.Site=b.Site and a.AssJobSeqNo=b.SeqNo
  371. <where>
  372. AND a.site=#{site}
  373. <if test="orderNo != null and orderNo != ''">
  374. and a.OrderNo like #{orderNo}
  375. </if>
  376. <if test="workCenterNo != null and workCenterNo != ''">
  377. and a.WorkCenterNo like #{workCenterNo}
  378. </if>
  379. <if test="partNo != null and partNo != ''">
  380. and b.partNo like #{partNo}
  381. </if>
  382. <if test="itemNo != null and itemNo != ''">
  383. and a.ItemNo = #{itemNo}
  384. </if>
  385. <if test="resourceId != null and resourceId != ''">
  386. and a.ResourceID = #{resourceId}
  387. </if>
  388. <if test="shiftNo != null and shiftNo != ''">
  389. and b.S_ShiftNo = #{shiftNo}
  390. </if>
  391. <if test="startDate != null ">
  392. and b.ReportDate >= #{startDate}
  393. </if>
  394. <if test="endDate != null ">
  395. and #{endDate} >= b.ReportDate
  396. </if>
  397. </where>
  398. ) d
  399. group by WorkCenterNo,partDesc,partNo order by WorkCenterNo ,partNo
  400. </select>
  401. <select id="sfdcDefectForm" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  402. select b.site,b.OrderNo,b.ItemNo ,b.SeqNo,b.WorkCenterNo,b.ReportDate,b.OperatorID,b.ReportQty,b.ApproveQty,b.ReportedManfTime,
  403. b.AssJobSeqNo,b.ResourceID,b.BatchNo,c.S_ShiftNo ShiftNo,c.partNo,c.operation_desc,
  404. dbo.Get_OperatorDesc(b.site,b.OperatorID) OperatorName,d.ShiftDesc,e.ResourceDesc,b.Reverseflag,a.DefectCode,a.DefectDesc,a.DefectQty
  405. from SFDC_DefectHist a left join sfdc b on a.site=b.Site and a.OrderNo=b.OrderNo and a.ItemNo=b.ItemNo and a.SeqNo=b.SeqNo
  406. left join SOScheduledRouting c on a.Site=c.Site and a.HistSeqNo=c.SeqNo
  407. LEFT JOIN Calendar_DateType_Shift d on a.Site=d.Site and c.S_ShiftNo=d.ShiftNo
  408. left join WorkCenterResource e on a.Site=e.Site and b.ResourceID =e.ResourceID and b.WorkCenterNo=e.WorkCenterNo
  409. <where>
  410. AND a.site=#{site}
  411. AND b.Reverseflag='N'
  412. <if test="orderNo != null and orderNo != ''">
  413. and c.OrderNo like #{orderNo}
  414. </if>
  415. <if test="workCenterNo != null and workCenterNo != ''">
  416. and b.WorkCenterNo like #{workCenterNo}
  417. </if>
  418. <if test="partNo != null and partNo != ''">
  419. and c.partNo like #{partNo}
  420. </if>
  421. <if test="itemNo != null and itemNo != ''">
  422. and a.ItemNo = #{itemNo}
  423. </if>
  424. <if test="resourceId != null and resourceId != ''">
  425. and b.ResourceID = #{resourceId}
  426. </if>
  427. <if test="shiftNo != null and shiftNo != ''">
  428. and c.S_ShiftNo = #{shiftNo}
  429. </if>
  430. <if test="startDate != null ">
  431. and b.ReportDate >= #{startDate}
  432. </if>
  433. <if test="endDate != null ">
  434. and #{endDate} >= b.ReportDate
  435. </if>
  436. <if test="defectCode != null and defectCode != ''">
  437. and a.defectCode like #{defectCode}
  438. </if>
  439. <if test="defectDesc != null and defectDesc != ''">
  440. and a.defectDesc like #{defectDesc}
  441. </if>
  442. </where>
  443. </select>
  444. <select id="sfdcDefectSummay" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  445. SELECT DefectCode,DefectDesc,sum(DefectQty) DefectQty,partNo,site,dbo.Get_PartDesc( site,partNo) partDesc
  446. from (
  447. select b.site,b.OrderNo,b.ItemNo ,b.SeqNo,b.WorkCenterNo,b.ReportDate,b.OperatorID,b.ReportQty,b.ApproveQty,b.ReportedManfTime,
  448. b.AssJobSeqNo,b.ResourceID,b.BatchNo,c.S_ShiftNo ShiftNo,c.partNo,c.operation_desc,
  449. dbo.Get_OperatorDesc(b.site,b.OperatorID) OperatorName,d.ShiftDesc,e.ResourceDesc,b.Reverseflag,a.DefectCode,a.DefectDesc,a.DefectQty
  450. from SFDC_DefectHist a left join sfdc b on a.site=b.Site and a.OrderNo=b.OrderNo and a.ItemNo=b.ItemNo and a.SeqNo=b.SeqNo
  451. left join SOScheduledRouting c on a.Site=c.Site and a.HistSeqNo=c.SeqNo
  452. LEFT JOIN Calendar_DateType_Shift d on a.Site=d.Site and c.S_ShiftNo=d.ShiftNo
  453. left join WorkCenterResource e on a.Site=e.Site and b.ResourceID =e.ResourceID and b.WorkCenterNo=e.WorkCenterNo
  454. <where>
  455. AND a.site=#{site} AND b.Reverseflag='N'
  456. <if test="orderNo != null and orderNo != ''">
  457. and a.OrderNo like #{orderNo}
  458. </if>
  459. <if test="workCenterNo != null and workCenterNo != ''">
  460. and a.WorkCenterNo like #{workCenterNo}
  461. </if>
  462. <if test="partNo != null and partNo != ''">
  463. and b.partNo like #{partNo}
  464. </if>
  465. <if test="itemNo != null and itemNo != ''">
  466. and a.ItemNo = #{itemNo}
  467. </if>
  468. <if test="resourceId != null and resourceId != ''">
  469. and a.ResourceID = #{resourceId}
  470. </if>
  471. <if test="shiftNo != null and shiftNo != ''">
  472. and b.S_ShiftNo = #{shiftNo}
  473. </if>
  474. <if test="startDate != null ">
  475. and b.ReportDate >= #{startDate}
  476. </if>
  477. <if test="endDate != null ">
  478. and #{endDate} >= b.ReportDate
  479. </if>
  480. </where>
  481. ) a
  482. GROUP BY DefectCode,DefectDesc,partNo,site
  483. </select>
  484. <select id="sfdcDefectOperator" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  485. SELECT OperatorID,OperatorName,sum(DefectQty) DefectQty,partNo,site,dbo.Get_PartDesc( site,partNo) partDesc
  486. from (
  487. select b.site,b.OrderNo,b.ItemNo ,b.SeqNo,b.WorkCenterNo,b.ReportDate,b.OperatorID,b.ReportQty,b.ApproveQty,b.ReportedManfTime,
  488. b.AssJobSeqNo,b.ResourceID,b.BatchNo,c.S_ShiftNo ShiftNo,c.partNo,c.operation_desc,
  489. dbo.Get_OperatorDesc(b.site,b.OperatorID) OperatorName,d.ShiftDesc,e.ResourceDesc,b.Reverseflag,a.DefectCode,a.DefectDesc,a.DefectQty
  490. from SFDC_DefectHist a left join sfdc b on a.site=b.Site and a.OrderNo=b.OrderNo and a.ItemNo=b.ItemNo and a.SeqNo=b.SeqNo
  491. left join SOScheduledRouting c on a.Site=c.Site and a.HistSeqNo=c.SeqNo
  492. LEFT JOIN Calendar_DateType_Shift d on a.Site=d.Site and c.S_ShiftNo=d.ShiftNo
  493. left join WorkCenterResource e on a.Site=e.Site and b.ResourceID =e.ResourceID and b.WorkCenterNo=e.WorkCenterNo
  494. <where>
  495. AND a.site=#{site} AND b.Reverseflag='N'
  496. <if test="orderNo != null and orderNo != ''">
  497. and a.OrderNo like #{orderNo}
  498. </if>
  499. <if test="workCenterNo != null and workCenterNo != ''">
  500. and a.WorkCenterNo like #{workCenterNo}
  501. </if>
  502. <if test="partNo != null and partNo != ''">
  503. and b.partNo like #{partNo}
  504. </if>
  505. <if test="itemNo != null and itemNo != ''">
  506. and a.ItemNo = #{itemNo}
  507. </if>
  508. <if test="resourceId != null and resourceId != ''">
  509. and a.ResourceID = #{resourceId}
  510. </if>
  511. <if test="shiftNo != null and shiftNo != ''">
  512. and b.S_ShiftNo = #{shiftNo}
  513. </if>
  514. <if test="startDate != null ">
  515. and b.ReportDate >= #{startDate}
  516. </if>
  517. <if test="endDate != null ">
  518. and #{endDate} >= b.ReportDate
  519. </if>
  520. </where>
  521. ) a
  522. GROUP BY OperatorID,OperatorName,partNo,site
  523. </select>
  524. <select id="sfdcDefectResource" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  525. SELECT ResourceID,ResourceDesc,sum(DefectQty) DefectQty,partNo,site,dbo.Get_PartDesc( site,partNo) partDesc
  526. from (
  527. select b.site,b.OrderNo,b.ItemNo ,b.SeqNo,b.WorkCenterNo,b.ReportDate,b.OperatorID,b.ReportQty,b.ApproveQty,b.ReportedManfTime,
  528. b.AssJobSeqNo,b.ResourceID,b.BatchNo,c.S_ShiftNo ShiftNo,c.partNo,c.operation_desc,
  529. dbo.Get_OperatorDesc(b.site,b.OperatorID) OperatorName,d.ShiftDesc,e.ResourceDesc,b.Reverseflag,a.DefectCode,a.DefectDesc,a.DefectQty
  530. from SFDC_DefectHist a left join sfdc b on a.site=b.Site and a.OrderNo=b.OrderNo and a.ItemNo=b.ItemNo and a.SeqNo=b.SeqNo
  531. left join SOScheduledRouting c on a.Site=c.Site and a.HistSeqNo=c.SeqNo
  532. LEFT JOIN Calendar_DateType_Shift d on a.Site=d.Site and c.S_ShiftNo=d.ShiftNo
  533. left join WorkCenterResource e on a.Site=e.Site and b.ResourceID =e.ResourceID and b.WorkCenterNo=e.WorkCenterNo
  534. <where>
  535. AND a.site=#{site} AND b.Reverseflag='N'
  536. <if test="orderNo != null and orderNo != ''">
  537. and a.OrderNo like #{orderNo}
  538. </if>
  539. <if test="workCenterNo != null and workCenterNo != ''">
  540. and a.WorkCenterNo like #{workCenterNo}
  541. </if>
  542. <if test="partNo != null and partNo != ''">
  543. and b.partNo like #{partNo}
  544. </if>
  545. <if test="itemNo != null and itemNo != ''">
  546. and a.ItemNo = #{itemNo}
  547. </if>
  548. <if test="resourceId != null and resourceId != ''">
  549. and a.ResourceID = #{resourceId}
  550. </if>
  551. <if test="shiftNo != null and shiftNo != ''">
  552. and b.S_ShiftNo = #{shiftNo}
  553. </if>
  554. <if test="startDate != null ">
  555. and b.ReportDate >= #{startDate}
  556. </if>
  557. <if test="endDate != null ">
  558. and #{endDate} >= b.ReportDate
  559. </if>
  560. </where>
  561. ) a
  562. GROUP BY ResourceID,ResourceDesc,partNo,site
  563. </select>
  564. <select id="sfdcDefectWorkCenter" resultType="com.srq.modules.schedule.entity.SfdcFormData">
  565. SELECT WorkCenterNo,sum(DefectQty) DefectQty,partNo,site,dbo.Get_PartDesc( site,partNo) partDesc
  566. from (
  567. select b.site,b.OrderNo,b.ItemNo ,b.SeqNo,b.WorkCenterNo,b.ReportDate,b.OperatorID,b.ReportQty,b.ApproveQty,b.ReportedManfTime,
  568. b.AssJobSeqNo,b.ResourceID,b.BatchNo,c.S_ShiftNo ShiftNo,c.partNo,c.operation_desc,
  569. dbo.Get_OperatorDesc(b.site,b.OperatorID) OperatorName,d.ShiftDesc,e.ResourceDesc,b.Reverseflag,a.DefectCode,a.DefectDesc,a.DefectQty
  570. from SFDC_DefectHist a left join sfdc b on a.site=b.Site and a.OrderNo=b.OrderNo and a.ItemNo=b.ItemNo and a.SeqNo=b.SeqNo
  571. left join SOScheduledRouting c on a.Site=c.Site and a.HistSeqNo=c.SeqNo
  572. LEFT JOIN Calendar_DateType_Shift d on a.Site=d.Site and c.S_ShiftNo=d.ShiftNo
  573. left join WorkCenterResource e on a.Site=e.Site and b.ResourceID =e.ResourceID and b.WorkCenterNo=e.WorkCenterNo
  574. <where>
  575. AND a.site=#{site} AND b.Reverseflag='N'
  576. <if test="orderNo != null and orderNo != ''">
  577. and a.OrderNo like #{orderNo}
  578. </if>
  579. <if test="workCenterNo != null and workCenterNo != ''">
  580. and a.WorkCenterNo like #{workCenterNo}
  581. </if>
  582. <if test="partNo != null and partNo != ''">
  583. and b.partNo like #{partNo}
  584. </if>
  585. <if test="itemNo != null and itemNo != ''">
  586. and a.ItemNo = #{itemNo}
  587. </if>
  588. <if test="resourceId != null and resourceId != ''">
  589. and a.ResourceID = #{resourceId}
  590. </if>
  591. <if test="shiftNo != null and shiftNo != ''">
  592. and b.S_ShiftNo = #{shiftNo}
  593. </if>
  594. <if test="startDate != null ">
  595. and b.ReportDate >= #{startDate}
  596. </if>
  597. <if test="endDate != null ">
  598. and #{endDate} >= b.ReportDate
  599. </if>
  600. </where>
  601. ) a
  602. GROUP BY WorkCenterNo,partNo,site
  603. </select>
  604. </mapper>