Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
1c61f959
Commit
1c61f959
authored
Feb 27, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
cf1c11a7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
18 deletions
+117
-18
bpo-tax/app/base/controller/impl/tax/tcompanytaxitemCtl.js
+32
-7
bpo-tax/app/base/db/impl/tax/tcompanytaxitemDao.js
+16
-0
bpo-tax/app/base/db/models/tax/tcompanytaxitem.js
+2
-1
bpo-tax/app/base/service/impl/tax/tcompanytaxitemSve.js
+4
-0
bpo-tax/app/base/service/impl/tax/tcompanytaxocrSve.js
+63
-10
No files found.
bpo-tax/app/base/controller/impl/tax/tcompanytaxitemCtl.js
View file @
1c61f959
...
@@ -7,12 +7,14 @@ const logCtl = system.getObject("web.common.oplogCtl");
...
@@ -7,12 +7,14 @@ const logCtl = system.getObject("web.common.oplogCtl");
const
md5
=
require
(
"MD5"
);
const
md5
=
require
(
"MD5"
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
crypto
=
require
(
'crypto'
);
const
crypto
=
require
(
'crypto'
);
const
axios
=
require
(
"axios"
);
var
cacheBaseComp
=
null
;
var
cacheBaseComp
=
null
;
class
TcompanytaxitemCtl
extends
CtlBase
{
class
TcompanytaxitemCtl
extends
CtlBase
{
constructor
()
{
constructor
()
{
super
(
"tax"
,
CtlBase
.
getServiceName
(
TcompanytaxitemCtl
));
super
(
"tax"
,
CtlBase
.
getServiceName
(
TcompanytaxitemCtl
));
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
tcompanytaxocrSve
=
system
.
getObject
(
"service.tax.tcompanytaxocrSve"
);
}
}
async
taxPage
(
pobj
,
pobj2
,
req
,
res
)
{
async
taxPage
(
pobj
,
pobj2
,
req
,
res
)
{
...
@@ -42,17 +44,40 @@ class TcompanytaxitemCtl extends CtlBase {
...
@@ -42,17 +44,40 @@ class TcompanytaxitemCtl extends CtlBase {
async
taxUrl
(
pobj
,
pobj2
,
req
,
res
)
{
async
taxUrl
(
pobj
,
pobj2
,
req
,
res
)
{
let
id
=
pobj
.
id
;
let
id
=
pobj
.
id
;
try
{
try
{
let
item
=
await
this
.
service
.
findById
(
id
);
let
target
=
await
this
.
service
.
findById
(
id
);
if
(
!
item
)
{
if
(
!
target
)
{
return
system
.
getResult
(
null
,
"税务信息不存在"
);
return
system
.
getResult
(
null
,
"税务信息不存在"
);
}
}
// TODO 请求张云飞
// 整理请求数据
item
.
last_at
=
new
Date
();
let
itemList
=
await
this
.
service
.
byImagepath
(
target
.
imagepath
);
item
.
save
();
return
system
.
getResultSuccess
({
let
data
=
[];
taxUrl
:
"https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_7511582721898214202026205818214tfb_month_12.pdf"
for
(
let
item
of
itemList
)
{
data
.
push
({
idName
:
item
.
idName
,
idNo
:
item
.
idNo
,
locations
:
JSON
.
parse
(
item
.
locations
)
});
}
let
params
=
{
target_id
:
target
.
idNo
,
image_path
:
target
.
imagepath
,
data
:
data
,
}
// 请求ocr工具
let
res
=
await
axios
({
method
:
'post'
,
url
:
"http://43.247.184.92:9002/gsb/ocr/mosaic"
,
data
:
params
});
});
if
(
!
res
||
!
res
.
data
||
!
res
.
data
.
mosaicurl
)
{
return
system
.
getResult
(
null
,
"获取完税图片失败"
);
}
return
system
.
getResultSuccess
({
taxUrl
:
res
.
data
.
mosaicurl
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
return
system
.
getResult
(
-
1
,
`服务异常`
);
return
system
.
getResult
(
-
1
,
`服务异常`
);
...
...
bpo-tax/app/base/db/impl/tax/tcompanytaxitemDao.js
View file @
1c61f959
...
@@ -5,6 +5,22 @@ class TCompanytaxitemDao extends Dao{
...
@@ -5,6 +5,22 @@ class TCompanytaxitemDao extends Dao{
super
(
Dao
.
getModelName
(
TCompanytaxitemDao
));
super
(
Dao
.
getModelName
(
TCompanytaxitemDao
));
}
}
async
byImagepath
(
imagepath
)
{
if
(
!
imagepath
)
{
return
[];
}
let
sql
=
"SELECT * FROM t_company_tax_item WHERE imagepath = :imagepath"
;
return
await
this
.
customQuery
(
sql
,
{
imagepath
:
imagepath
});
}
async
delByTaxOcrId
(
taxOcrId
)
{
if
(
!
taxOcrId
)
{
return
;
}
let
sql
=
"DELETE FROM t_company_tax_item WHERE taxOcrId = :taxOcrId"
;
await
this
.
customUpdate
(
sql
,
{
taxOcrId
:
taxOcrId
});
}
async
countByCondition
(
condition
)
{
async
countByCondition
(
condition
)
{
var
sql
=
[];
var
sql
=
[];
sql
.
push
(
"SELECT COUNT(1) AS num FROM `t_company_tax_item` WHERE 1 = 1"
);
sql
.
push
(
"SELECT COUNT(1) AS num FROM `t_company_tax_item` WHERE 1 = 1"
);
...
...
bpo-tax/app/base/db/models/tax/tcompanytaxitem.js
View file @
1c61f959
...
@@ -13,7 +13,8 @@ module.exports = (db, DataTypes) => {
...
@@ -13,7 +13,8 @@ module.exports = (db, DataTypes) => {
incomeTax
:
DataTypes
.
STRING
,
incomeTax
:
DataTypes
.
STRING
,
actualAmt
:
DataTypes
.
STRING
,
actualAmt
:
DataTypes
.
STRING
,
grant_time
:
DataTypes
.
STRING
,
grant_time
:
DataTypes
.
STRING
,
param
:
DataTypes
.
STRING
,
imagepath
:
DataTypes
.
STRING
,
locations
:
DataTypes
.
STRING
,
last_at
:
DataTypes
.
DATE
,
last_at
:
DataTypes
.
DATE
,
tax_url
:
DataTypes
.
STRING
,
tax_url
:
DataTypes
.
STRING
,
},{
},{
...
...
bpo-tax/app/base/service/impl/tax/tcompanytaxitemSve.js
View file @
1c61f959
...
@@ -73,5 +73,9 @@ class TcompanytaxitemService extends ServiceBase {
...
@@ -73,5 +73,9 @@ class TcompanytaxitemService extends ServiceBase {
await
ocr
.
save
();
await
ocr
.
save
();
return
system
.
getResultSuccess
();
return
system
.
getResultSuccess
();
}
}
async
byImagepath
(
imagepath
)
{
return
this
.
dao
.
byImagepath
(
imagepath
);
}
}
}
module
.
exports
=
TcompanytaxitemService
;
module
.
exports
=
TcompanytaxitemService
;
bpo-tax/app/base/service/impl/tax/tcompanytaxocrSve.js
View file @
1c61f959
const
system
=
require
(
"../../../system"
);
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
)
const
settings
=
require
(
"../../../../config/settings"
);
const
axios
=
require
(
"axios"
);
class
TcompanytaxocrService
extends
ServiceBase
{
class
TcompanytaxocrService
extends
ServiceBase
{
constructor
()
{
constructor
()
{
super
(
"tax"
,
ServiceBase
.
getDaoName
(
TcompanytaxocrService
));
super
(
"tax"
,
ServiceBase
.
getDaoName
(
TcompanytaxocrService
));
this
.
tcompanytaxitemDao
=
system
.
getObject
(
"db.tax.tcompanytaxitemDao"
);
this
.
ocr_url
=
"http://43.247.184.92:9002/gsb/ocr/ocrtable"
;
}
}
async
sendImg
(
limit
)
{
async
sendImg
(
limit
)
{
let
item
s
=
await
this
.
dao
.
findUnSendIds
(
limit
);
let
ocrId
s
=
await
this
.
dao
.
findUnSendIds
(
limit
);
if
(
!
items
||
item
s
.
length
==
0
)
{
if
(
!
ocrIds
||
ocrId
s
.
length
==
0
)
{
return
;
return
;
}
}
for
(
let
item
of
item
s
)
{
for
(
let
ocrObj
of
ocrId
s
)
{
let
ocr
=
await
this
.
dao
.
findById
(
item
.
id
);
let
ocr
=
await
this
.
dao
.
findById
(
ocrObj
.
id
);
try
{
try
{
// TODO 张云飞接口
let
data
=
{
ocr
.
isSend
=
true
;
"taxOcrId"
:
1
,
ocr
.
send_time
=
new
Date
();
"tax_img"
:
ocr
.
tax_img
,
await
ocr
.
save
();
};
// 张云飞接口
let
res
=
await
axios
({
method
:
'post'
,
url
:
this
.
ocr_url
,
data
:
data
});
if
(
!
res
.
data
||
!
res
.
data
.
data
)
{
break
;
}
await
this
.
saveOcrItems
(
ocr
,
res
.
data
.
data
);
console
.
log
(
ocrObj
.
id
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
}
}
}
}
}
}
async
saveOcrItems
(
ocr
,
itemList
)
{
if
(
!
ocr
)
{
return
;
}
let
items
=
[];
for
(
let
obj
of
itemList
)
{
if
(
!
obj
.
idNo
)
{
continue
;
}
items
.
push
({
companyId
:
ocr
.
companyId
,
taxId
:
ocr
.
taxId
,
taxOcrId
:
ocr
.
id
,
month
:
ocr
.
month
,
month_date
:
ocr
.
month_date
,
idName
:
obj
.
idName
,
idNo
:
obj
.
idNo
,
incomeTax
:
obj
.
incomeTax
,
actualAmt
:
obj
.
actualAmt
,
grant_time
:
obj
.
grant_time
,
imagepath
:
obj
.
imagepath
,
locations
:
JSON
.
stringify
(
obj
.
locations
)
});
}
await
this
.
tcompanytaxitemDao
.
delByTaxOcrId
(
ocr
.
id
);
await
this
.
tcompanytaxitemDao
.
bulkCreate
(
items
);
ocr
.
isOCR
=
true
;
ocr
.
ocr_time
=
new
Date
();
await
ocr
.
save
();
return
system
.
getResultSuccess
();
}
}
}
module
.
exports
=
TcompanytaxocrService
;
module
.
exports
=
TcompanytaxocrService
;
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