赫艾后端
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.

1115 lines
62 KiB

4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
2 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
2 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
2 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
2 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
4 years ago
2 years ago
4 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
2 years ago
4 years ago
3 years ago
4 years ago
2 years ago
4 years ago
2 years ago
3 years ago
3 years ago
4 years ago
2 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
4 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
4 years ago
2 years ago
4 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 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.heai.modules.production.dao.DailyPlanMapper">
  4. <select id="getShopOrderData" resultType="com.heai.modules.production.entity.ShopOrderData" parameterType="com.heai.modules.production.entity.DailyPlanInData">
  5. select a.site, a.OrderNo,a.PartNo,a.Status,a.PlanStartDate,a.NeedDate,a.LotSize,a.EnterDate,a.UserName,
  6. P.Spec+'/'+isnull(P.PartDescription,'') PartDescription,P.Spec,ROUND(ISNULL(so.scheduling_size,0),3) as scheduling_size,dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo) as weightFactor,
  7. Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.LotSize,2) as weight
  8. FROM ShopOrder a
  9. LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site
  10. LEFT JOIN so_scheduled_list so ON a.site=so.Site AND a.OrderNo= so.order_no
  11. <where>
  12. <if test="site != null and site != ''">
  13. AND a.site = #{site}
  14. </if>
  15. <if test="partDescription != null and partDescription != ''">
  16. AND P.Spec+'/'+isnull(P.PartDescription,'') like #{partDescription}
  17. </if>
  18. <if test="orderNo != null and orderNo != ''">
  19. AND a.OrderNo LIKE #{orderNo}
  20. </if>
  21. <if test="status !=null and status != ''">
  22. AND a.Status IN ${status}
  23. </if>
  24. <if test="startDate1 != null ">
  25. AND a.EnterDate >= #{startDate1}
  26. </if>
  27. <if test="endDate1 != null ">
  28. AND #{endDate1} >= DATEADD(dd, -1, a.EnterDate)
  29. </if>
  30. <if test="startDate2 != null ">
  31. AND a.PlanStartDate >= #{startDate2}
  32. </if>
  33. <if test="endDate2 != null ">
  34. AND #{endDate2} >= a.PlanStartDate
  35. </if>
  36. <if test="startDate3 != null ">
  37. AND a.NeedDate >= #{startDate3}
  38. </if>
  39. <if test="endDate3 != null ">
  40. AND #{endDate3} >= a.NeedDate
  41. </if>
  42. <if test="partNo != null and partNo != ''">
  43. AND a.PartNo LIKE #{partNo}
  44. </if>
  45. <if test="planStatus != null and planStatus != ''">
  46. and ${planStatus}
  47. </if>
  48. AND a.PartNo like 'SP%'
  49. </where>
  50. order by a.PlanStartDate
  51. </select>
  52. <select id="getGenerateReportList" resultType="com.heai.modules.production.entity.GenerateReportData">
  53. Select T.Site,T.OrderNo,T.ItemNo,T.OperationDesc,T.WorkCenterNo,W.WorkCenterDesc,T.QtyRequired,T.QtyReported
  54. ,T.QtyApprove ,T.TimeRequired,T.TimeReported,T.PlanStartTime,T.PlanFinishTime
  55. ,T.ClosedFlag,T.PartNo,P.PartDescription,P.Spec,D.NeedDate,D.PlanStartDate,D.Status
  56. ,D.LotSize,D.FinishedQty
  57. from SORouting as T,ShopOrder as D,WorkCenter as W,Part as P
  58. <where>
  59. T.Site=D.Site and T.OrderNo=D.OrderNo and T.Site=W.Site and T.WorkCenterNo=W.WorkCenterNo
  60. and D.Site=P.Site and D.PartNo=P.PartNo
  61. <if test="site != null and site != ''">
  62. and T.site = #{site,jdbcType=VARCHAR}
  63. </if>
  64. <if test="workCenterNo != null and workCenterNo != ''">
  65. and T.WorkCenterNo like '%' + #{workCenterNo,jdbcType=VARCHAR} + '%'
  66. </if>
  67. <if test="partNo != null and partNo != ''">
  68. and T.PartNo like '%' + #{partNo,jdbcType=VARCHAR} + '%'
  69. </if>
  70. <if test="orderNo != null and orderNo != ''">
  71. and T.OrderNo like '%' + #{orderNo,jdbcType=VARCHAR} + '%'
  72. </if>
  73. </where>
  74. </select>
  75. <select id="getShopOrderForHunlian" resultType="com.heai.modules.production.entity.ShopOrderData">
  76. select A.OrderNo ,A.Site ,A.EnterDate ,A.UserName ,A.NeedDate ,A.OriginalNeedDate ,A.PlanStartDate ,A.ReleaseDate
  77. ,A.ReleaseGuys ,A.ScheduleDate ,A.Scheduler ,A.IssueDate ,A.ReportDate ,A.ReceiveDate ,A.CloseDate
  78. ,A.Planner ,A.Status ,A.Status_Tmp ,A.Printed ,A.OrderType ,A.PartNo ,A.LotSize ,A.FinishedQty
  79. ,A.ProjectID ,A.BOMRevNo ,A.RoutingRevNo ,A.Leadtime ,A.Remark ,A.OrderRef1 ,A.OrderRef2 ,A.CostRollUpFlag
  80. ,A.ManualFlag ,A.OriSOOrderNo ,A.CustomerID ,A.TechInfo ,A.ReceiveStatus ,A.E_OriginalOrderNo
  81. ,A.E_Levels ,A.E_OriginalOrderType ,A.E_SeqNo ,A.E_LevelCode ,A.SFDCReportedFlag ,A.RepairSOFlag
  82. ,A.ConfigurationFlag ,A.MaterialSplitFlag ,A.ObjectVersion ,A.ExpandFlag ,A.CodeNo ,A.LE_SeqNo
  83. ,A.LE_ItemNo ,A.LE_Levels
  84. ,B.PartDescription,dbo.Get_PartWeightFactorForReport(A.Site ,A.PartNo,A.OrderNo) as weightFactor,
  85. Round(dbo.Get_PartWeightFactorForReport(A.Site ,A.PartNo,A.OrderNo)*A.LotSize,2) weight
  86. from ShopOrder A
  87. left join Part B on A.site = B.site and A.PartNo = B.PartNo
  88. <where>
  89. and (a.PartNo like 'RC%' or a.PartNo like 'SC%')
  90. <if test="site != null and site != ''">
  91. and A.Site = #{site,jdbcType=VARCHAR}
  92. </if>
  93. <if test="orderNo != null and orderNo != ''">
  94. and A.OrderNo = #{orderNo,jdbcType=VARCHAR}
  95. </if>
  96. </where>
  97. </select>
  98. <select id="getHunlianTaskHeader" resultType="com.heai.modules.production.entity.HunlianData">
  99. select Site,TaskNo,orderRef1 from Hunlian_TaskHeader where DeleteFlag='N' and TaskNo=#{taskNo}
  100. </select>
  101. <select id="getShopOrderList" resultType="com.heai.modules.production.entity.ShopOrderData">
  102. select A.OrderNo ,A.Site ,A.EnterDate ,A.UserName ,A.NeedDate ,A.OriginalNeedDate ,A.PlanStartDate ,A.ReleaseDate
  103. ,A.ReleaseGuys ,A.ScheduleDate ,A.Scheduler ,A.IssueDate ,A.ReportDate ,A.ReceiveDate ,A.CloseDate
  104. ,A.Planner ,A.Status ,A.Status_Tmp ,A.Printed ,A.OrderType ,A.PartNo ,A.LotSize ,A.FinishedQty
  105. ,A.ProjectID ,A.BOMRevNo ,A.RoutingRevNo ,A.Leadtime ,A.Remark ,A.OrderRef1 ,A.OrderRef2 ,A.CostRollUpFlag
  106. ,A.ManualFlag ,A.OriSOOrderNo ,A.CustomerID ,A.TechInfo ,A.ReceiveStatus ,A.E_OriginalOrderNo
  107. ,A.E_Levels ,A.E_OriginalOrderType ,A.E_SeqNo ,A.E_LevelCode ,A.SFDCReportedFlag ,A.RepairSOFlag
  108. ,A.ConfigurationFlag ,A.MaterialSplitFlag ,A.ObjectVersion ,A.ExpandFlag ,A.CodeNo ,A.LE_SeqNo
  109. ,A.LE_ItemNo ,A.LE_Levels
  110. ,B.PartDescription
  111. from ShopOrder A
  112. left join Part B on A.site = B.site and A.PartNo = B.PartNo
  113. <where>
  114. <if test="site != null and site != ''">
  115. and A.Site = #{site,jdbcType=VARCHAR}
  116. </if>
  117. <if test="orderNo != null and orderNo != ''">
  118. and A.OrderNo = #{orderNo,jdbcType=VARCHAR}
  119. </if>
  120. </where>
  121. </select>
  122. <select id="getTransfer" resultType="com.heai.modules.production.entity.ShopOrderData">
  123. select a.TransNo as transFerNo ,b.PartNo,c.PartDescription,a.Status,b.TransQty as lotSize,b.ConfirmQty as FinishedQty,a.Site, b.OrderNo,dbo.Get_PartWeightFactorForReport(A.Site ,b.PartNo,b.OrderNo) as weightFactor,
  124. dbo.Get_Part_DefaultWarehouseID(a.Site,b.PartNo) DefaultWarehouseID,b.seqNo,a.needReceiveFlag,Round(isnull(b.boxWeight,0),2) boxWeight
  125. from SOOpsTransferHeader a left join SOOpsTransferDetail b on a.TransNo=b.TransNo and a.Site=b.Site
  126. LEFT JOIN Part c on b.partNo=c.partNo and c.site=a.site
  127. <where>
  128. <if test="transFerNo != null and transFerNo != ''">
  129. and a.TransNo = #{transFerNo}
  130. </if>
  131. </where>
  132. </select>
  133. <select id="checkShopOrderStatus" resultType="com.heai.modules.production.entity.ShopOrderData">
  134. select orderNo,status from shopOrder where Site=#{site} and OrderNo=#{orderNo}
  135. </select>
  136. <select id="getOperatorData" resultType="com.heai.modules.production.entity.OperatorData" >
  137. select Site,OperatorID,OperatorName,Active,Department,CreatedDate,Passwords,LineLeader,tv_id
  138. from Operator
  139. <where>
  140. <if test="site != null and site != ''">
  141. and Site = #{site}
  142. </if>
  143. <if test="operatorID != null and operatorID != ''">
  144. and OperatorID like #{operatorID,jdbcType=VARCHAR}
  145. </if>
  146. <if test="operatorName != null and operatorName != ''">
  147. and OperatorName like #{operatorName}
  148. </if>
  149. <if test="active != null and active != ''">
  150. and Active = #{active}
  151. </if>
  152. <if test="department != null and department != '' and department != 'all'">
  153. and department = #{department}
  154. </if>
  155. </where>
  156. order by CreatedDate
  157. </select>
  158. <select id="getWorkCenterData" resultType="WorkCenterData">
  159. select a.Site,a.WorkCenterNo,a.WorkCenterDesc,a.Active FROM WorkCenter a left join
  160. operator_work_center b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo and b.OperatorID=#{operatorID}
  161. where a.site=#{site} and b.WorkCenterNo is null
  162. order by a.WorkCenterNo
  163. </select>
  164. <select id="getWorkCenterOperatorData" resultType="WorkCenterData">
  165. select a.Site,a.WorkCenterNo,b.WorkCenterDesc,b.Active FROM operator_work_center a left join
  166. WorkCenter b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo
  167. where a.site=#{site} and a.OperatorID=#{operatorID}
  168. order by a.WorkCenterNo
  169. </select>
  170. <insert id="addSkill">
  171. insert into operator_work_center(OperatorID,WorkCenterNo,created_by,created_date,Site)
  172. values(#{operatorID},#{workCenterNo},#{user},GetDate(),#{site})
  173. </insert>
  174. <delete id="deleteSkill">
  175. delete from operator_work_center where OperatorID=#{operatorID} and Site=#{site} and WorkCenterNo=#{workCenterNo}
  176. </delete>
  177. <insert id="addUserSkill">
  178. insert into user_work_center(UserId,WorkCenterNo,created_by,created_date,Site)
  179. values(#{userId},#{workCenterNo},#{user},GetDate(),#{site})
  180. </insert>
  181. <insert id="addUserSkillAll">
  182. insert into user_work_center(UserId,WorkCenterNo,created_by,created_date,Site)
  183. SELECT #{userId} ,a.WorkCenterNo ,#{user},GETDATE(), a.site FROM WorkCenter a
  184. left join user_work_center b on a.site=b.site and a.WorkCenterNo=b.WorkCenterNo and b.UserId= #{userId}
  185. where b.Site is null
  186. </insert>
  187. <delete id="deleteUserSkill">
  188. delete from user_work_center where UserId=#{userId} and Site=#{site} and WorkCenterNo=#{workCenterNo}
  189. </delete>
  190. <delete id="deleteUserSkillAll">
  191. delete from user_work_center where UserId=#{userId}
  192. </delete>
  193. <select id="checkWorkCenterOperatorData" resultType="WorkCenterData">
  194. select site FROM operator_work_center where OperatorID=#{operatorID} and Site=#{site} and WorkCenterNo=#{workCenterNo}
  195. </select>
  196. <select id="checkUserOperatorData" resultType="WorkCenterData">
  197. select site FROM user_work_center where userId=#{userId} and Site=#{site} and WorkCenterNo=#{workCenterNo}
  198. </select>
  199. <select id="getAllWorkCenterDataForUser" resultType="WorkCenterData">
  200. select a.Site,a.WorkCenterNo,a.WorkCenterDesc,a.Active FROM WorkCenter a left join
  201. user_work_center b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo and b.userId=#{user}
  202. where b.WorkCenterNo is null and a.Active='Y'
  203. order by a.WorkCenterNo ,a.site
  204. </select>
  205. <select id="getWorkCenterUserData" resultType="WorkCenterData">
  206. select a.Site,a.WorkCenterNo,b.WorkCenterDesc,b.Active FROM user_work_center a left join
  207. WorkCenter b on a.Site=b.Site and a.WorkCenterNo=b.WorkCenterNo
  208. where a.userId=#{user} and b.Active='Y'
  209. order by a.WorkCenterNo,a.site
  210. </select>
  211. <select id="getShopOrderRoutingData" resultType="ShopOrderRoutingData">
  212. select a.site, a.OrderNo,a.PartNo,a.Status,a.PlanStartDate,a.NeedDate,a.LotSize,a.EnterDate,a.UserName,
  213. P.Spec+'/'+isnull(P.PartDescription,'') PartDescription,P.Spec,isnull(SL.scheduledQty,0) as scheduledQty,s.workCenterNo,S.qtyReported,S.qtyApprove,S.machSetupTime,
  214. S.machRunFactor,S.factorUnit,S.ItemNo,S.OperationDesc,s.Efficiency,isnull(SOP.TotalFinishedQty,0) lastApproveQty,dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo) weightFactor,
  215. Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.LotSize,2) weight,dbo.Get_PartPlanQty(a.site,a.PartNo,a.OrderNo) partPlanQty,cod.PlanShipDate,
  216. dbo.Get_LastStartTime( a.site, a.OrderNo,S.ItemNo) LastStartDate,Round(S.DefectiveQty,3) DefectiveQty
  217. FROM ShopOrder a
  218. LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site
  219. LEFT JOIN SORouting S on S.site=a.site and S.OrderNo=a.orderNo
  220. LEFT JOIN ScheduleList SL on S.site=SL.site and S.OrderNo=SL.orderNo and S.ItemNo=SL.ItemNo
  221. LEFT JOIN SORoutingOutput SOP ON a.site=SOP.site and a.OrderNo=SOP.OrderNo and SOP.itemNo=dbo.Get_SORouting_PreviousOperationItemNo(a.site,a.OrderNo,S.itemNo)
  222. left join user_work_center uwc on a.site=uwc.site and s.workCenterNo =uwc.WorkCenterNo and uwc.userId=#{userId}
  223. left join CODetail cod on a.site=cod.site and a.orderRef1=cod.OrderNo and a.orderRef2= CONVERT(VARCHAR(10),cod.ItemNo)
  224. <where>
  225. and uwc.WorkCenterNo is not null
  226. and a.PartNo NOT like 'SP%' and a.PartNo NOT like 'RC%' and a.PartNo NOT like 'SC%' AND a.OrderNo not LIKE 'HL%'
  227. <if test="site != null and site != ''">
  228. AND a.site = #{site}
  229. </if>
  230. <if test="orderNo != null and orderNo != ''">
  231. AND a.OrderNo LIKE #{orderNo}
  232. </if>
  233. and a.status in ('已下达','已发料','已入库','已开工','已排产')
  234. <if test="startDate1 != null ">
  235. AND a.EnterDate >= #{startDate1}
  236. </if>
  237. <if test="endDate1 != null ">
  238. AND #{endDate1} >= DATEADD(dd, -1, a.EnterDate)
  239. </if>
  240. <if test="startDate2 != null ">
  241. AND a.PlanStartDate >= #{startDate2}
  242. </if>
  243. <if test="endDate2 != null ">
  244. AND #{endDate2} >= a.PlanStartDate
  245. </if>
  246. <if test="startDate3 != null ">
  247. AND a.NeedDate >= #{startDate3}
  248. </if>
  249. <if test="endDate3 != null ">
  250. AND #{endDate3} >= a.NeedDate
  251. </if>
  252. <if test="startDate4 != null ">
  253. AND cod.PlanShipDate >= #{startDate4}
  254. </if>
  255. <if test="endDate4 != null ">
  256. AND #{endDate4} >= cod.PlanShipDate
  257. </if>
  258. <if test="partNo != null and partNo != ''">
  259. AND a.PartNo LIKE #{partNo}
  260. </if>
  261. <if test="planStatus != null and planStatus != ''">
  262. and ${planStatus}
  263. </if>
  264. <if test="itemNo != null and itemNo != ''">
  265. and S.ItemNo = #{itemNo}
  266. </if>
  267. <if test="partDescription != null and partDescription != ''">
  268. and P.Spec+'/'+isnull(P.PartDescription,'') like #{partDescription}
  269. </if>
  270. <if test="eLevels != null ">
  271. and a.E_Levels = #{eLevels}
  272. </if>
  273. </where>
  274. order by a.PlanStartDate desc,s.itemNo
  275. </select>
  276. <update id="updateSOTaskCombineTime">
  277. update SOTaskOrderHeader set CombineTime = GetDate() where site=#{site} and orderNo=#{orderNo}
  278. </update>
  279. <select id="getSOTastRoutingData" resultType="ShopOrderRoutingData">
  280. select a.site, a.OrderNo,a.PartNo,a.Status,a.OrderRef1,a.OrderDate,a.OrderQty as LotSize,dbo.Get_PartValue(a.site,a.PartNo,'equipment') as equipment,
  281. P.Spec+'/'+isnull(P.PartDescription,'') PartDescription,P.Spec,isnull(SL.scheduledQty,0) as scheduledQty,s.workCenterNo,S.machSetupTime,
  282. S.machRunFactor,S.factorUnit,S.ItemNo,S.OperationDesc,s.Efficiency,a.qtyfinished,a.finishFlag,ROUND(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderRef1)*a.OrderQty,2) as weight,
  283. dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderRef1) as weightFactor,dbo.Get_PartPlanQty(a.site,a.PartNo,a.OrderRef1) partPlanQty,so.needDate,cod.PlanShipDate
  284. ,a.comBineTime lastStartDate
  285. FROM SOTaskOrderHeader a
  286. LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site
  287. LEFT JOIN SORouting S on S.site=a.site and S.OrderNo=a.OrderRef1
  288. LEFT JOIN ScheduleList SL on S.site=SL.site and a.OrderNo=SL.orderNo and S.ItemNo=SL.ItemNo
  289. left join user_work_center uwc on a.site=uwc.site and s.workCenterNo =uwc.WorkCenterNo and uwc.userId=#{userId}
  290. LEFT JOIN ShopOrder so on a.OrderRef1=so.OrderNo and a.site=so.site
  291. left join CODetail cod on so.site=cod.site and so.orderRef1=cod.OrderNo and so.orderRef2= CONVERT(VARCHAR(10),cod.ItemNo)
  292. <where>
  293. and uwc.WorkCenterNo is not null
  294. and so.status not in ('已关闭','已计划','已取消')
  295. <if test="site != null and site != ''">
  296. AND a.site = #{site}
  297. </if>
  298. <if test="orderNo != null and orderNo != ''">
  299. AND a.OrderNo LIKE #{orderNo}
  300. </if>
  301. <if test="status !=null and status != ''">
  302. AND a.Status IN ${status}
  303. </if>
  304. <if test="startDate1 != null ">
  305. AND a.orderDate >= #{startDate1}
  306. </if>
  307. <if test="endDate1 != null ">
  308. AND #{endDate1} >= a.orderDate
  309. </if>
  310. <if test="partDescription != null and partDescription != ''">
  311. and P.Spec+'/'+isnull(P.PartDescription,'') like #{partDescription}
  312. </if>
  313. <if test="orderRef1 != null and orderRef1 != ''">
  314. AND a.OrderRef1 LIKE #{orderRef1}
  315. </if>
  316. <if test="partNo != null and partNo != ''">
  317. AND a.PartNo LIKE #{partNo}
  318. </if>
  319. <if test="planStatus != null and planStatus != ''">
  320. and ${planStatus}
  321. </if>
  322. <if test="itemNo != null and itemNo != ''">
  323. and S.ItemNo = #{itemNo}
  324. </if>
  325. <if test="finishFlag != null and finishFlag != ''">
  326. AND a.FinishFlag=#{finishFlag}
  327. </if>
  328. <if test="startDate3 != null ">
  329. AND so.NeedDate >= #{startDate3}
  330. </if>
  331. <if test="endDate3 != null ">
  332. AND #{endDate3} >= so.NeedDate
  333. </if>
  334. <if test="startDate4 != null ">
  335. AND cod.PlanShipDate >= #{startDate4}
  336. </if>
  337. <if test="endDate4 != null ">
  338. AND #{endDate4} >= cod.PlanShipDate
  339. </if>
  340. </where>
  341. order by a.OrderDate desc,s.itemNo
  342. </select>
  343. <select id="getWorkCenterOperatorList" resultType="OperatorData">
  344. Select a.OperatorID,a.OperatorName from Operator a left join operator_work_center b on a.site=b.site and a.OperatorID=b.OperatorID
  345. where a.site=#{site} and b.WorkCenterNo=#{workCenterNo} and a.Active='Y'
  346. </select>
  347. <select id="checkScheduleQty" resultType="ScheduleCheckData">
  348. Select a.lotSize as Qty,isnull(b.scheduledQty,0) scheduledQty from ShopOrder a left join ScheduleList b on a.site=b.site and a.orderNo=b.orderNo and b.itemNo=#{itemNo} where a.Site=#{site} and a.OrderNo=#{orderNo}
  349. </select>
  350. <select id="checkScheduleQtyForSoTask" resultType="ScheduleCheckData">
  351. Select a.OrderQty as Qty,isnull(b.scheduledQty,0) scheduledQty from SOTaskOrderHeader a left join ScheduleList b on a.site=b.site and a.orderNo=b.orderNo and b.itemNo=#{itemNo} where a.Site=#{site} and a.OrderNo=#{orderNo}
  352. </select>
  353. <select id="checkScheduleList" resultType="ScheduleCheckData">
  354. Select Qty from ScheduleList where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo}
  355. </select>
  356. <insert id="saveScheduleList">
  357. insert into ScheduleList(Site,OrderNo,ItemNo,Type,Type_db,Qty,scheduledQty) values (#{site},#{orderNo},#{itemNo},'生产订单派工单','S',#{qty},0)
  358. </insert>
  359. <insert id="saveScheduleListForSOTask">
  360. insert into ScheduleList(Site,OrderNo,ItemNo,Type,Type_db,Qty,scheduledQty) values (#{site},#{orderNo},#{itemNo},'日计划派工单','D',#{qty},0)
  361. </insert>
  362. <select id="getDataSequence" resultType="integer">
  363. select seqNo from DataSequence where SeqType= 'A'
  364. </select>
  365. <update id="updateDataSequence">
  366. update DataSequence set seqNo=seqNo+1 where SeqType= 'A'
  367. </update>
  368. <insert id="saveSchedule">
  369. Insert into soscheduledrouting(Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime
  370. ,BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ShiftNo,S_WorkCenterNo
  371. ,SelectedFlag,SourceFlag,ParkFlag,TimeRequired_Original,QtyRequired_Original
  372. ,StartProdFlag,CancelledProdFlag,Efficiency,EnteredDate,scheduleType,operatorId,partNo,OrderRef1,cancelReportFlag,CreateBy,WorkTime,stopTime,jobType)
  373. values(#{site},#{orderNo},#{itemNo},#{seqNo},#{scheduleQty},0,0,dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),0,#{scheduleDate},#{scheduleDate}
  374. ,'*',#{remark},1,'N',0,'Y',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo}
  375. ,'N','N','N',dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),#{scheduleQty}
  376. ,'N','N',#{efficiency},GETDATE(),'生产订单派工单',#{operatorId},#{partNo},#{orderNo},'N',#{createBy},0,0,#{jobType})
  377. </insert>
  378. <insert id="saveScheduleForSOTask">
  379. Insert into soscheduledrouting(Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime
  380. ,BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ShiftNo,S_WorkCenterNo
  381. ,SelectedFlag,SourceFlag,ParkFlag,TimeRequired_Original,QtyRequired_Original
  382. ,StartProdFlag,CancelledProdFlag,Efficiency,EnteredDate,scheduleType,operatorId,partNo,OrderRef1,cancelReportFlag,CreateBy,WorkTime,stopTime,jobType)
  383. values(#{site},#{orderRef1},#{itemNo},#{seqNo},#{scheduleQty},0,0,dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderRef1},#{itemNo},#{scheduleQty}),0,#{scheduleDate},#{scheduleDate}
  384. ,'*',#{remark},1,'N',0,'Y',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo}
  385. ,'N','N','N',dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderRef1},#{itemNo},#{scheduleQty}),#{scheduleQty}
  386. ,'N','N',#{efficiency},GETDATE(),'日计划派工单',#{operatorId},#{partNo},#{orderNo},'N',#{createBy},0,0,#{jobType})
  387. </insert>
  388. <update id="updateScheduleListQty">
  389. update ScheduleList set scheduledQty=scheduledQty+#{sumQty} where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} and type=#{scheduleType}
  390. </update>
  391. <select id="searchReportedQty" resultType="SORoutingData">
  392. select top 1 isnull(a.QtyReported,0) QtyReported,isnull(SOP.TotalFinishedQty,0) lastApproveQty ,dbo.Get_PartWeightFactorForReport(#{site},#{partNo},#{orderNo}) as weightFactor,dbo.Get_sfdcReportedSetupTime(#{site},#{seqNo}) as timeReported,
  393. [dbo].[Get_Part_Cavity](#{site},#{partNo},#{orderNo}) as cavity
  394. from SORouting a
  395. LEFT JOIN SORoutingOutput SOP ON a.site=SOP.site and a.OrderNo=SOP.OrderNo and SOP.itemNo=dbo.Get_SORouting_PreviousOperationItemNo(a.site,a.OrderNo,a.itemNo)
  396. where a.Site=#{site} and a.OrderNo=#{orderNo} and a.itemNo=#{itemNo}
  397. </select>
  398. <select id="getSPBomQtyAssembly" resultType="com.heai.modules.app.entity.SoBomData">
  399. select QtyAssembly from SOBOM where site=#{site} and OrderNo=#{orderNo} and ComponentPartNo like 'SP%'
  400. </select>
  401. <select id="searchLastApproveQty" resultType="SORoutingData">
  402. select top 1 isnull(TotalFinishedQty,0) lastApproveQty from SORoutingOutput where Site=#{site} and OrderNo=#{orderNo} and itemNo=dbo.Get_SORouting_PreviousOperationItemNo(#{site},#{orderNo},#{itemNo})
  403. </select>
  404. <select id="getSOScheduleRoutingDataForShiyanshi" resultType="SOScheduledRoutingOutData">
  405. select a.Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,
  406. BarcodeID,Remark,Crewsize,ClosedFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  407. S_WorkCenterNo, EnteredDate,scheduleType,operatorId,partNo,dbo.Get_Part_SpecDesc(a.Site,partNo) as partDesc,
  408. dbo.Get_OperatorDesc(a.Site,operatorId) as operatorName,dbo.Get_ItemDesc(a.Site,OrderNo,ItemNo) as itemDesc,orderRef1 ,
  409. dbo.Get_WorkCenterDesc(a.Site,S_WorkCenterNo) as workCenterDesc , dbo.Get_Part_SpecDesc(a.Site,partNo) as partSpec,circulation_seqNo,circulation_qty
  410. ,dbo.Get_PartWeightFactorForReport(a.site,PartNo,OrderNo) as weightFactor,dbo.Get_Part_UMID(a.Site,PartNo) umid,
  411. Round(dbo.Get_PartWeightFactorForReport(a.site,PartNo,OrderNo)*QtyRequired,2) as weight from SOScheduledRouting a
  412. <where>
  413. <if test="seqNo != null and seqNo != ''">
  414. AND a.seqNo = #{seqNo}
  415. </if>
  416. <if test="site != null and site != ''">
  417. AND a.site = #{site}
  418. </if>
  419. </where>
  420. order by S_ScheduledDate
  421. </select>
  422. <select id="getSOScheduleRoutingData" resultType="SOScheduledRoutingOutData">
  423. select a.Site,a.OrderNo,a.ItemNo,a.SeqNo,a.QtyRequired,a.QtyReported,a.QtyApprove,a.TimeRequired,a.TimeReported,a.previousSeqNo,a.previousBatchNo,a.materSeqNo,
  424. a.BarcodeID,a.Remark,a.Crewsize,a.ClosedFlag,a.S_ScheduledDate,a.S_ResourceID,a.S_ScheduledSeqNo,a.S_ShiftNo,
  425. a.S_WorkCenterNo, a.EnteredDate,a.scheduleType,a.operatorId,a.partNo,dbo.Get_Part_SpecDesc(a.Site,a.partNo) as partDesc,
  426. dbo.Get_OperatorDesc(a.Site,a.operatorId) as operatorName,dbo.Get_ItemDesc(a.Site,a.OrderNo,a.ItemNo) as itemDesc,a.orderRef1 ,
  427. dbo.Get_WorkCenterDesc(a.Site,a.S_WorkCenterNo) as workCenterDesc , dbo.Get_Part_SpecDesc(a.Site,a.partNo) as partSpec,a.circulation_seqNo,a.circulation_qty
  428. ,dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo) as weightFactor,dbo.Get_Part_UMID(a.Site,a.PartNo) umid,a.jobType,
  429. case when a.worktime is not null and a.worktime>0 then Round(a.QtyReported/a.worktime,2) else Round(a.QtyReported/0.1,2) end as efficiency,Round(isnull(a.workTime,0),2) workTime,
  430. Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.QtyRequired,2) as weight ,c.MachRunFactor
  431. ,case when 0>=c.MachRunFactor then 0 else Round(a.QtyReported*100/case when isnull(a.worktime,0.1)=0 then 0.1 else isnull(a.worktime,0.1) end/c.MachRunFactor,2) end as xiaolv
  432. from SOScheduledRouting a
  433. left join user_work_center uwc on a.site=uwc.site and a.S_WorkCenterNo =uwc.WorkCenterNo and uwc.userId=#{userId}
  434. left join SORouting c on a.Site=c.Site and a.orderNo=c.orderNo and a.itemNo=c.itemNo
  435. <where>
  436. and uwc.WorkCenterNo is not null
  437. <if test="site != null and site != ''">
  438. AND a.site = #{site}
  439. </if>
  440. <if test="orderNo != null and orderNo != ''">
  441. AND a.OrderNo LIKE #{orderNo}
  442. </if>
  443. <if test="partDesc != null and partDesc != ''">
  444. AND dbo.Get_Part_SpecDesc(a.Site,a.partNo) LIKE #{partDesc}
  445. </if>
  446. <if test="seqNo != null ">
  447. AND a.seqNo = #{seqNo}
  448. </if>
  449. <if test="partNo != null and partNo != ''">
  450. AND a.PartNo LIKE #{partNo}
  451. </if>
  452. <if test="sWorkCenterNo != null and sWorkCenterNo != ''">
  453. AND a.S_WorkCenterNo LIKE #{sWorkCenterNo}
  454. </if>
  455. <if test="itemNo != null and itemNo != ''">
  456. and a.ItemNo = #{itemNo}
  457. </if>
  458. <if test="itemDesc != null and itemDesc != ''">
  459. and dbo.Get_ItemDesc(a.Site,a.OrderNo,a.ItemNo) = #{itemDesc}
  460. </if>
  461. <if test="closedFlag != null and closedFlag != ''">
  462. and a.ClosedFlag = #{closedFlag}
  463. </if>
  464. <if test="startDate != null ">
  465. and a.S_ScheduledDate >= #{startDate}
  466. </if>
  467. <if test="endDate != null ">
  468. and #{endDate} >= a.S_ScheduledDate
  469. </if>
  470. <if test="scheduleType != null and scheduleType != ''">
  471. and a.scheduleType = #{scheduleType}
  472. </if>
  473. <if test="reportFlag != null and reportFlag != ''">
  474. and ${reportFlag}
  475. </if>
  476. <if test="operatorName != null and operatorName != ''">
  477. and dbo.Get_OperatorDesc(a.Site,a.operatorId) like #{operatorName}
  478. </if>
  479. <if test="sResourceID != null and sResourceID != ''">
  480. and a.S_ResourceID like #{sResourceID}
  481. </if>
  482. <if test="sShiftNo != null and sShiftNo != ''">
  483. and a.S_ShiftNo = #{sShiftNo}
  484. </if>
  485. <if test="previousSeqNo != null ">
  486. and a.previousSeqNo = #{previousSeqNo}
  487. </if>
  488. <if test="materSeqNo != null ">
  489. and a.materSeqNo = #{materSeqNo}
  490. </if>
  491. </where>
  492. order by a.S_ScheduledDate
  493. </select>
  494. <select id="checkUserSeqNo" resultType="SOScheduledRoutingOutData">
  495. select seqNo ,CancelReportFlag,a.mat_issueflag,a.site,a.OrderNo,a.ItemNo,a.QtyRequired,a.S_WorkCenterNo,a.operatorId,a.partNo,dbo.Get_Part_Spec(a.site,a.partNo) PartSpec
  496. ,PreviousSeqNo,PreviousBatchNo,materSeqNo from SOScheduledRouting a
  497. left join user_work_center uwc on a.site=uwc.site and a.S_WorkCenterNo =uwc.WorkCenterNo and uwc.userId=#{userId}
  498. where seqNo=#{seqNo} and uwc.WorkCenterNo is not null
  499. </select>
  500. <select id="checkLastItemReport" resultType="SORoutingData">
  501. SELECT max(ItemNo) itemNo,QtyReported FROM [dbo].[SORouting]
  502. <where>
  503. <if test="site != null and site != ''">
  504. AND site = #{site}
  505. </if>
  506. and orderNo=#{orderNo} and #{itemNo}>ItemNo
  507. </where>
  508. Group by QtyReported
  509. </select>
  510. <select id="getStockPrint" resultType="com.heai.modules.production.entity.StockPrintData">
  511. select a.TransNo,a.Site,a.WareHouseId,a.BatchNo,a.LocationId,a.PartNo,a.OrderNo,a.TransDate,a.Qty,a.PrintFlag,dbo.Get_PartDesc(a.Site,a.PartNo) as partDesc,Round(dbo.Get_Part_NetWeight(a.Site,a.PartNo)*a.Qty/1000,2) weight
  512. ,dbo.Get_WareHouseDesc(a.Site,a.WareHouseId) as wareHouseDesc,dbo.Get_Part_UMID(a.Site,a.PartNo) umid,dbo.get_expiredDate_print(a.Site,a.PartNo,a.BatchNo) expiredDate
  513. ,dbo.Get_StorePrintPartStatus(a.Site,a.PartNo,a.BatchNo) status,isnull(Round(b.QtyOnHand,3),0) QtyOnHand
  514. from StockPrint a
  515. left join InventoryStock b on a.Site=b.site and a.WareHouseId=b.WarehouseID and a.PartNo=b.PartNo and a.BatchNo=b.BatchNo and
  516. a.LocationId=b.LocationId
  517. <where>
  518. <if test="startDate != null ">
  519. and a.TransDate >= #{startDate}
  520. </if>
  521. <if test="endDate != null ">
  522. and #{endDate} >= a.TransDate -1
  523. </if>
  524. <if test="site != null and site != ''">
  525. AND a.site = #{site}
  526. </if>
  527. <if test="orderNo != null and orderNo != ''">
  528. AND a.orderNo LIKE #{orderNo}
  529. </if>
  530. <if test="seqNo != null and seqNo != ''">
  531. AND a.seqNo = #{seqNo}
  532. </if>
  533. <if test="printFlag != null and printFlag != ''">
  534. AND a.printFlag = #{printFlag}
  535. </if>
  536. <if test="batchNo != null and batchNo != ''">
  537. AND a.BatchNo LIKE #{batchNo}
  538. </if>
  539. <if test="partNo != null and partNo != ''">
  540. AND a.PartNo LIKE #{partNo}
  541. </if>
  542. </where>
  543. order by a.TransDate desc
  544. </select>
  545. <update id="updatePrintStock">
  546. update StockPrint set PrintFlag='Y' where Site=#{site} and TransNo=#{transNo}
  547. </update>
  548. <update id="updatePrintInfo">
  549. update print_info set status='Y' where Site=#{site} and orderref1=#{transNo}
  550. </update>
  551. <select id="checkFirstItem" resultType="SOScheduledRoutingOutData">
  552. select site,OrderNo,ItemNo from SORouting where orderNo=#{orderNo} and site=#{site} and #{itemNo} >itemNo order by itemNo desc
  553. </select>
  554. <select id="searchSeqNo" resultType="SOScheduledRoutingOutData">
  555. select top 1 Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,
  556. BarcodeID,Remark,Crewsize,ClosedFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  557. S_WorkCenterNo, EnteredDate,scheduleType,operatorId,partNo,dbo.Get_PartDesc(Site,partNo) as partDesc,
  558. dbo.Get_OperatorDesc(Site,operatorId) as operatorName,dbo.Get_ItemDesc(site,orderNo,ItemNo) as itemDesc,orderRef1 ,
  559. dbo.Get_WorkCenterDesc(Site,S_WorkCenterNo) as workCenterDesc , dbo.Get_Part_SpecDesc(Site,partNo) as partSpec,closedFlag,outWorkFlag,ParkFlag,CancelReportFlag
  560. from SOScheduledRouting
  561. where site=#{site} and SeqNo=#{seqNo}
  562. </select>
  563. <select id="checkELevels" resultType="Integer">
  564. select isnull(E_Levels,-1) E_Levels from shoporder where site=#{site} and orderNo=#{orderNo}
  565. </select>
  566. <select id="checkShopOrderForTransfer" resultType="com.heai.modules.production.entity.ShopOrderData">
  567. select orderNo,PartNo from shoporder where site=#{site} and orderNo=#{orderNo}
  568. </select>
  569. <select id="checkReceiveFlag" resultType="com.heai.modules.production.entity.SOOpsTransferData">
  570. select a.TransNo from SOOpsTransferHeader a left join SOOpsTransferDetail b on a.site=b.site and a.TransNo=b.TransNo
  571. where a.site=#{site} and b.seqNo=#{seqNo} and a.Status='已录入' and a.NeedReceiveFlag='Y' and a.ToTypeFlag_DB='W'
  572. </select>
  573. <select id="checkNotInspectTransFer" resultType="com.heai.modules.production.entity.SOOpsTransferData">
  574. select a.TransNo from SOOpsTransferHeader a left join SOOpsTransferDetail b on a.site=b.site and a.TransNo=b.TransNo
  575. where a.site=#{site} and b.seqNo=#{seqNo} and a.Status='已录入' and a.NeedReceiveFlag='Y' and a.ToTypeFlag_DB='I'
  576. </select>
  577. <select id="getSOScheduledRoutingOutData" resultType="SOScheduledRoutingOutData">
  578. select Site,OrderNo,seqNo,itemNo,S_ShiftNo,scheduleType,operatorId from SOScheduledRouting where seqNo=#{seqNo}
  579. </select>
  580. <select id="checkItemNoForIssue" resultType="SORoutingData">
  581. select Site,OrderNo,itemNo from SORouting where Site=#{site} and orderNo=#{orderNo} and #{itemNo}>itemNo
  582. </select>
  583. <select id="getsfdcTimeHistData" resultType="com.heai.modules.production.entity.SfdcTimeHistData">
  584. select top 1 site,OrderNo,ItemNo,SeqNo,#{username} as Enteredby ,ClosedFlag,OutWorkFlag from SOScheduledRouting where site=#{site} and SeqNo=#{seqNo} and ClosedFlag='N'
  585. </select>
  586. <select id="getsfdcTimeHistAbnormal" resultType="com.heai.modules.production.entity.SfdcTimeHistData">
  587. select top 1 site,SeqNo,AbnormalCode,AbnormalRemark from SFDC_TimeHist where site=#{site} and SeqNo=#{seqNo} and EventType='D' order by HistSeqNo desc
  588. </select>
  589. <select id="getSeqNoSite" resultType="String">
  590. select site from SOScheduledRouting where SeqNo=#{seqNo}
  591. </select>
  592. <select id="checkSfdcTimeHistData" resultType="com.heai.modules.production.entity.SfdcTimeHistData">
  593. select site,OrderNo,ItemNo,SeqNo from SFDC_TimeHist where site=#{site} and seqNo=#{seqNo} and EventDesc='开始生产' and CompletedFlag='N'
  594. </select>
  595. <select id="getHistSeqNo" resultType="Integer">
  596. select isnull(max(HistSeqNo),0)+1 from SFDC_TimeHist where site=#{site} and seqNo=#{seqNo}
  597. </select>
  598. <update id="updateSfdcTimeHistDataContinue" >
  599. Update SFDC_TimeHist set CompletedFlag='Y' ,TillTime=GETDATE(),TillEnteredTime=GETDATE(),TillEnteredBy=#{enteredby},TotalTime=Round(datediff(mi,EventTime,GETDATE())/60.0,2) where SeqNo=#{seqNo,jdbcType=INTEGER} and Site=#{site} and CompletedFlag='N' and EventDesc='暂停生产'
  600. </update>
  601. <update id="updateStopWork" >
  602. update SOScheduledRouting set OutWorkFlag=#{flag} where Site=#{site} and seqNo=#{seqNo}
  603. </update>
  604. <insert id="saveSfdcTimeHistDataStart">
  605. insert into SFDC_TimeHist (Site,OrderNo,ItemNo,SeqNo,HistSeqNo,EventTime,Enteredby,EventDesc,DowntimeCode,EventType,LinkHistSeqNo,TillTime,TillEnteredTime,
  606. TillEnteredBy,CompletedFlag,TotalTime,DowntimePhaseIn,RollNo,LastStartTime) values
  607. (#{site},#{orderNo},#{itemNo},#{seqNo},#{histSeqNo},GetDate(),#{enteredby},'开始生产','','P',null,null,null,null,'N',0,'','*',#{lastStartTime})
  608. </insert>
  609. <insert id="saveSfdcTimeHistDataStop">
  610. insert into SFDC_TimeHist (Site,OrderNo,ItemNo,SeqNo,HistSeqNo,EventTime,Enteredby,EventDesc,DowntimeCode,EventType,LinkHistSeqNo,TillTime,TillEnteredTime,
  611. TillEnteredBy,CompletedFlag,TotalTime,DowntimePhaseIn,RollNo,AbnormalCode,AbnormalRemark) values
  612. (#{site},#{orderNo},#{itemNo},#{seqNo},#{histSeqNo},GetDate(),#{enteredby},'暂停生产','','D',null,null,null,null,'N',0,'','*',#{abnormalCode},#{abnormalRemark})
  613. </insert>
  614. <select id="getOldSOScheduledRoutingOutData" resultType="SOScheduledRoutingOutData">
  615. select Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime,
  616. BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  617. S_WorkCenterNo,ParkFlag,TimeRequired_Original,QtyRequired_Original,QtyReturntoSchedule,StartProdFlag,CancelledProdFlag,
  618. Efficiency,EnteredDate,SelectedFlag,SourceFlag,Closedby,ClosedDate,VirtualResourceFlag,mat_issueflag,plate_issueflag,
  619. tool_issueflag,scheduleType,operatorId,partNo,orderRef1,circulation_seqNo,circulation_qty,PreviousSeqNo,PreviousBatchNo,materSeqNo,jobType from SOScheduledRouting where
  620. site=#{site} and seqNo=#{seqNo}
  621. </select>
  622. <update id="closeOldSchedule">
  623. update SOScheduledRouting set ClosedFlag='Y',circulation_seqNo=#{newSeqNo},circulation_qty=#{circulationQty} where site=#{site} and seqNo=#{oldSeqNo}
  624. </update>
  625. <insert id="saveCirculationSchedule" >
  626. INSERT into SOScheduledRouting (Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime,
  627. BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ScheduledSeqNo,S_ShiftNo,
  628. S_WorkCenterNo,ParkFlag,TimeRequired_Original,QtyRequired_Original,QtyReturntoSchedule,StartProdFlag,CancelledProdFlag,
  629. Efficiency,EnteredDate,SelectedFlag,SourceFlag,Closedby,ClosedDate,VirtualResourceFlag,mat_issueflag,plate_issueflag,
  630. tool_issueflag,scheduleType,operatorId,partNo,orderRef1,jobType,PreviousSeqNo,PreviousBatchNo,materSeqNo) values
  631. (#{site},#{orderNo},#{itemNo},#{seqNo},#{qtyRequired},0,0,0,0,#{planStartTime},#{planFinishTime},
  632. #{barcodeID},#{remark},#{crewsize},'N',0,'Y',#{sScheduledDate},#{sResourceID},#{sScheduledSeqNo},#{sShiftNo},
  633. #{sWorkCenterNo},#{parkFlag},#{timeRequiredOriginal},#{qtyRequiredOriginal},null,'N','N',
  634. 0,GetDate(),'N','N',NULL,NULL,NULL,#{matIssueflag},'N','N',#{scheduleType},#{operatorId},#{partNo},#{orderRef1},#{jobType}
  635. ,#{previousSeqNo},#{previousBatchNo},#{materSeqNo})
  636. </insert>
  637. <update id="closeSchedule">
  638. update SOScheduledRouting set ClosedFlag='Y' where site=#{site} and seqNo=#{seqNo}
  639. </update>
  640. <select id="getTransData" resultType="com.heai.modules.production.entity.SOOpsTransferData">
  641. select top 1 a.TransNo,a.Site,b.FromWorkCenterNo WorkCenterNo ,b.OrderNo,b.TransQty,a.TransDate,b.PartNo,b.seqNo,dbo.Get_Part_SpecDesc(a.Site,b.PartNo) partDesc
  642. ,dbo.Get_Part_UMID(a.Site,b.PartNo) umid,'trans' as type ,b.OrderRef5
  643. FROM SOOpsTransferHeader a left join SOOpsTransferDetail b on a.site=b.site and a.TransNo=b.TransNo
  644. where a.TransNo=#{transNo} and a.Site=#{site} and ToTypeFlag_DB!='I'
  645. </select>
  646. <select id="getBadPrintData" resultType="com.heai.modules.production.entity.SOOpsTransferData">
  647. SELECT top 1 b.partNo ,dbo.Get_Part_SpecDesc(b.Site,b.partNo) as partDesc,b.SeqNo,b.S_WorkCenterNo workCenterNo ,b.OrderNo,a.DefectQty transQty,
  648. dbo.Get_Part_UMID(b.Site,b.partNo) as umid,a.ReportDate as transDate ,b.site ,Round(a.DefectQty*dbo.Get_PartWeightFactorForReport(b.Site,b.partNo,''),3) as orderRef5,a.Remark,
  649. c.createdBy userName,'bad' as type
  650. FROM SFDC_DefectHist a
  651. left join sfdc c on a.Site=c.Site and a.SeqNo=c.SeqNo and a.OrderNo=c.OrderNo and a.ItemNo=c.ItemNo
  652. left join SOScheduledRouting b on c.AssJobSeqNo=b.SeqNo and a.Site=b.Site
  653. where a.site=#{site} and b.seqNo=#{seqNo} and a.DefectCode='PQ003'
  654. order by a.seqNo desc
  655. </select>
  656. <select id="printDefectCard" resultType="com.heai.modules.production.entity.SOOpsTransferData">
  657. SELECT b.partNo ,dbo.Get_Part_SpecDesc(b.Site,b.partNo) as partDesc,b.SeqNo,b.S_WorkCenterNo workCenterNo ,b.OrderNo,a.DefectQty transQty,
  658. dbo.Get_Part_UMID(b.Site,b.partNo) as umid,a.ReportDate as transDate ,b.site ,convert(varchar(20),Round(a.DefectQty*dbo.Get_PartWeightFactorForReport(b.Site,b.partNo,''),3) )as orderRef5,a.Remark,
  659. c.createdBy userName,'bad' as type
  660. FROM SFDC_DefectHist a
  661. left join sfdc c on a.Site=c.Site and a.SeqNo=c.SeqNo and a.OrderNo=c.OrderNo and a.ItemNo=c.ItemNo
  662. left join SOScheduledRouting b on c.AssJobSeqNo=b.SeqNo and a.Site=b.Site
  663. where a.site=#{site} and a.orderNo=#{orderNo} and a.SeqNo=#{seqNo} and a.ItemNo=#{itemNo} and a.DefectCode='PQ003'
  664. </select>
  665. <select id="searchTaskTransNo" resultType="String">
  666. select top 1 TransNo from SOOpsTransferDetail where OrderNo=#{taskNo} and site=#{site}
  667. </select>
  668. <select id="transFerSearch" resultType="com.heai.modules.production.entity.SOOpsTransferData">
  669. SELECT a.transNo ,a.site,b.seqNo,a.TransDate,b.TransQty ,b.OrderNo ,b.PartNo,c.PartDescription as partDesc,
  670. case when a.status ='已入库' then '已入库' else '未入库' end as status
  671. FROM SOOpsTransferHeader a LEFT JOIN SOOpsTransferDetail b on a.TransNo=b.TransNo and a.site=b.Site
  672. LEFT JOIN Part c on b.PartNo=c.PartNo and b.site=c.site
  673. <where>
  674. and a.Status!='已取消' and a.ToTypeFlag_DB not in ('I','Q')
  675. <if test="startDate != null ">
  676. and TransDate >= #{startDate}
  677. </if>
  678. <if test="endDate != null ">
  679. and #{endDate} >= TransDate -1
  680. </if>
  681. <if test="site != null and site != ''">
  682. AND a.site = #{site}
  683. </if>
  684. <if test="orderNo != null and orderNo != ''">
  685. AND orderNo LIKE #{orderNo}
  686. </if>
  687. <if test="seqNo != null and seqNo != ''">
  688. AND seqNo = #{seqNo}
  689. </if>
  690. <if test="partNo != null and partNo != ''">
  691. AND b.PartNo LIKE #{partNo}
  692. </if>
  693. </where>
  694. ORDER BY a.TransDate
  695. </select>
  696. <select id="getPartCardPrintData" resultType="com.heai.modules.production.entity.PartCardPrintData">
  697. select top 1 a.orderNo,a.partNo,c.partDescription+'/'+C.Spec as partDesc,a.QtyRequired,a.S_ScheduledDate,
  698. dbo.Get_OperatorDesc(a.site,a.operatorId) OperatorName ,c.ToExpireDays,b.TechInfo,c.remark,Round(dbo.Get_PartWeightFactorForReport(a.site,a.PartNo,a.OrderNo)*a.QtyRequired,2) as weight
  699. from SOScheduledRouting a left join ShopOrder b on a.site=b.site and a.OrderNo=b.OrderNo
  700. left join part c on a.partNo=c.PartNo and a.site=c.site
  701. where a.site=#{site} and a.seqNo=#{seqNo}
  702. </select>
  703. <select id="checkTool" resultType="com.heai.modules.production.entity.SOToolData">
  704. select ToolID from SOTool where site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo}
  705. </select>
  706. <select id="getHunlianTaskNo" resultType="String">
  707. select 'HL'+CONVERT(varchar(100), GETDATE(), 112)+ Right( '00000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(TaskNo, 11,4))),0)+1) ,4) from Hunlian_TaskHeader where TaskNo like 'HL'+CONVERT(varchar(100), GETDATE(), 112)+'%'
  708. </select>
  709. <insert id="saveHunlianTaskDetailData" >
  710. insert into Hunlian_TaskDetail (Site,TaskNo,OrderNo,OrderRef1,OrderRef2,OrderQty,HunlianQty,OrderDate,PartNo,HunlianPartNo)
  711. select top 1 #{site},#{taskNo},#{orderNo},#{orderRef1},SO.OrderNo, SOT.OrderQty,#{hunlianQty},#{orderDate},SOT.partNo,#{hunlianPartNo}
  712. from SOTaskOrderHeader SOT
  713. left join ShopOrder t on t.site=#{site} and t.orderNo=#{orderRef1}
  714. left join ShopOrder SO on SOT.site=SO.Site and t.orderNo=SO.Prelev_order_no and t.E_OriginalOrderType=SO.E_OriginalOrderType and (SO.PartNo like 'RC%' or SO.PartNo like 'SC%' )
  715. where SOT.site=#{site} and SOT.orderNo=#{orderNo}
  716. </insert>
  717. <select id="getShopOrderScheduledQty" resultType="Double">
  718. select SUM(QtyRequired-isnull(circulation_qty,0)) from SOScheduledRouting where site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo}
  719. </select>
  720. <select id="getOrderNoLotSizeSchedulingSize" resultType="com.heai.modules.production.entity.ShopOrderData">
  721. select lotSize, dbo.Get_PartPlanQty(site,PartNo,OrderNo) schedulingSize from ShopOrder where site=#{site} and OrderNo=#{orderNo}
  722. </select>
  723. <select id="checkTask" resultType="com.heai.modules.production.entity.HunlianTaskDetailData">
  724. select OrderNo as orderRef1 ,orderNo_hunlian as orderNo FROM view_KANBAN_SO_Hunlian_Plan
  725. where site=#{site} and (erpStatus='已取消' or FinishedFlag in ('2','3') or dispatched_hunlian='Y' ) and orderNo_hunlian in
  726. (select orderNo from Hunlian_TaskDetail where site=#{site} and TaskNo=#{taskNo} )
  727. </select>
  728. <update id="updateSOTaskDispatchedFlag" >
  729. update SOTaskOrderHeader set dispatched_hunlian =#{flag} where site=#{site} and orderNo in
  730. (select orderNo from Hunlian_TaskDetail where site=#{site} and TaskNo=#{taskNo} )
  731. </update>
  732. <update id="updateTaskReportFlag" >
  733. update Hunlian_TaskHeader set ReportFlag=#{flag} ,ReportQty=#{reportQty},reportReal=#{qtyReal},reportDate=#{reportDate} where site=#{site} and TaskNo=#{taskNo}
  734. </update>
  735. <insert id="saveHunlianTaskHeaderData" >
  736. insert into Hunlian_TaskHeader (Site,TaskNo,TaskQty,PartNo,CreateDate,CreateBy,ReportFlag,ReportQty,DeleteFlag,WareHouseFlag,WareHouseQty,Remark,OrderRef1)
  737. values(#{site},#{taskNo},#{taskQty},#{partNo},GetDate(),#{createBy},'N',0,'N','N',0,#{remark},#{orderRef1})
  738. </insert>
  739. <select id="getPartNoOnHand" resultType="com.heai.modules.production.entity.InventoryStockSearchData">
  740. select site,partNo, Round(sum(QtyOnHand),2) QtyOnHand from InventoryStock where site=#{site} and partNo=#{partNo} group by site,partNo
  741. </select>
  742. <select id="getHunlianTaskData" resultType="com.heai.modules.production.entity.HunlianData">
  743. select a.Site,a.TaskNo,a.TaskQty,a.PartNo,a.CreateDate,a.CreateBy,a.ReportFlag,a.ReportQty,dbo.Get_Part_SpecDesc(a.Site,a.PartNo) as partDesc
  744. ,b.toExpireDays,a.WareHouseFlag,a.remark,a.orderRef1
  745. from Hunlian_TaskHeader a
  746. left join part b on a.site=b.site and a.PartNo=b.partNo
  747. <where>
  748. and a.deleteFlag='N'
  749. <if test="startDate != null ">
  750. and a.CreateDate >= #{startDate}
  751. </if>
  752. <if test="endDate != null ">
  753. and #{endDate} >= a.CreateDate -1
  754. </if>
  755. <if test="reportFlag != null and reportFlag != ''">
  756. AND a.reportFlag = #{reportFlag}
  757. </if>
  758. <if test="partNo != null and partNo != ''">
  759. AND a.partNo like #{partNo}
  760. </if>
  761. <if test="taskNo != null and taskNo != ''">
  762. AND a.taskNo LIKE #{taskNo}
  763. </if>
  764. </where>
  765. ORDER BY a.CreateDate
  766. </select>
  767. <select id="getHunlianTaskDetailData" resultType="com.heai.modules.production.entity.HunlianTaskDetailData">
  768. select a.Site,a.TaskNo,a.OrderNo,a.OrderRef1,a.OrderRef2,a.OrderQty,a.HunlianQty,a.OrderDate,a.PartNo,a.HunlianPartNo,
  769. dbo.Get_Part_SpecDesc(a.Site,a.HunlianPartNo) as partDesc
  770. from Hunlian_TaskDetail a
  771. where site=#{site} and TaskNo=#{taskNo}
  772. </select>
  773. <select id="getHunlianTaskDetailDataSum" resultType="com.heai.modules.production.entity.HunlianTaskDetailData">
  774. select a.Site,a.TaskNo,a.OrderRef2,SUM(a.HunlianQty) HunlianQty,a.HunlianPartNo
  775. from Hunlian_TaskDetail a
  776. where site=#{site} and TaskNo=#{taskNo}
  777. GROUP BY a.Site,a.TaskNo,a.OrderRef2,a.HunlianPartNo
  778. </select>
  779. <select id="checkTaskHeader" resultType="com.heai.modules.production.entity.HunlianData">
  780. select Site,TaskNo,TaskQty,PartNo,CreateDate,CreateBy,ReportFlag,ReportQty,DeleteFlag,DeleteBy,DeleteDate,WareHouseFlag,orderRef1 from Hunlian_TaskHeader
  781. where site=#{site} and DeleteFlag='N' and TaskNo=#{taskNo}
  782. </select>
  783. <select id="checkTaskOrder" resultType="com.heai.modules.production.entity.HunlianData">
  784. select orderNo from shopOrder where status in ('已取消','已关闭') and site=#{site} and orderNo in (select orderRef1 from Hunlian_TaskDetail where site=#{site}
  785. and taskNo=#{taskNo} )
  786. </select>
  787. <update id="deleteTask">
  788. update Hunlian_TaskHeader set DeleteFlag='Y',DeleteBy=#{userId},DeleteDate=GetDate() where site=#{site} and TaskNo=#{taskNo}
  789. </update>
  790. <update id="updateSOTaskReport" parameterType="com.heai.modules.production.entity.DailyReportInData">
  791. update SOTaskOrderHeader SET Qtyfinished=Round(#{reportQty}*#{orderQty}/#{taskQty},1),ReportTime=GetDate(),FinishFlag='Y',ReportBy=#{userId} ,InputQty=Round(#{reportQty}*#{hunlianQty}/#{taskQty},1) where OrderNo=#{orderNo} and site =#{site}
  792. </update>
  793. <update id="cancelReportSOTask" parameterType="com.heai.modules.production.entity.HunlianData">
  794. update SOTaskOrderHeader SET Qtyfinished=0,ReportTime=null,FinishFlag='N',ReportBy=null ,InputQty=0 where site =#{site} and orderNo in (select orderNo from Hunlian_TaskDetail where site =#{site} and taskNo=#{taskNo})
  795. </update>
  796. <insert id="saveSOOpsTransferHeader">
  797. INSERT INTO SOOpsTransferHeader (TransNo,Site,FromProLineNo,ToProLineNo,ToWarehouseID,FromEnteredby,FromEnteredDate,TransDate,ToReceiver,FromReceiver,
  798. FromRemark,ToRemark,ConfirmedFlag,ToConfirmedBy,ToEnteredby,RecordVersion,
  799. Status,ToTypeFlag_DB,ToTypeFlag,ConfirmedTransNo,need_inspect_flag,NeedReceiveFlag) VALUES
  800. (#{transNo},#{site},'*','*','*',#{userId},GETDATE(),GETDATE(),'',#{userId},
  801. '','','N','N','','0',
  802. '已录入','W','混炼胶入库','','Y','N')
  803. </insert>
  804. <insert id="saveSOOpsTransferDetail">
  805. INSERT INTO SOOpsTransferDetail (TransNo,Site,ItemNo,FromOpsID,FromWorkCenterNo,ToWorkCenterNo,ToOpsID,OrderNo,PartNo,TransQty,ConfirmQty,TaskNo,InsStatus,
  806. ToConfirmQty) VALUES
  807. ( #{transNo},#{site},1,1,'*','',0,#{taskNo},#{partNo},#{reportQty},0,#{taskNo},'合格',0)
  808. </insert>
  809. <insert id="saveSOOpsTransferHeaderForShiYanShi">
  810. INSERT INTO SOOpsTransferHeader (TransNo,Site,FromProLineNo,ToProLineNo,ToWarehouseID,FromEnteredby,FromEnteredDate,TransDate,ToReceiver,FromReceiver,
  811. FromRemark,ToRemark,ConfirmedFlag,ToConfirmedBy,ToEnteredby,RecordVersion,
  812. Status,ToTypeFlag_DB,ToTypeFlag,ConfirmedTransNo,need_inspect_flag,NeedReceiveFlag,inspect_remark) VALUES
  813. (#{transNo},#{site},'*','*','*',#{operatorId},GETDATE(),GETDATE(),'',#{operatorId},
  814. '','','N','N','','0',
  815. '已录入','I',#{toTypeFlag},'','Y','N',#{inspectRemark})
  816. </insert>
  817. <insert id="saveSOOpsTransferDetailForShiYanShi">
  818. INSERT INTO SOOpsTransferDetail (TransNo,Site,ItemNo,FromOpsID,FromWorkCenterNo,ToWorkCenterNo,ToOpsID,OrderNo,PartNo,TransQty,ConfirmQty,TaskNo,InsStatus,
  819. ToConfirmQty,seqNo) VALUES
  820. ( #{transNo},#{site},1,1,#{sWorkCenterNo},'',0,#{orderNo},#{partNo},#{qtyRequired},0,#{orderNo},'待检验',0,#{seqNo})
  821. </insert>
  822. <select id="getTransNo" resultType="String">
  823. select 'OT'+CONVERT(varchar(100), GETDATE(), 112)+ Right( '00000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(TransNo, 11,4))),0)+1) ,4)
  824. from SOOpsTransferHeader where TransNo like 'OT'+CONVERT(varchar(100), GETDATE(), 112)+'%'
  825. </select>
  826. <select id="checkLocationId" resultType="com.heai.modules.production.entity.LocationData">
  827. select LocationID,Site,LocationName,WareHouseID,Keeper,Active
  828. from Location where site=#{site} and LocationID=#{locationId}
  829. </select>
  830. <delete id="deleteSOOpsTransferHeader">
  831. update SOOpsTransferHeader set Status='已取消' where site=#{site} and transNo=#{transNo}
  832. </delete>
  833. <delete id="deleteSOOpsTransferDetail">
  834. delete from SOOpsTransferDetail where site=#{site} and transNo=#{transNo}
  835. </delete>
  836. <select id="getSfdcList" resultType="com.heai.modules.production.entity.SfdcCancel">
  837. select a.site,a.OrderNo,a.ItemNo ,a.SeqNo,a.WorkCenterNo,a.ReportDate,a.OperatorID,a.ReportQty,a.ApproveQty,a.ReportedManfTime,a.StatisticDate,
  838. a.AssJobSeqNo,a.Scheduled_ResourceId ResourceID,b.S_ShiftNo ShiftNo,b.partNo,dbo.Get_ItemDesc(a.site,a.OrderNo,a.ItemNo) operation_desc,c.OperatorName,b.S_ShiftNo ShiftDesc,e.ResourceDesc,Reverseflag
  839. ,a.reportWeight,a.approveWeight,a.moldQty,a.stopTime,dbo.Get_Part_Spec(a.site,b.partNo) partSpec,dbo.Get_PartDesc(a.site,b.partNo) PartDesc,wasteWeight,b.jobType,
  840. f.Remark as scrapRemark,f.DefectQty as scrapQty,g.Remark as acceptRemark,g.DefectQty as acceptQty
  841. from sfdc a LEFT JOIN SOScheduledRouting b on a.Site=b.Site and a.AssJobSeqNo=b.SeqNo
  842. left join Operator c on a.site=c.site and a.OperatorID=c.OperatorID
  843. left join WorkCenterResource e on a.Site=e.Site and a.Scheduled_ResourceId =e.ResourceID and a.WorkCenterNo=e.WorkCenterNo
  844. left join SFDC_DefectHist f on a.site=f.site and a.OrderNo=f.OrderNo and a.seqNo=f.SeqNo and f.DefectCode='PQ001'
  845. left join SFDC_DefectHist g on a.site=g.site and a.OrderNo=g.OrderNo and a.seqNo=g.SeqNo and g.DefectCode='PQ003'
  846. <where>
  847. and a.AssJobSeqNo is not null
  848. <if test="orderNo != null and orderNo != ''">
  849. and a.OrderNo like #{orderNo}
  850. </if>
  851. <if test="workCenterNo != null and workCenterNo != ''">
  852. and a.WorkCenterNo like #{workCenterNo}
  853. </if>
  854. <if test="partNo != null and partNo != ''">
  855. and b.partNo like #{partNo}
  856. </if>
  857. <if test="itemNo != null and itemNo != ''">
  858. and a.ItemNo = #{itemNo}
  859. </if>
  860. <if test="partDesc != null and partDesc != ''">
  861. and dbo.Get_Part_SpecDesc(a.site,b.partNo) like #{partDesc}
  862. </if>
  863. <if test="operatorName != null and operatorName != ''">
  864. and c.OperatorName like #{operatorName}
  865. </if>
  866. <if test="resourceId != null and resourceId != ''">
  867. and a.Scheduled_ResourceId = #{resourceId}
  868. </if>
  869. <if test="shiftNo != null and shiftNo != ''">
  870. and b.S_ShiftNo = #{shiftNo}
  871. </if>
  872. <if test="startDate != null ">
  873. and a.ReportDate >= #{startDate}
  874. </if>
  875. <if test="endDate != null ">
  876. and #{endDate} >= a.ReportDate
  877. </if>
  878. <if test="seqNo != null and seqNo != '' ">
  879. and a.AssJobSeqNo = #{seqNo}
  880. </if>
  881. <if test="operationDesc != null and operationDesc != ''">
  882. and dbo.Get_ItemDesc(a.site,a.OrderNo,a.ItemNo) like #{operationDesc}
  883. </if>
  884. </where>
  885. order by a.ReportDate desc
  886. </select>
  887. <update id="changeReceiveFlag">
  888. update SOOpsTransferHeader set NeedReceiveFlag=#{flag} from SOOpsTransferDetail b where SOOpsTransferHeader.site=b.site
  889. and SOOpsTransferHeader.transNo=b.transNo and SOOpsTransferHeader.status='已录入' and SOOpsTransferHeader.ToTypeFlag_DB='W' and
  890. b.seqNo=#{seqNo} and SOOpsTransferHeader.site=#{site}
  891. </update>
  892. <select id="getAllDepartment" resultType="OperatorData">
  893. select distinct isnull(Department,'') Department from Operator
  894. </select>
  895. <update id="updateLastStartTime" >
  896. update SORoutingOutput set LastStartTime=GetDate() where Site=#{site} and orderNo=#{orderNo} and itemNo=#{itemNo}
  897. </update>
  898. <select id="checkSORoutingOutput" resultType="SOScheduledRoutingOutData">
  899. select site,orderNo from SORoutingOutput where Site=#{site} and orderNo=#{orderNo} and itemNo=#{itemNo}
  900. </select>
  901. <insert id="createSORoutingOutput" >
  902. insert into SORoutingOutput (Site,OrderNo,ItemNo,TotalFinishedQty) values
  903. (#{site},#{orderNo},#{itemNo},0)
  904. </insert>
  905. <select id="getLevelOneOrderNo" resultType="SOScheduledRoutingOutData">
  906. select site,E_OriginalOrderNo OrderNo from shopOrder where orderNo=#{orderNo}
  907. </select>
  908. <update id="updateStockNewDate">
  909. update InventoryStock set ExpiredDate_new=#{newDate} where Site=#{site} and WarehouseID=#{warehouseID} and PartNo=#{partNo} and BatchNo=#{barchNo} and LocationID=#{locationID}
  910. </update>
  911. <select id="checkTV" resultType="com.heai.modules.production.entity.TvSopBaseData">
  912. select tv_id,work_station,now_seqNo,now_operator,sopAddress,badAddress from tv_sop_base
  913. where tv_id=#{tvId}
  914. </select>
  915. <update id="updateTV" >
  916. update Operator set tv_id=#{tvId} where site=#{site} and OperatorID=#{operatorID}
  917. </update>
  918. <select id="getTvList" resultType="com.heai.modules.production.entity.TvSopBaseData">
  919. select tv_id,work_station,now_seqNo,now_operator,sopAddress,badAddress from tv_sop_base
  920. <where>
  921. <if test="tvId != null and tvId != ''">
  922. and tv_id like #{tvId}
  923. </if>
  924. <if test="workStation != null and workStation != ''">
  925. AND work_station = #{workStation}
  926. </if>
  927. </where>
  928. </select>
  929. <update id="updateWorkStation">
  930. update tv_sop_base set work_station=#{workStation} where tv_id=#{tvId}
  931. </update>
  932. <select id="getPreviousSOSData" resultType="SOScheduledRoutingOutData">
  933. select seqNo,PreviousSeqNo,PreviousBatchNo,materSeqNo from SOScheduledRouting where seqNo=#{previousSeqNo,jdbcType=INTEGER}
  934. </select>
  935. <update id="updatePreviousSOSData">
  936. update SOScheduledRouting set PreviousSeqNo=#{previousSeqNo,jdbcType=INTEGER},PreviousBatchNo=#{previousBatchNo},materSeqNo=#{materSeqNo,jdbcType=INTEGER}
  937. where seqNo=#{seqNo}
  938. </update>
  939. <select id="sfdcCheck" resultType="com.heai.modules.production.entity.SfdcCancel">
  940. select Site,OrderNo,ItemNo,SeqNo from SFDC where AssJobSeqNo=#{seqNo}
  941. </select>
  942. <select id="selectSoScheduledRouting" resultType="SOScheduledRoutingOutData">
  943. select Site,OrderNo,seqNo,itemNo,S_ShiftNo,scheduleType,ClosedFlag from SOScheduledRouting
  944. <where>
  945. <if test="seqNo != null">
  946. and seqNo=#{seqNo}
  947. </if>
  948. </where>
  949. </select>
  950. <select id="selectSoTool" resultType="com.heai.modules.production.entity.SOToolData">
  951. select Site,OrderNo,ToolID,ToolQty,Remark,CreateDate,CreatedBy,ItemNo from SOTool
  952. <where>
  953. <if test="orderNo != null and orderNo != ''">
  954. and OrderNo = #{orderNo}
  955. </if>
  956. <if test="site != null and site != ''">
  957. and Site = #{site}
  958. </if>
  959. <if test="toolID != null and toolID != ''">
  960. and ToolID = #{toolID}
  961. </if>
  962. <if test="itemNo != null">
  963. and ItemNo = #{itemNo}
  964. </if>
  965. </where>
  966. </select>
  967. <select id="getToolHeaderDescription" resultType="java.lang.String">
  968. select top 1 ToolDescription from ToolHeader
  969. <where>
  970. <if test="toolID != null and toolID != ''">
  971. and ToolID = #{toolID}
  972. </if>
  973. <if test="site != null and site != ''">
  974. and Site = #{site}
  975. </if>
  976. </where>
  977. </select>
  978. <insert id="batchSaveToolingHist">
  979. <foreach collection="toolingHistDataList" separator=";" item="item">
  980. insert into SFDC_ToolingHist
  981. (Site, OrderNo, ItemNo, SeqNo, HistSeqNo, ReportDate, Reportedby,
  982. ToolInstanceID, StartDate, FinishDate, FinishFlag, Remark,
  983. StartFromRollNo, FinishQty, RollNo, moQty, useQty)
  984. values (#{item.site},#{item.orderNo},#{item.itemNo},#{item.seqNo},
  985. (select ISNULL(max(HistSeqNo),0)+1 from SFDC_ToolingHist where Site = #{item.site} and SeqNo = #{item.seqNo}),
  986. null,'',#{item.toolInstanceID},current_timestamp,null,'N','','',0,'',0,0)
  987. </foreach>
  988. </insert>
  989. <select id="getLastStartHist" resultType="com.heai.modules.production.entity.SfdcTimeHistData">
  990. select top 1 a.EventTime,a.site
  991. from SFDC_TimeHist a left join SOScheduledRouting b on a.Site=b.Site and a.SeqNo=b.SeqNo
  992. <where>
  993. and a.EventType='P'
  994. and b.operatorId=#{operatorId}
  995. </where>
  996. order by a.EventTime desc
  997. </select>
  998. </mapper>