|
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.gaotao.modules.base.dao.BaseMapper">
<select id="getCalendarData" resultType="com.gaotao.modules.base.entity.CalendarData" parameterType="com.gaotao.modules.base.entity.CalendarData"> SELECT * FROM calendar <where> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="calendarId != null and calendarId != ''"> AND CalendarID LIKE #{calendarId} </if> <if test="status != null and status != ''"> AND status = #{status} </if> <if test="calendarDesc != null and calendarDesc != ''"> AND CalendarDesc LIKE #{calendarDesc} </if> </where> </select>
<select id="findBySite" resultType="com.gaotao.modules.base.entity.CalendarDatetypeOutData"> SELECT * FROM calendar_datetype <where> <if test="site != null and site != ''"> AND site = #{site} </if> </where> </select>
<update id="editCalendar" > UPDATE calendar set CalendarDesc=#{calendarDesc},status=#{status}
WHERE CalendarID = #{calendarId}
<!-- <if test="version != null and version != ''">--><!-- AND version = #{version}--><!-- </if>-->
</update>
<select id="findByCalendarId" resultType="com.gaotao.modules.base.entity.CalendarData"> SELECT CalendarDesc FROM calendar <where> <if test="calendarId != null and calendarId != ''"> AND CalendarID = #{calendarId} </if> </where> </select>
<insert id="save" parameterType="com.gaotao.modules.base.entity.CalendarData"> INSERT INTO calendar(site,calendarID,calendarDesc,status) VALUES (#{site},#{calendarId},#{calendarDesc},#{status}) </insert>
<delete id="delCalendar" > DELETE FROM calendar WHERE CalendarID = #{calendarId}
</delete>
<select id="findByDatetypeAndSite" resultType="com.gaotao.modules.base.entity.CalendarDatetypeOutData"> select site,datetype,worktime,exceptexacttime1,exceptexacttime2,exceptexacttime3,exceptexacttime4,exceptexacttime5,exceptexacttime6, excepttime1,exceptduration1,excepttime2,exceptduration2,excepttime3,exceptduration3,excepttime4,exceptduration4, excepttime5,exceptduration5,excepttime6,exceptduration6 FROM calendar_datetype <where> <if test="dataType != null and dataType != ''"> AND datetype = #{dataType} </if> <if test="site != null and site != ''"> AND site = #{site} </if> </where> </select>
<select id="getCalendarEByCIdAndSDate" resultType="com.gaotao.modules.base.entity.CalendarExceptionData"> SELECT site,CalendarID,ScheduleDate FROM calendar_exception <where> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="calendarId != null and calendarId != ''"> AND CalendarID = #{calendarId} </if> <if test="scheduledate != null and scheduledate != ''"> AND ScheduleDate = #{scheduledate} </if> </where> </select>
<select id="findBySiteAndCalendarId" resultType="com.gaotao.modules.base.entity.CalendarExceptionData"> SELECT TOP 100 * FROM calendar_exception <where> <if test="site != null and site != ''"> AND Site = #{site} </if> <if test="calendarId != null and calendarId != ''"> AND CalendarID = #{calendarId} </if> </where> ORDER BY scheduledate DESC </select>
<update id="editShift" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData"> UPDATE calendar_datetype_shift set shiftdesc=#{shiftdesc},startexacttime=#{startexacttime} ,endexacttime=#{endexacttime},starttime=#{starttime},endtime=#{endtime} <where> <if test="site != null and site != ''"> AND site = #{site} </if> AND DateType = #{datetype} and ShiftNo =#{shiftno} </where> </update>
<select id="findShiftById" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData"> SELECT * FROM calendar_datetype_shift <where> <if test="id != null and id != ''"> AND id = #{id} </if> </where> </select>
<select id="findByShiftno" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData"> SELECT top 1 * FROM calendar_datetype_shift <where> <if test="site != null and site != ''"> AND site = #{site} </if> AND DateType = #{datetype} and ShiftNo =#{shiftno} </where> </select>
<insert id="saveCDS" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData"> INSERT INTO calendar_datetype_shift (shiftno,datetype,site,shiftdesc,startexacttime,endexacttime,starttime,endtime) VALUES (#{shiftno},#{datetype},#{site},#{shiftdesc},#{startexacttime},#{endexacttime},#{starttime},#{endtime}) </insert>
<select id="findBySiteAndDatetype" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData"> SELECT * FROM calendar_datetype_shift <where> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="datetype != null and datetype != ''"> AND datetype = #{datetype} </if> </where> </select>
<select id="findBySiteAndDatetype2" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftOutData"> SELECT * FROM calendar_datetype_shift <where> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="datetype != null and datetype != ''"> AND datetype = #{datetype} </if> and ShiftNo != #{shiftno} </where> </select>
<select id="findCDDByDatetypeAndSite" resultType="com.gaotao.modules.base.entity.CalendarDatetypeData"> SELECT datetype,site FROM Calendar_DateType <where> <if test="datetype != null and datetype != ''"> AND datetype = #{datetype} </if> <if test="site != null and site != ''"> AND site = #{site} </if> </where> </select>
<select id="findCDDById" resultType="com.gaotao.modules.base.entity.CalendarDatetypeData"> SELECT created_date,created_by,delflag FROM calendar_datetype <where> <if test="id != null and id != ''"> AND id = #{id} </if> </where> </select>
<insert id="saveCDD" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeData"> INSERT INTO calendar_datetype (site,datetype,excepttime1,exceptduration1,excepttime2,exceptduration2,excepttime3,exceptduration3,excepttime4,exceptduration4, excepttime5,exceptduration5,excepttime6,exceptduration6,worktime,remark,exceptexacttime1,exceptexacttime2,exceptexacttime3,exceptexacttime4,exceptexacttime5,exceptexacttime6) VALUES(#{site},#{datetype},#{excepttime1},#{exceptduration1},#{excepttime2},#{exceptduration2},#{excepttime3},#{exceptduration3},#{excepttime4},#{exceptduration4}, #{excepttime5},#{exceptduration5},#{excepttime6},#{exceptduration6},#{worktime},#{remark},#{exceptexacttime1},#{exceptexacttime2},#{exceptexacttime3},#{exceptexacttime4},#{exceptexacttime5},#{exceptexacttime6}) </insert>
<delete id="deleteById"> DELETE FROM calendar_datetype WHERE site= #{site} and datetype=#{datetype} </delete>
<select id="getCalendarESByCIdAndSDate" resultType="com.gaotao.modules.base.entity.CalendarExceptionShiftData"> select site,CalendarId,ScheduleDate from calendar_exception_shift <where> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="calendarId != null and calendarId != ''"> AND CalendarId = #{calendarId} </if> <if test="scheduledate != null and scheduledate != ''"> AND ScheduleDate = #{scheduledate} </if> </where> </select>
<delete id="deleteCESById"> DELETE FROM calendar_exception_shift WHERE site = #{site} AND CalendarId = #{calendarId} AND ScheduleDate = #{scheduledate} </delete>
<insert id="saveCED" parameterType="com.gaotao.modules.base.entity.CalendarExceptionData"> INSERT INTO calendar_exception (site,CalendarID,scheduledate,excepttime1,exceptduration1,excepttime2,exceptduration2,excepttime3 ,exceptduration3,excepttime4,exceptduration4,excepttime5,exceptduration5,excepttime6,exceptduration6,worktime,datetype,exceptexacttime1 ,exceptexacttime2,exceptexacttime3,exceptexacttime4,exceptexacttime5,exceptexacttime6) VALUES (#{site},#{calendarId},#{scheduledate},#{excepttime1},#{exceptduration1},#{excepttime2},#{exceptduration2},#{excepttime3}, #{exceptduration3},#{excepttime4},#{exceptduration4},#{excepttime5},#{exceptduration5},#{excepttime6},#{exceptduration6},#{worktime},#{datetype},#{exceptexacttime1} ,#{exceptexacttime2},#{exceptexacttime3},#{exceptexacttime4},#{exceptexacttime5},#{exceptexacttime6}) </insert>
<insert id="saveCESD" parameterType="com.gaotao.modules.base.entity.CalendarExceptionShiftInData"> INSERT INTO calendar_exception_shift (site,calendarID,shiftno,scheduledate,shiftdesc,startexacttime,endexacttime, starttime,endtime) VALUES (#{site},#{calendarId},#{shiftno},#{scheduledate},#{shiftdesc},#{startexacttime},#{endexacttime}, #{starttime},#{endtime}) </insert>
<delete id="deleteCEDById"> DELETE FROM calendar_exception WHERE site = #{site} and CalendarId = #{calendarId} AND scheduledate = #{scheduledate} </delete>
<update id="updateCDD" parameterType="com.gaotao.modules.base.entity.CalendarDatetypeData"> UPDATE calendar_datetype set excepttime1=#{excepttime1},exceptduration1=#{exceptduration1}, excepttime2=#{excepttime2},exceptduration2=#{exceptduration2},excepttime3=#{excepttime3},exceptduration3=#{exceptduration3},excepttime4=#{excepttime4},exceptduration4=#{exceptduration4}, excepttime5=#{excepttime5},exceptduration5=#{exceptduration5},excepttime6=#{excepttime6},exceptduration6=#{exceptduration6},worktime=#{worktime},remark=#{remark},exceptexacttime1=#{exceptexacttime1}, exceptexacttime2=#{exceptexacttime2},exceptexacttime3=#{exceptexacttime3},exceptexacttime4=#{exceptexacttime4},exceptexacttime5=#{exceptexacttime5},exceptexacttime6=#{exceptexacttime6} <where> <if test="site != null and site != ''"> AND site = #{site} </if> <if test="datetype != null and datetype != ''"> AND datetype = #{datetype} </if> </where> </update>
<select id="getAllShiftData" resultType="com.gaotao.modules.base.entity.CalendarDatetypeShiftData"> SELECT shiftno,shiftdesc,datetype,id FROM calendar_datetype_shift <where> AND site = #{site} </where> ORDER BY shiftno </select>
<select id="findDateType" resultType="com.gaotao.modules.base.entity.CalendarExceptionData"> SELECT site FROM calendar_exception <where> AND datetype = #{datetype} </where> </select> <delete id="deleteShift" > DELETE FROM calendar_datetype_shift WHERE shiftno=#{shiftno} AND site=#{site} AND DateType=#{datetype} </delete>
<select id="getShiftNo" resultType="int"> SELECT isnull(max(convert(INT,SUBSTRING(shiftno, 3,6))),0) FROM calendar_datetype_shift
</select>
<select id="getSiteAccessFlag" resultType="java.lang.String"> select dbo.Get_Site_Access_Flag(#{userId},#{site}) </select>
<select id="getSiteData" resultType="com.gaotao.modules.base.entity.SiteData"> Select T.* ,C.CompanyName from Site as T left join Company C ON T.CompanyID=C.CompanyID <where> <if test="companyID != null and companyID != ''"> AND T.CompanyID = #{companyID} </if> <if test="companyName != null and companyName != ''"> AND C.CompanyName = #{companyName} </if> </where> </select>
<select id="getCompanyData" resultType="com.gaotao.modules.base.entity.CompanyData"> Select CompanyID,CompanyName,Active,TaxNo,BankName,BankAccount,CutoffDate_DB,CutoffDate,CutoffDate_FixDate from Company </select>
<select id="checkSiteId" resultType="com.gaotao.modules.base.entity.SiteData"> select SiteName,SiteID from Site where SiteID=#{siteID} and Active='Y' </select>
<select id="checkCal" resultType="com.gaotao.modules.base.entity.CalendarData"> select calendarID from calendar where Site=#{site} and status='使用中' and calendarID=#{calendarID} </select>
<select id="checkResource" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData"> select site from WorkCenterResource where Site=#{site} and ResourceID=#{resourceID} </select>
<insert id="saveResource" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData"> INSERT INTO WorkCenterResource (Site,WorkCenterNo,ResourceID,ResourceDesc,Efficiency,Utilization,Active,Remark,CreatedDate,CalendarID,VirturlFlag) VALUES(#{site},#{workCenterNo},#{resourceID},#{resourceDesc},#{efficiency},#{utilization},#{active},#{remark},GetDate(),#{calendarID},'N') </insert> <update id="editResource" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData"> update WorkCenterResource SET ResourceDesc=#{resourceDesc},Efficiency=#{efficiency},Utilization=#{utilization},Active=#{active},Remark=#{remark},CalendarID=#{calendarID} where Site=#{site} and ResourceID=#{resourceID} </update>
<insert id="saveSite" parameterType="com.gaotao.modules.base.entity.SiteData"> INSERT INTO Site (SiteID,SiteName,SiteName_E,Address,Address_E,ContactName,PostCode,Email,FaxNo,PhoneNo,Active,Website,CompanyID,ShipTime, ReferenceCustomerID) VALUES (#{siteID},#{siteName},#{siteNameE},#{address},#{addressE},#{contactName},#{postCode},#{email},#{faxNo},#{phoneNo},#{active}, #{website},#{companyID},#{shipTime},#{referenceCustomerID}) </insert>
<update id="editSite" parameterType="com.gaotao.modules.base.entity.SiteData"> update Site SET SiteName=#{siteName},SiteName_E=#{siteNameE},Address=#{address},Address_E=#{addressE},ContactName=#{contactName},PostCode=#{postCode}, Email=#{email},FaxNo=#{faxNo},PhoneNo=#{phoneNo},Active=#{active},Website=#{website},CompanyID=#{companyID},ShipTime=#{shipTime},ReferenceCustomerID=#{referenceCustomerID} where SiteID=#{siteID} </update>
<select id="getPartFamily" resultType="com.gaotao.modules.base.entity.PartFamilyData"> Select T.FamilyID,T.Site,T.FamilyName,T.CostType,T.CostTypeDesc,T.Active,T.BatchCreatedMethod,T.CheckPercentage from PartFamily as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user})
</select>
<select id="checkAccessSite" resultType="com.gaotao.modules.base.entity.AccessSiteData"> Select UserID,Site from AccessSite where UserID=#{userID} and Site=#{site} </select> <select id="checkFamilyID" resultType="com.gaotao.modules.base.entity.PartFamilyData"> select FamilyID,FamilyName from PartFamily where FamilyID=#{familyID} and Site =#{site} </select> <insert id="savePartFamily" parameterType="com.gaotao.modules.base.entity.PartFamilyData"> INSERT INTO PartFamily (FamilyID,Site,FamilyName,Active,CheckPercentage) values (#{familyID},#{site},#{familyName},#{active},#{checkPercentage}) </insert> <update id="editPartFamily" parameterType="com.gaotao.modules.base.entity.PartFamilyData"> UPDATE PartFamily SET Site=#{site},FamilyName=#{familyName},Active=#{active},CheckPercentage=#{checkPercentage} where FamilyID=#{familyID} and Site=#{site} </update>
<delete id="deletePartFamily" parameterType="com.gaotao.modules.base.entity.PartFamilyData"> delete from PartFamily where FamilyID=#{familyID} and Site=#{site} </delete><!-- 计量单位 --> <select id="getUMData" resultType="com.gaotao.modules.base.entity.UmData"> Select T.UMID,T.Site,T.UMName,T.Active from UM as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user}) </select>
<select id="checkUmID" resultType="com.gaotao.modules.base.entity.UmData"> select UMID,UMName from UM where UMID=#{umid} and Site=#{site} </select> <insert id="saveUMData" parameterType="com.gaotao.modules.base.entity.UmData"> INSERT INTO UM (UMID,Site,UMName,Active) values (#{umid},#{site},#{uMName},#{active}) </insert> <update id="editUMData" parameterType="com.gaotao.modules.base.entity.UmData"> UPDATE UM SET Site=#{site},UMName=#{uMName},Active=#{active} where UMID=#{umid} and Site=#{site} </update> <select id="checkUmIDInPart" resultType="com.gaotao.modules.base.entity.PartData"> SELECT PartNo,PartDescription FROM Part where Site=#{site} and UMID=#{umid} </select> <delete id="deleteUMData" parameterType="com.gaotao.modules.base.entity.UmData"> delete from UM where UMID=#{umid} and Site=#{site} </delete><!-- 查询-物料编码 --> <select id="searchPartNoData" resultType="com.gaotao.modules.base.entity.PartData"> Select T.PartNo,T.Site,T.PartDescription,T.Spec,T.UMID,T.Active,T.CreateDate,T.Remark,T.ConfigurationTemplateID from Part as T <where> AND T.Site in (Select Site from AccessSite where upper(UserID)=#{user}) <if test=" site != null and site != ''"> AND T.Site = #{site} </if> <if test="partNo != null and partNo != ''"> AND T.PartNo LIKE #{partNo} </if> <if test="partDescription != null and partDescription != ''"> AND T.PartDescription LIKE #{partDescription} </if> <if test="spec != null and spec != ''"> AND T.Spec LIKE #{spec} </if> <if test="active != null and active != ''"> AND T.Active = #{active} </if> <if test=" date1 != null "> AND T.CreateDate >= #{date1} </if> <if test=" date2 != null "> AND #{date2} >=T.CreateDate </if> </where>
</select> <!-- 停机原因 --> <select id="getShutDownReasonData" resultType="com.gaotao.modules.base.entity.DowntimeReasonData"> Select Site,ReasonCode,Area,ReasonDescription,Active from DowntimeReason as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user}) </select>
<select id="checkRasonCode" resultType="com.gaotao.modules.base.entity.DowntimeReasonData"> select ReasonCode,ReasonDescription from DowntimeReason where ReasonCode=#{reasonCode} and Site=#{site} </select> <insert id="saveShutDownReasonData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData"> INSERT INTO DowntimeReason (Site,ReasonCode,Area,ReasonDescription,Active) values (#{site},#{reasonCode},#{area},#{reasonDescription},#{active}) </insert> <update id="editShutDownReasonData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData"> UPDATE DowntimeReason SET Active=#{active},Area=#{area},ReasonDescription=#{reasonDescription} where ReasonCode=#{reasonCode} and Site=#{site} </update>
<delete id="deleteShutDownReasonData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData"> delete from DowntimeReason where ReasonCode=#{reasonCode} and Site=#{site} </delete> <!-- 物料参照信息 --> <select id="getReferencePartInfoData" resultType="com.gaotao.modules.base.entity.ReferencePartInfoData"> 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 FROM ReferencePartInfo AS T LEFT JOIN Part AS P ON T.Site = P.Site AND T.PartNo = P.PartNo LEFT JOIN Part AS P2 ON T.Site = P2.Site AND T.FGPartNo = P2.PartNo LEFT JOIN Supplier AS S ON S.SupplierID=T.SupplierID and S.Site=T.Site WHERE T.Site IN ( SELECT Site FROM AccessSite WHERE UPPER (UserID) = #{user} ) </select>
<select id="getPartNoDetail" resultType="com.gaotao.modules.base.entity.PartData" > select partDescription,umid,spec from Part Where Site=#{site} and PartNo=#{partNo} and Active='Y' </select>
<select id="getSupplierDetail" resultType="com.gaotao.modules.base.entity.SupplierData" > select SupplierID,SupplierName from Supplier Where Site=#{site} and SupplierID=#{supplierID} and Active='Y' </select>
<select id="checkReferencePartInfo" resultType="com.gaotao.modules.base.entity.DowntimeReasonData"> select Site,PartNo from ReferencePartInfo where CustomerID=#{customerID} and Site=#{site} and FGPartNo=#{fGPartNo} and PartNo=#{partNo} </select> <insert id="saveReferencePartInfoData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData"> INSERT INTO ReferencePartInfo (Site,CustomerID,PartNo,ReferencePartDesc,SupplierID,FGPartNo,LastUpdateBy) values (#{site},#{customerID},#{partNo},#{referencePartDesc},#{supplierID},#{fGPartNo},#{user}) </insert> <update id="editReferencePartInfoData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData"> UPDATE ReferencePartInfo SET Site=#{site},CustomerID=#{customerID},PartNo=#{partNo},ReferencePartDesc=#{referencePartDesc},SupplierID=#{supplierID},FGPartNo=#{fGPartNo},LastUpdateBy=#{user} where CustomerID=#{customerID} and Site=#{site} and FGPartNo=#{fGPartNo} and PartNo=#{partNo} </update>
<delete id="deleteReferencePartInfoData" parameterType="com.gaotao.modules.base.entity.DowntimeReasonData"> delete from ReferencePartInfo where CustomerID=#{customerID} and Site=#{site} and FGPartNo=#{fGPartNo} and PartNo=#{partNo} </delete>
<!-- 生产线 --> <select id="getProductionLineData" resultType="com.gaotao.modules.base.entity.ProductionLineData"> Select T.Site,T.ProLineNo,T.ProLineDesc,T.Active,T.CreatedDate from ProductionLine as T where T.Site in (Select Site from AccessSite where upper(UserID)=#{user}) </select>
<select id="checkProLineNo" resultType="com.gaotao.modules.base.entity.ProductionLineData"> select ProLineNo,ProLineDesc from ProductionLine where ProLineNo=#{proLineNo} and Site=#{site} </select> <insert id="saveProductionLineData" parameterType="com.gaotao.modules.base.entity.ProductionLineData"> INSERT INTO ProductionLine (Site,ProLineNo,ProLineDesc,Active,CreatedDate) values (#{site},#{proLineNo},#{proLineDesc},#{active},#{createdDate}) </insert> <update id="editProductionLineData" parameterType="com.gaotao.modules.base.entity.ProductionLineData"> UPDATE ProductionLine SET ProLineDesc=#{proLineDesc},Active=#{active},CreatedDate=#{createdDate} where ProLineNo=#{proLineNo} and Site=#{site} </update>
<delete id="deleteProductionLineData" parameterType="com.gaotao.modules.base.entity.ProductionLineData"> delete from ProductionLine where ProLineNo=#{proLineNo} and Site=#{site} </delete>
<!-- 加工中心 --> <select id="getWorkCenterData" resultType="com.gaotao.modules.base.entity.WorkCenterData"> Select T.* ,P.ProLineDesc as ProductionLineDesc from WorkCenter as T LEFT JOIN ProductionLine P ON P.Site=T.Site and T.ProLineNo=P.ProLineNo <where> AND T.Site in (Select Site from AccessSite where upper(UserID)=#{user}) <if test=" site != null and site != ''"> and T.Site like #{site} </if> <if test=" workCenterNo != null and workCenterNo != ''"> and T.workCenterNo like #{workCenterNo} </if> </where> </select>
<select id="getWorkCenterResourceData" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData"> Select T.* from WorkCenterResource as T where T.Site =#{site} and T.WorkCenterNo=#{workCenterNo} </select> <select id="getProductInWorkCenterData" resultType="com.gaotao.modules.base.entity.ProductInWorkCenterData"> 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 from RoutingHeader as T,RoutingDetail as D Where T.Site=D.Site and T.PartNo=D.PartNo and T.RevNo=D.RevNo and T.Site=#{site} and D.WorkCenterNo=#{workCenterNo} </select> <select id="getProLineNoDetail" resultType="com.gaotao.modules.base.entity.ProductionLineData"> Select * FROM ProductionLine where Site=#{site} and ProLineNo=#{proLineNo} </select>
<select id="checkWorkCenter" resultType="com.gaotao.modules.base.entity.WorkCenterData"> select WorkCenterNo,WorkCenterDesc from WorkCenter where WorkCenterNo=#{workCenterNo} and Site=#{site} </select> <insert id="saveWorkCenterData" parameterType="com.gaotao.modules.base.entity.WorkCenterData"> INSERT INTO WorkCenter (Site,WorkCenterNo,WorkCenterDesc,WorkCenterType_DB,WorkCenterType,AverageCapacity,Efficiency,Utilization,CapacityType_DB,CapacityType,UMID,Active,Remark,CreatedDate,ProLineNo,CanCreateNewRollFlag,NeedSetupFlag) values (#{site},#{workCenterNo},#{workCenterDesc},#{workCenterTypeDb},#{workCenterType},0,100,100,'I','无限能力', #{umid},#{active},#{remark},#{createdDate},#{proLineNo},#{canCreateNewRollFlag},#{needSetupFlag}) </insert> <update id="editWorkCenterData" parameterType="com.gaotao.modules.base.entity.WorkCenterData"> UPDATE WorkCenter SET WorkCenterDesc=#{workCenterDesc},Active=#{active},WorkCenterType=#{workCenterNo},WorkCenterType_DB=#{workCenterTypeDb}, Remark=#{remark},CreatedDate=#{createdDate},ProLineNo=#{proLineNo}, CanCreateNewRollFlag=#{canCreateNewRollFlag},NeedSetupFlag=#{needSetupFlag} where WorkCenterNo=#{workCenterNo} and Site=#{site} </update>
<delete id="deleteWorkCenterData" parameterType="com.gaotao.modules.base.entity.WorkCenterData"> delete from WorkCenter where WorkCenterNo=#{workCenterNo} and Site=#{site} </delete>
<delete id="deleteResource" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData"> delete from WorkCenterResource where ResourceID=#{resourceID} and Site=#{site} </delete>
<update id="setResourceFlag" parameterType="com.gaotao.modules.base.entity.WorkCenterResourceData"> UPDATE WorkCenterResource SET VirturlFlag=#{virturlFlag} where ResourceID=#{resourceID} and Site=#{site} </update>
<select id="checkCustomerID" resultType="com.gaotao.modules.base.entity.PartData"> select PartNo,ConfigurationTemplateID from Part WHERE site=#{site} and ConfigurationTemplateID=#{configurationTemplateID} </select>
<select id="getCompanyInformation" resultType="com.gaotao.modules.base.entity.CompanyData"> Select * from Company <where>
<if test="companyID != null and companyID != ''"> AND companyID LIKE #{companyID} </if> <if test="companyName != null and companyName != ''"> AND companyName LIKE #{companyName} </if>
<if test="active != null and active != ''"> AND Active = #{active} </if> </where> </select> <select id="checkCompanyInformation" resultType="com.gaotao.modules.base.entity.CompanyData"> select companyID,companyName FROM Company WHERE companyID=#{companyID} </select>
<insert id="saveCompanyInformation" parameterType="com.gaotao.modules.base.entity.CompanyData"> INSERT INTO Company (CompanyID,CompanyName,Active,TaxNo,BankName,BankAccount,CutoffDate_DB,CutoffDate,CutoffDate_FixDate) values (#{companyID},#{companyName},#{active},#{taxNo},#{bankName},#{bankAccount},#{cutoffDateDb},#{cutoffDate},#{cutoffDateFixDate}) </insert> <update id="editCompanyInformation" parameterType="com.gaotao.modules.base.entity.CompanyData"> UPDATE Company SET CompanyName=#{companyName},CutoffDate_DB=#{cutoffDateDb},Active=#{active}, TaxNo=#{taxNo},BankName=#{bankName},BankAccount=#{bankAccount},CutoffDate=#{cutoffDate},CutoffDate_FixDate=#{cutoffDateFixDate} where CompanyID=#{companyID} </update> <delete id="deleteCompanyInformation" parameterType="com.gaotao.modules.base.entity.CompanyData"> delete from Company where CompanyID=#{companyID} </delete>
<select id="getPartFamilyList" resultType="com.gaotao.modules.base.entity.PartFamilyData"> select A.FamilyID,A.Site,A.FamilyName,A.CostType,A.CostTypeDesc,A.Active,A.BatchCreatedMethod,A.CheckPercentage from PartFamily A <where> <if test="site != null and site != ''"> and A.site = #{site,jdbcType=VARCHAR} </if> <if test="familyID != null and familyID != ''"> and A.FamilyID = #{familyID,jdbcType=VARCHAR} </if> <if test="familyName != null and familyName != ''"> and A.FamilyName = #{familyName,jdbcType=VARCHAR} </if> <if test="active != null and active != ''"> and A.Active = #{active,jdbcType=VARCHAR} </if> </where> </select>
<select id="checkConfigurationTemplateID" resultType="com.gaotao.modules.base.entity.PartData"> Select ConfigurationTemplateID from Part where ConfigurationTemplateID=#{configurationTemplateID} and site=#{site} </select>
<select id="checkCompanyInSite" resultType="com.gaotao.modules.base.entity.SiteData"> Select SiteID from site where CompanyID=#{companyID} </select><!--=================维护工艺路线信息===================--> <select id="searchRoutingWithPartNo" resultType="com.gaotao.modules.base.entity.RoutingHeaderData"> Select top 1000 r.Site,r.PartNo,r.RevNo,r.PhaseInDate,r.PhaseOutDate,r.RoutingType_DB,r.RoutingType,r.Status,r.Status_DB, r.Defaultflag,r.Remark,r.RepairFlag,p.PartDescription+' / '+isnull(p.Spec,'') as spec,p.umid from RoutingHeader r LEFT JOIN Part p on p.partNo=r.partNo and p.site=r.site <where> <if test="partNo != null and partNo != ''"> and r.partNo like #{partNo} </if> <if test="site != null and site != ''"> and r.site = #{site} </if> <if test="revNo != null and revNo != ''"> and r.revNo = #{revNo} </if> </where> </select>
<select id="searchRoutingDetailData" resultType="com.gaotao.modules.base.entity.RoutingDetailData"> Select Site,PartNo,RevNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor,FactorUnit_DB,FactorUnit,Efficiency,Crewsize,JJGZ_UnitFactor_DB,JJGZ_UnitFactor,JJGZ_UnitPrice,Remark,WX_PartNo,WX_UnitCost,BatchQty,dbo.Get_Part_DescSpec(Site,PartNo) as spec,dbo.Get_Part_DescSpec(site,WX_PartNo) as wxSpec,dbo.Get_WorkCenter_Type(Site,WorkCenterNo) as workCenterType ,dbo.Get_WorkCenterDesc(Site,WorkCenterNo) as workCenterDesc from RoutingDetail <where> <if test="partNo != null and partNo != ''"> and partNo like #{partNo} </if> <if test="site != null and site != ''"> and site = #{site} </if> <if test="revNo != null and revNo != ''"> and revNo = #{revNo} </if> </where> order by ItemNo </select>
<select id="checkRoutingItemNo" resultType="com.gaotao.modules.base.entity.RoutingDetailData"> Select ItemNo from RoutingDetail <where> <if test="partNo != null and partNo != ''"> and partNo like #{partNo} </if> <if test="site != null and site != ''"> and site = #{site} </if> <if test="revNo != null and revNo != ''"> and revNo = #{revNo} </if> <if test="itemNo != null and itemNo != ''"> and ItemNo = #{itemNo} </if> </where> </select>
<insert id="saveRoutingDetailData" parameterType="com.gaotao.modules.base.entity.RoutingDetailData"> insert into RoutingDetail (Site,PartNo,RevNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor,FactorUnit_DB,FactorUnit,Efficiency, Crewsize,JJGZ_UnitFactor_DB,JJGZ_UnitFactor,JJGZ_UnitPrice,Remark,WX_UnitCost,BatchQty) VALUES(#{site},#{partNo},#{revNo},#{itemNo},#{operationDesc},#{workCenterNo},#{machSetupTime},#{machRunFactor},#{factorUnitDb},#{factorUnit},#{efficiency}, #{crewsize},#{jjgzUnitFactorDb},#{jjgzUnitFactor},#{jjgzUnitPrice},#{remark},0,0) </insert>
<update id="editRoutingDetailData" parameterType="com.gaotao.modules.base.entity.RoutingDetailData"> UPDATE RoutingDetail SET OperationDesc=#{operationDesc},WorkCenterNo=#{workCenterNo},MachSetupTime=#{machSetupTime}, MachRunFactor=#{machRunFactor},FactorUnit_DB=#{factorUnitDb},FactorUnit=#{factorUnit},Efficiency=#{efficiency}, Crewsize=#{crewsize},JJGZ_UnitFactor_DB=#{jjgzUnitFactorDb},JJGZ_UnitFactor=#{jjgzUnitFactor},JJGZ_UnitPrice=#{jjgzUnitPrice},Remark=#{remark} WHERE partNo = #{partNo} and site = #{site} and revNo = #{revNo} and ItemNo = #{itemNo} </update>
<delete id="deleteRoutingDetail" parameterType="com.gaotao.modules.base.entity.RoutingDetailData"> delete from RoutingDetail where site=#{site} and PartNo=#{partNo} and RevNo=#{revNo} and ItemNo=#{itemNo} </delete> <select id="searchRoutingToolData" resultType="com.gaotao.modules.base.entity.RoutingToolData"> Select T.Site,T.RevNo,T.ItemNo,T.ToolID,P.ToolDescription,P.Spec ,T.ToolQty,P.FamilyID,dbo.Get_PartFamilyDesc(T.Site,P.FamilyID) as FamilyName,P.Active ,T.Remark,T.CreateDate,T.CreatedBy from RoutingTool as T,ToolHeader as P <where> <if test="toolID != null and toolID != ''"> and T.ToolID = #{toolID} </if> and T.Site=P.Site and T.ToolID=P.ToolID and T.PartNo=#{partNo} and T.Site=#{site} and T.RevNo=#{revNo} </where> </select>
<select id="searchAllResource" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData"> Select Site,WorkCenterNo,ResourceID,ResourceDesc,Active from WorkCenterResource where site=#{site} and WorkCenterNo=#{workCenterNo} and Active='Y' </select>
<select id="searchUsedResource" resultType="com.gaotao.modules.base.entity.WorkCenterResourceData"> SELECT R.ResourceID,W.ResourceDesc,W.Active FROM RoutingDetail_AvailableResource R LEFT JOIN WorkCenterResource W on W.ResourceID=R.ResourceID and R.Site=W.Site where R.site=#{site} and R.PartNo=#{partNo} and R.revNo=#{revNo} and R.itemNo=#{itemNo} </select>
<select id="checkRoutingResource" resultType="com.gaotao.modules.base.entity.RoutingDetailAvailableResourceData"> SELECT site,ResourceID FROM RoutingDetail_AvailableResource where site=#{site} and PartNo=#{partNo} and revNo=#{revNo} and itemNo=#{itemNo} and ResourceID=#{resourceID} </select>
<insert id="addRoutingResource" parameterType="com.gaotao.modules.base.entity.RoutingDetailAvailableResourceData"> INSERT INTO RoutingDetail_AvailableResource(Site,PartNo,RevNo,ItemNo,ResourceID) VALUES (#{site},#{partNo},#{revNo},#{itemNo},#{resourceID}) </insert>
<delete id="deleteRoutingResource" parameterType="com.gaotao.modules.base.entity.RoutingDetailAvailableResourceData"> delete from RoutingDetail_AvailableResource where site=#{site} and PartNo=#{partNo} and revNo=#{revNo} and itemNo=#{itemNo} and ResourceID=#{resourceID} </delete>
<select id="getItemSelect" resultType="com.gaotao.modules.base.entity.RoutingDetailData"> SELECT ItemNo,OperationDesc from RoutingDetail <where>
and partNo = #{partNo}
and site = #{site}
and revNo = #{revNo}
<if test="itemNo != null and itemNo != ''"> and ItemNo = #{itemNo} </if> </where> </select>
<select id="getToolDesc" resultType="com.gaotao.modules.base.entity.ToolHeaderData"> SELECT toolID,ToolDescription,Spec FROM ToolHeader WHERE site=#{site} and toolID=#{toolID} </select> <select id="checkToolHeader" resultType="com.gaotao.modules.base.entity.ToolHeaderData"> SELECT toolID,ToolDescription,Spec FROM ToolHeader WHERE site=#{site} and toolID=#{toolID} </select>
<insert id="saveRoutingToolData" parameterType="com.gaotao.modules.base.entity.RoutingToolData"> INSERT INTO RoutingTool(Site,PartNo,RevNo,ItemNo,ToolID,ToolQty,Remark,CreateDate,CreatedBy) VALUES(#{site},#{partNo},#{revNo},#{itemNo},#{toolID},#{toolQty},#{remark},GETDATE(),#{user} ) </insert>
<update id="editRoutingToolData" parameterType="com.gaotao.modules.base.entity.RoutingToolData"> update RoutingTool SET ToolQty=#{toolQty},Remark=#{remark} WHERE Site=#{site} and PartNo=#{partNo} and ToolID=#{toolID} and RevNo=#{revNo} and ItemNo=#{itemNo} </update>
<delete id="deleteRoutingTool" parameterType="com.gaotao.modules.base.entity.RoutingToolData"> delete from RoutingTool WHERE Site=#{site} and PartNo=#{partNo} and ToolID=#{toolID} and RevNo=#{revNo} and ItemNo=#{itemNo} </delete>
<update id="changeRoutingStatus" parameterType="com.gaotao.modules.base.entity.RoutingHeaderData"> update RoutingHeader SET status=#{status} where Site=#{site} and PartNo=#{partNo} and RevNo=#{revNo} </update>
<select id="checkRoutingStatus" resultType="com.gaotao.modules.base.entity.RoutingHeaderData"> Select top 1 Status from RoutingHeader where Site=#{site} and PartNo=#{partNo} and RevNo=#{revNo} </select>
<select id="shopOrderRoutingNumber" resultType="int"> Select count(1) as SL from ShopOrder as T where Site=#{site} and PartNo=#{partNo} and (Status='已计划' or Status='已下达') and Not exists(Select 1 from SOScheduledRouting as D Where T.Site=D.Site and T.OrderNo=D.OrderNo) and T.OrderType!='P' </select>
<insert id="saveRoutingChangeCach"> Select Site,OrderNo,LotSize into ${tableName} from ShopOrder as T where Site=#{site} and PartNo=#{partNo} and (Status='已计划' or Status='已下达') and Not exists(Select 1 from SOScheduledRouting as D Where T.Site=D.Site and T.OrderNo=D.OrderNo) and T.OrderType != 'P' </insert>
<update id="updateOrderRevNo"> Update ShopOrder Set RoutingRevNo=#{revNo} from ${tableName} as T where ShopOrder.Site=T.Site and ShopOrder.OrderNo=T.OrderNo </update>
<delete id="deleteNowItemNo"> Delete SORouting from ${tableName} as T where SORouting.Site=T.Site and SORouting.OrderNo=T.OrderNo </delete>
<delete id="deleteNowToolNo"> Delete SOTool from ${tableName} as T where SOTool.Site=T.Site and SOTool.OrderNo=T.OrderNo </delete>
<insert id="saveNewItemNo" > Insert into SORouting(Site,OrderNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor ,FactorUnit_DB,FactorUnit,TimeRequired,TimeReported,Efficiency,Remark,QtyRequired,QtyReported,QtyApprove ,PlanStartTime,PlanFinishTime,BarcodeID,PartNo,ClosedFlag,OutWorkFlag,OutWorkPartNo,QtyOnPR,QtyOnPO,QtyScrapt,Crewsize ,PreItemNo,NextItemNo,ScheduledFlag,QtyScheduled) Select T.Site,D.OrderNo,ItemNo,OperationDesc,WorkCenterNo,MachSetupTime,MachRunFactor,FactorUnit_DB,FactorUnit, (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 when FactorUnit_DB='3' then MachRunFactor end) end)/(Efficiency/100)) as TimeRequired,0,Efficiency,Remark ,D.LotSize,0,0,0,0 ,(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' ,(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 ,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) ,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) ,'N',0 from RoutingDetail as T, ${tableName} as D Where D.Site=T.Site and T.site=#{site} and T.PartNo=#{partNo} and T.RevNo=#{revNo} </insert>
<insert id="saveNewTool" > Insert into SOTool(Site,OrderNo,ItemNo,ToolID,ToolQty,Remark,CreateDate,CreatedBy) Select T.Site,D.OrderNo,ItemNo,ToolID,ToolQty,Remark,getdate(),#{user} from RoutingTool as T,${tableName} as D Where D.Site=T.Site and T.site=#{site} and T.PartNo=#{partNo} and T.RevNo=#{revNo} </insert>
<delete id="deleteRoutingChangeCach"> Drop table ${tableName} </delete></mapper>
|