Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
T
topjs3 study
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scott Sun
topjs3 study
Commits
85e0a5a7
Commit
85e0a5a7
authored
Jan 02, 2020
by
Scott Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s
parent
4372cebd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
confirmation-201912270900(1).XLSX
2019-12-31/rxlsx/confirmation-201912270900(1).XLSX
+0
-0
config.json
2019-12-31/scott/config.json
+1
-1
index.js
2019-12-31/scott/index.js
+11
-18
No files found.
2019-12-31/rxlsx/confirmation-201912270900(1).XLSX
View file @
85e0a5a7
No preview for this file type
2019-12-31/scott/config.json
View file @
85e0a5a7
{
"dirPath"
:
"../xlsx"
,
"isUseing"
:
false
,
"rdir"
:
"../rxlsx"
,
"dbconfig"
:{
"database_type"
:
"pg"
,
"database_host"
:
"139.196.104.13:5433"
,
"database_name"
:
"PMO_TRAINING"
,
"database_user"
:
"toplinker"
,
"database_pwd"
:
"TopLinker0510"
},
"dataKeys"
:{
"135aa36437beb6571531ca8e898ad57a"
:{
"name"
:
"Order
\n
生管投料单号"
,
"dbkey"
:
"order_no"
},
"a1deefe94c73d05d2a3b247c23362042"
:{
"name"
:
"Confirmation
\n
总数量"
,
"dbkey"
:
"confirmation"
},
"c46b4eb1d67a08b863072b33b646a810"
:{
"name"
:
"Plant
\n
厂别"
,
"dbkey"
:
"plant"
},
"e5018abee57b7f610ef8bb4d9eecc112"
:{
"name"
:
"Material
\n
批号"
,
"dbkey"
:
"material"
},
"f19e926ffab820b96d5a6aabf9aae616"
:{
"name"
:
"Material Description
\n
批次说明"
,
"dbkey"
:
"material_description"
},
"7e51e12322207097a84891f9d7445ad4"
:{
"name"
:
"Posting Date
\n
生产时间"
,
"dbkey"
:
"posting_date"
},
"8dba6faf3484a91f3b3940bb2e9ea459"
:{
"name"
:
"Confirmation Entry Time
\n
确认时间"
,
"dbkey"
:
"confirmation_entry_time"
},
"ecfc2dffe568c10a67dbc6d3724cfde2"
:{
"name"
:
"Activity"
,
"dbkey"
:
"activity"
},
"657a1d49f3e92290e56b692ff58a0a2d"
:{
"name"
:
"Work Center
\n
生产站别"
,
"dbkey"
:
"work_center"
},
"62f5f57f24ea1d0bc12aa535d6add05d"
:{
"name"
:
"Confirmed Yield (GMEIN)"
,
"dbkey"
:
"confirmed_yield"
},
"7c8590875b72ce8eca3c92f76b2c451b"
:{
"name"
:
"Base Unit of Measure (=GMEIN)"
,
"dbkey"
:
"base_unit"
},
"37c9b123cc9f488d3f7f8480146795e9"
:{
"name"
:
"Confirmed scrap (MEINH)
\n
报废数量"
,
"dbkey"
:
"confirmed_scrap"
},
"91b8b2e603be16c0a94658f0ced49c0b"
:{
"name"
:
"Reason for Variance
\n
报废代码"
,
"dbkey"
:
"reason_for_variance"
},
"55979da7be6e74a5ce14bd81cd31028d"
:{
"name"
:
"Rework
\n
重工数量"
,
"dbkey"
:
"rework"
},
"e820bdb5f699f28fb15c5d5e759f164b"
:{
"name"
:
"Confirmation text"
,
"dbkey"
:
"confirmation_text"
},
"da01091b1f5ddb363d498e844449a961"
:{
"name"
:
"Entered by User"
,
"dbkey"
:
"entered_by_user"
},
"664152bb1a151874f332b55ec47bc54d"
:{
"name"
:
"Ind.Final Confirmation"
,
"dbkey"
:
"ind_final_confirmation"
},
"196c6ed505a0dabe34f0aed4e2800535"
:{
"name"
:
"Milestone confirmed"
,
"dbkey"
:
"milestone_confirmed"
},
"0b9bf2967b86c25513ff839bcf3eab83"
:{
"name"
:
"Ind. delete doc."
,
"dbkey"
:
"ind_delete_doc"
},
"attr_data"
:{
"9518cf9f761a3441ba3fe75395cf364d"
:{
"name"
:
"Rf Data"
,
"dbkey"
:
"rf_data"
},
"5e55ab86da1ba43504940280f4877f6e"
:{
"name"
:
"New Data"
,
"dbkey"
:
"new_data"
},
"c7d681312342eb41005e286d676ee1ad"
:{
"name"
:
"other data"
,
"dbkey"
:
"other_data"
}}}}
{
"dirPath"
:
"../xlsx"
,
"isUseing"
:
false
,
"rdir"
:
"../rxlsx"
,
"dbconfig"
:{
"database_type"
:
"pg"
,
"database_host"
:
"139.196.104.13:5433"
,
"database_name"
:
"PMO_TRAINING"
,
"database_user"
:
"toplinker"
,
"database_pwd"
:
"TopLinker0510"
},
"dataKeys"
:{
"135aa36437beb6571531ca8e898ad57a"
:{
"name"
:
"Order
\n
生管投料单号"
,
"dbkey"
:
"order_no"
},
"a1deefe94c73d05d2a3b247c23362042"
:{
"name"
:
"Confirmation
\n
总数量"
,
"dbkey"
:
"confirmation"
},
"c46b4eb1d67a08b863072b33b646a810"
:{
"name"
:
"Plant
\n
厂别"
,
"dbkey"
:
"plant"
},
"e5018abee57b7f610ef8bb4d9eecc112"
:{
"name"
:
"Material
\n
批号"
,
"dbkey"
:
"material"
},
"f19e926ffab820b96d5a6aabf9aae616"
:{
"name"
:
"Material Description
\n
批次说明"
,
"dbkey"
:
"material_description"
},
"7e51e12322207097a84891f9d7445ad4"
:{
"name"
:
"Posting Date
\n
生产时间"
,
"dbkey"
:
"posting_date"
},
"8dba6faf3484a91f3b3940bb2e9ea459"
:{
"name"
:
"Confirmation Entry Time
\n
确认时间"
,
"dbkey"
:
"confirmation_entry_time"
},
"ecfc2dffe568c10a67dbc6d3724cfde2"
:{
"name"
:
"Activity"
,
"dbkey"
:
"activity"
},
"657a1d49f3e92290e56b692ff58a0a2d"
:{
"name"
:
"Work Center
\n
生产站别"
,
"dbkey"
:
"work_center"
},
"62f5f57f24ea1d0bc12aa535d6add05d"
:{
"name"
:
"Confirmed Yield (GMEIN)"
,
"dbkey"
:
"confirmed_yield"
},
"7c8590875b72ce8eca3c92f76b2c451b"
:{
"name"
:
"Base Unit of Measure (=GMEIN)"
,
"dbkey"
:
"base_unit"
},
"37c9b123cc9f488d3f7f8480146795e9"
:{
"name"
:
"Confirmed scrap (MEINH)
\n
报废数量"
,
"dbkey"
:
"confirmed_scrap"
},
"91b8b2e603be16c0a94658f0ced49c0b"
:{
"name"
:
"Reason for Variance
\n
报废代码"
,
"dbkey"
:
"reason_for_variance"
},
"55979da7be6e74a5ce14bd81cd31028d"
:{
"name"
:
"Rework
\n
重工数量"
,
"dbkey"
:
"rework"
},
"e820bdb5f699f28fb15c5d5e759f164b"
:{
"name"
:
"Confirmation text"
,
"dbkey"
:
"confirmation_text"
},
"da01091b1f5ddb363d498e844449a961"
:{
"name"
:
"Entered by User"
,
"dbkey"
:
"entered_by_user"
},
"664152bb1a151874f332b55ec47bc54d"
:{
"name"
:
"Ind.Final Confirmation"
,
"dbkey"
:
"ind_final_confirmation"
},
"196c6ed505a0dabe34f0aed4e2800535"
:{
"name"
:
"Milestone confirmed"
,
"dbkey"
:
"milestone_confirmed"
},
"0b9bf2967b86c25513ff839bcf3eab83"
:{
"name"
:
"Ind. delete doc."
,
"dbkey"
:
"ind_delete_doc"
},
"attr_data"
:{
"e721078261b58ddd2a9956d8cbce6a06"
:{
"name"
:
"ybl 新的"
,
"dbkey"
:
"ybl_e721078261"
},
"8191de2b5061888ea99973372e8e1a58"
:{
"name"
:
"中文字段"
,
"dbkey"
:
"_8191de2b50"
},
"e53fd971e62213827ea253985dcf430b"
:{
"name"
:
"normal da"
,
"dbkey"
:
"normal_da_e53fd971e6"
}}}}
\ No newline at end of file
\ No newline at end of file
2019-12-31/scott/index.js
View file @
85e0a5a7
...
@@ -2,17 +2,16 @@ var fs = require('fs');
...
@@ -2,17 +2,16 @@ var fs = require('fs');
var
book
=
require
(
'topsin.excelxs'
);
var
book
=
require
(
'topsin.excelxs'
);
var
db
=
require
(
'topsin.database'
);
var
db
=
require
(
'topsin.database'
);
var
crypto
=
require
(
'topsin.crypto'
);
var
crypto
=
require
(
'topsin.crypto'
);
var
error
=
require
(
'topsin.error'
);
// 读取配置文件
// 读取配置文件
var
config
=
JSON
.
parse
(
fs
.
readFile
(
'./config.json'
));
var
config
=
JSON
.
parse
(
fs
.
readFile
(
'./config.json'
));
// 主函数
// 主函数
function
Main
(
props
){
function
Main
(
props
){
// 执行初始化
// 执行初始化
this
.
init
();
this
.
init
();
}
}
// 初始化方法
// 初始化方法
Main
.
prototype
.
init
=
function
(){
Main
.
prototype
.
init
=
function
(){
this
.
dirlist
=
this
.
readDir
(
config
.
dirPath
,
-
1
)
// 获取文件夹下的文件列表
this
.
dirlist
=
this
.
readDir
(
config
.
dirPath
,
-
1
)
// 获取文件夹下的文件列表
...
@@ -33,7 +32,6 @@ Main.prototype.readXlsx = function(list){
...
@@ -33,7 +32,6 @@ Main.prototype.readXlsx = function(list){
that
.
excelxs
(
v
.
dir
+
'/'
+
v
.
name
,
v
.
name
)
that
.
excelxs
(
v
.
dir
+
'/'
+
v
.
name
,
v
.
name
)
})
})
}
}
// 读取excelxs
// 读取excelxs
Main
.
prototype
.
excelxs
=
function
(
path
,
name
){
Main
.
prototype
.
excelxs
=
function
(
path
,
name
){
if
(
book
.
open
(
path
))
{
if
(
book
.
open
(
path
))
{
...
@@ -41,7 +39,6 @@ Main.prototype.excelxs = function(path,name){
...
@@ -41,7 +39,6 @@ Main.prototype.excelxs = function(path,name){
if
(
sheet
.
isNull
()){
return
}
if
(
sheet
.
isNull
()){
return
}
// 获取表字段数量
// 获取表字段数量
var
keysCount
=
sheet
.
getLastCol
()
var
keysCount
=
sheet
.
getLastCol
()
// 获取字段数组
// 获取字段数组
this
.
keys
=
[]
// 存放所有字段
this
.
keys
=
[]
// 存放所有字段
this
.
newkeys
=
[]
// (如果有)存放新的字段
this
.
newkeys
=
[]
// (如果有)存放新的字段
...
@@ -70,10 +67,11 @@ Main.prototype.excelxs = function(path,name){
...
@@ -70,10 +67,11 @@ Main.prototype.excelxs = function(path,name){
dbkeyArr
.
push
(
str
)
dbkeyArr
.
push
(
str
)
str
=
""
str
=
""
}
else
{
}
else
{
retur
n
i
=
le
n
}
}
}
}
var
dbkey
=
dbkeyArr
.
join
(
"_"
)
var
dbkey
=
dbkeyArr
.
join
(
"_"
)
dbkey
+=
"_"
+
mdkey
.
substr
(
0
,
10
)
that
.
attrData
[
mdkey
]
=
{
// 内存中的attrData添加新字段的map
that
.
attrData
[
mdkey
]
=
{
// 内存中的attrData添加新字段的map
name
:
v
,
name
:
v
,
dbkey
:
dbkey
dbkey
:
dbkey
...
@@ -84,7 +82,6 @@ Main.prototype.excelxs = function(path,name){
...
@@ -84,7 +82,6 @@ Main.prototype.excelxs = function(path,name){
}
}
})
})
}
}
var
datalist
=
[]
// 定义数组 两次循环获取表数据
var
datalist
=
[]
// 定义数组 两次循环获取表数据
for
(
var
j
=
1
,
length
=
sheet
.
getLastRow
();
j
<
length
;
j
++
){
for
(
var
j
=
1
,
length
=
sheet
.
getLastRow
();
j
<
length
;
j
++
){
datalist
[
j
-
1
]
=
{}
datalist
[
j
-
1
]
=
{}
...
@@ -156,9 +153,9 @@ Main.prototype.insertAny = function(datas){ // 批量插入数据
...
@@ -156,9 +153,9 @@ Main.prototype.insertAny = function(datas){ // 批量插入数据
that
.
keys
,
that
.
keys
,
datas
datas
);
);
//
if (this.query.lastError().isValid()){
if
(
this
.
query
.
lastError
().
isValid
()){
//
throw this.query.lastError().text();
throw
this
.
query
.
lastError
().
text
();
//
}
}
this
.
query
.
commit
();
this
.
query
.
commit
();
}
}
catch
(
err
)
{
catch
(
err
)
{
...
@@ -195,14 +192,14 @@ Main.prototype.filterOldData = function (datas,dbdatas, type){
...
@@ -195,14 +192,14 @@ Main.prototype.filterOldData = function (datas,dbdatas, type){
// 获取dbdata的唯一字段列表
// 获取dbdata的唯一字段列表
dbI
=
dbdatas
.
map
(
function
(
v
){
dbI
=
dbdatas
.
map
(
function
(
v
){
var
tempStr
=
""
var
tempStr
=
""
tempStr
+=
v
[
"
order_no"
]
+
v
[
"confirmation"
]
+
v
[
"plant"
,
"material"
]
+
v
[
"material_description"
]
+
v
[
"posting_date"
]
+
v
[
"confirmation_entry_time
"
]
tempStr
+=
v
[
"
confirmation"
]
+
v
[
"plant"
]
+
v
[
"material"
]
+
v
[
"posting_date"
]
+
v
[
"confirmation_entry_time"
]
+
v
[
"activity
"
]
return
tempStr
return
tempStr
})
})
var
oldData
=
[],
var
oldData
=
[],
newData
=
[];
newData
=
[];
for
(
var
i
=
0
,
len
=
datas
.
length
;
i
<
len
;
i
++
){
for
(
var
i
=
0
,
len
=
datas
.
length
;
i
<
len
;
i
++
){
var
v
=
datas
[
i
]
var
v
=
datas
[
i
]
var
dataI
=
v
[
"
order_no"
]
+
v
[
"confirmation"
]
+
v
[
"plant"
,
"material"
]
+
v
[
"material_description"
]
+
v
[
"posting_date"
]
+
v
[
"confirmation_entry_time
"
]
var
dataI
=
v
[
"
confirmation"
]
+
v
[
"plant"
]
+
v
[
"material"
]
+
v
[
"posting_date"
]
+
v
[
"confirmation_entry_time"
]
+
v
[
"activity
"
]
if
(
dbI
.
indexOf
(
dataI
)
>=
0
){
if
(
dbI
.
indexOf
(
dataI
)
>=
0
){
// 老数据
// 老数据
if
(
type
===
"update"
){
if
(
type
===
"update"
){
...
@@ -233,9 +230,9 @@ Main.prototype.UpdateKeys = function(data,id){
...
@@ -233,9 +230,9 @@ Main.prototype.UpdateKeys = function(data,id){
where
:{
id
:
id
},
where
:{
id
:
id
},
update_policy
:{
tags
:
'array_append'
,
attr_data
:
'json_merge'
}
update_policy
:{
tags
:
'array_append'
,
attr_data
:
'json_merge'
}
})
})
//
if (this.query.lastError().isValid()){
if
(
this
.
query
.
lastError
().
isValid
()){
//
throw this.query.lastError().text();
throw
this
.
query
.
lastError
().
text
();
//
}
}
this
.
query
.
commit
();
this
.
query
.
commit
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"更新错误"
)
console
.
log
(
"更新错误"
)
...
@@ -243,9 +240,6 @@ Main.prototype.UpdateKeys = function(data,id){
...
@@ -243,9 +240,6 @@ Main.prototype.UpdateKeys = function(data,id){
this
.
query
.
rollback
();
this
.
query
.
rollback
();
}
}
}
}
function
formatDate
(
numb
)
{
function
formatDate
(
numb
)
{
var
time
=
new
Date
((
numb
-
1
)
*
24
*
3600000
+
1
)
var
time
=
new
Date
((
numb
-
1
)
*
24
*
3600000
+
1
)
time
.
setYear
(
time
.
getFullYear
()
-
70
)
time
.
setYear
(
time
.
getFullYear
()
-
70
)
...
@@ -278,7 +272,6 @@ function configReset(bol){
...
@@ -278,7 +272,6 @@ function configReset(bol){
config
.
isUseing
=
bol
config
.
isUseing
=
bol
fs
.
writeFile
(
'./config.json'
,
JSON
.
stringify
(
config
))
// 覆盖写入json
fs
.
writeFile
(
'./config.json'
,
JSON
.
stringify
(
config
))
// 覆盖写入json
}
}
if
(
!
config
.
isUseing
){
// 如果没在运行程序就可以实例化
if
(
!
config
.
isUseing
){
// 如果没在运行程序就可以实例化
configReset
(
true
)
// 状态变成运行中
configReset
(
true
)
// 状态变成运行中
var
demo
=
new
Main
()
var
demo
=
new
Main
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment