荣鑫后端
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.

844 lines
42 KiB

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
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
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
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
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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.gaotao.modules.base.dao.BaseMapper">
  4. <select id="getCalendarData" resultType="com.gaotao.modules.base.entity.CalendarData" parameterType="com.gaotao.modules.base.entity.CalendarData">
  5. SELECT * FROM calendar
  6. <where>
  7. <if test="site != null and site != ''">
  8. AND site = #{site}
  9. </if>
  10. <if test="calendarId != null and calendarId != ''">
  11. AND CalendarID LIKE #{calendarId}
  12. </if>
  13. <if test="status != null and status != ''">
  14. AND status = #{status}
  15. </if>
  16. <if test="calendarDesc != null and calendarDesc != ''">
  17. AND CalendarDesc LIKE #{calendarDesc}
  18. </if>
  19. </where>
  20. </select>
  21. <select id="findBySite" resultType="com.gaotao.modules.base.entity.CalendarDatetypeOutData">
  22. SELECT * FROM calendar_datetype
  23. <where>
  24. <if test="site != null and site != ''">
  25. AND site = #{site}
  26. </if>
  27. </where>
  28. </select>
  29. <update id="editCalendar" >
  30. UPDATE calendar set CalendarDesc=#{calendarDesc},status=#{status}
  31. WHERE CalendarID = #{calendarId}
  32. <!-- <if test="version != null and version != ''">-->
  33. <!-- AND version = #{version}-->
  34. <!-- </if>-->
  35. </update>
  36. <select id="findByCalendarId" resultType="com.gaotao.modules.base.entity.CalendarData">
  37. SELECT CalendarDesc FROM calendar
  38. <where>
  39. <if test="calendarId != null and calendarId != ''">
  40. AND CalendarID = #{calendarId}
  41. </if>
  42. </where>
  43. </select>
  44. <insert id="save" parameterType="com.gaotao.modules.base.entity.CalendarData">
  45. INSERT INTO calendar(site,calendarID,calendarDesc,status)
  46. VALUES (#{site},#{calendarId},#{calendarDesc},#{status})
  47. </insert>
  48. <delete id="delCalendar" >
  49. DELETE FROM calendar WHERE CalendarID = #{calendarId}
  50. </delete>
  51. <select id="findByDatetypeAndSite" resultType="com.gaotao.modules.base.entity.CalendarDatetypeOutData">
  52. select site,datetype,worktime,exceptexacttime1,exceptexacttime2,exceptexacttime3,exceptexacttime4,exceptexacttime5,exceptexacttime6,
  53. excepttime1,exceptduration1,excepttime2,exceptduration2,excepttime3,exceptduration3,excepttime4,exceptduration4,
  54. excepttime5,exceptduration5,excepttime6,exceptduration6 FROM calendar_datetype
  55. <where>
  56. <if test="dataType != null and dataType != ''">
  57. AND datetype = #{dataType}
  58. </if>
  59. <if test="site != null and site != ''">
  60. AND site = #{site}
  61. </if>
  62. </where>
  63. </select>
  64. <select id="getCalendarEByCIdAndSDate" resultType="com.gaotao.modules.base.entity.CalendarExceptionData">
  65. SELECT site,CalendarID,ScheduleDate FROM calendar_exception
  66. <where>
  67. <if test="site != null and site != ''">
  68. AND site = #{site}
  69. </if>
  70. <if test="calendarId != null and calendarId != ''">
  71. AND CalendarID = #{calendarId}
  72. </if>
  73. <if test="scheduledate != null and scheduledate != ''">
  74. AND ScheduleDate = #{scheduledate}
  75. </if>
  76. </where>
  77. </select>
  78. <select id="findBySiteAndCalendarId" resultType="com.gaotao.modules.base.entity.CalendarExceptionData">
  79. SELECT TOP 100 * FROM calendar_exception
  80. <where>
  81. <if test="site != null and site != ''">
  82. AND Site = #{site}
  83. </if>
  84. <if test="calendarId != null and calendarId != ''">
  85. AND CalendarID = #{calendarId}
  86. </if>
  87. </where>
  88. ORDER BY scheduledate DESC
  89. </select>
  90. <update id="editShift" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData">
  91. UPDATE calendar_datetype_shift set shiftdesc=#{shiftdesc},startexacttime=#{startexacttime}
  92. ,endexacttime=#{endexacttime},starttime=#{starttime},endtime=#{endtime}
  93. <where>
  94. <if test="site != null and site != ''">
  95. AND site = #{site}
  96. </if>
  97. AND DateType = #{datetype}
  98. and ShiftNo =#{shiftno}
  99. </where>
  100. </update>
  101. <select id="findShiftById" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData">
  102. SELECT * FROM calendar_datetype_shift
  103. <where>
  104. <if test="id != null and id != ''">
  105. AND id = #{id}
  106. </if>
  107. </where>
  108. </select>
  109. <select id="findByShiftno" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData">
  110. SELECT top 1 * FROM calendar_datetype_shift
  111. <where>
  112. <if test="site != null and site != ''">
  113. AND site = #{site}
  114. </if>
  115. AND DateType = #{datetype}
  116. and ShiftNo =#{shiftno}
  117. </where>
  118. </select>
  119. <insert id="saveCDS" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData">
  120. INSERT INTO calendar_datetype_shift (shiftno,datetype,site,shiftdesc,startexacttime,endexacttime,starttime,endtime)
  121. VALUES (#{shiftno},#{datetype},#{site},#{shiftdesc},#{startexacttime},#{endexacttime},#{starttime},#{endtime})
  122. </insert>
  123. <select id="findBySiteAndDatetype" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData">
  124. SELECT * FROM calendar_datetype_shift
  125. <where>
  126. <if test="site != null and site != ''">
  127. AND site = #{site}
  128. </if>
  129. <if test="datetype != null and datetype != ''">
  130. AND datetype = #{datetype}
  131. </if>
  132. </where>
  133. </select>
  134. <select id="findBySiteAndDatetype2" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData">
  135. SELECT * FROM calendar_datetype_shift
  136. <where>
  137. <if test="site != null and site != ''">
  138. AND site = #{site}
  139. </if>
  140. <if test="datetype != null and datetype != ''">
  141. AND datetype = #{datetype}
  142. </if>
  143. and ShiftNo != #{shiftno}
  144. </where>
  145. </select>
  146. <select id="findCDDByDatetypeAndSite" resultType="com.gaotao.modules.base.entity.CalendarDatetypeData">
  147. SELECT datetype,site FROM Calendar_DateType
  148. <where>
  149. <if test="datetype != null and datetype != ''">
  150. AND datetype = #{datetype}
  151. </if>
  152. <if test="site != null and site != ''">
  153. AND site = #{site}
  154. </if>
  155. </where>
  156. </select>
  157. <select id="findCDDById" resultType="com.gaotao.modules.base.entity.CalendarDatetypeData">
  158. SELECT created_date,created_by,delflag FROM calendar_datetype
  159. <where>
  160. <if test="id != null and id != ''">
  161. AND id = #{id}
  162. </if>
  163. </where>
  164. </select>
  165. <insert id="saveCDD" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeData">
  166. INSERT INTO calendar_datetype (site,datetype,excepttime1,exceptduration1,excepttime2,exceptduration2,excepttime3,exceptduration3,excepttime4,exceptduration4,
  167. excepttime5,exceptduration5,excepttime6,exceptduration6,worktime,remark,exceptexacttime1,exceptexacttime2,exceptexacttime3,exceptexacttime4,exceptexacttime5,exceptexacttime6)
  168. VALUES(#{site},#{datetype},#{excepttime1},#{exceptduration1},#{excepttime2},#{exceptduration2},#{excepttime3},#{exceptduration3},#{excepttime4},#{exceptduration4},
  169. #{excepttime5},#{exceptduration5},#{excepttime6},#{exceptduration6},#{worktime},#{remark},#{exceptexacttime1},#{exceptexacttime2},#{exceptexacttime3},#{exceptexacttime4},#{exceptexacttime5},#{exceptexacttime6})
  170. </insert>
  171. <delete id="deleteById">
  172. DELETE FROM calendar_datetype WHERE site= #{site} and datetype=#{datetype}
  173. </delete>
  174. <select id="getCalendarESByCIdAndSDate" resultType="com.gaotao.modules.base.entity.CalendarExceptionShiftData">
  175. select site,CalendarId,ScheduleDate from calendar_exception_shift
  176. <where>
  177. <if test="site != null and site != ''">
  178. AND site = #{site}
  179. </if>
  180. <if test="calendarId != null and calendarId != ''">
  181. AND CalendarId = #{calendarId}
  182. </if>
  183. <if test="scheduledate != null and scheduledate != ''">
  184. AND ScheduleDate = #{scheduledate}
  185. </if>
  186. </where>
  187. </select>
  188. <delete id="deleteCESById">
  189. DELETE FROM calendar_exception_shift WHERE site = #{site} AND CalendarId = #{calendarId} AND ScheduleDate = #{scheduledate}
  190. </delete>
  191. <insert id="saveCED" parameterType="com.gaotao.modules.base.entity.CalendarExceptionData">
  192. INSERT INTO calendar_exception (site,CalendarID,scheduledate,excepttime1,exceptduration1,excepttime2,exceptduration2,excepttime3
  193. ,exceptduration3,excepttime4,exceptduration4,excepttime5,exceptduration5,excepttime6,exceptduration6,worktime,datetype,exceptexacttime1
  194. ,exceptexacttime2,exceptexacttime3,exceptexacttime4,exceptexacttime5,exceptexacttime6)
  195. VALUES (#{site},#{calendarId},#{scheduledate},#{excepttime1},#{exceptduration1},#{excepttime2},#{exceptduration2},#{excepttime3},
  196. #{exceptduration3},#{excepttime4},#{exceptduration4},#{excepttime5},#{exceptduration5},#{excepttime6},#{exceptduration6},#{worktime},#{datetype},#{exceptexacttime1}
  197. ,#{exceptexacttime2},#{exceptexacttime3},#{exceptexacttime4},#{exceptexacttime5},#{exceptexacttime6})
  198. </insert>
  199. <insert id="saveCESD" parameterType="com.gaotao.modules.base.entity.CalendarExceptionShiftInData">
  200. INSERT INTO calendar_exception_shift (site,calendarID,shiftno,scheduledate,shiftdesc,startexacttime,endexacttime,
  201. starttime,endtime)
  202. VALUES (#{site},#{calendarId},#{shiftno},#{scheduledate},#{shiftdesc},#{startexacttime},#{endexacttime},
  203. #{starttime},#{endtime})
  204. </insert>
  205. <delete id="deleteCEDById">
  206. DELETE FROM calendar_exception WHERE site = #{site} and CalendarId = #{calendarId} AND scheduledate = #{scheduledate}
  207. </delete>
  208. <update id="updateCDD" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeData">
  209. UPDATE calendar_datetype set excepttime1=#{excepttime1},exceptduration1=#{exceptduration1},
  210. excepttime2=#{excepttime2},exceptduration2=#{exceptduration2},excepttime3=#{excepttime3},exceptduration3=#{exceptduration3},excepttime4=#{excepttime4},exceptduration4=#{exceptduration4},
  211. excepttime5=#{excepttime5},exceptduration5=#{exceptduration5},excepttime6=#{excepttime6},exceptduration6=#{exceptduration6},worktime=#{worktime},remark=#{remark},exceptexacttime1=#{exceptexacttime1},
  212. exceptexacttime2=#{exceptexacttime2},exceptexacttime3=#{exceptexacttime3},exceptexacttime4=#{exceptexacttime4},exceptexacttime5=#{exceptexacttime5},exceptexacttime6=#{exceptexacttime6}
  213. <where>
  214. <if test="site != null and site != ''">
  215. AND site = #{site}
  216. </if>
  217. <if test="datetype != null and datetype != ''">
  218. AND datetype = #{datetype}
  219. </if>
  220. </where>
  221. </update>
  222. <select id="getAllShiftData" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData">
  223. SELECT shiftno,shiftdesc,datetype,id FROM calendar_datetype_shift
  224. <where>
  225. AND site = #{site}
  226. </where>
  227. ORDER BY shiftno
  228. </select>
  229. <select id="findDateType" resultType="com.gaotao.modules.base.entity.CalendarExceptionData">
  230. SELECT site FROM calendar_exception
  231. <where>
  232. AND datetype = #{datetype}
  233. </where>
  234. </select>
  235. <delete id="deleteShift" >
  236. DELETE FROM calendar_datetype_shift WHERE shiftno=#{shiftno} AND site=#{site} AND DateType=#{datetype}
  237. </delete>
  238. <select id="getShiftNo" resultType="int">
  239. SELECT isnull(max(convert(INT,SUBSTRING(shiftno, 3,6))),0) FROM calendar_datetype_shift
  240. </select>
  241. <select id="getSiteAccessFlag" resultType="java.lang.String">
  242. select dbo.Get_Site_Access_Flag(#{userId},#{site})
  243. </select>
  244. <select id="getSiteData" resultType="com.gaotao.modules.base.entity.SiteData">
  245. Select T.* ,C.CompanyName from Site as T left join Company C ON T.CompanyID=C.CompanyID
  246. <where>
  247. <if test="companyID != null and companyID != ''">
  248. AND T.CompanyID = #{companyID}
  249. </if>
  250. <if test="companyName != null and companyName != ''">
  251. AND C.CompanyName = #{companyName}
  252. </if>
  253. </where>
  254. </select>
  255. <select id="getCompanyData" resultType="com.gaotao.modules.base.entity.CompanyData">
  256. Select CompanyID,CompanyName,Active,TaxNo,BankName,BankAccount,CutoffDate_DB,CutoffDate,CutoffDate_FixDate from Company
  257. </select>
  258. <select id="checkSiteId" resultType="com.gaotao.modules.base.entity.SiteData">
  259. select SiteName,SiteID from Site where SiteID=#{siteID} and Active='Y'
  260. </select>
  261. <select id="checkCal" resultType="com.gaotao.modules.base.entity.CalendarData">
  262. select calendarID from calendar where Site=#{site} and status='使用中' and calendarID=#{calendarID}
  263. </select>
  264. <select id="checkResource" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  265. select site from WorkCenterResource where Site=#{site} and ResourceID=#{resourceID}
  266. </select>
  267. <insert id="saveResource" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  268. INSERT INTO WorkCenterResource (Site,WorkCenterNo,ResourceID,ResourceDesc,Efficiency,Utilization,Active,Remark,CreatedDate,CalendarID,VirturlFlag)
  269. VALUES(#{site},#{workCenterNo},#{resourceID},#{resourceDesc},#{efficiency},#{utilization},#{active},#{remark},GetDate(),#{calendarID},'N')
  270. </insert>
  271. <update id="editResource" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  272. update WorkCenterResource SET ResourceDesc=#{resourceDesc},Efficiency=#{efficiency},Utilization=#{utilization},Active=#{active},Remark=#{remark},CalendarID=#{calendarID}
  273. where Site=#{site} and ResourceID=#{resourceID}
  274. </update>
  275. <insert id="saveSite" parameterType="com.gaotao.modules.base.entity.SiteData">
  276. INSERT INTO Site (SiteID,SiteName,SiteName_E,Address,Address_E,ContactName,PostCode,Email,FaxNo,PhoneNo,Active,Website,CompanyID,ShipTime,
  277. ReferenceCustomerID)
  278. VALUES (#{siteID},#{siteName},#{siteNameE},#{address},#{addressE},#{contactName},#{postCode},#{email},#{faxNo},#{phoneNo},#{active},
  279. #{website},#{companyID},#{shipTime},#{referenceCustomerID})
  280. </insert>
  281. <update id="editSite" parameterType="com.gaotao.modules.base.entity.SiteData">
  282. update Site SET SiteName=#{siteName},SiteName_E=#{siteNameE},Address=#{address},Address_E=#{addressE},ContactName=#{contactName},PostCode=#{postCode},
  283. Email=#{email},FaxNo=#{faxNo},PhoneNo=#{phoneNo},Active=#{active},Website=#{website},CompanyID=#{companyID},ShipTime=#{shipTime},ReferenceCustomerID=#{referenceCustomerID}
  284. where SiteID=#{siteID}
  285. </update>
  286. <select id="getPartFamily" resultType="com.gaotao.modules.base.entity.PartFamilyData">
  287. Select T.FamilyID,T.Site,T.FamilyName,T.CostType,T.CostTypeDesc,T.Active,T.BatchCreatedMethod,T.CheckPercentage
  288. from PartFamily as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
  289. </select>
  290. <select id="checkAccessSite" resultType="com.gaotao.modules.base.entity.AccessSiteData">
  291. Select UserID,Site from AccessSite where UserID=#{userID} and Site=#{site}
  292. </select>
  293. <select id="checkFamilyID" resultType="com.gaotao.modules.base.entity.PartFamilyData">
  294. select FamilyID,FamilyName from PartFamily where FamilyID=#{familyID} and Site =#{site}
  295. </select>
  296. <insert id="savePartFamily" parameterType="com.gaotao.modules.base.entity.PartFamilyData">
  297. INSERT INTO PartFamily (FamilyID,Site,FamilyName,Active,CheckPercentage)
  298. values (#{familyID},#{site},#{familyName},#{active},#{checkPercentage})
  299. </insert>
  300. <update id="editPartFamily" parameterType="com.gaotao.modules.base.entity.PartFamilyData">
  301. UPDATE PartFamily SET Site=#{site},FamilyName=#{familyName},Active=#{active},CheckPercentage=#{checkPercentage}
  302. where FamilyID=#{familyID} and Site=#{site}
  303. </update>
  304. <delete id="deletePartFamily" parameterType="com.gaotao.modules.base.entity.PartFamilyData">
  305. delete from PartFamily where FamilyID=#{familyID} and Site=#{site}
  306. </delete>
  307. <!-- 计量单位 -->
  308. <select id="getUMData" resultType="com.gaotao.modules.base.entity.UmData">
  309. Select T.UMID,T.Site,T.UMName,T.Active
  310. from UM as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
  311. </select>
  312. <select id="checkUmID" resultType="com.gaotao.modules.base.entity.UmData">
  313. select UMID,UMName from UM where UMID=#{umid} and Site=#{site}
  314. </select>
  315. <insert id="saveUMData" parameterType="com.gaotao.modules.base.entity.UmData">
  316. INSERT INTO UM (UMID,Site,UMName,Active)
  317. values (#{umid},#{site},#{uMName},#{active})
  318. </insert>
  319. <update id="editUMData" parameterType="com.gaotao.modules.base.entity.UmData">
  320. UPDATE UM SET Site=#{site},UMName=#{uMName},Active=#{active}
  321. where UMID=#{umid} and Site=#{site}
  322. </update>
  323. <select id="checkUmIDInPart" resultType="com.gaotao.modules.base.entity.PartData">
  324. SELECT PartNo,PartDescription FROM Part where Site=#{site} and UMID=#{umid}
  325. </select>
  326. <delete id="deleteUMData" parameterType="com.gaotao.modules.base.entity.UmData">
  327. delete from UM where UMID=#{umid} and Site=#{site}
  328. </delete>
  329. <!-- 查询-物料编码 -->
  330. <select id="searchPartNoData" resultType="com.gaotao.modules.base.entity.PartData">
  331. Select T.PartNo,T.Site,T.PartDescription,T.Spec,T.UMID,T.Active,T.CreateDate,T.Remark,T.ConfigurationTemplateID
  332. from Part as T
  333. <where>
  334. AND T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
  335. <if test=" site != null and site != ''">
  336. AND T.Site = #{site}
  337. </if>
  338. <if test="partNo != null and partNo != ''">
  339. AND T.PartNo LIKE #{partNo}
  340. </if>
  341. <if test="partDescription != null and partDescription != ''">
  342. AND T.PartDescription LIKE #{partDescription}
  343. </if>
  344. <if test="spec != null and spec != ''">
  345. AND T.Spec LIKE #{spec}
  346. </if>
  347. <if test="active != null and active != ''">
  348. AND T.Active = #{active}
  349. </if>
  350. <if test=" date1 != null ">
  351. AND T.CreateDate >= #{date1}
  352. </if>
  353. <if test=" date2 != null ">
  354. AND #{date2} >=T.CreateDate
  355. </if>
  356. </where>
  357. </select>
  358. <!-- 停机原因 -->
  359. <select id="getShutDownReasonData" resultType="com.gaotao.modules.base.entity.DowntimeReasonData">
  360. Select Site,ReasonCode,Area,ReasonDescription,Active
  361. from DowntimeReason as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
  362. </select>
  363. <select id="checkRasonCode" resultType="com.gaotao.modules.base.entity.DowntimeReasonData">
  364. select ReasonCode,ReasonDescription from DowntimeReason where ReasonCode=#{reasonCode} and Site=#{site}
  365. </select>
  366. <insert id="saveShutDownReasonData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData">
  367. INSERT INTO DowntimeReason (Site,ReasonCode,Area,ReasonDescription,Active)
  368. values (#{site},#{reasonCode},#{area},#{reasonDescription},#{active})
  369. </insert>
  370. <update id="editShutDownReasonData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData">
  371. UPDATE DowntimeReason SET Active=#{active},Area=#{area},ReasonDescription=#{reasonDescription}
  372. where ReasonCode=#{reasonCode} and Site=#{site}
  373. </update>
  374. <delete id="deleteShutDownReasonData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData">
  375. delete from DowntimeReason where ReasonCode=#{reasonCode} and Site=#{site}
  376. </delete>
  377. <!-- 物料参照信息 -->
  378. <select id="getReferencePartInfoData" resultType="com.gaotao.modules.base.entity.ReferencePartInfoData">
  379. SELECT T.Site,T.CustomerID,T.FGPartNo,T.PartNo,T.ReferencePartDesc,T.LastUpdateBy,T.Remark,T.SupplierID,P.PartDescription,P2.PartDescription AS fGPartDescription,p.umid,S.SupplierName
  380. FROM
  381. ReferencePartInfo AS T
  382. LEFT JOIN Part AS P ON T.Site = P.Site AND T.PartNo = P.PartNo
  383. LEFT JOIN Part AS P2 ON T.Site = P2.Site AND T.FGPartNo = P2.PartNo
  384. LEFT JOIN Supplier AS S ON S.SupplierID=T.SupplierID and S.Site=T.Site
  385. WHERE
  386. T.Site IN (
  387. SELECT
  388. Site
  389. FROM
  390. AccessSite
  391. WHERE
  392. UPPER (UserID) = #{user}
  393. )
  394. </select>
  395. <select id="getPartNoDetail" resultType="com.gaotao.modules.base.entity.PartData" >
  396. select partDescription,umid,spec from Part Where Site=#{site} and PartNo=#{partNo} and Active='Y'
  397. </select>
  398. <select id="getSupplierDetail" resultType="com.gaotao.modules.base.entity.SupplierData" >
  399. select SupplierID,SupplierName from Supplier Where Site=#{site} and SupplierID=#{supplierID} and Active='Y'
  400. </select>
  401. <select id="checkReferencePartInfo" resultType="com.gaotao.modules.base.entity.DowntimeReasonData">
  402. select Site,PartNo from ReferencePartInfo where CustomerID=#{customerID} and Site=#{site} and FGPartNo=#{fGPartNo} and PartNo=#{partNo}
  403. </select>
  404. <insert id="saveReferencePartInfoData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData">
  405. INSERT INTO ReferencePartInfo (Site,CustomerID,PartNo,ReferencePartDesc,SupplierID,FGPartNo,LastUpdateBy)
  406. values (#{site},#{customerID},#{partNo},#{referencePartDesc},#{supplierID},#{fGPartNo},#{user})
  407. </insert>
  408. <update id="editReferencePartInfoData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData">
  409. UPDATE ReferencePartInfo SET Site=#{site},CustomerID=#{customerID},PartNo=#{partNo},ReferencePartDesc=#{referencePartDesc},SupplierID=#{supplierID},FGPartNo=#{fGPartNo},LastUpdateBy=#{user}
  410. where CustomerID=#{customerID} and Site=#{site} and FGPartNo=#{fGPartNo} and PartNo=#{partNo}
  411. </update>
  412. <delete id="deleteReferencePartInfoData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData">
  413. delete from ReferencePartInfo where CustomerID=#{customerID} and Site=#{site} and FGPartNo=#{fGPartNo} and PartNo=#{partNo}
  414. </delete>
  415. <!-- 生产线 -->
  416. <select id="getProductionLineData" resultType="com.gaotao.modules.base.entity.ProductionLineData">
  417. Select T.Site,T.ProLineNo,T.ProLineDesc,T.Active,T.CreatedDate
  418. from ProductionLine as T
  419. where T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
  420. </select>
  421. <select id="checkProLineNo" resultType="com.gaotao.modules.base.entity.ProductionLineData">
  422. select ProLineNo,ProLineDesc from ProductionLine where ProLineNo=#{proLineNo} and Site=#{site}
  423. </select>
  424. <insert id="saveProductionLineData" parameterType="com.gaotao.modules.base.entity.ProductionLineData">
  425. INSERT INTO ProductionLine (Site,ProLineNo,ProLineDesc,Active,CreatedDate)
  426. values (#{site},#{proLineNo},#{proLineDesc},#{active},#{createdDate})
  427. </insert>
  428. <update id="editProductionLineData" parameterType="com.gaotao.modules.base.entity.ProductionLineData">
  429. UPDATE ProductionLine SET ProLineDesc=#{proLineDesc},Active=#{active},CreatedDate=#{createdDate}
  430. where ProLineNo=#{proLineNo} and Site=#{site}
  431. </update>
  432. <delete id="deleteProductionLineData" parameterType="com.gaotao.modules.base.entity.ProductionLineData">
  433. delete from ProductionLine where ProLineNo=#{proLineNo} and Site=#{site}
  434. </delete>
  435. <!-- 加工中心 -->
  436. <select id="getWorkCenterData" resultType="com.gaotao.modules.base.entity.WorkCenterData">
  437. Select T.* ,P.ProLineDesc as ProductionLineDesc
  438. from WorkCenter as T
  439. LEFT JOIN ProductionLine P ON P.Site=T.Site and T.ProLineNo=P.ProLineNo
  440. <where>
  441. AND T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
  442. <if test=" site != null and site != ''">
  443. and T.Site like #{site}
  444. </if>
  445. <if test=" workCenterNo != null and workCenterNo != ''">
  446. and T.workCenterNo like #{workCenterNo}
  447. </if>
  448. </where>
  449. </select>
  450. <select id="getWorkCenterResourceData" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  451. Select T.*
  452. from WorkCenterResource as T
  453. where T.Site =#{site} and T.WorkCenterNo=#{workCenterNo}
  454. </select>
  455. <select id="getProductInWorkCenterData" resultType="com.gaotao.modules.base.entity.ProductInWorkCenterData">
  456. Select T.Site,T.PartNo,T.RevNo,D.ItemNo,D.OperationDesc,D.MachSetuptime,D.MachRunFactor,D.FactorUnit,D.Crewsize,D.Efficiency,D.Remark,T.Status,T.RoutingType
  457. from RoutingHeader as T,RoutingDetail as D
  458. Where T.Site=D.Site and T.PartNo=D.PartNo and T.RevNo=D.RevNo and T.Site=#{site} and D.WorkCenterNo=#{workCenterNo}
  459. </select>
  460. <select id="getProLineNoDetail" resultType="com.gaotao.modules.base.entity.ProductionLineData">
  461. Select * FROM ProductionLine where Site=#{site} and ProLineNo=#{proLineNo}
  462. </select>
  463. <select id="checkWorkCenter" resultType="com.gaotao.modules.base.entity.WorkCenterData">
  464. select WorkCenterNo,WorkCenterDesc from WorkCenter where WorkCenterNo=#{workCenterNo} and Site=#{site}
  465. </select>
  466. <insert id="saveWorkCenterData" parameterType="com.gaotao.modules.base.entity.WorkCenterData">
  467. INSERT INTO WorkCenter (Site,WorkCenterNo,WorkCenterDesc,WorkCenterType_DB,WorkCenterType,AverageCapacity,Efficiency,Utilization,CapacityType_DB,
  468. CapacityType,UMID,Active,Remark,CreatedDate,ProLineNo,CanCreateNewRollFlag,NeedSetupFlag)
  469. values (#{site},#{workCenterNo},#{workCenterDesc},#{workCenterTypeDb},#{workCenterType},0,100,100,'I','无限能力',
  470. #{umid},#{active},#{remark},#{createdDate},#{proLineNo},#{canCreateNewRollFlag},#{needSetupFlag})
  471. </insert>
  472. <update id="editWorkCenterData" parameterType="com.gaotao.modules.base.entity.WorkCenterData">
  473. UPDATE WorkCenter SET WorkCenterDesc=#{workCenterDesc},Active=#{active},WorkCenterType=#{workCenterNo},WorkCenterType_DB=#{workCenterTypeDb},
  474. Remark=#{remark},CreatedDate=#{createdDate},ProLineNo=#{proLineNo},
  475. CanCreateNewRollFlag=#{canCreateNewRollFlag},NeedSetupFlag=#{needSetupFlag}
  476. where WorkCenterNo=#{workCenterNo} and Site=#{site}
  477. </update>
  478. <delete id="deleteWorkCenterData" parameterType="com.gaotao.modules.base.entity.WorkCenterData">
  479. delete from WorkCenter where WorkCenterNo=#{workCenterNo} and Site=#{site}
  480. </delete>
  481. <delete id="deleteResource" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  482. delete from WorkCenterResource where ResourceID=#{resourceID} and Site=#{site}
  483. </delete>
  484. <update id="setResourceFlag" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  485. UPDATE WorkCenterResource SET VirturlFlag=#{virturlFlag} where ResourceID=#{resourceID} and Site=#{site}
  486. </update>
  487. <select id="checkCustomerID" resultType="com.gaotao.modules.base.entity.PartData">
  488. select PartNo,ConfigurationTemplateID from Part WHERE site=#{site} and ConfigurationTemplateID=#{configurationTemplateID}
  489. </select>
  490. <select id="getCompanyInformation" resultType="com.gaotao.modules.base.entity.CompanyData">
  491. Select * from Company
  492. <where>
  493. <if test="companyID != null and companyID != ''">
  494. AND companyID LIKE #{companyID}
  495. </if>
  496. <if test="companyName != null and companyName != ''">
  497. AND companyName LIKE #{companyName}
  498. </if>
  499. <if test="active != null and active != ''">
  500. AND Active = #{active}
  501. </if>
  502. </where>
  503. </select>
  504. <select id="checkCompanyInformation" resultType="com.gaotao.modules.base.entity.CompanyData">
  505. select companyID,companyName FROM Company WHERE companyID=#{companyID}
  506. </select>
  507. <insert id="saveCompanyInformation" parameterType="com.gaotao.modules.base.entity.CompanyData">
  508. INSERT INTO Company (CompanyID,CompanyName,Active,TaxNo,BankName,BankAccount,CutoffDate_DB,CutoffDate,CutoffDate_FixDate)
  509. values (#{companyID},#{companyName},#{active},#{taxNo},#{bankName},#{bankAccount},#{cutoffDateDb},#{cutoffDate},#{cutoffDateFixDate})
  510. </insert>
  511. <update id="editCompanyInformation" parameterType="com.gaotao.modules.base.entity.CompanyData">
  512. UPDATE Company SET CompanyName=#{companyName},CutoffDate_DB=#{cutoffDateDb},Active=#{active},
  513. TaxNo=#{taxNo},BankName=#{bankName},BankAccount=#{bankAccount},CutoffDate=#{cutoffDate},CutoffDate_FixDate=#{cutoffDateFixDate}
  514. where CompanyID=#{companyID}
  515. </update>
  516. <delete id="deleteCompanyInformation" parameterType="com.gaotao.modules.base.entity.CompanyData">
  517. delete from Company where CompanyID=#{companyID}
  518. </delete>
  519. <select id="getPartFamilyList" resultType="com.gaotao.modules.base.entity.PartFamilyData">
  520. select A.FamilyID,A.Site,A.FamilyName,A.CostType,A.CostTypeDesc,A.Active,A.BatchCreatedMethod,A.CheckPercentage
  521. from PartFamily A
  522. <where>
  523. <if test="site != null and site != ''">
  524. and A.site = #{site,jdbcType=VARCHAR}
  525. </if>
  526. <if test="familyID != null and familyID != ''">
  527. and A.FamilyID = #{familyID,jdbcType=VARCHAR}
  528. </if>
  529. <if test="familyName != null and familyName != ''">
  530. and A.FamilyName = #{familyName,jdbcType=VARCHAR}
  531. </if>
  532. <if test="active != null and active != ''">
  533. and A.Active = #{active,jdbcType=VARCHAR}
  534. </if>
  535. </where>
  536. </select>
  537. <select id="checkConfigurationTemplateID" resultType="com.gaotao.modules.base.entity.PartData">
  538. Select ConfigurationTemplateID
  539. from Part where ConfigurationTemplateID=#{configurationTemplateID} and site=#{site}
  540. </select>
  541. <select id="checkCompanyInSite" resultType="com.gaotao.modules.base.entity.SiteData">
  542. Select SiteID from site where CompanyID=#{companyID}
  543. </select>
  544. <!--=================维护工艺路线信息===================-->
  545. <select id="searchRoutingWithPartNo" resultType="com.gaotao.modules.base.entity.RoutingHeaderData">
  546. Select top 1000 r.Site,r.PartNo,r.RevNo,r.PhaseInDate,r.PhaseOutDate,r.RoutingType_DB,r.RoutingType,r.Status,r.Status_DB,
  547. r.Defaultflag,r.Remark,r.RepairFlag,p.PartDescription+' / '+isnull(p.Spec,'') as spec,p.umid
  548. from RoutingHeader r
  549. LEFT JOIN Part p on p.partNo=r.partNo and p.site=r.site
  550. <where>
  551. <if test="partNo != null and partNo != ''">
  552. and r.partNo like #{partNo}
  553. </if>
  554. <if test="site != null and site != ''">
  555. and r.site = #{site}
  556. </if>
  557. <if test="revNo != null and revNo != ''">
  558. and r.revNo = #{revNo}
  559. </if>
  560. </where>
  561. </select>
  562. <select id="searchRoutingDetailData" resultType="com.gaotao.modules.base.entity.RoutingDetailData">
  563. Select Site,PartNo,RevNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor,FactorUnit_DB,FactorUnit,Efficiency,
  564. Crewsize,JJGZ_UnitFactor_DB,JJGZ_UnitFactor,JJGZ_UnitPrice,Remark,WX_PartNo,WX_UnitCost,BatchQty,dbo.Get_Part_DescSpec(Site,PartNo) as spec,
  565. dbo.Get_Part_DescSpec(site,WX_PartNo) as wxSpec,dbo.Get_WorkCenter_Type(Site,WorkCenterNo) as workCenterType ,dbo.Get_WorkCenterDesc(Site,WorkCenterNo) as workCenterDesc
  566. from RoutingDetail
  567. <where>
  568. <if test="partNo != null and partNo != ''">
  569. and partNo like #{partNo}
  570. </if>
  571. <if test="site != null and site != ''">
  572. and site = #{site}
  573. </if>
  574. <if test="revNo != null and revNo != ''">
  575. and revNo = #{revNo}
  576. </if>
  577. </where>
  578. order by ItemNo
  579. </select>
  580. <select id="checkRoutingItemNo" resultType="com.gaotao.modules.base.entity.RoutingDetailData">
  581. Select ItemNo from RoutingDetail
  582. <where>
  583. <if test="partNo != null and partNo != ''">
  584. and partNo like #{partNo}
  585. </if>
  586. <if test="site != null and site != ''">
  587. and site = #{site}
  588. </if>
  589. <if test="revNo != null and revNo != ''">
  590. and revNo = #{revNo}
  591. </if>
  592. <if test="itemNo != null and itemNo != ''">
  593. and ItemNo = #{itemNo}
  594. </if>
  595. </where>
  596. </select>
  597. <insert id="saveRoutingDetailData" parameterType="com.gaotao.modules.base.entity.RoutingDetailData">
  598. insert into RoutingDetail (Site,PartNo,RevNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor,FactorUnit_DB,FactorUnit,Efficiency,
  599. Crewsize,JJGZ_UnitFactor_DB,JJGZ_UnitFactor,JJGZ_UnitPrice,Remark,WX_UnitCost,BatchQty)
  600. VALUES(#{site},#{partNo},#{revNo},#{itemNo},#{operationDesc},#{workCenterNo},#{machSetupTime},#{machRunFactor},#{factorUnitDb},#{factorUnit},#{efficiency},
  601. #{crewsize},#{jjgzUnitFactorDb},#{jjgzUnitFactor},#{jjgzUnitPrice},#{remark},0,0)
  602. </insert>
  603. <update id="editRoutingDetailData" parameterType="com.gaotao.modules.base.entity.RoutingDetailData">
  604. UPDATE RoutingDetail SET OperationDesc=#{operationDesc},WorkCenterNo=#{workCenterNo},MachSetupTime=#{machSetupTime},
  605. MachRunFactor=#{machRunFactor},FactorUnit_DB=#{factorUnitDb},FactorUnit=#{factorUnit},Efficiency=#{efficiency},
  606. Crewsize=#{crewsize},JJGZ_UnitFactor_DB=#{jjgzUnitFactorDb},JJGZ_UnitFactor=#{jjgzUnitFactor},JJGZ_UnitPrice=#{jjgzUnitPrice},Remark=#{remark}
  607. WHERE partNo = #{partNo} and site = #{site} and revNo = #{revNo} and ItemNo = #{itemNo}
  608. </update>
  609. <delete id="deleteRoutingDetail" parameterType="com.gaotao.modules.base.entity.RoutingDetailData">
  610. delete from RoutingDetail where site=#{site} and PartNo=#{partNo} and RevNo=#{revNo} and ItemNo=#{itemNo}
  611. </delete>
  612. <select id="searchRoutingToolData" resultType="com.gaotao.modules.base.entity.RoutingToolData">
  613. Select T.Site,T.RevNo,T.ItemNo,T.ToolID,P.ToolDescription,P.Spec
  614. ,T.ToolQty,P.FamilyID,dbo.Get_PartFamilyDesc(T.Site,P.FamilyID) as FamilyName,P.Active
  615. ,T.Remark,T.CreateDate,T.CreatedBy
  616. from RoutingTool as T,ToolHeader as P
  617. <where>
  618. <if test="toolID != null and toolID != ''">
  619. and T.ToolID = #{toolID}
  620. </if>
  621. and T.Site=P.Site and T.ToolID=P.ToolID
  622. and T.PartNo=#{partNo}
  623. and T.Site=#{site} and T.RevNo=#{revNo}
  624. </where>
  625. </select>
  626. <select id="searchAllResource" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  627. Select Site,WorkCenterNo,ResourceID,ResourceDesc,Active
  628. from WorkCenterResource
  629. where site=#{site} and WorkCenterNo=#{workCenterNo} and Active='Y'
  630. </select>
  631. <select id="searchUsedResource" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData">
  632. SELECT R.ResourceID,W.ResourceDesc,W.Active FROM
  633. RoutingDetail_AvailableResource R
  634. LEFT JOIN WorkCenterResource W on W.ResourceID=R.ResourceID and R.Site=W.Site
  635. where R.site=#{site} and R.PartNo=#{partNo} and R.revNo=#{revNo} and R.itemNo=#{itemNo}
  636. </select>
  637. <select id="checkRoutingResource" resultType="com.gaotao.modules.base.entity.RoutingDetailAvailableResourceData">
  638. SELECT site,ResourceID FROM
  639. RoutingDetail_AvailableResource
  640. where site=#{site} and PartNo=#{partNo} and revNo=#{revNo} and itemNo=#{itemNo} and ResourceID=#{resourceID}
  641. </select>
  642. <insert id="addRoutingResource" parameterType="com.gaotao.modules.base.entity.RoutingDetailAvailableResourceData">
  643. INSERT INTO RoutingDetail_AvailableResource(Site,PartNo,RevNo,ItemNo,ResourceID)
  644. VALUES (#{site},#{partNo},#{revNo},#{itemNo},#{resourceID})
  645. </insert>
  646. <delete id="deleteRoutingResource" parameterType="com.gaotao.modules.base.entity.RoutingDetailAvailableResourceData">
  647. delete from RoutingDetail_AvailableResource
  648. where site=#{site} and PartNo=#{partNo} and revNo=#{revNo} and itemNo=#{itemNo} and ResourceID=#{resourceID}
  649. </delete>
  650. <select id="getItemSelect" resultType="com.gaotao.modules.base.entity.RoutingDetailData">
  651. SELECT ItemNo,OperationDesc from RoutingDetail
  652. <where>
  653. and partNo = #{partNo}
  654. and site = #{site}
  655. and revNo = #{revNo}
  656. <if test="itemNo != null and itemNo != ''">
  657. and ItemNo = #{itemNo}
  658. </if>
  659. </where>
  660. </select>
  661. <select id="getToolDesc" resultType="com.gaotao.modules.base.entity.ToolHeaderData">
  662. SELECT toolID,ToolDescription,Spec
  663. FROM ToolHeader
  664. WHERE site=#{site} and toolID=#{toolID}
  665. </select>
  666. <select id="checkToolHeader" resultType="com.gaotao.modules.base.entity.ToolHeaderData">
  667. SELECT toolID,ToolDescription,Spec
  668. FROM ToolHeader
  669. WHERE site=#{site} and toolID=#{toolID}
  670. </select>
  671. <insert id="saveRoutingToolData" parameterType="com.gaotao.modules.base.entity.RoutingToolData">
  672. INSERT INTO RoutingTool(Site,PartNo,RevNo,ItemNo,ToolID,ToolQty,Remark,CreateDate,CreatedBy)
  673. VALUES(#{site},#{partNo},#{revNo},#{itemNo},#{toolID},#{toolQty},#{remark},GETDATE(),#{user} )
  674. </insert>
  675. <update id="editRoutingToolData" parameterType="com.gaotao.modules.base.entity.RoutingToolData">
  676. update RoutingTool SET ToolQty=#{toolQty},Remark=#{remark}
  677. WHERE Site=#{site} and PartNo=#{partNo} and ToolID=#{toolID} and RevNo=#{revNo} and ItemNo=#{itemNo}
  678. </update>
  679. <delete id="deleteRoutingTool" parameterType="com.gaotao.modules.base.entity.RoutingToolData">
  680. delete from RoutingTool WHERE Site=#{site} and PartNo=#{partNo} and ToolID=#{toolID} and RevNo=#{revNo} and ItemNo=#{itemNo}
  681. </delete>
  682. <update id="changeRoutingStatus" parameterType="com.gaotao.modules.base.entity.RoutingHeaderData">
  683. update RoutingHeader SET status=#{status} where Site=#{site} and PartNo=#{partNo} and RevNo=#{revNo}
  684. </update>
  685. <select id="checkRoutingStatus" resultType="com.gaotao.modules.base.entity.RoutingHeaderData">
  686. Select top 1 Status from RoutingHeader
  687. where Site=#{site} and PartNo=#{partNo} and RevNo=#{revNo}
  688. </select>
  689. <select id="shopOrderRoutingNumber" resultType="int">
  690. Select count(1) as SL from ShopOrder as T
  691. where Site=#{site} and PartNo=#{partNo}
  692. and (Status='已计划' or Status='已下达')
  693. and Not exists(Select 1 from SOScheduledRouting as D Where T.Site=D.Site and T.OrderNo=D.OrderNo)
  694. and T.OrderType!='P'
  695. </select>
  696. <insert id="saveRoutingChangeCach">
  697. Select Site,OrderNo,LotSize into ${tableName} from ShopOrder as T
  698. where Site=#{site} and PartNo=#{partNo}
  699. and (Status='已计划' or Status='已下达')
  700. and Not exists(Select 1 from SOScheduledRouting as D Where T.Site=D.Site and T.OrderNo=D.OrderNo)
  701. and T.OrderType != 'P'
  702. </insert>
  703. <update id="updateOrderRevNo">
  704. Update ShopOrder Set RoutingRevNo=#{revNo}
  705. from ${tableName} as T where ShopOrder.Site=T.Site and ShopOrder.OrderNo=T.OrderNo
  706. </update>
  707. <delete id="deleteNowItemNo">
  708. Delete SORouting from ${tableName} as T where SORouting.Site=T.Site and SORouting.OrderNo=T.OrderNo
  709. </delete>
  710. <delete id="deleteNowToolNo">
  711. Delete SOTool from ${tableName} as T where SOTool.Site=T.Site and SOTool.OrderNo=T.OrderNo
  712. </delete>
  713. <insert id="saveNewItemNo" >
  714. Insert into SORouting(Site,OrderNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor
  715. ,FactorUnit_DB,FactorUnit,TimeRequired,TimeReported,Efficiency,Remark,QtyRequired,QtyReported,QtyApprove
  716. ,PlanStartTime,PlanFinishTime,BarcodeID,PartNo,ClosedFlag,OutWorkFlag,OutWorkPartNo,QtyOnPR,QtyOnPO,QtyScrapt,Crewsize
  717. ,PreItemNo,NextItemNo,ScheduledFlag,QtyScheduled)
  718. Select T.Site,D.OrderNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor,FactorUnit_DB,FactorUnit,
  719. (MachSetupTime+(Case when MachRunFactor=0 then 0 else (Case when FactorUnit_DB='1' then D.LotSize/MachRunFactor when FactorUnit_DB='2' then D.LotSize*MachRunFactor
  720. when FactorUnit_DB='3' then MachRunFactor end) end)/(Efficiency/100)) as TimeRequired,0,Efficiency,Remark ,D.LotSize,0,0,0,0
  721. ,(Case when len(OrderNo)>10 then D.Site + '-' + D.OrderNo + '-' + dbo.Get_PadL(ItemNo,4,'0') else D.Site + '-' + dbo.Get_PadL(D.OrderNo,10,'0') + '-' + dbo.Get_PadL(ItemNo,4,'0') end),T.PartNo,'N'
  722. ,(Case when dbo.Get_WorkCenter_TypeDB(T.Site,WorkCenterNo)='O' then 'Y' else 'N' end) as OutWorkFlag,WX_PartNo as OutWorkPartNo,0.0 as QtyOnPR,0.0 as QtyOnPO,0.0 as QtyScrapt,Crewsize
  723. ,Isnull((Select Max(D.ItemNo) as PreItemNo from RoutingDetail as D Where D.Site=T.Site and D.PartNo=T.PartNo and D.RevNo=T.RevNo and T.ItemNo>D.ItemNo),0)
  724. ,Isnull((Select Min(D.ItemNo) as NextItemNo from RoutingDetail as D Where D.Site=T.Site and D.PartNo=T.PartNo and D.RevNo=T.RevNo and D.ItemNo>T.ItemNo),0)
  725. ,'N',0
  726. from RoutingDetail as T, ${tableName} as D
  727. Where D.Site=T.Site
  728. and T.site=#{site} and T.PartNo=#{partNo} and T.RevNo=#{revNo}
  729. </insert>
  730. <insert id="saveNewTool" >
  731. Insert into SOTool(Site,OrderNo,ItemNo,ToolID,ToolQty,Remark,CreateDate,CreatedBy)
  732. Select T.Site,D.OrderNo,ItemNo,ToolID,ToolQty,Remark,getdate(),#{user}
  733. from RoutingTool as T,${tableName} as D
  734. Where D.Site=T.Site and T.site=#{site} and T.PartNo=#{partNo} and T.RevNo=#{revNo}
  735. </insert>
  736. <delete id="deleteRoutingChangeCach">
  737. Drop table ${tableName}
  738. </delete>
  739. </mapper>