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.

842 lines
33 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.gaotao.modules.shopOrder.dao.ShopOrderMapper">
  4. <!-- =============生产订单类型===================-->
  5. <select id="getShopOrderFamily" resultType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
  6. Select OrderType, TypeDesc, Site, Active
  7. from SOOrderType as T
  8. where T.Site in (Select Site from AccessSite where upper(UserID) = #{user})
  9. </select>
  10. <insert id="saveShopOrderFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
  11. INSERT INTO SOOrderType (OrderType, TypeDesc, Site, Active)
  12. values (#{orderType}, #{typeDesc}, #{site}, #{active})
  13. </insert>
  14. <update id="editShopOrderFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
  15. UPDATE SOOrderType
  16. SET TypeDesc=#{typeDesc},
  17. Active=#{active},
  18. Site=#{site}
  19. where OrderType = #{orderType}
  20. and Site = #{site}
  21. </update>
  22. <delete id="deleteShopOrderFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
  23. delete
  24. from SOOrderType
  25. where OrderType = #{orderType}
  26. and Site = #{site}
  27. </delete>
  28. <select id="checkOrderType" resultType="com.gaotao.modules.shopOrder.entity.SOOrderTypeData">
  29. select OrderType, TypeDesc
  30. from SOOrderType
  31. where OrderType = #{orderType}
  32. and Site = #{site}
  33. </select>
  34. <!-- =============生产计划===================-->
  35. <select id="getPlanFamily" resultType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
  36. Select PlannerType, TypeDesc, Site, Active
  37. from SOPlanner as T
  38. where T.Site in (Select Site from AccessSite where upper(UserID) = #{user})
  39. </select>
  40. <insert id="savePlanFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
  41. INSERT INTO SOPlanner (PlannerType, TypeDesc, Site, Active)
  42. values (#{plannerType}, #{typeDesc}, #{site}, #{active})
  43. </insert>
  44. <update id="editPlanFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
  45. UPDATE SOPlanner
  46. SET TypeDesc=#{typeDesc},
  47. Active=#{active},
  48. Site=#{site}
  49. where PlannerType = #{plannerType}
  50. and Site = #{site}
  51. </update>
  52. <delete id="deletePlanFamily" parameterType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
  53. delete
  54. from SOPlanner
  55. where PlannerType = #{plannerType}
  56. and Site = #{site}
  57. </delete>
  58. <select id="checkPlannerType" resultType="com.gaotao.modules.shopOrder.entity.SOPlannerData">
  59. select PlannerType, TypeDesc
  60. from SOPlanner
  61. where PlannerType = #{plannerType}
  62. and Site = #{site}
  63. </select>
  64. <!-- 查询-生产订单无工艺路线 -->
  65. <select id="searchShopOrderWithNoProcessRoute"
  66. resultType="com.gaotao.modules.shopOrder.entity.ShopOrderWithNoProcessRouteData">
  67. Select * from view_SOrouting_check as T
  68. <where>
  69. AND T.site in (Select Site from AccessSite where upper(UserID)=#{user})
  70. <if test=" site != null and site != ''">
  71. AND Site like #{site}
  72. </if>
  73. <if test=" orderNo != null and orderNo != ''">
  74. AND OrderNo like #{orderNo}
  75. </if>
  76. <if test=" partNo != null and partNo != ''">
  77. AND PartNo like #{partNo}
  78. </if>
  79. <if test=" date1 != null ">
  80. AND EnterDate >= #{date1}
  81. </if>
  82. <if test=" date2 != null ">
  83. AND dateadd( DAY, 1, #{date2} ) > EnterDate
  84. </if>
  85. </where>
  86. </select>
  87. <select id="searchProductionDispatchList"
  88. resultType="com.gaotao.modules.shopOrder.entity.SearchProductionDispatchListData">
  89. SELECT
  90. T.Site,
  91. T.OrderNo,
  92. T.ItemNo,
  93. S.OperationDesc,
  94. S.PartNo,
  95. P.PartDescription,
  96. P.Spec,
  97. T.QtyRequired AS LotSize,
  98. T.QtyReported,
  99. D.NeedDate,
  100. S.PreItemNo,
  101. S1.OperationDesc AS PreOperationDesc,
  102. S1.ScheduledFlag AS PreScheduledFlag,
  103. S.NextItemNo,
  104. S2.OperationDesc AS NextOperationDesc,
  105. S2.ScheduledFlag AS NextScheduledFlag,
  106. D.CustomerID,
  107. P.ConfigurationTemplateID AS CustomerName,
  108. D.EnterDate,
  109. dbo.Get_SOOpsScheduleAvailResource (
  110. T.Site,
  111. T.OrderNo,
  112. T.S_WorkCenterNo,
  113. T.ItemNo
  114. ) AS AvailResource,
  115. T.S_WorkCenterNo AS WorkCenterNo,
  116. S.MachRunFactor,
  117. S.MachSetupTime,
  118. S.FactorUnit,
  119. T.ClosedFlag,
  120. isnull(E.S_ScheduledSeqNo ,- 1) AS S_ScheduledSeqNo,
  121. T.PlanStartTime,
  122. T.PlanFinishTime,
  123. T.S_ResourceID,
  124. ROUND(T.TimeRequired,2),
  125. T.SeqNo,
  126. T.SelectedFlag,
  127. T.SourceFlag,
  128. S1.QtyScheduled AS QtyScheduled_PreOps,
  129. T.ParkFlag,
  130. ROUND(T.TimeRequired_Original,2),
  131. T.QtyRequired_Original,
  132. S1.PlanStartTime AS PreOpsPlanStartTime,
  133. S1.PlanFinishTime AS PreOpsPlanFinishTime,
  134. T.EnteredDate,
  135. (
  136. CASE
  137. WHEN S1.PlanStartTime > T.PlanStartTime THEN
  138. 'Y'
  139. ELSE
  140. 'N'
  141. END
  142. ) AS InAdvancedFlag,
  143. P.Remark AS CustPartNo,
  144. T.ClosedDate,
  145. T.closedby
  146. FROM
  147. SOScheduledRouting AS T
  148. LEFT JOIN ShopOrder AS D ON T.Site = D.Site
  149. AND T.OrderNo = D.OrderNo
  150. LEFT JOIN SOScheduledList AS E ON E.Site = T.Site
  151. AND E.LinkedSeqNo = T.SeqNo,
  152. SORouting AS S
  153. LEFT JOIN Part AS P ON S.Site = P.Site
  154. AND S.PartNo = P.PartNo
  155. LEFT JOIN SORouting AS S1 ON S.Site = S1.Site
  156. AND S.OrderNo = S1.OrderNo
  157. AND S.PreItemNo = S1.ItemNo
  158. LEFT JOIN SORouting AS S2 ON S.Site = S2.Site
  159. AND S.OrderNo = S2.OrderNo
  160. AND S.NextItemNo = S2.ItemNo
  161. <where>
  162. AND T.Site = S.Site
  163. AND T.OrderNo = S.OrderNo
  164. AND T.ItemNo = S.ItemNo
  165. <if test=" site != null and site != ''">
  166. AND T.Site like #{site}
  167. </if>
  168. <if test=" orderNo != null and orderNo != ''">
  169. AND T.OrderNo like #{orderNo}
  170. </if>
  171. <if test=" partNo != null and partNo != ''">
  172. AND S.PartNo like #{partNo}
  173. </if>
  174. <if test=" sResourceID != null and sResourceID != ''">
  175. AND T.S_ResourceID like #{sResourceID}
  176. </if>
  177. <if test=" workCenterNo != null and workCenterNo != ''">
  178. AND T.S_WorkCenterNo like #{workCenterNo}
  179. </if>
  180. <if test=" date1 != null ">
  181. AND D.EnterDate >= #{date1}
  182. </if>
  183. <if test=" date2 != null ">
  184. AND dateadd( DAY, 1, #{date2} ) > D.EnterDate
  185. </if>
  186. <if test=" date3 != null ">
  187. AND T.PlanStartTime >= #{date3}
  188. </if>
  189. <if test=" date4 != null ">
  190. AND dateadd( DAY, 1, #{date4} ) > T.PlanStartTime
  191. </if>
  192. <if test=" date5 != null ">
  193. AND T.PlanFinishTime>= #{date5}
  194. </if>
  195. <if test=" date6 != null ">
  196. AND dateadd( DAY, 1, #{date6} ) > T.PlanFinishTime
  197. </if>
  198. ${sql}
  199. </where>
  200. </select>
  201. <select id="searchShopOrder" resultType="com.gaotao.modules.shopOrder.entity.SearchShopOrder">
  202. Select T.OrderNo,T.NeedDate,T.OrderType,T.PartNo,p.PartDescription+' / '+isnull(p.Spec,'') as PartDescription,
  203. T.LotSize,T.Planner,T.Status,T.CustomerID,P.ConfigurationTemplateID as CustomerName,T.PlanStartDate,T.Leadtime,
  204. T.EnterDate,T.Username,T.FinishedQty,T.ReleaseDate,T.ReleaseGuys,T.ScheduleDate,T.Scheduler,T.IssueDate,
  205. T.ReportDate,T.ReceiveDate,T.Printed,T.ProjectID,pr.ProjectName,T.BOMRevNo,T.RoutingRevNo,T.OriginalNeedDate,
  206. T.OrderRef1,T.OrderRef2,T.Site,T.Remark,CostRollUpFlag,T.ManualFlag,T.OriSOOrderNo,P.FamilyID,
  207. dbo.Get_PartFamilyDesc(P.Site,P.FamilyID) as FamilyName,P.GroupID,dbo.Get_PartGroupDesc(P.Site,P.GroupID) as
  208. GroupName,
  209. T.ReceiveStatus,T.RepairSOFlag,T.E_OriginalOrderType,T.E_OriginalOrderNo,T.E_Levels,P.PartType,P.Remark as
  210. CustPartNo,
  211. T.NeedDate as COPlanShipDate
  212. from Part as p,ShopOrder as T
  213. left join Project as pr on pr.Site=T.Site and pr.Projectid=T.ProjectID
  214. <where>
  215. AND T.Site=p.Site and T.PartNo=p.PartNo
  216. and T.site in (Select Site from AccessSite where upper(UserID)=#{user})
  217. <if test=" orderType != null and orderType != ''">
  218. AND T.OrderType like #{orderType}
  219. </if>
  220. <if test=" planner != null and planner != ''">
  221. AND T.Planner like #{planner}
  222. </if>
  223. <if test=" site != null and site != ''">
  224. AND T.Site like #{site}
  225. </if>
  226. <if test=" buNo != null and buNo != ''">
  227. AND T.bu_no like #{buNo}
  228. </if>
  229. <if test=" partType != null and partType != ''">
  230. AND P.PartType like #{partType}
  231. </if>
  232. <if test=" partNo != null and partNo != ''">
  233. AND T.PartNo like #{partNo}
  234. </if>
  235. <if test=" partDescription != null and partDescription != ''">
  236. AND p.PartDescription like #{partDescription}
  237. </if>
  238. <if test=" projectID != null and projectID != ''">
  239. AND T.ProjectID like #{projectID}
  240. </if>
  241. <if test=" remark != null and remark != ''">
  242. AND T.Remark like #{remark}
  243. </if>
  244. <if test=" orderNo != null and orderNo != ''">
  245. AND T.OrderNo like #{orderNo}
  246. </if>
  247. <if test=" orderRef1 != null and orderRef1 != ''">
  248. AND T.OrderRef1 like #{orderRef1}
  249. </if>
  250. <if test=" costRollUpFlag != null and costRollUpFlag != ''">
  251. AND CostRollUpFlag like #{costRollUpFlag}
  252. </if>
  253. <if test=" statusList != null and statusList.size > 0 ">
  254. AND T.Status in
  255. <foreach item="item" collection="statusList" open="(" separator="," close=")">
  256. #{item}
  257. </foreach>
  258. </if>
  259. <if test=" date1 != null ">
  260. AND T.EnterDate >= #{date1}
  261. </if>
  262. <if test=" date2 != null ">
  263. AND dateadd( DAY, 1, #{date2} ) > T.EnterDate
  264. </if>
  265. <if test=" date3 != null ">
  266. AND T.PlanStartDate >= #{date3}
  267. </if>
  268. <if test=" date4 != null ">
  269. AND dateadd( DAY, 1, #{date4} ) > T.PlanStartDate
  270. </if>
  271. </where>
  272. </select>
  273. <select id="searchShopOrderByPaging" parameterType="com.gaotao.modules.shopOrder.entity.SearchShopOrder" resultType="com.gaotao.modules.shopOrder.entity.SearchShopOrder">
  274. Select T.OrderNo,T.NeedDate,T.OrderType,T.PartNo,p.PartDescription+' / '+isnull(p.Spec,'') as PartDescription,
  275. T.LotSize,T.Planner,T.Status,T.CustomerID,P.ConfigurationTemplateID as CustomerName,T.PlanStartDate,T.Leadtime,
  276. T.EnterDate,T.Username,T.FinishedQty,T.ReleaseDate,T.ReleaseGuys,T.ScheduleDate,T.Scheduler,T.IssueDate,
  277. T.ReportDate,T.ReceiveDate,T.Printed,T.ProjectID,pr.ProjectName,T.BOMRevNo,T.RoutingRevNo,T.OriginalNeedDate,
  278. T.OrderRef1,T.OrderRef2,T.Site,T.Remark,CostRollUpFlag,T.ManualFlag,T.OriSOOrderNo,P.FamilyID,
  279. dbo.Get_PartFamilyDesc(P.Site,P.FamilyID) as FamilyName,P.GroupID,dbo.Get_PartGroupDesc(P.Site,P.GroupID) as
  280. GroupName,
  281. T.ReceiveStatus,T.RepairSOFlag,T.E_OriginalOrderType,T.E_OriginalOrderNo,T.E_Levels,P.PartType,P.Remark as
  282. CustPartNo,
  283. T.NeedDate as COPlanShipDate, T.batch_no batchNo,
  284. <!--(SELECT ROUND(SUM(issureQty),3) FROM SOIssueNotifyOrderList where Site = T.site and sOOrderNo = T.OrderNo)--> 0 alreadyApplyTotal
  285. from Part as p,ShopOrder as T
  286. left join Project as pr on pr.Site=T.Site and pr.Projectid=T.ProjectID
  287. <where>
  288. AND T.Site=p.Site and T.PartNo=p.PartNo
  289. and T.site in (Select Site from AccessSite where upper(UserID)=#{query.user})
  290. <if test=" query.orderType != null and query.orderType != ''">
  291. AND T.OrderType like #{query.orderType}
  292. </if>
  293. <if test=" query.planner != null and query.planner != ''">
  294. AND T.Planner like #{query.planner}
  295. </if>
  296. <if test=" query.site != null and query.site != ''">
  297. AND T.Site like #{query.site}
  298. </if>
  299. <if test=" query.buNo != null and query.buNo != ''">
  300. AND T.bu_no like #{query.buNo}
  301. </if>
  302. <if test=" query.partType != null and query.partType != ''">
  303. AND P.PartType like #{query.partType}
  304. </if>
  305. <if test=" query.partNo != null and query.partNo != ''">
  306. AND T.PartNo like #{query.partNo}
  307. </if>
  308. <if test=" query.statusList != null and query.statusList.size > 0 ">
  309. AND T.Status in
  310. <foreach item="item" collection="query.statusList" open="(" separator="," close=")">
  311. #{item}
  312. </foreach>
  313. </if>
  314. <if test=" query.partDescription != null and query.partDescription != ''">
  315. AND p.PartDescription like #{query.partDescription}
  316. </if>
  317. <if test=" query.projectID != null and query.projectID != ''">
  318. AND T.ProjectID like #{query.projectID}
  319. </if>
  320. <if test=" query.remark != null and query.remark != ''">
  321. AND T.Remark like #{query.remark}
  322. </if>
  323. <if test=" query.orderNo != null and query.orderNo != ''">
  324. AND T.OrderNo like #{query.orderNo}
  325. </if>
  326. <if test=" query.orderRef1 != null and query.orderRef1 != ''">
  327. AND T.OrderRef1 like #{query.orderRef1}
  328. </if>
  329. <if test=" query.costRollUpFlag != null and query.costRollUpFlag != ''">
  330. AND CostRollUpFlag like #{query.costRollUpFlag}
  331. </if>
  332. <if test=" query.statusList != null and query.statusList.size > 0 ">
  333. AND T.Status in
  334. <foreach item="item" collection="query.statusList" open="(" separator="," close=")">
  335. #{item}
  336. </foreach>
  337. </if>
  338. <if test=" query.date1 != null ">
  339. AND T.EnterDate >= #{query.date1}
  340. </if>
  341. <if test=" query.date2 != null ">
  342. AND dateadd( DAY, 1, #{query.date2} ) > T.EnterDate
  343. </if>
  344. <if test=" query.date3 != null ">
  345. AND T.PlanStartDate >= #{query.date3}
  346. </if>
  347. <if test=" query.date4 != null ">
  348. AND dateadd( DAY, 1, #{query.date4} ) > T.PlanStartDate
  349. </if>
  350. </where>
  351. </select>
  352. <select id="getShopOrderData" resultType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
  353. SELECT
  354. T.*,dbo.Get_ProjectDesc(T.Site,T.ProjectID) as ProjectIDName,P.Remark as PartRemark,P.ConfigurationTemplateID,
  355. P.UMID,p.PartDescription+' / '+isnull(p.Spec,'') as PartDesc
  356. FROM
  357. ShopOrder AS T
  358. LEFT JOIN
  359. Part as P ON P.Site=T.Site and P.PartNo=T.PartNo
  360. <where>
  361. AND MaterialSplitFlag = 'N'
  362. and T.Site IN (
  363. SELECT
  364. Site
  365. FROM
  366. AccessSite
  367. WHERE
  368. UPPER (UserID) = #{user}
  369. )
  370. <if test=" orderNo != null and orderNo != ''">
  371. AND T.OrderNo like #{orderNo}
  372. </if>
  373. <if test=" site != null and site != ''">
  374. AND T.Site like #{site}
  375. </if>
  376. <if test=" partNo != null and partNo != ''">
  377. AND T.PartNo like #{partNo}
  378. </if>
  379. <if test=" status != null and status != ''">
  380. AND T.Status = #{status}
  381. </if>
  382. <if test=" date1 != null ">
  383. AND T.NeedDate >= #{date1}
  384. </if>
  385. <if test=" date2 != null ">
  386. AND dateadd( DAY, 1, #{date2} ) > T.NeedDate
  387. </if>
  388. <if test=" date3 != null ">
  389. AND T.PlanStartDate >= #{date3}
  390. </if>
  391. <if test=" date4 != null ">
  392. AND dateadd( DAY, 1, #{date4} ) > T.PlanStartDate
  393. </if>
  394. </where>
  395. </select>
  396. <delete id="deleteShopOrderData">
  397. delete
  398. from ShopOrder
  399. where site = #{site}
  400. and orderNo = #{orderNo}
  401. </delete>
  402. <delete id="deleteRouteInShopOrder">
  403. delete
  404. from SORouting
  405. where site = #{site}
  406. and orderNo = #{orderNo}
  407. and itemNo = #{itemNo}
  408. </delete>
  409. <insert id="insertRouteInShopOrder">
  410. insert into SORouting (Site, OrderNo, ItemNo, OperationDesc,
  411. WorkCenterNo, MachSetupTime, MachRunFactor,
  412. FactorUnit_DB, FactorUnit, QtyRequired,
  413. QtyReported, QtyApprove, TimeRequired,
  414. TimeReported, Efficiency, PlanStartTime,
  415. PlanFinishTime, BarcodeID, Remark,
  416. PartNo, Crewsize, ClosedFlag,
  417. ActionNotes, QtyScheduled)
  418. values (#{site}, #{orderNo}, #{itemNo}, #{operationDesc}, #{workCenterNo}, #{machSetupTime}, #{machRunFactor},
  419. #{factorUnit_DB},
  420. #{factorUnit}, #{qtyRequired}, #{qtyReported}, #{qtyApprove}, #{timeRequired}, #{timeReported},
  421. #{efficiency},
  422. #{planStartTime}, #{planFinishTime}, #{barcodeID}, #{remark}, #{partNo}, #{crewsize}, #{closedFlag},
  423. #{actionNotes}, 0)
  424. </insert>
  425. <delete id="deleteAvailResourceInShopOrder">
  426. delete from SORouting_AvailableResource where site=#{site} and orderNo=#{orderNo} and ItemNo=#{itemNo}
  427. </delete>
  428. <update id="updateRouteInShopOrder">
  429. update SORouting
  430. set OperationDesc = #{operationDesc}
  431. , WorkCenterNo = #{workCenterNo}
  432. , MachSetupTime = #{machSetupTime}
  433. , MachRunFactor = #{machRunFactor}
  434. , FactorUnit = #{factorUnit}
  435. , Efficiency =#{efficiency}
  436. , TimeReported =#{timeRequired}
  437. , PlanFinishTime = #{planFinishTime}
  438. , PlanStartTime = #{planStartTime}
  439. , Crewsize = #{crewsize}
  440. , Remark= #{remark}
  441. where site = #{site}
  442. and OrderNo = #{orderNo}
  443. and ItemNo = #{itemNo}
  444. </update>
  445. <select id="getRoutingTimeRequired" resultType="java.math.BigDecimal">
  446. select dbo.Get_Routing_TimeRequired(#{site}, #{lotSize}, #{machSetupTime}, #{machRunFactor}, #{factorUnit},
  447. #{efficiency})
  448. </select>
  449. <select id="getWorkCenterInfo" resultType="com.gaotao.modules.shopOrder.entity.vo.WorkCenterVo">
  450. Select WorkCenterNo Work_Center_No,
  451. WorkCenterDesc Work_Center_Desc,
  452. WorkCenterType Work_Center_Type,
  453. Active,
  454. Site
  455. from WorkCenter
  456. where WorkCenterNo = #{workCenterNo}
  457. and Site = #{site}
  458. </select>
  459. <select id="getOrderNoRouteInMaxItemNo" resultType="java.lang.String">
  460. select max(itemno)
  461. from SORouting
  462. where site = #{site}
  463. and orderNo = #{orderNo}
  464. </select>
  465. <select id="getOrderNoItemNoCenter" resultType="java.lang.String">
  466. select dbo.Get_SORoutingAvailResource(#{site}, #{orderNo}, #{workCenterNo}, #{itemNo})
  467. </select>
  468. <update id="saveShopOrderData" parameterType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
  469. update ShopOrder
  470. set NeedDate=#{needDate},
  471. PlanStartDate=#{planStartDate},
  472. OriginalNeedDate=#{originalNeedDate},
  473. OrderType=#{orderType},
  474. Planner=#{planner},
  475. OriSOOrderNo=#{oriSOOrderNo},
  476. ProjectID=#{projectID},
  477. Leadtime=#{leadtime,jdbcType=FLOAT},
  478. RepairSOFlag=#{repairSOFlag},
  479. TechInfo=#{techInfo},
  480. Remark=#{remark},
  481. batch_no=#{batchNo}
  482. where Site = #{site}
  483. and OrderNo = #{orderNo}
  484. </update>
  485. <select id="getRouteInShopOrderData" resultType="com.gaotao.modules.shopOrder.entity.RouteInShopOrderData">
  486. Select R.Site
  487. , R.OrderNo
  488. , R.ItemNo
  489. , R.OperationDesc
  490. , R.WorkCenterNo
  491. , W.WorkCenterDesc
  492. , R.MachSetupTime
  493. , R.MachRunFactor
  494. , R.FactorUnit_DB
  495. , R.FactorUnit
  496. , R.QtyRequired
  497. , R.QtyReported
  498. , R.QtyApprove
  499. , R.TimeRequired
  500. , R.TimeReported
  501. , R.Efficiency
  502. , R.PlanStartTime
  503. , R.PlanFinishTime
  504. , R.BarcodeID
  505. , R.Remark
  506. , R.PartNo
  507. , R.Crewsize
  508. , R.ClosedFlag
  509. , R.ActionNotes
  510. , W.WorkCenterType
  511. , dbo.Get_SORoutingAvailResource(R.Site, R.OrderNo, R.WorkCenterNo, R.ItemNo) as AvailResource
  512. from SORouting as R,
  513. WorkCenter as W
  514. <where>
  515. R.Site = W.Site
  516. and R.WorkCenterNo = W.WorkCenterNo
  517. and R.Site = #{site}
  518. and R.OrderNo = #{orderNo}
  519. <if test="itemNo!= null and itemNo != '' ">and R.itemNo = #{itemNo}</if>
  520. <if test=" itemDesc != null and itemDesc != ''">
  521. AND R.OperationDesc like #{itemDesc}
  522. </if>
  523. </where>
  524. order by R.ItemNo
  525. </select>
  526. <select id="getToolInShopOrder" resultType="com.gaotao.modules.shopOrder.entity.ToolInShopOrder">
  527. Select T.Site
  528. , T.OrderNo
  529. , ItemNo
  530. , T.ToolID
  531. , P.ToolDescription
  532. , P.Spec
  533. , T.ToolQty
  534. , P.UMID
  535. , P.FamilyID
  536. , dbo.Get_PartFamilyDesc(T.Site, P.FamilyID) as FamilyName
  537. , P.Active
  538. , T.Remark
  539. , T.CreateDate
  540. , T.CreatedBy
  541. from SOTool as T,
  542. ToolHeader as P
  543. Where T.Site = P.Site
  544. and T.ToolID = P.ToolID
  545. and T.Site = #{site}
  546. and T.OrderNo = #{orderNo}
  547. Order by ItemNo, T.ToolID
  548. </select>
  549. <select id="getProductMixInShopOrder" resultType="com.gaotao.modules.shopOrder.entity.ProductMixInShopOrder">
  550. Select B.Site
  551. , B.OrderNo
  552. , B.ItemNo
  553. , B.ComponentPartNo
  554. , P.PartDescription as PartDesc
  555. , P.Spec as PartSpec
  556. , P.UMid as PartUm
  557. , B.QtyAssembly
  558. , B.QtyFixedScrapt
  559. , B.ScraptFactor
  560. , B.Remark
  561. , B.QtyRequired
  562. , B.QtyIssue
  563. , B.IssueDate
  564. , B.QtyReserved
  565. , B.RMType_DB
  566. From dbo.view_SAP_SOBOM as B
  567. left join Part as P on B.Site = P.Site
  568. and B.ComponentPartNo = P.PartNo
  569. Where
  570. B.Site = #{site}
  571. and B.OrderNo = #{orderNo}
  572. Order by B.ItemNo
  573. </select>
  574. <select id="getShopOrderSapSOBOM" resultType="com.gaotao.modules.shopOrder.entity.ProductMixInShopOrder">
  575. Select T.ItemNo as item_no,
  576. T.ComponentPartNo as component_part_no,
  577. P.PartDescription as part_desc,
  578. P.Spec as part_spec,
  579. P.UMID,
  580. T.QtyRequired as qty_required
  581. ,
  582. P.DefaultLocationID as default_location_ID
  583. from dbo.view_SAP_SOBOM as T,
  584. Part as P
  585. Where T.Site = P.Site
  586. and T.ComponentPartNo = P.PartNo
  587. and T.Site = #{site}
  588. and T.OrderNo = #{orderNo}
  589. </select>
  590. <select id="getOrderInfo" resultType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
  591. Select T.OrderNo as order_no
  592. , T.PartNo as part_no
  593. , T.LotSize as lot_size
  594. , P.PartDescription as part_desc
  595. , isnull(P.Spec, '') as spec
  596. , T.Remark as remark
  597. , dbo.get_ShopOrderPrintInfo(T.Site, T.OrderNo) as first_item_no
  598. from ShopOrder as T,
  599. Part as P
  600. Where T.Site = P.Site
  601. and T.PartNo = P.PartNo
  602. and T.Site = #{site}
  603. and T.OrderNo = #{orderNo}
  604. </select>
  605. <!--获取工单的工具信息-->
  606. <select id="getShopOrderToolDatas" resultType="ShopOrderToolData">
  607. Select T.Site site,
  608. T.OrderNo orderNo,
  609. ItemNo itemNo,
  610. T.ToolID toolId,
  611. P.ToolDescription toolDesc,
  612. P.Spec toolSpec,
  613. T.ToolQty toolQty,
  614. P.UMID umid,
  615. P.FamilyID familyId,
  616. dbo.Get_SOOpsDescription(T.Site, T.OrderNo, ItemNo) itemDesc,
  617. dbo.Get_PartFamilyDesc(T.Site, P.FamilyID) familyName,
  618. P.Active active,
  619. T.Remark remark,
  620. T.CreateDate createdDate,
  621. T.CreatedBy createdBy
  622. FROM SOTool as T,
  623. ToolHeader as P
  624. Where T.Site = P.Site
  625. and T.ToolID = P.ToolID
  626. and T.Site = #{site}
  627. and T.OrderNo = #{orderNo}
  628. Order by ItemNo, T.ToolID
  629. </select>
  630. <select id="getOrderQtyRequired" resultType="java.lang.Double">
  631. Select LotSize
  632. from ShopOrder
  633. Where Site = #{site}
  634. and OrderNo = #{orderNo}
  635. </select>
  636. <select id="getSORoute" resultType="com.gaotao.modules.shopOrder.entity.RouteInShopOrderData">
  637. Select R.Site
  638. , R.OrderNo
  639. , R.ItemNo
  640. , ISNULL(R.NextItemNo, 0) next_item_no
  641. , ISNULL(R.PreItemNo, 0) pre_item_no
  642. from SORouting as R
  643. where R.site = #{site}
  644. and R.OrderNo = #{orderNo}
  645. and R.ItemNo = #{itemNo}
  646. </select>
  647. <update id="updateRouteByItemNo">
  648. update SORouting
  649. <set>
  650. <if test="nextItemNo != null">
  651. NextItemNo = #{nextItemNo},
  652. </if>
  653. <if test="preItemNo != null">
  654. PreItemNo = #{preItemNo},
  655. </if>
  656. </set>
  657. where site = #{site}
  658. and OrderNo = #{orderNo}
  659. and ItemNo = #{itemNo}
  660. </update>
  661. <select id="getSORouteItemNoOrderBy" resultType="com.gaotao.modules.shopOrder.entity.RouteInShopOrderData">
  662. select top 1 Site
  663. , OrderNo
  664. , ItemNo
  665. from SORouting
  666. <where>
  667. site = #{route.site}
  668. and OrderNo = #{route.orderNo}
  669. <if test="orderBy == 'desc'">
  670. and ItemNo <![CDATA[ < ]]> #{route.itemNo}
  671. </if>
  672. <if test="orderBy == 'asc'">
  673. and ItemNo > #{route.itemNo}
  674. </if>
  675. </where>
  676. order by ItemNo ${orderBy}
  677. </select>
  678. <select id="getShopOrderByPart" resultType="com.gaotao.modules.shopOrder.entity.ShopOrderData">
  679. SELECT
  680. *
  681. FROM
  682. ShopOrder AS T
  683. WHERE
  684. Site = #{site}
  685. AND PartNo = #{partNo}
  686. AND ( Status = '已计划' OR Status = '已下达' )
  687. AND NOT EXISTS ( SELECT 1 FROM SOScheduledRouting AS D WHERE T.Site = D.Site AND T.OrderNo = D.OrderNo )
  688. AND T.OrderType != 'P'
  689. </select>
  690. <select id="getRouteInShopOrderResource"
  691. resultType="com.gaotao.modules.shopOrder.entity.SoroutingAvailableresourceEntity">
  692. SELECT s.Site,s.OrderNo,s.ItemNo,s.WorkCenterNo,w.ResourceID FROM
  693. SORouting s,RoutingDetail e
  694. LEFT JOIN RoutingDetail_AvailableResource w ON
  695. e.Site = w.Site AND
  696. e.PartNo = w.PartNo AND
  697. e.RevNo = w.RevNo AND
  698. e.itemNo=w.itemNo
  699. WHERE s.Site = #{site} AND s.OrderNo = #{orderNo} AND
  700. e.Site = s.Site AND
  701. e.PartNo = s.PartNo AND
  702. e.RevNo=#{bOMRevNo}
  703. and s.ItemNo=e.ItemNo
  704. and s.itemNo in (select h.itemNo from RoutingDetail_AvailableResource h
  705. where h.site = e.site
  706. and h.partno = e.partno
  707. and h.revno = e.revno )
  708. Union all
  709. SELECT s.Site,s.OrderNo,s.ItemNo,s.WorkCenterNo,w.ResourceID FROM
  710. SORouting s
  711. LEFT JOIN WorkCenterResource w ON
  712. s.Site = w.Site AND
  713. s.WorkCenterNo = w.WorkCenterNo
  714. WHERE w.Active = 'Y' AND s.Site = #{site} AND s.OrderNo = #{orderNo}
  715. and s.itemNo not in (select h.itemNo from RoutingDetail_AvailableResource h
  716. where h.site = s.site
  717. and h.partno = s.partno
  718. and h.revno = #{bOMRevNo} )
  719. </select>
  720. <select id="getOrderSopFileInfo" resultType="com.gaotao.modules.oss.entity.SysOssEntity">
  721. SELECT
  722. *
  723. FROM
  724. (--如果工序有设置了可用机台的话,那么和可用机台关联
  725. SELECT
  726. t.Site,
  727. t.WorkCenterNo,
  728. d.ResourceID ,
  729. w.ResourceDesc
  730. FROM
  731. SORouting AS t,
  732. SORouting_AvailableResource AS d ,
  733. WorkCenterResource AS w
  734. WHERE
  735. t.site= d.site
  736. AND t.site= w.site
  737. AND t.WorkCenterNo= w.WorkCenterNo
  738. AND d.ResourceID = w.ResourceID
  739. AND t.OrderNo= d.OrderNo
  740. AND t.ItemNo= d.ItemNo
  741. AND t.Site=#{site}
  742. AND t.OrderNo=#{orderNo}
  743. UNION ALL--如果工序没有设置可用机台的话,那么和和该加工中心下的所有机台对应
  744. SELECT
  745. t.Site,
  746. t.WorkCenterNo,
  747. d.ResourceID ,
  748. w.ResourceDesc
  749. FROM
  750. SORouting AS t
  751. LEFT JOIN SORouting_AvailableResource AS d ON t.site= d.site
  752. AND t.OrderNo= d.OrderNo
  753. AND t.ItemNo= d.ItemNo
  754. ,
  755. WorkCenterResource AS w
  756. WHERE
  757. d.Site IS NULL
  758. AND t.site= w.site
  759. AND t.WorkCenterNo= w.WorkCenterNo
  760. AND d.ResourceID = w.ResourceID
  761. AND t.Site=#{site}
  762. AND t.OrderNo=#{orderNo}
  763. ) AS x,
  764. sys_oss AS y
  765. WHERE
  766. x.Site= y.order_ref1
  767. AND x.WorkCenterNo= y.order_ref2
  768. AND x.ResourceID= y.order_ref3
  769. ORDER BY ResourceID,order_ref4
  770. </select>
  771. <select id="getShopOrderSopSOBOM" resultType="com.gaotao.modules.shopOrder.entity.ProductMixInShopOrder">
  772. Select
  773. T.ItemNo as item_no,
  774. T.WOR1_ItemCode as component_part_no,
  775. T.WOR1_ItemName as part_desc,
  776. T.WOR1_PlannedQty as qty_required,
  777. T.U_SNUM AS qty_on_hand
  778. from dbo.sop_sobom as T
  779. Where
  780. T.Site = #{site}
  781. and T.DocEntry = #{orderNo}
  782. </select>
  783. <select id="getOrderSopInfo" resultType="com.gaotao.modules.shopOrder.entity.SopViewData">
  784. select * from sop
  785. where DocEntry = #{orderNo}
  786. </select>
  787. <select id="getFileData" resultType="SysOssEntity">
  788. select url,file_name,new_file_name from sys_oss where id = #{id}
  789. </select>
  790. <insert id="saveShopOrderData2">
  791. insert into ShopOrder
  792. (Site, bu_no, OrderNo, Status, Status_Tmp, EnterDate, NeedDate, PlanStartDate,
  793. OrderType, PartNo, LotSize, BOMRevNo, RoutingRevNo, ProjectID, CustomerID, batch_no, OrderRef1, OrderRef2)
  794. values
  795. (#{site}, #{buNo}, #{orderNo}, #{status}, #{statusTmp}, #{enterDate}, #{needDate}, #{planStartDate},
  796. #{orderType}, #{partNo}, #{lotSize,jdbcType=FLOAT}, #{bOMRevNo}, #{routingRevNo}, #{projectID}, #{customerID}, #{batchNo}, #{orderRef1}, #{orderRef2})
  797. </insert>
  798. </mapper>