---
# System prepended metadata

title: HLP

---

# HLP
## 匯入專案
```
git =>先clone 程式
intellij=> open=>找目錄(FIA-CDS/HLP/)把project import 進來
沒有MAVEN 要先匯入
有MAVEN 要最後匯入,不然會匯不進去
load 第二個project
File > New > Module from Existing Sources…

settings=>.m2
maven

intellij 變慢
=>settings =>combile =>heap size 700=>改高一點2000

```
![](https://i.imgur.com/IXM3PuL.png)

## [DB](https://hackmd.io/@mrcutejacky/openapi#%E5%A6%82%E4%BD%95%E5%9C%A8%E6%9C%AC%E6%A9%9F%E7%94%A2%E8%A3%BDClient%E7%B5%A6Frontend%E6%B8%AC%E8%A9%A6%EF%BC%9F)
```
hlp-admin這包
HLP.zip

application.yml
cors: 把前端 port 加入
例: http://localhost:5173/ 



設定 cors
jhipster:
  clientApp:
    name: 'PTL'
  cors:
    allowed-origins: "https://10.201.101.31, http://localhost:9000, http://localhost:5173"
    

frontend
api 
[https://hackmd.io/@mrcutejacky/frontend-develop-guide#Api-client](https://api-client)
設定對應服務
# app services
VITE_APP_SERVICES_APP_SETTINGS_URL=http://localhost:8081/ptl/portal

[https://i.imgur.com/rdNvii4.png](https://i.imgur.com/rdNvii4.png)


application-dev.yml
datasource:
#url: jdbc:h2:mem:testdb
url: jdbc:h2:D:/0_再造/12_DEV/H2/HLP;IFEXISTS=TRUE;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE;AUTO_SERVER=TRUE
username: sa
password:
driver-class-name: org.h2.Driver
路徑再改成你本機放的路徑

select LPAD(to_char(EINV_RTGID_SEQ.NEXTVAL),8,'0') SEQNO from DUAL;
沒檔案，要自建
create sequence EINV_RTGID_SEQ    
    start with 1
    increment by 1
    nocycle;

```
[genDB1](
https://xenby.com/b/264-%E6%95%99%E5%AD%B8-intellij-idea-%E4%BD%BF%E7%94%A8%E5%A5%97%E4%BB%B6%E7%94%A2%E7%94%9F-jpa-%E8%88%87-repository)
[genDB2](
https://www.baeldung.com/spring-data-jpa-generate-db-schema)

## 問題1
```
Q:
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an in
stall with npm@5 or later to generate it, then try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\...\AppData\Roaming\npm-cache\_logs\2022-08-16T05_55_15_582Z-debug.log

A:
node 版本太舊
上網下載最新版即可
目前版本--node-v16.16.0-x64.msi
https://nodejs.org/en/

https://www.npmjs.com/package/vsts-npm-auth
cmd:
1.node -v
2.npm install -g vsts-npm-auth
3.vsts-npm-auth -config .npmrc

外網.npmrc
proxy=http://proxy.cht.com.tw:8080/
https-proxy=http://proxy.cht.com.tw:8080
要拿掉

npm-cache 清不掉

[https://developercommunity.visualstudio.com/t/401-on-accessing-azure-feeds-with-npm-v7/1313512](https://developercommunity.visualstudio.com/t/401-on-accessing-azure-feeds-with-npm-v7/1313512)
https://www.npmjs.com/package/vsts-npm-auth
清機碼 HS
14
vsts-npm-auth -config .npmrc -force -V Detailed

vsts-npm-auth v0.42.1.0
-----------------------
Parameters:
  AuthenticationProviders=wia,federated
  Config=.npmrc
  Help=False
  NonInteractive=False
  TargetConfig=
  ExpirationMinutes=129600
  ReadOnly=False
  Force=True
  Verbosity=Detailed
INI (resolved): registry=https://pkgs.dev.azure.com/chte/fia-cds/_packaging/fia-cds-feed/npm/registry/
INI (resolved): always-auth=true
Probing https://pkgs.dev.azure.com/chte/fia-cds/_packaging/fia-cds-feed/npm/registry/
Probe response code: 401 Unauthorized
Credential type: Sps.
Has valid credentials: False.
Getting new credentials for source:https://pkgs.dev.azure.com/chte/fia-cds/_packaging/fia-cds-feed/npm/registry/, scope:vso.packaging_write vso.drop_write
Getting authentication token from https://vssps.dev.azure.com/chte/
Trying authentication provider Windows Integrated Authentication via Azure AD...
Authorization failure while retrieving a session token
Microsoft.VisualStudio.Services.Common.VssUnauthorizedException: VS30063: 您未取得存取 https://vssps.dev.azure.com 的授 權。



```
## vu3
```
https://ithelp.ithome.com.tw/articles/10279703

```

## yml
```
application.yml
加
jhipster:
  clientApp:
    name: 'HLP'
  cors:
    allowed-origins: "http://localhost:9000,http://localhost:3000"<==
    allowed-methods: "*"
    allowed-headers: "*"
    exposed-headers: "Authorization,x-request-id,x-inv-alert,x-inv-params"
    allow-credentials: true
    max-age: 1800

applictaion-dev.yml
加功能

```

## .env.development
```
.env.development

# common
VITE_APP_TITLE=電子發票整合服務平台(傳輸紀錄查詢系統)
VITE_APP_NAME=hlp
VITE_APP_ROOT=/dashboard/hlp/

# sso
VITE_APP_SSO_LOGIN=http://localhost:9080/proxyLogin
VITE_APP_SSO_LOGOUT=http://localhost:9080/proxyLogout

# common services
VITE_APP_SERVICES_ACT_URL=/act
VITE_APP_ACT_URL=/act

# app services
VITE_APP_SERVICES_HLP_URL=http://localhost:8081/hlp

```

## [openAPI](https://hackmd.io/@mrcutejacky/openapi#OpenAPI) 前後端介接

1.server端admin啟好後
檢查路徑--http://localhost:8081/hlp/v3/api-docs
檔案是否有新加入的---------------

2.安裝openapi-generator-cli
npm install -g @openapitools/openapi-generator-cli

****本機不要再重裝, 會把jar 檔刪除


3.產製api.ts檔
openapi-generator-cli generate -i http://localhost:8081/hlp/v3/api-docs -g typescript-axios --additional-properties=npmName=@fia-cds/einvoice-hlp-admin-client,npmVersion=0.0.15 --type-mappings=DateTime=Date -o einvoice-hlp-admin-client

會有一個檔案+版號, 本機再對應package.json裡的版號

openapi-generator-cli generate -i http://localhost:8081/ptl/v3/api-docs -g typescript-axios --additional-properties=npmName=@fia-cds/einvoice-ptl-admin-client,npmVersion=0.0.7 --type-mappings=DateTime=Date -o einvoice-ptl-admin-client
****


新專案, 把之前專案下的openapitools.json
copy 到新專案下---ex.原hlp=>ptl

4.
package.json 裡的設定, 自行變更

"dependencies": {
 "@fia-cds/einvoice-hlp-admin-client": "^0.0.5",
 本機會置換成自行產製的路徑
 "@fia-cds/einvoice-hlp-admin-client": "file:../einvoice-hlp-admin-client/fia-cds-einvoice-hlp-admin-client-0.0.10.tgz",
...
}

5.npm
本機 
A.在產好檔案的目錄下(\einvoice-hlp-admin-client)執行
1)npm install
2)npm run build
3)npm pack
B.再回到hlp/frontend 目錄下執行
A所產製好的檔案
npm install ..\einvoice-hlp-admin-client\fia-cds-einvoice-hlp-admin-client-0.0.10.tgz

