select distinct RepairSOFlag from SHOPORDER where site=#{site} and orderNo in
select distinct isnull(RepairSOFlag,'') RepairSOFlag from SHOPORDER where site=#{site} and orderNo in
( select OrderRef2 from Hunlian_TaskDetail
( select OrderRef2 from Hunlian_TaskDetail
where Site=#{site} and taskNo=#{taskNo} and OrderRef2 is not null and OrderRef2 !='')
where Site=#{site} and taskNo=#{taskNo} and OrderRef2 is not null and OrderRef2 !='')
</select>
</select>
@ -152,8 +152,71 @@ PartNo,UserName,EnterDate,Qtyfinished,ShiftId,dispatched_hunlian FROM SOTaskOrde
</select>
</select>
<selectid="getCombineOrderNo"resultType="String">
<selectid="getCombineOrderNo"resultType="String">
Select 'HL'+ Right( '00000000'+ convert(VARCHAR(10),isnull( max(convert(float(8),substring(OrderNo,3,9))),0)+1),7) as PRNOs from OutWorkOrder where Site='1'
Select 'HL'+ Right( '00000000'+ convert(VARCHAR(10),isnull( max(convert(float(8),substring(OrderNo,3,9))),0)+1),7) as PRNOs from ShopOrder where Site='1'
JJGZ_UnitFactor,JJGZ_UnitPrice,0 from SORouting where orderNo=#{orderNo} and site=#{site}
</insert>
<insertid="saveTool">
INSERT into SOTool (Site,OrderNo,ToolID,ToolQty,Remark,CreateDate,CreatedBy,ItemNo)
select Site,#{newOrderNo},ToolID,ToolQty,Remark,GETDATE(),#{createBy},ItemNo from SOTool where orderNo=#{orderNo} and site=#{site}
</insert>
<updateid="updateOldOrderNo">
update ShopOrder set LotSize=round(LotSize- CONVERT(float, b.HunlianQty ),2),Status= CASE WHEN LotSize- CONVERT(float, b.HunlianQty )>0 THEN Status ELSE '已取消' END
from (select site,TaskNo,OrderRef2 ,sum(HunlianQty) HunlianQty from Hunlian_TaskDetail where TaskNo=#{taskNo} and site=#{site} GROUP BY site,TaskNo,OrderRef2 )
as b where ShopOrder.orderNo=b.OrderRef2 and ShopOrder.site=b.site
</update>
<updateid="updateOldSOBom">
update SOBOM set QtyRequired =ROUND(b.lotSize*QtyAssembly/(1-ScraptFactor/100)+isnull(QtyFixedScrapt,0),2) from ShopOrder b
where SOBOM.site=b.site and SOBOM.OrderNo=b.orderNo and SOBOM.orderNo in ( select OrderRef2 from Hunlian_TaskDetail
where taskNo=#{taskNo} and site=#{site} and OrderRef2 is not null and OrderRef2 !='')
</update>
<updateid="updateRouting">
update SORouting set QtyRequired =b.lotSize , TimeRequired=dbo.Get_SORouting_TimeRequired(SORouting.site,SORouting.OrderNo,SORouting.ItemNo) from ShopOrder b
where SORouting.site=b.site and SORouting.OrderNo=b.orderNo and SORouting.orderNo in ( select OrderRef2 from Hunlian_TaskDetail
where taskNo=#{taskNo} and site=#{site} and OrderRef2 is not null and OrderRef2 !='')