SQL語法針對 BOM減少一階 後做用料量彙總

–bom2要被減少的階層 此處用量皆為重量,算出總重量,屆時可依比例更新用量回主BOM,即bom1

update Cf_inv_bom_2
set Cf_inv_bom_2.sum_qty = t1.c_sum
from (select assy_no,sum(qty) c_sum from Cf_inv_bom_2 group by assy_no) t1
where Cf_inv_bom_2.assy_no = t1.assy_no

–bom1無下階先抓出來

select * from cf_inv_bom_1
where item_no not in (select assy_no from cf_inv_bom_2 )

–再結合有bom1有下階的資料(用量=>被替換子件原用量*(下階子件用量/下階用量之和))

select * from cf_inv_bom_1
where item_no not in (select assy_no from cf_inv_bom_2 )
union all
select T1.assy_no,T2.item_no,CAST(t1.qty*t2.qty/t2.sum_qty AS DECIMAL(10,4) ) d_qty,T1.sum_qty
from cf_inv_bom_2 T2,cf_inv_bom_1 T1
where T2.assy_no=T1.item_no order by 1,2

–由於合併後發現兩階間有共用子件因此多一層group來加總資件用量

select Tu.assy_no,tu.item_no,sum(tu.qty),max(Tu.sum_qty) from
(select [assy_no]
,[item_no]
,[qty]
,[sum_qty] from cf_inv_bom_1
where item_no not in (select assy_no from cf_inv_bom_2 )
union all
select T1.assy_no,T2.item_no,CAST(t1.qty*t2.qty/t2.sum_qty AS DECIMAL(10,4) ) d_qty,T1.sum_qty
from cf_inv_bom_2 T2,cf_inv_bom_1 T1
where T2.assy_no=T1.item_no) as Tu
group by Tu.assy_no,tu.item_no
order by 1,2

Excel VBA 迴圈抓取每三欄轉置成多筆資料 用array寫出

Sub LoopThroughRowsByRefBom()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
FirstRow = 1
i = FirstRow
FirstColumn = 1
Do Until i > LastRow
    LastColumn = Cells(i, Columns.Count).End(xlToLeft).Column
    j = FirstColumn
    Do Until j > LastColumn
        If i Mod 15 = 1 And j Mod 3 = 1 Then
            For k = 0 To 10
               Cells(i + k, j + 2).Value = Cells(i, j)
            Next k
        End If
        j = j + 3
    Loop
    i = i + 15
Loop

 Dim dynArray(1 To 5000, 1 To 4) As String
 i = 1
  k = 1
 Do Until i > LastRow
     LastColumn = Cells(i, Columns.Count).End(xlToLeft).Column
    j = 1
    Do Until j > LastColumn
        If j Mod 3 = 1 And i Mod 15 <= 10 And Not IsEmpty(Cells(i, j + 1).Value) And Cells(i, j + 1).Value > 0 Then
            dynArray(k, 1) = Cells(i, j + 2)
            dynArray(k, 2) = Cells((i \ 15) * 15 + 12, j + 1)
            dynArray(k, 3) = Cells(i, j)
            dynArray(k, 4) = Cells(i, j + 1)
             k = k + 1
        End If
        j = j + 3
    Loop
  i = i + 1
Loop

Dim De1 As Range
Set De1 = Range("AK1")
De1.Resize(UBound(dynArray, 1), UBound(dynArray, 2)).Value = dynArray
End Sub

印表機分享異常處理

連接win 10印表機出現0x0000011b錯誤解決方法 fix-0x0000011b
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print]
“RpcAuthnLevelPrivacyEnabled”=dword:00000000

解決Win10-1709版更新後無法存取網路芳鄰分享的共用資料夾\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\LanmanWorkstation\Parameters
add dword
AllowInsecureGuestAuth=1

Win10 關閉 UAC

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Policies\ System
DWORD 值
EnableLUA=0

[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print]
“RpcAuthnLevelPrivacyEnabled”=dword:00000001

列印伺服器
只要將下列機碼中的內容匯出就 ok 了,日後新電腦只要重新匯入 3 秒鐘就可搞定。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Forms

新增資料夾_==>命名為 “Printers.{2227A280-3AEA-1069-A2DE-08002B30309D}”可顯示所有印表機
https://www.dhb-scripting.com/Forums/posts/t46-Windows-10-Printers-Not-Showing-Up

其他可用系統資料夾

Default Programs. {17cd9488-1228-4b2f-88ce-4298e93e0966}
MyComputer. {20D04FE0-3AEA-1069-A2D8-08002B30309D}
Network. {208D2C60-3AEA-1069-A2D7-08002B30309D}
All Networks For Current Connection. {1FA9085F-25A2-489B-85D4-86326EEDCD87}
Programs and Features. {15eae92e-f17a-4431-9f28-805e482dafd4}
Power Settings. {025A5937-A6BE-4686-A844-36FE4BEC8B6D}
Printers. {2227A280-3AEA-1069-A2DE-08002B30309D}
Icons And Notifications. {05d7b0f4-2121-4eff-bf6b-ed3f69b894d9}
Firewall and Security. {4026492F-2F69-46B8-B9BF-5654FC07E423}
All NET Frameworks and COM Libraries. {1D2680C9-0E2A-469d-B787-065558BC7D43}
Application Connections. {241D7C96-F8BF-4F85-B01F-E2B043341A4B}
Administrative Tools. {D20EA4E1-3957-11d2-A40B-0C5020524153}
Credentials and Logins. {1206F5F1-0569-412C-8FEC-3204630DFB70}
Speech Recognition. {58E3C745-D971-4081-9034-86E34B30836A}

Oracle免費主機架設LAMP 跑WordPress

Oracle cloud infrastructure + Freenom + Cloudflare =>Free VPS + DNS + CDN

L: ubuntu 20.04 A:apache 2 M: mySQL P: PHP LAMP Stack setup – Linux Apache MySQL PHP https://www.cloudsigma.com/lamp-stack-setup-linux-apache-mysql-php/

How to Install WordPress with LAMP on Ubuntu 20.04 https://www.cloudsigma.com/how-to-install-wordpress-with-lamp-on-ubuntu-20-04/

How To Secure Apache with Let’s Encrypt on Ubuntu 22.04 https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-22-04