預設
npm install @fia-cds/einvoice-hlp-admin-client@0.0.6 --save

****
1. einvoice-ptl-admin-client 
下執行
    a. npm install
    b. npm run build
    c. npm pack 
    產出 ex. fia-cds-einvoice-ptl-admin-client-0.0.1.tgz
2. D:\workSpace\FIA-CDS\PTL>cd einvoice-ptl-admin-frontend
3. D:\workSpace\FIA-CDS\PTL\einvoice-ptl-admin-frontend>npm install ..\einvoice-ptl-admin-client\fia-cds-einvoice-ptl-admin-client-0.0.1.tgz

http://localhost:8081/ptl/v3/api-docs


****
azure 上的操作
pilelines 
要選到publish-client-einvoice-ptl-admin 執行 run pipeline

再去artifacts 看gen 出來的版本有沒存在
再去改frontend =>package.json =>client 版號

**********
 產openapi.json
openapi-generator-cli generate -i http://localhost:8081/ptl/v3/api-docs -g typescript-axios --additional-properties=npmName=@fia-cds/einvoice-ptl-admin-client,npmVersion=0.0.3 --type-mappings=DateTime=Date -o einvoice-ptl-admin-client

## app.vue
```
statuscode 有沒有註冊
i18n

```

## 待改sftp 的api
![](https://i.imgur.com/QWOeXKz.jpg)

```
hlp call sftp api 這支要再修一下
原先的寫法會有Injection 的問題
所以這段的寫法再修一下
設定的資料在application.yml中

application-dev.yml要加
goanywhere:
enable: false
ip: 10.201.101.41
port: 8000
loginId:
loginPw:



ddl

  CREATE TABLE PCOMMMGR.PTL_FOCUS_BASE    (        FOCUS_NO VARCHAR2(20) NOT NULL ENABLE,     FOCUS_NAME VARCHAR2(200),     FOCUS_NAME_EN VARCHAR2(200),    SORT_NO NUMBER DEFAULT 0,    --新增欄位    IN_USED NUMBER DEFAULT 0,    CREATED_BY VARCHAR2(100) DEFAULT 'SYS' NOT NULL ENABLE,     CREATED_DATE DATE DEFAULT SYSDATE NOT NULL ENABLE,     CREATED_IP VARCHAR2(50),     CREATED_FUNC VARCHAR2(20) DEFAULT 'FUNC' NOT NULL ENABLE,     LAST_MODIFIED_BY VARCHAR2(100),     LAST_MODIFIED_DATE DATE,     LAST_MODIFIED_IP VARCHAR2(50),     LAST_MODIFIED_FUNC VARCHAR2(20)   );


  CREATE TABLE PTL_STATIC_HTML 
   (
    HTML_NO VARCHAR2(20) NOT NULL , 
HTML_SUBJECT VARCHAR2(200), 
--WITH_CSS NUMBER, 
HTML_LANGUAGE NUMBER DEFAULT 0, 
HTML_FILENAME VARCHAR2(200), 
CREATED_BY VARCHAR2(100) DEFAULT 'SYS' NOT NULL , 
CREATED_DATE DATE DEFAULT CURRENT_TIMESTAMP NOT NULL , 
CREATED_IP VARCHAR2(50), 
CREATED_FUNC VARCHAR2(20) DEFAULT 'FUNC' NOT NULL , 
LAST_MODIFIED_BY VARCHAR2(100), 
LAST_MODIFIED_DATE DATE , 
LAST_MODIFIED_IP VARCHAR2(50), 
LAST_MODIFIED_FUNC VARCHAR2(20)
   );


  CREATE TABLE PTL_FOCUS_BASE
   (    
    FOCUS_NO VARCHAR2(20) NOT NULL ,
    FOCUS_NAME VARCHAR2(200),
    FOCUS_NAME_EN VARCHAR2(200),
    SORT_NO NUMBER DEFAULT 0,
    IN_USED NUMBER DEFAULT 0,
    CREATED_BY VARCHAR2(100) DEFAULT 'SYS' NOT NULL ,
    CREATED_DATE DATE DEFAULT CURRENT_TIMESTAMP NOT NULL ,
    CREATED_IP VARCHAR2(50),
    CREATED_FUNC VARCHAR2(20) DEFAULT 'FUNC' NOT NULL ,
    LAST_MODIFIED_BY VARCHAR2(100),
    LAST_MODIFIED_DATE DATE,
    LAST_MODIFIED_IP VARCHAR2(50),
    LAST_MODIFIED_FUNC VARCHAR2(20)
   );
```
