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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
19 deletions
+118
-19
bpo-tax/app/base/controller/impl/tax/tcompanytaxitemCtl.js
+33
-8
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");
const
md5
=
require
(
"MD5"
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
crypto
=
require
(
'crypto'
);
const
axios
=
require
(
"axios"
);
var
cacheBaseComp
=
null
;
class
TcompanytaxitemCtl
extends
CtlBase
{
constructor
()
{
super
(
"tax"
,
CtlBase
.
getServiceName
(
TcompanytaxitemCtl
));
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
tcompanytaxocrSve
=
system
.
getObject
(
"service.tax.tcompanytaxocrSve"
);
}
async
taxPage
(
pobj
,
pobj2
,
req
,
res
)
{
...
...
@@ -42,17 +44,40 @@ class TcompanytaxitemCtl extends CtlBase {
async
taxUrl
(
pobj
,
pobj2
,
req
,
res
)
{
let
id
=
pobj
.
id
;
try
{
let
item
=
await
this
.
service
.
findById
(
id
);
if
(
!
item
)
{
let
target
=
await
this
.
service
.
findById
(
id
);
if
(
!
target
)
{
return
system
.
getResult
(
null
,
"税务信息不存在"
);
}
// TODO 请求张云飞
item
.
last_at
=
new
Date
();
item
.
save
();
return
system
.
getResultSuccess
({
taxUrl
:
"https://gsb-zc.oss-cn-beijing.aliyuncs.com//zc_7511582721898214202026205818214tfb_month_12.pdf"
// 整理请求数据
let
itemList
=
await
this
.
service
.
byImagepath
(
target
.
imagepath
);
let
data
=
[];
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
)
{
console
.
log
(
error
);
return
system
.
getResult
(
-
1
,
`服务异常`
);
...
...
bpo-tax/app/base/db/impl/tax/tcompanytaxitemDao.js
View file @
1c61f959
...
...
@@ -5,6 +5,22 @@ class TCompanytaxitemDao extends Dao{
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
)
{
var
sql
=
[];
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) => {
incomeTax
:
DataTypes
.
STRING
,
actualAmt
:
DataTypes
.
STRING
,
grant_time
:
DataTypes
.
STRING
,
param
:
DataTypes
.
STRING
,
imagepath
:
DataTypes
.
STRING
,
locations
:
DataTypes
.
STRING
,
last_at
:
DataTypes
.
DATE
,
tax_url
:
DataTypes
.
STRING
,
},{
...
...
bpo-tax/app/base/service/impl/tax/tcompanytaxitemSve.js
View file @
1c61f959
...
...
@@ -73,5 +73,9 @@ class TcompanytaxitemService extends ServiceBase {
await
ocr
.
save
();
return
system
.
getResultSuccess
();
}
async
byImagepath
(
imagepath
)
{
return
this
.
dao
.
byImagepath
(
imagepath
);
}
}
module
.
exports
=
TcompanytaxitemService
;
bpo-tax/app/base/service/impl/tax/tcompanytaxocrSve.js
View file @
1c61f959
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
const
settings
=
require
(
"../../../../config/settings"
)
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
axios
=
require
(
"axios"
);
class
TcompanytaxocrService
extends
ServiceBase
{
constructor
()
{
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
)
{
let
item
s
=
await
this
.
dao
.
findUnSendIds
(
limit
);
if
(
!
items
||
item
s
.
length
==
0
)
{
let
ocrId
s
=
await
this
.
dao
.
findUnSendIds
(
limit
);
if
(
!
ocrIds
||
ocrId
s
.
length
==
0
)
{
return
;
}
for
(
let
item
of
item
s
)
{
let
ocr
=
await
this
.
dao
.
findById
(
item
.
id
);
for
(
let
ocrObj
of
ocrId
s
)
{
let
ocr
=
await
this
.
dao
.
findById
(
ocrObj
.
id
);
try
{
// TODO 张云飞接口
ocr
.
isSend
=
true
;
ocr
.
send_time
=
new
Date
();
await
ocr
.
save
();
let
data
=
{
"taxOcrId"
:
1
,
"tax_img"
:
ocr
.
tax_img
,
};
// 张云飞接口
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
)
{
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
;
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