# app_db

id: 618499a5993236a4844fa1d5
pid: 6183205599328c3820c0ca0b
name: nullable
code: 618499a5993236a4844fa1d5
namepath: /dzpz_pz/lastmodifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045
fullname: /dzpz_pz/lastmodifieddate/nullable
nodetype: column
value: true
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.446
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045.618499a5993236a4844fa1d5


id: 618499a5993236a4844fa1d6
pid: 6183205599328c3820c0ca0b
name: updatable
code: 618499a5993236a4844fa1d6
namepath: /dzpz_pz/lastmodifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045
fullname: /dzpz_pz/lastmodifieddate/updatable
nodetype: column
value: true
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.446
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045.618499a5993236a4844fa1d6


id: 618499a5993236a4844fa1d7
pid: 6183205599328c3820c0ca0b
name: smartretrieve
code: 618499a5993236a4844fa1d7
namepath: /dzpz_pz/lastmodifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045
fullname: /dzpz_pz/lastmodifieddate/smartretrieve
nodetype: column
value: false
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.446
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045.618499a5993236a4844fa1d7


id: 618499a5993236a4844fa1d8
pid: 6183205599328c3820c0ca0b
name: usedingroupby
code: 618499a5993236a4844fa1d8
namepath: /dzpz_pz/lastmodifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045
fullname: /dzpz_pz/lastmodifieddate/usedingroupby
nodetype: column
value: false
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.446
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045.618499a5993236a4844fa1d8


id: 618499a5993236a4844fa1d9
pid: 6183205599328c3820c0ca0b
name: usedinsum
code: 618499a5993236a4844fa1d9
namepath: /dzpz_pz/lastmodifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045
fullname: /dzpz_pz/lastmodifieddate/usedinsum
nodetype: column
value: false
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.446
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045.618499a5993236a4844fa1d9


id: 619a5454993208680e5229a5
pid: 619a5454993208680e5229a1
name: apibody
code: 60c560a05db2e8eff0d867cb2021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apibody
nodetype: column
createdate: 2021.06.13 09:37:35.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867cb2021110407504420211121221444


id: 619a5454993208680e5229a9
pid: 619a5454993208680e5229a1
name: apicolumndefine
code: 60c560a05db2e8eff0d867c82021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apicolumndefine
nodetype: column
createdate: 2021.06.13 09:37:35.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c82021110407504420211121221444


id: 619a5454993208680e5229ad
pid: 619a5454993208680e5229a1
name: apiheader
code: 60c560a05db2e8eff0d867ca2021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apiheader
nodetype: column
createdate: 2021.06.13 09:37:35.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867ca2021110407504420211121221444


id: 619a5454993208680e5229b1
pid: 619a5454993208680e5229a1
name: apipagecount
code: 60c5615f5db2e8eff0d867d32021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apipagecount
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d32021110407504420211121221444


id: 619a5454993208680e5229b5
pid: 619a5454993208680e5229a1
name: apiresultconvert
code: 60c5615f5db2e8eff0d867ce2021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apiresultconvert
nodetype: column
createdate: 2021.06.13 09:37:36.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867ce2021110407504420211121221444


id: 619a5454993208680e5229b9
pid: 619a5454993208680e5229a1
name: apiresultpath
code: 60c5615f5db2e8eff0d867d22021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apiresultpath
nodetype: column
createdate: 2021.06.13 09:37:36.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d22021110407504420211121221444


id: 619a5454993208680e5229bd
pid: 619a5454993208680e5229a1
name: apiurl
code: 60c560a05db2e8eff0d867c92021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/apiurl
nodetype: column
createdate: 2021.06.13 09:37:35.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c92021110407504420211121221444


id: 619a5454993208680e5229c9
pid: 619a5454993208680e5229a1
name: autoretrieve
code: 60c560a05db2e8eff0d867b52021110407504420211121221444
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/autoretrieve
nodetype: column
value: true
createdate: 2021.06.13 09:37:14.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867b52021110407504420211121221444


id: 619a5454993208680e522a25
pid: 619a5454993208680e5229a1
name: c_xh
code: 60c7d41b5db2f19751803a1a2021110407504420211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/c_xh
nodetype: computer
createdate: 2021.06.15 06:12:48.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445


id: 619a5454993208680e522a29
pid: 619a5454993208680e522a25
name: description
code: 60c7d4645db2f19751803a2d2021110407504420211121221445
namepath: /dzpz_pz/c_xh
fullname: /dzpz_pz/c_xh/description
nodetype: column
createdate: 2021.06.15 06:13:00.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445.60c7d4645db2f19751803a2d2021110407504420211121221445


id: 619a5454993208680e522a2d
pid: 619a5454993208680e522a25
name: dynamicwhere2_tokens
code: 60c7d4645db2f19751803a2e2021110407504420211121221445
namepath: /dzpz_pz/c_xh
fullname: /dzpz_pz/c_xh/dynamicwhere2_tokens
nodetype: column
value: {}
createdate: 2021.06.15 06:13:00.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445.60c7d4645db2f19751803a2e2021110407504420211121221445


id: 619a5454993208680e522a31
pid: 619a5454993208680e522a25
name: expression
code: 60c7d4645db2f19751803a2c2021110407504420211121221445
namepath: /dzpz_pz/c_xh
fullname: /dzpz_pz/c_xh/expression
nodetype: column
value: thisrow()+1
createdate: 2021.06.15 06:13:00.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445.60c7d4645db2f19751803a2c2021110407504420211121221445


id: 619a5454993208680e522a35
pid: 619a5454993208680e522a25
name: fillback
code: 60c7d4645db2f19751803a2b2021110407504420211121221445
namepath: /dzpz_pz/c_xh
fullname: /dzpz_pz/c_xh/fillback
nodetype: column
createdate: 2021.06.15 06:12:59.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c7d41b5db2f19751803a1a2021110407504420211121221445.60c7d4645db2f19751803a2b2021110407504420211121221445


id: 619a5454993208680e522a39
pid: 619a5454993208680e5229a1
name: corpid
code: 61403c23993240476a10dc3a2021110407504420211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/corpid
nodetype: dbcol
value: 账套ID
createdate: 2021.09.14 14:13:40.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.61403c23993240476a10dc3a2021110407504420211121221445


id: 619a5454993208680e522a3d
pid: 619a5454993208680e522a39
name: colsize
code: 61403c23993240476a10dc3c2021110407504420211121221445
namepath: /dzpz_pz/corpid
fullname: /dzpz_pz/corpid/colsize
nodetype: column
value: 10
createdate: 2021.09.14 14:13:40.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.61403c23993240476a10dc3a2021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.61403c23993240476a10dc3a2021110407504420211121221445.61403c23993240476a10dc3c2021110407504420211121221445


id: 619a5454993208680e522a41
pid: 619a5454993208680e522a39
name: coltype
code: 61403c23993240476a10dc3b2021110407504420211121221445
namepath: /dzpz_pz/corpid
fullname: /dzpz_pz/corpid/coltype
nodetype: column
value: varchar
createdate: 2021.09.14 14:13:40.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.61403c23993240476a10dc3a2021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.61403c23993240476a10dc3a2021110407504420211121221445.61403c23993240476a10dc3b2021110407504420211121221445


id: 619a5454993208680e522a45
pid: 619a5454993208680e5229a1
name: corporationid
code: 60c562fa5db2e8eff0d869012021110407504420211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/corporationid
nodetype: dbcol
value: 帐套ID
createdate: 2021.06.13 09:44:28.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869012021110407504420211121221445


id: 619a5454993208680e522a49
pid: 619a5454993208680e522a45
name: colsize
code: 60c562fa5db2e8eff0d869032021110407504420211121221445
namepath: /dzpz_pz/corporationid
fullname: /dzpz_pz/corporationid/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:28.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869012021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869012021110407504420211121221445.60c562fa5db2e8eff0d869032021110407504420211121221445


id: 619a5454993208680e522a4d
pid: 619a5454993208680e522a45
name: coltype
code: 60c562fa5db2e8eff0d869022021110407504420211121221445
namepath: /dzpz_pz/corporationid
fullname: /dzpz_pz/corporationid/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:28.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869012021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869012021110407504420211121221445.60c562fa5db2e8eff0d869022021110407504420211121221445


id: 619a5454993208680e522a51
pid: 619a5454993208680e5229a1
name: dbpool
code: 60c560a05db2e8eff0d867c72021110407504420211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/dbpool
nodetype: column
value: default
createdate: 2021.06.13 09:37:34.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c72021110407504420211121221445


id: 619a5454993208680e522a55
pid: 619a5454993208680e5229a1
name: dbpool_expression
code: 613fd2c9993240476a10d29e2021110407504420211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/dbpool_expression
nodetype: column
createdate: 2021.09.14 06:38:15.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.613fd2c9993240476a10d29e2021110407504420211121221445


id: 619a5454993208680e522a59
pid: 619a5454993208680e5229a1
name: deleteflag
code: 60c562fa5db2e8eff0d869052021110407504420211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/deleteflag
nodetype: dbcol
value: 删除标记
createdate: 2021.06.13 09:44:29.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869052021110407504420211121221445


id: 619a5454993208680e522a5d
pid: 619a5454993208680e522a59
name: coltype
code: 60c562fa5db2e8eff0d869062021110407504420211121221445
namepath: /dzpz_pz/deleteflag
fullname: /dzpz_pz/deleteflag/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:29.000
lastmodifieddate: 2025.02.24 16:57:53.447
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869052021110407504420211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869052021110407504420211121221445.60c562fa5db2e8eff0d869062021110407504420211121221445


id: 619a5454993208680e522a61
pid: 619a5454993208680e5229a1
name: description
code: 60c5615f5db2e8eff0d867d92021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/description
nodetype: column
createdate: 2021.06.13 09:37:38.000
lastmodifieddate: 2025.02.24 16:57:53.447
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d92021110407504520211121221445


id: 619a5454993208680e522a65
pid: 619a5454993208680e5229a1
name: dynamicwhere
code: 60c5615f5db2e8eff0d867d82021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/dynamicwhere
nodetype: column
createdate: 2021.06.13 09:37:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d82021110407504520211121221445


id: 619a5454993208680e522a69
pid: 619a5454993208680e5229a1
name: dynamicwhere2
code: 60c5615f5db2e8eff0d867d62021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/dynamicwhere2
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d62021110407504520211121221445

value:
"a.corpid='"+ st_corpid+"' "
"b.y='"+st_y+"'"
"b.m='"+st_m+"'"
"b.code='"+st_code+"'"
"b.pzh like '%"+st_pzh+"%'"
iif( shzt==1, " c.verifierid is not null" , iif ( shzt==2, "c.verifierid is null ", ""))
"b."+st_key1+" like '%"+st_value1+"%'"
"b."+st_key2+" like '%"+st_value2+"%'"
"b.pzrq >='"+st_date1+"'"
"b.pzrq <'"+date2yyyymmdd(nextDate(yyyymmdd2Date(st_date2),1))+"'"


id: 619a5454993208680e522a6d
pid: 619a5454993208680e5229a1
name: dynamicwhere2_tokens
code: 60c5615f5db2e8eff0d867d72021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/dynamicwhere2_tokens
nodetype: column
createdate: 2021.06.13 09:37:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d72021110407504520211121221445

value:
{
    "\"a.corpid='\"+ st_corpid+\"' \"": "st_corpid",
    "\"b.y='\"+st_y+\"'\"": "st_y",
    "\"b.m='\"+st_m+\"'\"": "st_m",
    "\"b.code='\"+st_code+\"'\"": "st_code",
    "\"b.pzh like '%\"+st_pzh+\"%'\"": "st_pzh",
    "iif( shzt==1, \" c.verifierid is not null\" , iif ( shzt==2, \"c.verifierid is null \", \"\"))": "shzt",
    "\"b.\"+st_key1+\" like '%\"+st_value1+\"%'\"": "st_key1,st_value1",
    "\"b.\"+st_key2+\" like '%\"+st_value2+\"%'\"": "st_key2,st_value2",
    "\"b.pzrq >='\"+st_date1+\"'\"": "st_date1",
    "\"b.pzrq <'\"+date2yyyymmdd(nextDate(yyyymmdd2Date(st_date2),1))+\"'\"": "st_date2"
}


id: 619a5454993208680e522a71
pid: 619a5454993208680e5229a1
name: dynamicwheredata2
code: 60c5615f5db2e8eff0d867d52021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/dynamicwheredata2
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d52021110407504520211121221445

value:
st_corpid:filter!st_corpid
st_y:filter!st_y
st_m:filter!st_m
st_code:filter!st_code
st_pzh:filter!st_pzh
shzt:filter!shzt
st_key1:filter!st_key1
st_value1:filter!st_value1
st_key2:filter!st_key2
st_value2:filter!st_value2
st_date1:date2yyyymmdd(filter!st_date1)
st_date2:date2yyyymmdd(filter!st_date2)


id: 619a5454993208680e522a75
pid: 619a5454993208680e5229a1
name: fj
code: 60c562fa5db2e8eff0d869522021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/fj
nodetype: dbcol
value: 附件的图片数
createdate: 2021.06.13 09:44:43.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869522021110407504520211121221445


id: 619a5454993208680e522a79
pid: 619a5454993208680e522a75
name: coltype
code: 60c562fa5db2e8eff0d869532021110407504520211121221445
namepath: /dzpz_pz/fj
fullname: /dzpz_pz/fj/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:43.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869522021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869522021110407504520211121221445.60c562fa5db2e8eff0d869532021110407504520211121221445


id: 619a5454993208680e522a7d
pid: 619a5454993208680e5229a1
name: gguid
code: 60c562fa5db2e8eff0d869082021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/gguid
nodetype: dbcol
value: GGUID
createdate: 2021.06.13 09:44:29.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869082021110407504520211121221445


id: 619a5454993208680e522a81
pid: 619a5454993208680e522a7d
name: colsize
code: 60c562fa5db2e8eff0d8690a2021110407504520211121221445
namepath: /dzpz_pz/gguid
fullname: /dzpz_pz/gguid/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869082021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869082021110407504520211121221445.60c562fa5db2e8eff0d8690a2021110407504520211121221445


id: 619a5455993208680e522a85
pid: 619a5454993208680e522a7d
name: coltype
code: 60c562fa5db2e8eff0d869092021110407504520211121221445
namepath: /dzpz_pz/gguid
fullname: /dzpz_pz/gguid/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869082021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869082021110407504520211121221445.60c562fa5db2e8eff0d869092021110407504520211121221445


id: 619a5455993208680e522a89
pid: 619a5454993208680e5229a1
name: gguidinject
code: 613fd2c9993240476a10d2972021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/gguidinject
nodetype: column
value: false
createdate: 2021.09.14 06:38:11.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.613fd2c9993240476a10d2972021110407504520211121221445


id: 619a5455993208680e522a8d
pid: 619a5454993208680e5229a1
name: id
code: 60c562fa5db2e8eff0d8690c2021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/id
nodetype: dbcol
value: ID
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d8690c2021110407504520211121221445


id: 619a5455993208680e522a91
pid: 619a5455993208680e522a8d
name: colsize
code: 60c562fa5db2e8eff0d8690e2021110407504520211121221445
namepath: /dzpz_pz/id
fullname: /dzpz_pz/id/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:31.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d8690c2021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d8690c2021110407504520211121221445.60c562fa5db2e8eff0d8690e2021110407504520211121221445


id: 619a5455993208680e522a95
pid: 619a5455993208680e522a8d
name: coltype
code: 60c562fa5db2e8eff0d8690d2021110407504520211121221445
namepath: /dzpz_pz/id
fullname: /dzpz_pz/id/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d8690c2021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d8690c2021110407504520211121221445.60c562fa5db2e8eff0d8690d2021110407504520211121221445


id: 619a5455993208680e522aa5
pid: 619a5454993208680e5229a1
name: lastmodifieddate
code: 60c562fa5db2e8eff0d869172021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/lastmodifieddate
nodetype: dbcol
value: 数据最后修改日期
createdate: 2021.06.13 09:44:32.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445


id: 619a5455993208680e522aa9
pid: 619a5455993208680e522aa5
name: coltype
code: 60c562fa5db2e8eff0d869182021110407504520211121221445
namepath: /dzpz_pz/lastmodifieddate
fullname: /dzpz_pz/lastmodifieddate/coltype
nodetype: column
value: datetime
createdate: 2021.06.13 09:44:32.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445.60c562fa5db2e8eff0d869182021110407504520211121221445


id: 619a5455993208680e522aad
pid: 619a5455993208680e522aa5
name: nullable
code: 618499a5993236a4844fa1d520211121221445
namepath: /dzpz_pz/lastmodifieddate
fullname: /dzpz_pz/lastmodifieddate/nullable
nodetype: column
value: true
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445.618499a5993236a4844fa1d520211121221445


id: 619a5455993208680e522ab1
pid: 619a5455993208680e522aa5
name: smartretrieve
code: 618499a5993236a4844fa1d720211121221445
namepath: /dzpz_pz/lastmodifieddate
fullname: /dzpz_pz/lastmodifieddate/smartretrieve
nodetype: column
value: false
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445.618499a5993236a4844fa1d720211121221445


id: 619a5455993208680e522ab5
pid: 619a5455993208680e522aa5
name: updatable
code: 618499a5993236a4844fa1d620211121221445
namepath: /dzpz_pz/lastmodifieddate
fullname: /dzpz_pz/lastmodifieddate/updatable
nodetype: column
value: true
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445.618499a5993236a4844fa1d620211121221445


id: 619a5455993208680e522ab9
pid: 619a5455993208680e522aa5
name: usedingroupby
code: 618499a5993236a4844fa1d820211121221445
namepath: /dzpz_pz/lastmodifieddate
fullname: /dzpz_pz/lastmodifieddate/usedingroupby
nodetype: column
value: false
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445.618499a5993236a4844fa1d820211121221445


id: 619a5455993208680e522abd
pid: 619a5455993208680e522aa5
name: usedinsum
code: 618499a5993236a4844fa1d920211121221445
namepath: /dzpz_pz/lastmodifieddate
fullname: /dzpz_pz/lastmodifieddate/usedinsum
nodetype: column
value: false
createdate: 2021.11.05 11:56:38.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869172021110407504520211121221445.618499a5993236a4844fa1d920211121221445


id: 619a5455993208680e522ac1
pid: 619a5454993208680e5229a1
name: multirow
code: 60c560a05db2e8eff0d867b32021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/multirow
nodetype: column
value: true
createdate: 2021.06.13 09:37:13.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867b32021110407504520211121221445


id: 619a5455993208680e522ac5
pid: 619a5454993208680e5229a1
name: needcache
code: 60c560a05db2e8eff0d867b72021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/needcache
nodetype: column
value: false
createdate: 2021.06.13 09:37:15.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867b72021110407504520211121221445


id: 619a5455993208680e522ad5
pid: 619a5454993208680e5229a1
name: primarykey
code: 60c560a05db2e8eff0d867c52021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/primarykey
nodetype: column
value: id
createdate: 2021.06.13 09:37:32.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c52021110407504520211121221445


id: 619a5455993208680e522ad9
pid: 619a5454993208680e5229a1
name: pz
code: 60c562fa5db2e8eff0d869552021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/pz
nodetype: dbcol
value: 凭证的图片数
createdate: 2021.06.13 09:44:44.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869552021110407504520211121221445


id: 619a5455993208680e522add
pid: 619a5455993208680e522ad9
name: coltype
code: 60c562fa5db2e8eff0d869562021110407504520211121221445
namepath: /dzpz_pz/pz
fullname: /dzpz_pz/pz/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:44.000
lastmodifieddate: 2025.02.24 16:57:53.448
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869552021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869552021110407504520211121221445.60c562fa5db2e8eff0d869562021110407504520211121221445


id: 619a5455993208680e522ae1
pid: 619a5454993208680e5229a1
name: pzh
code: 60c562fa5db2e8eff0d869202021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/pzh
nodetype: dbcol
value: 凭证号
createdate: 2021.06.13 09:44:33.000
lastmodifieddate: 2025.02.24 16:57:53.448
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869202021110407504520211121221445


id: 619a5455993208680e522ae5
pid: 619a5455993208680e522ae1
name: colsize
code: 60c562fa5db2e8eff0d869222021110407504520211121221445
namepath: /dzpz_pz/pzh
fullname: /dzpz_pz/pzh/colsize
nodetype: column
value: 20
createdate: 2021.06.13 09:44:34.000
lastmodifieddate: 2025.02.24 16:57:53.449
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869202021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869202021110407504520211121221445.60c562fa5db2e8eff0d869222021110407504520211121221445


id: 619a5455993208680e522ae9
pid: 619a5455993208680e522ae1
name: coltype
code: 60c562fa5db2e8eff0d869212021110407504520211121221445
namepath: /dzpz_pz/pzh
fullname: /dzpz_pz/pzh/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:34.000
lastmodifieddate: 2025.02.24 16:57:53.449
codepath:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869202021110407504520211121221445

fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c562fa5db2e8eff0d869202021110407504520211121221445.60c562fa5db2e8eff0d869212021110407504520211121221445


id: 619a5455993208680e522aed
pid: 619a5454993208680e5229a1
name: redis
code: 60c560a05db2e8eff0d867c62021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/redis
nodetype: column
createdate: 2021.06.13 09:37:34.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c62021110407504520211121221445


id: 619a5455993208680e522af1
pid: 619a5454993208680e5229a1
name: rowcountlimit
code: 60c560a05db2e8eff0d867b62021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/rowcountlimit
nodetype: column
value: 0
createdate: 2021.06.13 09:37:14.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867b62021110407504520211121221445


id: 619a5455993208680e522b29
pid: 619a5454993208680e5229a1
name: sourcetype
code: 60c560a05db2e8eff0d867c22021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/sourcetype
nodetype: column
value: sql
createdate: 2021.06.13 09:37:31.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c22021110407504520211121221445


id: 619a5455993208680e522b2d
pid: 619a5454993208680e5229a1
name: sql
code: 60c5615f5db2e8eff0d867d42021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/sql
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c5615f5db2e8eff0d867d42021110407504520211121221445

value:
select
  a.corpid,
  b.*,
  c.id as img_id,
  c.pz,
  c.fj,
  ifnull(c.pz, 0) + ifnull(c.fj, 0) as img_sl,
  case when c.verifierid is not null then 1 else 0 end as is_verified
from
  pzdj a
  inner join pzdjex b on a.gguid = b.gguid
  left join dzpz_pz c on a.corpid = c.corpid
  and b.pzh = c.pzh
order by
  a.corpid asc,
  b.y asc,
  b.m asc,
  b.pzh asc


id: 619a5455993208680e522b31
pid: 619a5454993208680e5229a1
name: sqlinject
code: 60c560a05db2e8eff0d867b42021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/sqlinject
nodetype: column
value: true
createdate: 2021.06.13 09:37:14.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867b42021110407504520211121221445


id: 619a5455993208680e522b41
pid: 619a5454993208680e5229a1
name: timeout
code: 60c560a05db2e8eff0d867b82021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/timeout
nodetype: column
value: 30
createdate: 2021.06.13 09:37:15.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867b82021110407504520211121221445


id: 619a5455993208680e522b51
pid: 619a5454993208680e5229a1
name: type_api
code: 60c560a05db2e8eff0d867c32021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/type_api
nodetype: column
value: api
createdate: 2021.06.13 09:37:31.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c32021110407504520211121221445


id: 619a5455993208680e522b55
pid: 619a5454993208680e5229a1
name: type_sql
code: 60c560a05db2e8eff0d867c12021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/type_sql
nodetype: column
value: sql
createdate: 2021.06.13 09:37:31.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c12021110407504520211121221445


id: 619a5455993208680e522b59
pid: 619a5454993208680e5229a1
name: updatedtable
code: 60c560a05db2e8eff0d867c42021110407504520211121221445
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444
fullname: /dzpz_pz/updatedtable
nodetype: column
value: dzpz_pz
createdate: 2021.06.13 09:37:32.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.60c560a05db2e8eff0d867c42021110407504520211121221445


id: 619a54f8993208680e522d5d
pid: 619a54f8993208680e522d5c
name: coltype
code: 619a54f8993208680e522d5d
namepath: /dzpz_pz/bz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d5c
fullname: /dzpz_pz/bz/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d5c.619a54f8993208680e522d5d


id: 619a54f8993208680e522d5e
pid: 619a54f8993208680e522d5c
name: colsize
code: 619a54f8993208680e522d5e
namepath: /dzpz_pz/bz
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d5c
fullname: /dzpz_pz/bz/colsize
nodetype: column
value: 50
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d5c.619a54f8993208680e522d5e


id: 619a54f8993208680e522d61
pid: 619a54f8993208680e522d60
name: coltype
code: 619a54f8993208680e522d61
namepath: /dzpz_pz/code
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d60
fullname: /dzpz_pz/code/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d60.619a54f8993208680e522d61


id: 619a54f8993208680e522d62
pid: 619a54f8993208680e522d60
name: colsize
code: 619a54f8993208680e522d62
namepath: /dzpz_pz/code
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d60
fullname: /dzpz_pz/code/colsize
nodetype: column
value: 20
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d60.619a54f8993208680e522d62


id: 619a54f8993208680e522d65
pid: 619a54f8993208680e522d64
name: coltype
code: 619a54f8993208680e522d65
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a54f8993208680e522d65


id: 619a54f8993208680e522d66
pid: 619a54f8993208680e522d64
name: colsize
code: 619a54f8993208680e522d66
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/colsize
nodetype: column
value: 10
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a54f8993208680e522d66


id: 619a54f8993208680e522d6d
pid: 619a54f8993208680e522d6c
name: coltype
code: 619a54f8993208680e522d6d
namepath: /dzpz_pz/inner_xh
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d6c
fullname: /dzpz_pz/inner_xh/coltype
nodetype: column
value: int
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d6c.619a54f8993208680e522d6d


id: 619a54f8993208680e522d71
pid: 619a54f8993208680e522d70
name: coltype
code: 619a54f8993208680e522d71
namepath: /dzpz_pz/m
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d70
fullname: /dzpz_pz/m/coltype
nodetype: column
value: int
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.449
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d70.619a54f8993208680e522d71


id: 619a54f8993208680e522d74
pid: 619a54f8993208680e522d73
name: coltype
code: 619a54f8993208680e522d74
namepath: /dzpz_pz/posted
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d73
fullname: /dzpz_pz/posted/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.881
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d73.619a54f8993208680e522d74


id: 619a54f8993208680e522d75
pid: 619a54f8993208680e522d73
name: colsize
code: 619a54f8993208680e522d75
namepath: /dzpz_pz/posted
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d73
fullname: /dzpz_pz/posted/colsize
nodetype: column
value: 4
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.881
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d73.619a54f8993208680e522d75


id: 619a54f8993208680e522d79
pid: 619a54f8993208680e522d78
name: coltype
code: 619a54f8993208680e522d79
namepath: /dzpz_pz/pzrq
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d78
fullname: /dzpz_pz/pzrq/coltype
nodetype: column
value: datetime
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.881
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d78.619a54f8993208680e522d79


id: 619a54f8993208680e522d7c
pid: 619a54f8993208680e522d7b
name: coltype
code: 619a54f8993208680e522d7c
namepath: /dzpz_pz/y
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d7b
fullname: /dzpz_pz/y/coltype
nodetype: column
value: int
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d7b.619a54f8993208680e522d7c


id: 619a54f8993208680e522d7f
pid: 619a54f8993208680e522d7e
name: coltype
code: 619a54f8993208680e522d7f
namepath: /dzpz_pz/kmdm
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d7e
fullname: /dzpz_pz/kmdm/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d7e.619a54f8993208680e522d7f


id: 619a54f8993208680e522d80
pid: 619a54f8993208680e522d7e
name: colsize
code: 619a54f8993208680e522d80
namepath: /dzpz_pz/kmdm
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d7e
fullname: /dzpz_pz/kmdm/colsize
nodetype: column
value: 50
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d7e.619a54f8993208680e522d80


id: 619a54f8993208680e522d83
pid: 619a54f8993208680e522d82
name: coltype
code: 619a54f8993208680e522d83
namepath: /dzpz_pz/kmmc
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d82
fullname: /dzpz_pz/kmmc/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d82.619a54f8993208680e522d83


id: 619a54f8993208680e522d84
pid: 619a54f8993208680e522d82
name: colsize
code: 619a54f8993208680e522d84
namepath: /dzpz_pz/kmmc
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d82
fullname: /dzpz_pz/kmmc/colsize
nodetype: column
value: 100
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d82.619a54f8993208680e522d84


id: 619a54f8993208680e522d87
pid: 619a54f8993208680e522d86
name: coltype
code: 619a54f8993208680e522d87
namepath: /dzpz_pz/rkdh
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d86
fullname: /dzpz_pz/rkdh/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d86.619a54f8993208680e522d87


id: 619a54f8993208680e522d88
pid: 619a54f8993208680e522d86
name: colsize
code: 619a54f8993208680e522d88
namepath: /dzpz_pz/rkdh
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d86
fullname: /dzpz_pz/rkdh/colsize
nodetype: column
value: 50
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d86.619a54f8993208680e522d88


id: 619a54f8993208680e522d8b
pid: 619a54f8993208680e522d8a
name: coltype
code: 619a54f8993208680e522d8b
namepath: /dzpz_pz/zdr
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d8a
fullname: /dzpz_pz/zdr/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d8a.619a54f8993208680e522d8b


id: 619a54f8993208680e522d8c
pid: 619a54f8993208680e522d8a
name: colsize
code: 619a54f8993208680e522d8c
namepath: /dzpz_pz/zdr
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d8a
fullname: /dzpz_pz/zdr/colsize
nodetype: column
value: 30
createdate: 2021.11.21 22:18:24.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d8a.619a54f8993208680e522d8c


id: 619a5530993208680e522dd1
pid: 619a5530993208680e522dd0
name: coltype
code: 619a5530993208680e522dd1
namepath: /dzpz_pz/img_id
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522dd0
fullname: /dzpz_pz/img_id/coltype
nodetype: column
value: varchar
createdate: 2021.11.21 22:19:10.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522dd0.619a5530993208680e522dd1


id: 619a5530993208680e522dd2
pid: 619a5530993208680e522dd0
name: colsize
code: 619a5530993208680e522dd2
namepath: /dzpz_pz/img_id
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522dd0
fullname: /dzpz_pz/img_id/colsize
nodetype: column
value: 40
createdate: 2021.11.21 22:19:10.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522dd0.619a5530993208680e522dd2


id: 619a559d993208680e522e06
pid: 619a5530993208680e522e05
name: coltype
code: 619a559d993208680e522e06
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/coltype
nodetype: column
value: int
createdate: 2021.11.21 22:20:13.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a559d993208680e522e06


id: 619a55c7993208680e522e7e
pid: 619a5530993208680e522e05
name: nullable
code: 619a55c7993208680e522e7e
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/nullable
nodetype: column
value: true
createdate: 2021.11.21 22:21:06.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e7e


id: 619a55c7993208680e522e7f
pid: 619a5530993208680e522e05
name: updatable
code: 619a55c7993208680e522e7f
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/updatable
nodetype: column
value: true
createdate: 2021.11.21 22:21:06.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e7f


id: 619a55c7993208680e522e80
pid: 619a5530993208680e522e05
name: smartretrieve
code: 619a55c7993208680e522e80
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/smartretrieve
nodetype: column
value: false
createdate: 2021.11.21 22:21:06.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e80


id: 619a55c7993208680e522e81
pid: 619a5530993208680e522e05
name: usedingroupby
code: 619a55c7993208680e522e81
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/usedingroupby
nodetype: column
value: false
createdate: 2021.11.21 22:21:06.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e81


id: 619a55c7993208680e522e82
pid: 619a5530993208680e522e05
name: usedinsum
code: 619a55c7993208680e522e82
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/usedinsum
nodetype: column
value: false
createdate: 2021.11.21 22:21:06.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e82


id: 619a55c7993208680e522e89
pid: 619a5530993208680e522e05
name: colsize
code: 619a55c7993208680e522e89
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/colsize
nodetype: column
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e89


id: 619a55c7993208680e522e8a
pid: 619a5530993208680e522e05
name: decimalcount
code: 619a55c7993208680e522e8a
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/decimalcount
nodetype: column
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e8a


id: 619a55c7993208680e522e8b
pid: 619a5530993208680e522e05
name: defaultvalue
code: 619a55c7993208680e522e8b
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/defaultvalue
nodetype: column
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.882
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e8b


id: 619a55c7993208680e522e8c
pid: 619a5530993208680e522e05
name: dbdefaultvalue
code: 619a55c7993208680e522e8c
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/dbdefaultvalue
nodetype: column
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e8c


id: 619a55c7993208680e522e8d
pid: 619a5530993208680e522e05
name: datamask
code: 619a55c7993208680e522e8d
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/datamask
nodetype: column
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e8d


id: 619a55c7993208680e522e8e
pid: 619a5530993208680e522e05
name: description
code: 619a55c7993208680e522e8e
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/description
nodetype: column
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e8e


id: 619a55c7993208680e522e8f
pid: 619a5530993208680e522e05
name: dynamicwhere2_tokens
code: 619a55c7993208680e522e8f
namepath: /dzpz_pz/img_sl
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05
fullname: /dzpz_pz/img_sl/dynamicwhere2_tokens
nodetype: column
value: {}
createdate: 2021.11.21 22:21:19.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a5530993208680e522e05.619a55c7993208680e522e8f


id: 619a55c7993208680e522ea3
pid: 619a54f8993208680e522d64
name: nullable
code: 619a55c7993208680e522ea3
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/nullable
nodetype: column
value: true
createdate: 2021.11.21 22:21:31.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a55c7993208680e522ea3


id: 619a55c7993208680e522ea4
pid: 619a54f8993208680e522d64
name: updatable
code: 619a55c7993208680e522ea4
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/updatable
nodetype: column
value: true
createdate: 2021.11.21 22:21:31.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a55c7993208680e522ea4


id: 619a55c7993208680e522ea5
pid: 619a54f8993208680e522d64
name: smartretrieve
code: 619a55c7993208680e522ea5
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/smartretrieve
nodetype: column
value: false
createdate: 2021.11.21 22:21:31.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a55c7993208680e522ea5


id: 619a55c7993208680e522ea6
pid: 619a54f8993208680e522d64
name: usedingroupby
code: 619a55c7993208680e522ea6
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/usedingroupby
nodetype: column
value: false
createdate: 2021.11.21 22:21:31.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a55c7993208680e522ea6


id: 619a55c7993208680e522ea7
pid: 619a54f8993208680e522d64
name: usedinsum
code: 619a55c7993208680e522ea7
namepath: /dzpz_pz/pzdjex_corpid
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64
fullname: /dzpz_pz/pzdjex_corpid/usedinsum
nodetype: column
value: false
createdate: 2021.11.21 22:21:31.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a54f8993208680e522d64.619a55c7993208680e522ea7


id: 619a59ed993208680e522edd
pid: 619a59ed993208680e522edc
name: coltype
code: 619a59ed993208680e522edd
namepath: /dzpz_pz/is_verified
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619a59ed993208680e522edc
fullname: /dzpz_pz/is_verified/coltype
nodetype: column
value: int
createdate: 2021.11.21 22:38:38.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619a59ed993208680e522edc.619a59ed993208680e522edd


id: 619b10ef993208680e523518
pid: 619b10ef993208680e523517
name: coltype
code: 619b10ef993208680e523518
namepath: /dzpz_pz/ckzcmxdm
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523517
fullname: /dzpz_pz/ckzcmxdm/coltype
nodetype: column
value: varchar
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523517.619b10ef993208680e523518


id: 619b10ef993208680e523519
pid: 619b10ef993208680e523517
name: colsize
code: 619b10ef993208680e523519
namepath: /dzpz_pz/ckzcmxdm
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523517
fullname: /dzpz_pz/ckzcmxdm/colsize
nodetype: column
value: 50
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523517.619b10ef993208680e523519


id: 619b10ef993208680e52351c
pid: 619b10ef993208680e52351b
name: coltype
code: 619b10ef993208680e52351c
namepath: /dzpz_pz/ckzcmxmc
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351b
fullname: /dzpz_pz/ckzcmxmc/coltype
nodetype: column
value: varchar
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351b.619b10ef993208680e52351c


id: 619b10ef993208680e52351d
pid: 619b10ef993208680e52351b
name: colsize
code: 619b10ef993208680e52351d
namepath: /dzpz_pz/ckzcmxmc
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351b
fullname: /dzpz_pz/ckzcmxmc/colsize
nodetype: column
value: 100
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351b.619b10ef993208680e52351d


id: 619b10ef993208680e523520
pid: 619b10ef993208680e52351f
name: coltype
code: 619b10ef993208680e523520
namepath: /dzpz_pz/ykzcmxdm
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351f
fullname: /dzpz_pz/ykzcmxdm/coltype
nodetype: column
value: varchar
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351f.619b10ef993208680e523520


id: 619b10ef993208680e523521
pid: 619b10ef993208680e52351f
name: colsize
code: 619b10ef993208680e523521
namepath: /dzpz_pz/ykzcmxdm
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351f
fullname: /dzpz_pz/ykzcmxdm/colsize
nodetype: column
value: 50
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e52351f.619b10ef993208680e523521


id: 619b10ef993208680e523524
pid: 619b10ef993208680e523523
name: coltype
code: 619b10ef993208680e523524
namepath: /dzpz_pz/ykzcmxmc
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523523
fullname: /dzpz_pz/ykzcmxmc/coltype
nodetype: column
value: varchar
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523523.619b10ef993208680e523524


id: 619b10ef993208680e523525
pid: 619b10ef993208680e523523
name: colsize
code: 619b10ef993208680e523525
namepath: /dzpz_pz/ykzcmxmc
codepath: 60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523523
fullname: /dzpz_pz/ykzcmxmc/colsize
nodetype: column
value: 100
createdate: 2021.11.22 11:39:28.000
lastmodifieddate: 2025.02.24 16:57:53.883
fullcode:
60c560a05db2e8eff0d867a82021110407504420211121221444.619b10ef993208680e523523.619b10ef993208680e523525


id: 673210839932478770cad311
pid: 673210829932478770cad2c9
name: dynamicwhere2
code: 60ab31c65db2f37491f998b020241111221115
nodetype: column
createdate: 2021.05.24 12:59:01.000
lastmodifieddate: 2025.02.24 16:57:55.145
value:
" corpid='"+ corpid+"'  "
" ym="+ym 
st_key1+"  like  '%"+ st_value1+"%' "
st_datetype +" >='"+ st_date1+"' "
st_datetype +" <'"+ date2yyyymmdd(nextDate(yyyymmdd2Date(st_date2),1))+"' "


id: 673210839932478770cad315
pid: 673210829932478770cad2c9
name: dynamicwhere2_tokens
code: 60ab31c65db2f37491f998b120241111221115
nodetype: column
createdate: 2021.05.24 12:59:01.000
lastmodifieddate: 2025.02.24 16:57:55.145
value:
{
    "\" corpid='\"+ corpid+\"'  \"": "corpid",
    "\" ym=\"+ym": "ym",
    "st_key1+\"  like  '%\"+ st_value1+\"%' \"": "st_key1,st_value1",
    "st_datetype +\" >='\"+ st_date1+\"' \"": "st_datetype,st_date1",
    "st_datetype +\" <'\"+ date2yyyymmdd(nextDate(yyyymmdd2Date(st_date2),1))+\"' \"": "st_datetype,st_date2"
}


id: 673210839932478770cad319
pid: 673210829932478770cad2c9
name: dynamicwheredata2
code: 60ab31c65db2f37491f998af20241111221115
nodetype: column
createdate: 2021.05.24 12:59:01.000
lastmodifieddate: 2025.02.24 16:57:55.145
value:
corpid:凭证清单!corpid
pzh: 凭证清单!pzh
ym:凭证清单!ym
st_datetype:凭证清单!st_datetype
st_date1: date2yyyymmdd( 凭证清单!st_date1)
st_date2: date2yyyymmdd( 凭证清单!st_date2)
st_key1:凭证清单!st_key1
st_value1:凭证清单!st_value1
is_about_me:凭证清单!is_about_me


id: 673210839932478770cad375
pid: 673210829932478770cad2c9
name: sql
code: 60ab31c65db2f37491f998ae20241111221115
nodetype: column
createdate: 2021.05.24 12:59:01.000
lastmodifieddate: 2025.02.24 16:57:55.146
value:
select
  id,
  pz,
  pzh,
  userid,
  username,
  verifieddate,
  verifierid,
  verifiername,
  xm,
  ym,
  case when verifierid > 0 then 1 else 0 end as verified
from
  dzpz_pz
order by
  pzh desc


id: 673210859932478770cad521
pid: 673210849932478770cad48d
name: sql
code: 60abac6c5db2a837c83ac63620241111221117
nodetype: column
createdate: 2021.05.24 21:39:48.000
lastmodifieddate: 2025.02.24 16:57:55.579
value:
select
  id,
  pzh,
  url_img,
  url_thumbnail,
  attachmentcount,
  pz,
  fj,
  username,
  verifiername
from
  dzpz_pz


id: 60c9faff9932d177d8ac6123
pid: 60c9bd189932d177d8ac5e81
name: sql
code: 60c9faff9932d177d8ac6123
namepath: /pzh_check
codepath: 60c9bd189932d177d8ac5e81
fullname: /pzh_check/sql
fullcode: 60c9bd189932d177d8ac5e81.60c9faff9932d177d8ac6123
nodetype: column
createdate: 2021.06.16 21:22:08.000
lastmodifieddate: 2025.02.24 16:57:56.007
value:
select
  a.pzh
from
  (
    select
      concat(
        ':pzh_prefix{}',
        right(concat('0000000000', id), :pzh_len { 4 })
      ) as pzh
    from
      app_int  -- 这个表就是一个整数序列表
    where
      id <= (
        select
          cast(right(max(b.pzh), :pzh_len { 4 }) as decimal) as maxpzh  --取出当月最大的凭证号的后几位去掉前缀
        from
          dzpz_pz b
        where
          b.ym = :ym { 202106 }
          and b.corpid = ':corpid{-}'
      )
  ) a  --  把从1 到 最大凭证号 构建一个凭证号码完成序列表 
where
  a.pzh not in (  --  不存在的就是
    select
      pzh
    from
      dzpz_pz b
    where
      b.ym = :ym { 202106 }
      and b.corpid = ':corpid{-}'
  )


id: 6183205499328c3820c0c92b
pid: 6183205499328c3820c0c927
name: coltype
code: 60c5623b5db2e8eff0d868f020211104075044
namepath: /dzpz_pz/attachmentcount
codepath: 60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868ef20211104075044
fullname: /dzpz_pz/attachmentcount/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:25.000
lastmodifieddate: 2025.02.24 16:57:56.855
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868ef20211104075044.60c5623b5db2e8eff0d868f020211104075044


id: 6183205499328c3820c0c937
pid: 6183205499328c3820c0c933
name: coltype
code: 60c5623b5db2e8eff0d868f320211104075044
namepath: /dzpz_pz/billdate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868f220211104075044
fullname: /dzpz_pz/billdate/coltype
nodetype: column
value: datetime
createdate: 2021.06.13 09:44:25.000
lastmodifieddate: 2025.02.24 16:57:56.855
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868f220211104075044.60c5623b5db2e8eff0d868f320211104075044


id: 6183205499328c3820c0c93f
pid: 6183205499328c3820c0c93b
name: colsize
code: 60c5623b5db2e8eff0d868f720211104075044
namepath: /dzpz_pz/billno
codepath: 60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868f520211104075044
fullname: /dzpz_pz/billno/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:26.000
lastmodifieddate: 2025.02.24 16:57:56.855
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868f520211104075044.60c5623b5db2e8eff0d868f720211104075044


id: 6183205499328c3820c0c943
pid: 6183205499328c3820c0c93b
name: coltype
code: 60c5623b5db2e8eff0d868f620211104075044
namepath: /dzpz_pz/billno
codepath: 60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868f520211104075044
fullname: /dzpz_pz/billno/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:26.000
lastmodifieddate: 2025.02.24 16:57:56.855
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c5623b5db2e8eff0d868f520211104075044.60c5623b5db2e8eff0d868f620211104075044


id: 6183205499328c3820c0c94b
pid: 6183205499328c3820c0c947
name: colsize
code: 60c562fa5db2e8eff0d868fd20211104075044
namepath: /dzpz_pz/billtype
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d868fb20211104075044
fullname: /dzpz_pz/billtype/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:27.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d868fb20211104075044.60c562fa5db2e8eff0d868fd20211104075044


id: 6183205499328c3820c0c94f
pid: 6183205499328c3820c0c947
name: coltype
code: 60c562fa5db2e8eff0d868fc20211104075044
namepath: /dzpz_pz/billtype
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d868fb20211104075044
fullname: /dzpz_pz/billtype/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:27.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d868fb20211104075044.60c562fa5db2e8eff0d868fc20211104075044


id: 6183205499328c3820c0c957
pid: 6183205499328c3820c0c953
name: colsize
code: 60c562fa5db2e8eff0d8694c20211104075044
namepath: /dzpz_pz/bm
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694a20211104075044
fullname: /dzpz_pz/bm/colsize
nodetype: column
value: 200
createdate: 2021.06.13 09:44:42.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694a20211104075044.60c562fa5db2e8eff0d8694c20211104075044


id: 6183205499328c3820c0c95b
pid: 6183205499328c3820c0c953
name: coltype
code: 60c562fa5db2e8eff0d8694b20211104075044
namepath: /dzpz_pz/bm
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694a20211104075044
fullname: /dzpz_pz/bm/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:42.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694a20211104075044.60c562fa5db2e8eff0d8694b20211104075044


id: 6183205499328c3820c0c963
pid: 6183205499328c3820c0c95f
name: colsize
code: 60c7d6795db2f19751803b0620211104075044
namepath: /dzpz_pz/c_sh1
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0420211104075044
fullname: /dzpz_pz/c_sh1/colsize
nodetype: column
value: 2
createdate: 2021.06.15 06:21:58.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0420211104075044.60c7d6795db2f19751803b0620211104075044


id: 6183205499328c3820c0c96f
pid: 6183205499328c3820c0c96b
name: colsize
code: 60c7d6795db2f19751803b0a20211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/colsize
nodetype: column
value: 4
createdate: 2021.06.15 06:21:58.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.60c7d6795db2f19751803b0a20211104075044


id: 6183205499328c3820c0c977
pid: 6183205499328c3820c0c96b
name: nullable
code: 615187ec99326278b943ff4820211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/nullable
nodetype: column
value: true
createdate: 2021.09.27 17:08:01.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.615187ec99326278b943ff4820211104075044


id: 6183205499328c3820c0c97b
pid: 6183205499328c3820c0c96b
name: smartretrieve
code: 615187ec99326278b943ff4a20211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/smartretrieve
nodetype: column
value: false
createdate: 2021.09.27 17:08:01.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.615187ec99326278b943ff4a20211104075044


id: 6183205499328c3820c0c97f
pid: 6183205499328c3820c0c96b
name: updatable
code: 615187ec99326278b943ff4920211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/updatable
nodetype: column
value: true
createdate: 2021.09.27 17:08:01.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.615187ec99326278b943ff4920211104075044


id: 6183205499328c3820c0c983
pid: 6183205499328c3820c0c96b
name: usedingroupby
code: 615187ec99326278b943ff4b20211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/usedingroupby
nodetype: column
value: false
createdate: 2021.09.27 17:08:01.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.615187ec99326278b943ff4b20211104075044


id: 6183205499328c3820c0c987
pid: 6183205499328c3820c0c96b
name: usedinsum
code: 615187ec99326278b943ff4c20211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/usedinsum
nodetype: column
value: false
createdate: 2021.09.27 17:08:01.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.615187ec99326278b943ff4c20211104075044


id: 6183205499328c3820c0c98f
pid: 6183205499328c3820c0c98b
name: description
code: 60c7d4645db2f19751803a2d20211104075044
namepath: /dzpz_pz/c_xh
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044
fullname: /dzpz_pz/c_xh/description
nodetype: column
createdate: 2021.06.15 06:13:00.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044.60c7d4645db2f19751803a2d20211104075044


id: 6183205499328c3820c0c993
pid: 6183205499328c3820c0c98b
name: dynamicwhere2_tokens
code: 60c7d4645db2f19751803a2e20211104075044
namepath: /dzpz_pz/c_xh
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044
fullname: /dzpz_pz/c_xh/dynamicwhere2_tokens
nodetype: column
value: {}
createdate: 2021.06.15 06:13:00.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044.60c7d4645db2f19751803a2e20211104075044


id: 6183205499328c3820c0c997
pid: 6183205499328c3820c0c98b
name: expression
code: 60c7d4645db2f19751803a2c20211104075044
namepath: /dzpz_pz/c_xh
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044
fullname: /dzpz_pz/c_xh/expression
nodetype: column
value: thisrow()+1
createdate: 2021.06.15 06:13:00.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044.60c7d4645db2f19751803a2c20211104075044


id: 6183205499328c3820c0c99b
pid: 6183205499328c3820c0c98b
name: fillback
code: 60c7d4645db2f19751803a2b20211104075044
namepath: /dzpz_pz/c_xh
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044
fullname: /dzpz_pz/c_xh/fillback
nodetype: column
createdate: 2021.06.15 06:12:59.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f19751803a1a20211104075044.60c7d4645db2f19751803a2b20211104075044


id: 6183205499328c3820c0c973
pid: 6183205499328c3820c0c96b
name: coltype
code: 60c7d6795db2f19751803b0920211104075044
namepath: /dzpz_pz/c_sh2
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044
fullname: /dzpz_pz/c_sh2/coltype
nodetype: column
value: text
createdate: 2021.06.15 06:21:58.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0820211104075044.60c7d6795db2f19751803b0920211104075044


id: 6183205499328c3820c0c9a3
pid: 6183205499328c3820c0c99f
name: colsize
code: 61403c23993240476a10dc3c20211104075044
namepath: /dzpz_pz/corpid
codepath: 60c560a05db2e8eff0d867a820211104075044.61403c23993240476a10dc3a20211104075044
fullname: /dzpz_pz/corpid/colsize
nodetype: column
value: 32
createdate: 2021.09.14 14:13:40.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.61403c23993240476a10dc3a20211104075044.61403c23993240476a10dc3c20211104075044


id: 6183205499328c3820c0c9a7
pid: 6183205499328c3820c0c99f
name: coltype
code: 61403c23993240476a10dc3b20211104075044
namepath: /dzpz_pz/corpid
codepath: 60c560a05db2e8eff0d867a820211104075044.61403c23993240476a10dc3a20211104075044
fullname: /dzpz_pz/corpid/coltype
nodetype: column
value: varchar
createdate: 2021.09.14 14:13:40.000
lastmodifieddate: 2025.02.24 16:57:56.856
fullcode:
60c560a05db2e8eff0d867a820211104075044.61403c23993240476a10dc3a20211104075044.61403c23993240476a10dc3b20211104075044


id: 6183205499328c3820c0c9af
pid: 6183205499328c3820c0c9ab
name: colsize
code: 60c562fa5db2e8eff0d8690320211104075044
namepath: /dzpz_pz/corporationid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690120211104075044
fullname: /dzpz_pz/corporationid/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:28.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690120211104075044.60c562fa5db2e8eff0d8690320211104075044


id: 6183205499328c3820c0c9b3
pid: 6183205499328c3820c0c9ab
name: coltype
code: 60c562fa5db2e8eff0d8690220211104075044
namepath: /dzpz_pz/corporationid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690120211104075044
fullname: /dzpz_pz/corporationid/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:28.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690120211104075044.60c562fa5db2e8eff0d8690220211104075044


id: 6183205499328c3820c0c9c3
pid: 6183205499328c3820c0c9bf
name: coltype
code: 60c562fa5db2e8eff0d8690620211104075044
namepath: /dzpz_pz/deleteflag
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690520211104075044
fullname: /dzpz_pz/deleteflag/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:29.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690520211104075044.60c562fa5db2e8eff0d8690620211104075044


id: 6183205499328c3820c0c9df
pid: 6183205499328c3820c0c9db
name: coltype
code: 60c562fa5db2e8eff0d8695320211104075045
namepath: /dzpz_pz/fj
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8695220211104075045
fullname: /dzpz_pz/fj/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:43.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8695220211104075045.60c562fa5db2e8eff0d8695320211104075045


id: 6183205499328c3820c0c9e7
pid: 6183205499328c3820c0c9e3
name: colsize
code: 60c562fa5db2e8eff0d8690a20211104075045
namepath: /dzpz_pz/gguid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690820211104075045
fullname: /dzpz_pz/gguid/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690820211104075045.60c562fa5db2e8eff0d8690a20211104075045


id: 6183205499328c3820c0c9eb
pid: 6183205499328c3820c0c9e3
name: coltype
code: 60c562fa5db2e8eff0d8690920211104075045
namepath: /dzpz_pz/gguid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690820211104075045
fullname: /dzpz_pz/gguid/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690820211104075045.60c562fa5db2e8eff0d8690920211104075045


id: 6183205499328c3820c0c9cf
pid: 6183205499328c3820c0c907
name: dynamicwhere2
code: 60c5615f5db2e8eff0d867d620211104075045
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a820211104075044
fullname: /dzpz_pz/dynamicwhere2
fullcode: 60c560a05db2e8eff0d867a820211104075044.60c5615f5db2e8eff0d867d620211104075045
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:56.857
value:
"corpid='"+ st_corpid+"' "
iif( shzt==1, " verifierid is not null" , iif ( shzt==2, "verifierid is null ", ""))

beWhere_code(st_code)


id: 6183205499328c3820c0c9d3
pid: 6183205499328c3820c0c907
name: dynamicwhere2_tokens
code: 60c5615f5db2e8eff0d867d720211104075045
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a820211104075044
fullname: /dzpz_pz/dynamicwhere2_tokens
fullcode: 60c560a05db2e8eff0d867a820211104075044.60c5615f5db2e8eff0d867d720211104075045
nodetype: column
createdate: 2021.06.13 09:37:38.000
lastmodifieddate: 2025.02.24 16:57:56.857
value:
{
    "\"corpid='\"+ st_corpid+\"' \"": "st_corpid",
    "iif( shzt==1, \" verifierid is not null\" , iif ( shzt==2, \"verifierid is null \", \"\"))": "shzt",
    "beWhere_code(st_code)": "st_code"
}


id: 6183205599328c3820c0c9f7
pid: 6183205599328c3820c0c9f3
name: colsize
code: 60c562fa5db2e8eff0d8690e20211104075045
namepath: /dzpz_pz/id
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690c20211104075045
fullname: /dzpz_pz/id/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:31.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690c20211104075045.60c562fa5db2e8eff0d8690e20211104075045


id: 6183205599328c3820c0c9fb
pid: 6183205599328c3820c0c9f3
name: coltype
code: 60c562fa5db2e8eff0d8690d20211104075045
namepath: /dzpz_pz/id
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690c20211104075045
fullname: /dzpz_pz/id/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:30.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8690c20211104075045.60c562fa5db2e8eff0d8690d20211104075045


id: 6183205599328c3820c0ca03
pid: 6183205599328c3820c0c9ff
name: colsize
code: 60c562fa5db2e8eff0d8691520211104075045
namepath: /dzpz_pz/imgid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691020211104075045
fullname: /dzpz_pz/imgid/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:31.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691020211104075045.60c562fa5db2e8eff0d8691520211104075045


id: 6183205599328c3820c0ca07
pid: 6183205599328c3820c0c9ff
name: coltype
code: 60c562fa5db2e8eff0d8691320211104075045
namepath: /dzpz_pz/imgid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691020211104075045
fullname: /dzpz_pz/imgid/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:31.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691020211104075045.60c562fa5db2e8eff0d8691320211104075045


id: 6183205599328c3820c0ca0f
pid: 6183205599328c3820c0ca0b
name: coltype
code: 60c562fa5db2e8eff0d8691820211104075045
namepath: /dzpz_pz/lastmodifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045
fullname: /dzpz_pz/lastmodifieddate/coltype
nodetype: column
value: datetime
createdate: 2021.06.13 09:44:32.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691720211104075045.60c562fa5db2e8eff0d8691820211104075045


id: 6183205599328c3820c0ca1f
pid: 6183205599328c3820c0ca1b
name: colsize
code: 60c562fa5db2e8eff0d8691e20211104075045
namepath: /dzpz_pz/open_bill_with_url
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691c20211104075045
fullname: /dzpz_pz/open_bill_with_url/colsize
nodetype: column
value: 300
createdate: 2021.06.13 09:44:33.000
lastmodifieddate: 2025.02.24 16:57:56.857
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691c20211104075045.60c562fa5db2e8eff0d8691e20211104075045


id: 6183205599328c3820c0ca23
pid: 6183205599328c3820c0ca1b
name: coltype
code: 60c562fa5db2e8eff0d8691d20211104075045
namepath: /dzpz_pz/open_bill_with_url
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691c20211104075045
fullname: /dzpz_pz/open_bill_with_url/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:33.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8691c20211104075045.60c562fa5db2e8eff0d8691d20211104075045


id: 6183205599328c3820c0ca2f
pid: 6183205599328c3820c0ca2b
name: coltype
code: 60c562fa5db2e8eff0d8695620211104075045
namepath: /dzpz_pz/pz
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8695520211104075045
fullname: /dzpz_pz/pz/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:44.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8695520211104075045.60c562fa5db2e8eff0d8695620211104075045


id: 6183205599328c3820c0ca37
pid: 6183205599328c3820c0ca33
name: colsize
code: 60c562fa5db2e8eff0d8692220211104075045
namepath: /dzpz_pz/pzh
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692020211104075045
fullname: /dzpz_pz/pzh/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:34.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692020211104075045.60c562fa5db2e8eff0d8692220211104075045


id: 6183205599328c3820c0ca3b
pid: 6183205599328c3820c0ca33
name: coltype
code: 60c562fa5db2e8eff0d8692120211104075045
namepath: /dzpz_pz/pzh
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692020211104075045
fullname: /dzpz_pz/pzh/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:34.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692020211104075045.60c562fa5db2e8eff0d8692120211104075045


id: 6183205599328c3820c0ca4b
pid: 6183205599328c3820c0ca47
name: colsize
code: 60c7d4645db2f19751803a4f20211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/colsize
nodetype: column
createdate: 2021.06.15 06:15:12.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a4f20211104075045


id: 6183205599328c3820c0ca4f
pid: 6183205599328c3820c0ca47
name: coltype
code: 60c7d41b5db2f197518039d620211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/coltype
nodetype: column
value: int
createdate: 2021.06.15 06:11:52.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d41b5db2f197518039d620211104075045


id: 6183205599328c3820c0ca53
pid: 6183205599328c3820c0ca47
name: datamask
code: 60c7d4645db2f19751803a5220211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/datamask
nodetype: column
createdate: 2021.06.15 06:15:12.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a5220211104075045


id: 6183205599328c3820c0ca57
pid: 6183205599328c3820c0ca47
name: decimalcount
code: 60c7d4645db2f19751803a5020211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/decimalcount
nodetype: column
createdate: 2021.06.15 06:15:12.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a5020211104075045


id: 6183205599328c3820c0ca5b
pid: 6183205599328c3820c0ca47
name: defaultvalue
code: 60c7d4645db2f19751803a5120211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/defaultvalue
nodetype: column
createdate: 2021.06.15 06:15:12.000
lastmodifieddate: 2025.02.24 16:57:56.858
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a5120211104075045


id: 6183205599328c3820c0ca5f
pid: 6183205599328c3820c0ca47
name: description
code: 60c7d4645db2f19751803a5320211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/description
nodetype: column
createdate: 2021.06.15 06:15:13.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a5320211104075045


id: 6183205599328c3820c0ca63
pid: 6183205599328c3820c0ca47
name: dynamicwhere2_tokens
code: 60c7d4645db2f19751803a5420211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/dynamicwhere2_tokens
nodetype: column
value: {}
createdate: 2021.06.15 06:15:13.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a5420211104075045


id: 6183205599328c3820c0ca67
pid: 6183205599328c3820c0ca47
name: nullable
code: 60c7d4645db2f19751803a4420211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/nullable
nodetype: column
value: true
createdate: 2021.06.15 06:15:07.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a4420211104075045


id: 6183205599328c3820c0ca6b
pid: 6183205599328c3820c0ca47
name: smartretrieve
code: 60c7d4645db2f19751803a4620211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/smartretrieve
nodetype: column
value: false
createdate: 2021.06.15 06:15:07.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a4620211104075045


id: 6183205599328c3820c0ca6f
pid: 6183205599328c3820c0ca47
name: updatable
code: 60c7d4645db2f19751803a4520211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/updatable
nodetype: column
value: false
createdate: 2021.06.15 06:15:07.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a4520211104075045


id: 6183205599328c3820c0ca73
pid: 6183205599328c3820c0ca47
name: usedingroupby
code: 60c7d4645db2f19751803a4720211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/usedingroupby
nodetype: column
value: false
createdate: 2021.06.15 06:15:07.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a4720211104075045


id: 6183205599328c3820c0ca77
pid: 6183205599328c3820c0ca47
name: usedinsum
code: 60c7d4645db2f19751803a4820211104075045
namepath: /dzpz_pz/selected
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045
fullname: /dzpz_pz/selected/usedinsum
nodetype: column
value: false
createdate: 2021.06.15 06:15:07.000
lastmodifieddate: 2025.02.24 16:57:57.291
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d41b5db2f197518039d520211104075045.60c7d4645db2f19751803a4820211104075045


id: 6183205599328c3820c0ca7f
pid: 6183205499328c3820c0c907
name: sql
code: 60c5615f5db2e8eff0d867d420211104075045
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a820211104075044
fullname: /dzpz_pz/sql
fullcode: 60c560a05db2e8eff0d867a820211104075044.60c5615f5db2e8eff0d867d420211104075045
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:57.291
value:
select
  dzpz_pz.*,
  0 as selected,
  '' as tipinfo,
  case when verifierid is null then '校对' else '' end as c_sh1,
  case when verifierid is null then '' else '取消校对' end as c_sh2
from
  dzpz_pz
where
  ifnull(deleteflag, 0) = 0
order by
  ym,
  pzh


id: 6183205599328c3820c0ca8b
pid: 6183205599328c3820c0ca87
name: colsize
code: 60c562fa5db2e8eff0d8692820211104075045
namepath: /dzpz_pz/summary
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692420211104075045
fullname: /dzpz_pz/summary/colsize
nodetype: column
value: 200
createdate: 2021.06.13 09:44:35.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692420211104075045.60c562fa5db2e8eff0d8692820211104075045


id: 6183205599328c3820c0ca8f
pid: 6183205599328c3820c0ca87
name: coltype
code: 60c562fa5db2e8eff0d8692520211104075045
namepath: /dzpz_pz/summary
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692420211104075045
fullname: /dzpz_pz/summary/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:34.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692420211104075045.60c562fa5db2e8eff0d8692520211104075045


id: 6183205599328c3820c0ca9b
pid: 6183205599328c3820c0ca97
name: colsize
code: 60c800ef5db2d209d074b49b20211104075045
namepath: /dzpz_pz/tipinfo
codepath: 60c560a05db2e8eff0d867a820211104075044.60c800ef5db2d209d074b49920211104075045
fullname: /dzpz_pz/tipinfo/colsize
nodetype: column
value: 0
createdate: 2021.06.15 09:23:00.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c800ef5db2d209d074b49920211104075045.60c800ef5db2d209d074b49b20211104075045


id: 6183205599328c3820c0cab3
pid: 6183205599328c3820c0caaf
name: colsize
code: 60c562fa5db2e8eff0d8692c20211104075045
namepath: /dzpz_pz/url_img
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692a20211104075045
fullname: /dzpz_pz/url_img/colsize
nodetype: column
value: 1000
createdate: 2021.06.13 09:44:36.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692a20211104075045.60c562fa5db2e8eff0d8692c20211104075045


id: 6183205599328c3820c0cab7
pid: 6183205599328c3820c0caaf
name: coltype
code: 60c562fa5db2e8eff0d8692b20211104075045
namepath: /dzpz_pz/url_img
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692a20211104075045
fullname: /dzpz_pz/url_img/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:35.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692a20211104075045.60c562fa5db2e8eff0d8692b20211104075045


id: 6183205599328c3820c0cabf
pid: 6183205599328c3820c0cabb
name: colsize
code: 60c562fa5db2e8eff0d8693020211104075045
namepath: /dzpz_pz/url_thumbnail
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692e20211104075045
fullname: /dzpz_pz/url_thumbnail/colsize
nodetype: column
value: 1000
createdate: 2021.06.13 09:44:36.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692e20211104075045.60c562fa5db2e8eff0d8693020211104075045


id: 6183205599328c3820c0cac3
pid: 6183205599328c3820c0cabb
name: coltype
code: 60c562fa5db2e8eff0d8692f20211104075045
namepath: /dzpz_pz/url_thumbnail
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692e20211104075045
fullname: /dzpz_pz/url_thumbnail/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:36.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8692e20211104075045.60c562fa5db2e8eff0d8692f20211104075045


id: 6183205599328c3820c0cacb
pid: 6183205599328c3820c0cac7
name: coltype
code: 60c562fa5db2e8eff0d8693520211104075045
namepath: /dzpz_pz/userid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693420211104075045
fullname: /dzpz_pz/userid/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:37.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693420211104075045.60c562fa5db2e8eff0d8693520211104075045


id: 6183205599328c3820c0cad3
pid: 6183205599328c3820c0cacf
name: colsize
code: 60c562fa5db2e8eff0d8693920211104075045
namepath: /dzpz_pz/username
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693720211104075045
fullname: /dzpz_pz/username/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:38.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693720211104075045.60c562fa5db2e8eff0d8693920211104075045


id: 6183205599328c3820c0cad7
pid: 6183205599328c3820c0cacf
name: coltype
code: 60c562fa5db2e8eff0d8693820211104075045
namepath: /dzpz_pz/username
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693720211104075045
fullname: /dzpz_pz/username/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:38.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693720211104075045.60c562fa5db2e8eff0d8693820211104075045


id: 6183205599328c3820c0cadf
pid: 6183205599328c3820c0cadb
name: coltype
code: 60c562fa5db2e8eff0d8693c20211104075045
namepath: /dzpz_pz/verifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045
fullname: /dzpz_pz/verifieddate/coltype
nodetype: column
value: datetime
createdate: 2021.06.13 09:44:39.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045.60c562fa5db2e8eff0d8693c20211104075045


id: 6183205599328c3820c0cae3
pid: 6183205599328c3820c0cadb
name: nullable
code: 60c7f6715db2d209d074b40520211104075045
namepath: /dzpz_pz/verifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045
fullname: /dzpz_pz/verifieddate/nullable
nodetype: column
value: true
createdate: 2021.06.15 08:56:55.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045.60c7f6715db2d209d074b40520211104075045


id: 6183205599328c3820c0cae7
pid: 6183205599328c3820c0cadb
name: smartretrieve
code: 60c7f6715db2d209d074b40720211104075045
namepath: /dzpz_pz/verifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045
fullname: /dzpz_pz/verifieddate/smartretrieve
nodetype: column
value: false
createdate: 2021.06.15 08:56:56.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045.60c7f6715db2d209d074b40720211104075045


id: 6183205599328c3820c0caeb
pid: 6183205599328c3820c0cadb
name: updatable
code: 60c7f6715db2d209d074b40620211104075045
namepath: /dzpz_pz/verifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045
fullname: /dzpz_pz/verifieddate/updatable
nodetype: column
value: true
createdate: 2021.06.15 08:56:55.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045.60c7f6715db2d209d074b40620211104075045


id: 6183205599328c3820c0caef
pid: 6183205599328c3820c0cadb
name: usedingroupby
code: 60c7f6715db2d209d074b40820211104075045
namepath: /dzpz_pz/verifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045
fullname: /dzpz_pz/verifieddate/usedingroupby
nodetype: column
value: false
createdate: 2021.06.15 08:56:56.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045.60c7f6715db2d209d074b40820211104075045


id: 6183205599328c3820c0caf3
pid: 6183205599328c3820c0cadb
name: usedinsum
code: 60c7f6715db2d209d074b40920211104075045
namepath: /dzpz_pz/verifieddate
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045
fullname: /dzpz_pz/verifieddate/usedinsum
nodetype: column
value: false
createdate: 2021.06.15 08:56:56.000
lastmodifieddate: 2025.02.24 16:57:57.292
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693b20211104075045.60c7f6715db2d209d074b40920211104075045


id: 6183205599328c3820c0cafb
pid: 6183205599328c3820c0caf7
name: coltype
code: 60c562fa5db2e8eff0d8693f20211104075045
namepath: /dzpz_pz/verifierid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045
fullname: /dzpz_pz/verifierid/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:39.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045.60c562fa5db2e8eff0d8693f20211104075045


id: 6183205599328c3820c0caff
pid: 6183205599328c3820c0caf7
name: nullable
code: 60c7f6715db2d209d074b41a20211104075045
namepath: /dzpz_pz/verifierid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045
fullname: /dzpz_pz/verifierid/nullable
nodetype: column
value: true
createdate: 2021.06.15 09:04:50.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045.60c7f6715db2d209d074b41a20211104075045


id: 6183205599328c3820c0cb03
pid: 6183205599328c3820c0caf7
name: smartretrieve
code: 60c7f6715db2d209d074b41c20211104075045
namepath: /dzpz_pz/verifierid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045
fullname: /dzpz_pz/verifierid/smartretrieve
nodetype: column
value: false
createdate: 2021.06.15 09:04:51.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045.60c7f6715db2d209d074b41c20211104075045


id: 6183205599328c3820c0cb07
pid: 6183205599328c3820c0caf7
name: updatable
code: 60c7f6715db2d209d074b41b20211104075045
namepath: /dzpz_pz/verifierid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045
fullname: /dzpz_pz/verifierid/updatable
nodetype: column
value: true
createdate: 2021.06.15 09:04:51.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045.60c7f6715db2d209d074b41b20211104075045


id: 6183205599328c3820c0cb0b
pid: 6183205599328c3820c0caf7
name: usedingroupby
code: 60c7f6715db2d209d074b41d20211104075045
namepath: /dzpz_pz/verifierid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045
fullname: /dzpz_pz/verifierid/usedingroupby
nodetype: column
value: false
createdate: 2021.06.15 09:04:51.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045.60c7f6715db2d209d074b41d20211104075045


id: 6183205599328c3820c0cb0f
pid: 6183205599328c3820c0caf7
name: usedinsum
code: 60c7f6715db2d209d074b41e20211104075045
namepath: /dzpz_pz/verifierid
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045
fullname: /dzpz_pz/verifierid/usedinsum
nodetype: column
value: false
createdate: 2021.06.15 09:04:51.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8693e20211104075045.60c7f6715db2d209d074b41e20211104075045


id: 6183205599328c3820c0cb17
pid: 6183205599328c3820c0cb13
name: colsize
code: 60c562fa5db2e8eff0d8694320211104075045
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/colsize
nodetype: column
value: 40
createdate: 2021.06.13 09:44:40.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c562fa5db2e8eff0d8694320211104075045


id: 6183205599328c3820c0cb1b
pid: 6183205599328c3820c0cb13
name: coltype
code: 60c562fa5db2e8eff0d8694220211104075045
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:40.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c562fa5db2e8eff0d8694220211104075045


id: 6183205599328c3820c0cb1f
pid: 6183205599328c3820c0cb13
name: nullable
code: 60c800ef5db2d209d074b4ab20211104075045
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/nullable
nodetype: column
value: true
createdate: 2021.06.15 09:25:32.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c800ef5db2d209d074b4ab20211104075045


id: 6183205599328c3820c0cb23
pid: 6183205599328c3820c0cb13
name: smartretrieve
code: 60c800ef5db2d209d074b4ad20211104075046
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/smartretrieve
nodetype: column
value: false
createdate: 2021.06.15 09:25:33.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c800ef5db2d209d074b4ad20211104075046


id: 6183205599328c3820c0cb27
pid: 6183205599328c3820c0cb13
name: updatable
code: 60c800ef5db2d209d074b4ac20211104075046
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/updatable
nodetype: column
value: true
createdate: 2021.06.15 09:25:33.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c800ef5db2d209d074b4ac20211104075046


id: 6183205599328c3820c0cb2b
pid: 6183205599328c3820c0cb13
name: usedingroupby
code: 60c800ef5db2d209d074b4ae20211104075046
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/usedingroupby
nodetype: column
value: false
createdate: 2021.06.15 09:25:34.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c800ef5db2d209d074b4ae20211104075046


id: 6183205599328c3820c0cb2f
pid: 6183205599328c3820c0cb13
name: usedinsum
code: 60c800ef5db2d209d074b4af20211104075046
namepath: /dzpz_pz/verifiername
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045
fullname: /dzpz_pz/verifiername/usedinsum
nodetype: column
value: false
createdate: 2021.06.15 09:25:35.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694120211104075045.60c800ef5db2d209d074b4af20211104075046


id: 6183205599328c3820c0cb37
pid: 6183205599328c3820c0cb33
name: colsize
code: 60c562fa5db2e8eff0d8695020211104075046
namepath: /dzpz_pz/xm
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694e20211104075046
fullname: /dzpz_pz/xm/colsize
nodetype: column
value: 200
createdate: 2021.06.13 09:44:43.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694e20211104075046.60c562fa5db2e8eff0d8695020211104075046


id: 6183205599328c3820c0cb3b
pid: 6183205599328c3820c0cb33
name: coltype
code: 60c562fa5db2e8eff0d8694f20211104075046
namepath: /dzpz_pz/xm
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694e20211104075046
fullname: /dzpz_pz/xm/coltype
nodetype: column
value: varchar
createdate: 2021.06.13 09:44:42.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694e20211104075046.60c562fa5db2e8eff0d8694f20211104075046


id: 6183205599328c3820c0cb43
pid: 6183205599328c3820c0cb3f
name: coltype
code: 60c562fa5db2e8eff0d8694620211104075046
namepath: /dzpz_pz/ym
codepath: 60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694520211104075046
fullname: /dzpz_pz/ym/coltype
nodetype: column
value: int
createdate: 2021.06.13 09:44:41.000
lastmodifieddate: 2025.02.24 16:57:57.293
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c562fa5db2e8eff0d8694520211104075046.60c562fa5db2e8eff0d8694620211104075046


id: 60ab9dd75db2a837c83ac52b
pid: 60a31c475db27838e0c0134b
name: dynamicwhere2
code: 60ab9dd75db2a837c83ac52b
namepath: /dzpz_pz
codepath: 60a31c475db27838e0c0134b
fullname: /dzpz_pz/dynamicwhere2
fullcode: 60a31c475db27838e0c0134b.60ab9dd75db2a837c83ac52b
nodetype: column
createdate: 2021.05.24 20:51:58.000
lastmodifieddate: 2025.02.24 16:57:58.567
value:
"  corpid='"+ corpid+"' "
"ym="+ym
"pzh like '%"+pzh+"%' "
" bm like '%"+bm+"%' "
 " labeldata->'$."+'"'+labelname+ '"'+ "'  like  '%"+labelvalue+"%' "


id: 60ab9dd75db2a837c83ac52c
pid: 60a31c475db27838e0c0134b
name: dynamicwhere2_tokens
code: 60ab9dd75db2a837c83ac52c
namepath: /dzpz_pz
codepath: 60a31c475db27838e0c0134b
fullname: /dzpz_pz/dynamicwhere2_tokens
fullcode: 60a31c475db27838e0c0134b.60ab9dd75db2a837c83ac52c
nodetype: column
createdate: 2021.05.24 20:51:58.000
lastmodifieddate: 2025.02.24 16:57:58.567
value:
{
    "\"  corpid='\"+ corpid+\"' \"": "corpid",
    "\"ym=\"+ym": "ym",
    "\"pzh like '%\"+pzh+\"%' \"": "pzh",
    "\" bm like '%\"+bm+\"%' \"": "bm",
    "\" labeldata->'$.\"+'\"'+labelname+ '\"'+ \"'  like  '%\"+labelvalue+\"%' \"": "labelname,labelvalue"
}


id: 60c5615f5db2e8eff0d867d5
pid: 60c560a05db2e8eff0d867a8
name: dynamicwheredata2
code: 60c5615f5db2e8eff0d867d5
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a8
fullname: /dzpz_pz/dynamicwheredata2
fullcode: 60c560a05db2e8eff0d867a8.60c5615f5db2e8eff0d867d5
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:59.433
value:
st_corpid:main!st_corpid
shzt:main!shzt
ym:main!ym
st_username:main!st_username
pzh1:main!pzh_prefix+main!pzh1
pzh2:main!pzh_prefix+main!pzh2


id: 60c5615f5db2e8eff0d867d6
pid: 60c560a05db2e8eff0d867a8
name: dynamicwhere2
code: 60c5615f5db2e8eff0d867d6
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a8
fullname: /dzpz_pz/dynamicwhere2
fullcode: 60c560a05db2e8eff0d867a8.60c5615f5db2e8eff0d867d6
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:57:59.433
value:
"corpid='"+ st_corpid+"' "
iif( shzt==1, " verifierid is not null" , iif ( shzt==2, "verifierid is null ", ""))
"ym="+ym
"username="+st_username
"pzh >= '"+pzh1+"' "
"pzh <= '"+pzh2+"' "


id: 60c5615f5db2e8eff0d867d7
pid: 60c560a05db2e8eff0d867a8
name: dynamicwhere2_tokens
code: 60c5615f5db2e8eff0d867d7
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a8
fullname: /dzpz_pz/dynamicwhere2_tokens
fullcode: 60c560a05db2e8eff0d867a8.60c5615f5db2e8eff0d867d7
nodetype: column
createdate: 2021.06.13 09:37:38.000
lastmodifieddate: 2025.02.24 16:57:59.433
value:
{
    "\"corpid='\"+ st_corpid+\"' \"": "st_corpid",
    "iif( shzt==1, \" verifierid is not null\" , iif ( shzt==2, \"verifierid is null \", \"\"))": "shzt",
    "\"ym=\"+ym": "ym",
    "\"username=\"+st_username": "st_username",
    "\"pzh >= '\"+pzh1+\"' \"": "pzh1",
    "\"pzh <= '\"+pzh2+\"' \"": "pzh2"
}


id: 6183205599328c3820c0ca9f
pid: 6183205599328c3820c0ca97
name: coltype
code: 60c800ef5db2d209d074b49a20211104075045
namepath: /dzpz_pz/tipinfo
codepath: 60c560a05db2e8eff0d867a820211104075044.60c800ef5db2d209d074b49920211104075045
fullname: /dzpz_pz/tipinfo/coltype
nodetype: column
value: text
createdate: 2021.06.15 09:23:00.000
lastmodifieddate: 2025.02.24 16:58:00.305
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c800ef5db2d209d074b49920211104075045.60c800ef5db2d209d074b49a20211104075045


id: 6183205499328c3820c0c967
pid: 6183205499328c3820c0c95f
name: coltype
code: 60c7d6795db2f19751803b0520211104075044
namepath: /dzpz_pz/c_sh1
codepath: 60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0420211104075044
fullname: /dzpz_pz/c_sh1/coltype
nodetype: column
value: text
createdate: 2021.06.15 06:21:58.000
lastmodifieddate: 2025.02.24 16:58:00.305
fullcode:
60c560a05db2e8eff0d867a820211104075044.60c7d6795db2f19751803b0420211104075044.60c7d6795db2f19751803b0520211104075044


id: 60c5615f5db2e8eff0d867d4
pid: 60c560a05db2e8eff0d867a8
name: sql
code: 60c5615f5db2e8eff0d867d4
namepath: /dzpz_pz
codepath: 60c560a05db2e8eff0d867a8
fullname: /dzpz_pz/sql
fullcode: 60c560a05db2e8eff0d867a8.60c5615f5db2e8eff0d867d4
nodetype: column
createdate: 2021.06.13 09:37:37.000
lastmodifieddate: 2025.02.24 16:58:00.305
value:
select
  dzpz_pz.*,
  0 as selected,
  '' as tipinfo,
  case when verifierid is null then '校对' else '' end as c_sh1,
  case when verifierid is null then '' else '取消' end as c_sh2
from
  dzpz_pz
where
  corpid= ':st_corpid {00}' 
  and isnull(deleteflag, 0) = 0 
order by
  ym,
  pzh


# app_script

id: 60a321f05db27838e0c014bf
pid: templateScriptOnServer
name: templateScriptOnServer-60a321f05db27838e0c014bf
code: 60a321f05db27838e0c014bf
fullname: /templateScriptOnServer-60a321f05db27838e0c014bf
fullcode: 60a321f05db27838e0c014bf
nodetype: leaf
lastmodifieddate: 2025.02.24 16:58:01.385
value:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount = config.onceCount;
    if (onceCount == undefined) onceCount = 500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  (gguid='" + config.gguid +
        "'  or groupname='设备自动上传' ) and ifnull(info2,'')=''  order by  "+ runTask('imgOrderBy',{});
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println(ret);
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };


}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;
}

//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid, ym) {
    return runTask("getPZHPrefix", { ym: ym, corpid: corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", { corpid: corpid }));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config) {
    config.src = config.src.replace(/电子凭证/g, ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage('pz_ocr', { action: 'info', message: config.src }, currentUserId());
    var ret = OCR(config);
    println(ret);
    var t = ret.text || '';
    if (t == '') return '';

    //下面的算法， 根据每家凭证号的特点需要定制
    t = t.replace(/\s/g, '');
    var n = '' + t.match(/20[0-9]{2}-[0-9]{2}-[0-9]{2}/g);
    println(n);
    if(n)
    { 
    ym = '' + n;

    println( typeof( ym));

    ym = ym.replace(/[-]/g, '');
    if (ym.length > 6) ym = ym.substring(2, 6)   ;
    println(ym);
    }else{
        println("无法识别年月");
    }
    p = t.indexOf('第');
    if (p < 0) return '';
    t = t.substring(p + 1);
    p = t.substring(0, 4)

    return ym + right('0000' + p, 4);


}


id: 60a31c475db27838e0c01344
pid: templateScriptOnServer
name: templateScriptOnServer-60a31c475db27838e0c01344
code: 60a31c475db27838e0c01344
fullname: /templateScriptOnServer-60a31c475db27838e0c01344
fullcode: 60a31c475db27838e0c01344
nodetype: leaf
lastmodifieddate: 2025.02.24 16:58:01.385
value:
function saveLabel(corpid,data) {
    println(data.length);
    println("=====");
    println(JSON.stringify(data));
     

    var labels={};
    var dzpz_pz_ds = newDataStore("", "select * from dzpz_pz");
    dzpz_pz_ds.setUpdateProperty("dzpz_pz", "id", "*", "id");

    for (var i = 0; i < data.length; i++) {
        var one = data[i];

        var ym = one['记帐期'];
        var pzh = one['凭证号'];
        println(pzh);
        dzpz_pz_ds.retrieve(" corpid='" +  corpid + "' and  ym=" + ym + " and pzh='" + pzh + "'");
        var t = dzpz_pz_ds.getString(0, "labeldata");
        var id = dzpz_pz_ds.getString(0, "id");
        try {
            if (t != '') {
                t = JSON.parse(t);
            } else { t = {}; }
        } catch (err) {
            t = {};
        }
        println(typeof (t));
        if (typeof (t) != 'object') t = {};

        for (var p in one) {
            if( labels[p]==undefined) labels[p]=1;//记录下标签名称 
            var v = one[p];
            t[p] = v;
        }

        t = JSON.stringify(t);
        runSQL("", "update dzpz_pz set  labeldata='" + t + "' where  corpid='" + corpid  + "' and  ym=" + ym + " and pzh='" + pzh + "' and id='" + id + "'   ", true);

    }

    //最后再把标签名称保存一下
    runTask("保存标签名称" , { labels: Object.keys(labels) },10); //延时

}


id: 60a3505f5db27838e0c01592
pid: 60a321f05db27838e0c014bf
name: functionGroup
code: 60a3505f5db27838e0c01592
namepath: /templateScriptOnServer-60a321f05db27838e0c014bf
codepath: 60a321f05db27838e0c014bf
fullname: /templateScriptOnServer-60a321f05db27838e0c014bf/functionGroup
fullcode: 60a321f05db27838e0c014bf.60a3505f5db27838e0c01592
nodetype: column
createdate: 2021.05.18 16:22:19.000
lastmodifieddate: 2025.02.24 16:58:01.385
value:
{"全局函数":[{"source":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)\nfunction getImagePoolGGUID()","comment":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)","group":"","caption":"得到当前操作员待归档图片对应的GGUID","needRightControl":"false","func":"getImagePoolGGUID","funcTitle":"function getImagePoolGGUID","index":0},{"source":"function getImagePoolBlockSize()","comment":"","group":"","caption":"","needRightControl":"","func":"getImagePoolBlockSize","funcTitle":"function getImagePoolBlockSize","index":1},{"source":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)\nfunction setImagePoolBlockSize(id, blockSize)","comment":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)","group":"","caption":"保存当前的缩略图大小","needRightControl":"false","func":"setImagePoolBlockSize","funcTitle":"function setImagePoolBlockSize","index":2},{"source":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)\nfunction loadImagePoolData(config)","comment":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)","group":"","caption":"得到待归档的图片清单","needRightControl":"true","func":"loadImagePoolData","funcTitle":"function loadImagePoolData","index":3},{"source":"function getTotalImageCount()","comment":"","group":"","caption":"","needRightControl":"","func":"getTotalImageCount","funcTitle":"function getTotalImageCount","index":4},{"source":"//@comment (group=,caption=保存监控目录设置,needRightControl=false)\nfunction setMonitePath(hostName, path)","comment":"//@comment (group=,caption=保存监控目录设置,needRightControl=false)","group":"","caption":"保存监控目录设置","needRightControl":"false","func":"setMonitePath","funcTitle":"function setMonitePath","index":5},{"source":"//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)\nfunction getMonitePath(hostName)","comment":"//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)","group":"","caption":"获取指定机器的监控目录","needRightControl":"false","func":"getMonitePath","funcTitle":"function getMonitePath","index":6},{"source":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)\nfunction getPZFJ(id)","comment":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)","group":"","caption":"构建凭证附件清单","needRightControl":"false","func":"getPZFJ","funcTitle":"function getPZFJ","index":7},{"source":"//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)\nfunction putImageBackToPool(id)","comment":"//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)","group":"","caption":"把凭证中的附件图片回归到待归档池中","needRightControl":"false","func":"putImageBackToPool","funcTitle":"function putImageBackToPool","index":8},{"source":"//@comment (group=,caption=追加图片到凭证中,needRightControl=false)\nfunction addImageToPZ(pzid, images)","comment":"//@comment (group=,caption=追加图片到凭证中,needRightControl=false)","group":"","caption":"追加图片到凭证中","needRightControl":"false","func":"addImageToPZ","funcTitle":"function addImageToPZ","index":9},{"source":"function deletePZAndPutBackToPool(id)","comment":"","group":"","caption":"","needRightControl":"","func":"deletePZAndPutBackToPool","funcTitle":"function deletePZAndPutBackToPool","index":10},{"source":"function moveImageToRecycle(id)","comment":"","group":"","caption":"","needRightControl":"","func":"moveImageToRecycle","funcTitle":"function moveImageToRecycle","index":11},{"source":"//@comment (group=,caption=凭证号前缀,needRightControl=false)\nfunction getPZHPrefix(corpid, ym)","comment":"//@comment (group=,caption=凭证号前缀,needRightControl=false)","group":"","caption":"凭证号前缀","needRightControl":"false","func":"getPZHPrefix","funcTitle":"function getPZHPrefix","index":12},{"source":"//@comment (group=,caption=凭证号长度,needRightControl=false)\nfunction getPZHLen(corpid)","comment":"//@comment (group=,caption=凭证号长度,needRightControl=false)","group":"","caption":"凭证号长度","needRightControl":"false","func":"getPZHLen","funcTitle":"function getPZHLen","index":13},{"source":"function getLastPZH(corpid, ym)","comment":"","group":"","caption":"","needRightControl":"","func":"getLastPZH","funcTitle":"function getLastPZH","index":14},{"source":"function do_imageRotate(id, rt)","comment":"","group":"","caption":"","needRightControl":"","func":"do_imageRotate","funcTitle":"function do_imageRotate","index":15},{"source":"function reorderImageFileIndex(imgs)","comment":"","group":"","caption":"","needRightControl":"","func":"reorderImageFileIndex","funcTitle":"function reorderImageFileIndex","index":16},{"source":"function back_ocr(config)","comment":"","group":"","caption":"","needRightControl":"","func":"back_ocr","funcTitle":"function back_ocr","index":17}]}


id: 60a370d25db2863f93619766
pid: 60a321f05db27838e0c014bf
name: functionlist
code: 60a370d25db2863f93619766
namepath: /templateScriptOnServer-60a321f05db27838e0c014bf
codepath: 60a321f05db27838e0c014bf
fullname: /templateScriptOnServer-60a321f05db27838e0c014bf/functionlist
fullcode: 60a321f05db27838e0c014bf.60a370d25db2863f93619766
nodetype: column
createdate: 2021.05.18 16:22:20.000
lastmodifieddate: 2025.02.24 16:58:01.385
value:
["back_ocr","reorderImageFileIndex","do_imageRotate","getLastPZH","getPZHLen","getPZHPrefix","moveImageToRecycle","deletePZAndPutBackToPool","addImageToPZ","putImageBackToPool","getPZFJ","getMonitePath","setMonitePath","getTotalImageCount","loadImagePoolData","setImagePoolBlockSize","getImagePoolBlockSize","getImagePoolGGUID"]


id: 60c1c2469932e1a17db2e49e
pid: 60a31c3c5db27838e0c0129e
name: functionGroup
code: 60c1c2469932e1a17db2e49e
namepath: /templateScriptOnServer-60a31c3c5db27838e0c0129e
codepath: 60a31c3c5db27838e0c0129e
fullname: /templateScriptOnServer-60a31c3c5db27838e0c0129e/functionGroup
fullcode: 60a31c3c5db27838e0c0129e.60c1c2469932e1a17db2e49e
nodetype: column
createdate: 2021.06.10 16:03:01.000
lastmodifieddate: 2025.02.24 16:58:01.386
value:
{"全局函数":[{"source":"function getImageList1()","comment":"","group":"","caption":"","needRightControl":"","func":"getImageList1","funcTitle":"function getImageList1","index":0},{"source":"function getImageList2()","comment":"","group":"","caption":"","needRightControl":"","func":"getImageList2","funcTitle":"function getImageList2","index":1},{"source":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)\nfunction getImageList(groupName)","comment":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)","group":"","caption":"得到待归档的图片清单","needRightControl":"true","func":"getImageList","funcTitle":"function getImageList","index":2},{"source":"function back_repair(url, pzh)","comment":"","group":"","caption":"","needRightControl":"","func":"back_repair","funcTitle":"function back_repair","index":4}],"单据":[{"source":"//@comment (group=单据,caption=单据删除语句执行后)\nfunction afterBillDeleteOnServer(gguid, session)","comment":"//@comment (group=单据,caption=单据删除语句执行后)","group":"单据","caption":"单据删除语句执行后","needRightControl":"","func":"afterBillDeleteOnServer","funcTitle":"function afterBillDeleteOnServer","index":3}]}


id: 60c56f335db26ca8759b1566
pid: 60c4bd735db2478f9c5a1118
name: finalscript
code: 60c56f335db26ca8759b1566
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118
codepath: 60c4bd735db2478f9c5a1118
fullname: /templateScriptOnServer-60c4bd735db2478f9c5a1118/finalscript
fullcode: 60c4bd735db2478f9c5a1118.60c56f335db26ca8759b1566
nodetype: column
createdate: 2021.06.13 10:47:52.000
lastmodifieddate: 2025.02.24 16:58:01.387
value:
//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    var ds = newDataStore("", "select id ,   url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id +
      "'  order by  " + runTask('imgOrderBy',{})  );
    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {

        var one = JSON.parse(ds.getJSONRow(i, true));
        one.url_img = one.url_img + "&imageForceWatermark=false"
        ret.push(one);

    }
    return ret;

}

//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}


function setImageGroupName( id , groupname)
{
    var ds = newDataStore("", "select id ,   groupname   from  dzpz_pzfj where  id='" + id + "'  ");
    var n = ds.retrieve();
    ds.setUpdateProperty("dzpz_pzfj","id","*","id");

    ds.setValue(0,"groupname", groupname);
    ds.update(true); 
     

}

function get_PZ_PDF_URL(id) {
    return  safeURL(  getStringFromSQL("select url_img from app_archive where gguid='" + id + "'") ) ;
}

//单独设置某张图片的序号
function back_setImageOrder(gguid, id, order) {
    var ds = newDataStore("", `select *  from  dzpz_pzfj where  gguid='${gguid}' order by  ` + runTask('imgOrderBy',{})  );
    ds.setUpdateProperty("dzpz_pzfj", "id", "*", "id");
    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());
    println(n);

    if( order>n)  order=n; 

    var old_xh = 0;
    for (var i = 0; i < n; i++) {

        var xh = right('0000' + (i + 1), 4);
        ds.setValue(i, "info2", xh);

        if (ds.getString(i, "id") == id) {

            old_xh = i + 1;
            xh = right('0000' + order, 4);
            ds.setValue(i, "info2", xh);
            println( "set   "+ i+" row , xh="+ xh );
        }
    }

//往后调
// 则把在此图片之后的图片到新位置之前的图片的序号减1
    if (order > old_xh) {
        for (var i = old_xh; i < order; i++) {
            var xh = right('0000' + (i), 4);
            ds.setValue(i, "info2", xh);
            println( "change  "+ i+" row , xh="+ xh );
        }

    } else {
        //往前调，则把新位置之后的图片到当前图片序号之间的图片的序号加1 
        //下面的 i , row  +1 , -1 是看着数据试验出来 的结果，不要凭空去想象
        for (var row = order -1    ; row < old_xh -1 ; row++) {
            var i= row+1; 
            var xh = right('0000' + (i + 1), 4);
            ds.setValue(row, "info2", xh);
            println( "change  "+ row +" row , xh="+ xh );
        }
    }




    if (!ds.update(true)) println(ds.getErrorMessage());
    return true;
}

function reOrderImage(ids) {
    var sqls = [];
    for (var i = 0; i < ids.length; i++) {
        var xh = right('0000' + (i + 1), 4);
        sqls.push("update dzpz_pzfj set info2 ='" + xh + "' where id='" + ids[i] + "' ");
    }
    runSQL("", sqls, true);
    println("调整顺序完成");

}


//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid, ym) {
    return runTask("getPZHPrefix", { corpid: corpid, ym: ym });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", { corpid: corpid }));
}



//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)
function do_sh(id, sh) {


    //if (!isRoleGrantedToUser(currentUserId(), "60c81b135db2d209d074b697")) return { success: false, message: "没有审核权限" };



    var dzpz_ds = newDataStore("", "select * from dzpz_pz where id='" + id + "'");
    dzpz_ds.setUpdateProperty("dzpz_pz", "id", "*", "id");
    dzpz_ds.retrieve();
    if (dzpz_ds.getRowCount() == 0) {
        return { success: false, message: "凭证不存在" };
    }
    if (sh) //做审核
    {
        var verifierid = dzpz_ds.getInt(0, "verifierid");
        if (verifierid != 0) return {
            success: true, verifierid: verifierid,
            verifiername: dzpz_ds.getString(0, "verifiername"),
            verifieddate: dzpz_ds.getString(0, "verifieddate"), message: "凭证已审核，不需要重复审核"
        };
        dzpz_ds.setValue(0, "verifierid", currentUserId());
        dzpz_ds.setValue(0, "verifiername", currentUserShowName());
        dzpz_ds.setValue(0, "verifieddate", newDate());

        if (!dzpz_ds.update(true)) return { success: false, message: dzpz_ds.getError().getMessage() };

        //审核后，归档
        runTask("pz_image2pdf", {
            id: id,
            overwrite: true  //如果已存在，删除并重新生成
        });

        return {
            success: true,
            verifierid: dzpz_ds.getString(0, "verifierid"),
            verifiername: dzpz_ds.getString(0, "verifiername"),
            verifieddate: dzpz_ds.getString(0, "verifieddate")
        };

    } else {
        //取消审核
        //取消审核时， 看看图片是不是没有，如果没有，那么从PDF中取出图片，并加到凭证的图片清单中
        if(  getIntFromSQL( `select count(*) from dzpz_pzfj where gguid='${id}' `  ) ==0 )
        {
            println( '凭证图片没有，只有PDf，现在从PDF中取出图片');
            var pzh= dzpz_ds.getString(0,"pzh");
            var url= getStringFromSQL( ` select url_img from app_archive  where  gguid= '${id}' ` );
            if( url=='') return {success:false, message:'没有图片清单，从PDF中修复，但是pdf文件又不存在'};
            var c = back_repair( id, url , pzh );

            dzpz_ds.setValue( 0,"attachmentcount", c);
            dzpz_ds.setValue( 0,"pz", 1);
            dzpz_ds.setValue( 0,"fj", c -1);
            dzpz_ds.update(true);

        }

        if( getIntFromSQL( `select count(*) from dzpz_pzfj where gguid='${id}' `  ) ==0 )
        {
            return  {success:false, message:'没有图片清单，禁止取消审核'};
        }


        var verifierid = dzpz_ds.getInt(0, "verifierid");
        println(verifierid);
        if (verifierid == 0) return { success: true, message: "凭证尚未审核，不需要取消审核" };
        if (verifierid != currentUserId()) {
            if (!isRoleGrantedToUser(currentUserId(), "60c81b135db2d209d074b6a7") && currentUserId() != 1) {

                return { success: false, message: "必须由审核人或超级审核员来取消审核" };
            }
        }
        dzpz_ds.setValue(0, "verifierid", null);
        dzpz_ds.setValue(0, "verifiername", null);
        dzpz_ds.setValue(0, "verifieddate", null);

        if (!dzpz_ds.update(true)) return { success: false, message: dzpz_ds.getError().getMessage() };
        return { success: true };
    }

}


function back_repair(gguid, url, pzh) {
    var result = extractImagesFromPDF( safeURL(url), pzh, 4 * 1024); //小于 4k的忽略 ，pdf中每个图片右上角有一个凭证号的小图片，这个需要排除掉
    println("currentguid= "+ gguid  );
    println(result);
    var imgs = result.imgs;
    for (var i = 0; i < imgs.length; i++) {
        uploadFile({
            file: imgs[i].path,
            serverIndex: 2,
            logTable: 'dzpz_pzfj',
            tableName: 'dzpz_pz',
            gguid: gguid,
            groupName: i == 0 ? "凭证" : "附件",
            info1: imgs[i].createDate
        });
    }

    return imgs.length;  
}


//@comment (group=,caption=图片旋转,needRightControl=false)
function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_pzfj", id, rt);
    println(JSON.stringify(ret));
    return ret;
}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}

  

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount = config.onceCount;
    if (onceCount == undefined) onceCount = 500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  (gguid='" + config.gguid +
        "'  or groupname='设备自动上传' ) and ifnull(info2,'')=''  order by  "+ runTask('imgOrderBy',{});
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println(ret);
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };


}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

 
//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}


function   影像主文档名称()
{
    return  getProperty( '/影像名称/主文档名称', '凭证') ;
}


//把指定id的凭证附件图片做裁剪
function back_imageCrop( id, config)
{
    return  imageCrop( "", "dzpz_pzfj" , id , config);
}

//图片还原
function back_imageRevertToOriginal( id)
{
    return  imageRevertToOriginal("", "dzpz_pzfj" , id );
}


id: 60c7e1015db21cf830816006
pid: 60c4bd735db2478f9c5a1118
name: functionlist
code: 60c7e1015db21cf830816006
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118
codepath: 60c4bd735db2478f9c5a1118
fullname: /templateScriptOnServer-60c4bd735db2478f9c5a1118/functionlist
fullcode: 60c4bd735db2478f9c5a1118.60c7e1015db21cf830816006
nodetype: column
createdate: 2021.06.15 07:06:42.000
lastmodifieddate: 2025.02.24 16:58:01.387
value:
["back_imageRevertToOriginal","back_imageCrop","影像主文档名称","addImageToPZ","getTotalImageCount","loadImagePoolData","setImagePoolBlockSize","getImagePoolBlockSize","putImageBackToPool","do_imageRotate","back_repair","do_sh","getPZHLen","getPZHPrefix","reOrderImage","back_setImageOrder","get_PZ_PDF_URL","setImageGroupName","getImagePoolGGUID","getPZFJ"]


id: 60c8686948741fc1098ac05a
pid: 60a31c475db27838e0c01344
name: functionGroup
code: 60c8686948741fc1098ac05a
namepath: /templateScriptOnServer-60a31c475db27838e0c01344
codepath: 60a31c475db27838e0c01344
fullname: /templateScriptOnServer-60a31c475db27838e0c01344/functionGroup
fullcode: 60a31c475db27838e0c01344.60c8686948741fc1098ac05a
nodetype: column
createdate: 2021.06.15 17:13:08.000
lastmodifieddate: 2025.02.24 16:58:01.388
value:
{"全局函数":[{"source":"function saveLabel(","comment":"","group":"","caption":"","needRightControl":"","func":"saveLabel","funcTitle":"function saveLabel","index":0}]}


id: 60d087860c749ebb2285579e
pid: 60d0840b0c749ebb22855746
name: functionGroup
code: 60d087860c749ebb2285579e
namepath: /凭证数字化/打包下载/单个凭证图片打包PDF
codepath: 60b71f5a5db22398a379d9ec.6181e0bcc76eefddf45ea027.pz_image2pdf
fullname: /凭证数字化/打包下载/单个凭证图片打包PDF/functionGroup
fullcode: 60b71f5a5db22398a379d9ec.6181e0bcc76eefddf45ea027.pz_image2pdf.60d087860c749ebb2285579e
nodetype: column
createdate: 2021.06.21 20:41:39.000
lastmodifieddate: 2025.02.24 16:58:01.815
value:
{"全局函数":[{"source":"function main(arg)","comment":"","group":"","caption":"","needRightControl":"","func":"main","funcTitle":"function main","index":0}]}


id: 6183205699328c3820c0cbf7
pid: 6183205499328c3820c0c8d9
name: group_4S6ZH2ECWLSY3D7EXSNOLBUF5GB2R2FHSLUITMQ=
code: 60c815e85db2d209d074b66620211104075046
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046
codepath: 6183205499328c3820c0c8d9
fullcode: 6183205499328c3820c0c8d9.60c815e85db2d209d074b66620211104075046
nodetype: column
value: false
createdate: 2021.06.15 11:05:42.000
lastmodifieddate: 2025.02.24 16:58:01.815
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046/group_4S6ZH2ECWLSY3D7EXSNOLBUF5GB2R2FHSLUITMQ=


id: 619a5456993208680e522c01
pid: 619a5454993208680e522973
name: deletelogafter
code: 60c7d6795db2f19751803b472021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c7d6795db2f19751803b472021110407504620211121221446
nodetype: column
value: 7
createdate: 2021.06.15 07:06:27.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/deletelogafter


id: 619a5456993208680e522c3d
pid: 619a5454993208680e522973
name: role-5fffc49c9932a2f576bbc87e
code: 60c815e85db2d209d074b6642021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6642021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:42.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-5fffc49c9932a2f576bbc87e


id: 619a5456993208680e522c41
pid: 619a5454993208680e522973
name: role-5fffc49c9932a2f576bbc8ab
code: 60c815e85db2d209d074b6652021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6652021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:42.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-5fffc49c9932a2f576bbc8ab


id: 619a5456993208680e522c19
pid: 619a5454993208680e522973
name: functioncheckpoint
code: 60c7e1015db21cf8308160072021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c7e1015db21cf8308160072021110407504620211121221446
nodetype: column
value: {}
createdate: 2021.06.15 07:06:42.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/functioncheckpoint


id: 619a5456993208680e522c25
pid: 619a5454993208680e522973
name: group_4S6ZH2ECWLSY3D7EXSNOLBUF5GB2R2FHSLUITMQ=
code: 60c815e85db2d209d074b6662021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6662021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:42.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/group_4S6ZH2ECWLSY3D7EXSNOLBUF5GB2R2FHSLUITMQ=


id: 619a5456993208680e522c29
pid: 619a5454993208680e522973
name: group_4W6IBZMPSHUKPEXIRGZA====
code: 60c815e85db2d209d074b6632021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6632021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:41.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/group_4W6IBZMPSHUKPEXIRGZA====


id: 619a5456993208680e522c2d
pid: 619a5454993208680e522973
name: group_AAAAAAA=
code: 60c815e85db2d209d074b65d2021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b65d2021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:40.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/group_AAAAAAA=


id: 619a5456993208680e522c31
pid: 619a5454993208680e522973
name: maxactivethreadcount
code: 60c7d6795db2f19751803b492021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c7d6795db2f19751803b492021110407504620211121221446
nodetype: column
value: 100
createdate: 2021.06.15 07:06:27.000
lastmodifieddate: 2025.02.24 16:58:01.817
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/maxactivethreadcount


id: 619a5456993208680e522c45
pid: 619a5454993208680e522973
name: role-601109b09932445fcc3950e7
code: 60c815e85db2d209d074b6602021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6602021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:41.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-601109b09932445fcc3950e7


id: 619a5456993208680e522c49
pid: 619a5454993208680e522973
name: role-608682ac993231a6fef4f736
code: 60c815e85db2d209d074b65e2021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b65e2021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:40.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-608682ac993231a6fef4f736


id: 619a5456993208680e522c4d
pid: 619a5454993208680e522973
name: role-60b727a299327aec523a283e
code: 60c815e85db2d209d074b6612021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6612021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:41.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60b727a299327aec523a283e


id: 619a5456993208680e522c51
pid: 619a5454993208680e522973
name: role-60b7489699327aec523a2ce1
code: 60c815e85db2d209d074b6672021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6672021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:42.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60b7489699327aec523a2ce1


id: 619a5456993208680e522c55
pid: 619a5454993208680e522973
name: role-60b7489699327aec523a2cf1
code: 60c815e85db2d209d074b6682021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6682021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:42.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60b7489699327aec523a2cf1


id: 619a5456993208680e522c59
pid: 619a5454993208680e522973
name: role-60b83c5999327aec523a2d01
code: 60c815e85db2d209d074b6622021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6622021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:41.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60b83c5999327aec523a2d01


id: 619a5456993208680e522c5d
pid: 619a5454993208680e522973
name: role-60bb95269932a3ac306d0316
code: 60c815e85db2d209d074b6692021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b6692021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:43.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60bb95269932a3ac306d0316


id: 619a5456993208680e522c61
pid: 619a5454993208680e522973
name: role-60bb95269932a3ac306d0326
code: 60c815e85db2d209d074b66a2021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b66a2021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:43.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60bb95269932a3ac306d0326


id: 619a5456993208680e522c65
pid: 619a5454993208680e522973
name: role-60bb95269932a3ac306d0336
code: 60c815e85db2d209d074b66b2021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b66b2021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:43.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60bb95269932a3ac306d0336


id: 619a5456993208680e522c69
pid: 619a5454993208680e522973
name: role-60bb95889932a3ac306d035a
code: 60c815e85db2d209d074b66c2021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c815e85db2d209d074b66c2021110407504620211121221446
nodetype: column
value: false
createdate: 2021.06.15 11:05:43.000
lastmodifieddate: 2025.02.24 16:58:01.818
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/role-60bb95889932a3ac306d035a


id: 619a5456993208680e522c89
pid: 619a5454993208680e522973
name: writeCallingLog
code: 60c7d6795db2f19751803b452021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c7d6795db2f19751803b452021110407504620211121221446
nodetype: column
value: true
createdate: 2021.06.15 07:06:26.000
lastmodifieddate: 2025.02.24 16:58:02.243
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/writeCallingLog


id: 673210859932478770cad59d
pid: 673210829932478770cad29b
name: functionlist
code: 60a370d25db2863f9361976620241111221118
nodetype: column
createdate: 2021.05.18 16:22:20.000
lastmodifieddate: 2025.02.24 16:58:02.244
value:
["set_auto_ocr","get_auto_ocr","影像主文档名称","back_ocr","reorderImageFileIndex","do_imageRotate","getLastPZH","getPZHLen","getPZHPrefix","moveImageToRecycle","deletePZAndPutBackToPool","addImageToPZ","putImageBackToPool","getPZFJ","getMonitePath","setMonitePath","getTotalImageCount","loadImagePoolData","setImagePoolBlockSize","getImagePoolBlockSize","getImagePoolGGUID"]


id: 673210859932478770cad591
pid: 673210829932478770cad29b
name: finalscript
code: 60a3505f5db27838e0c0159820241111221117
nodetype: column
createdate: 2021.05.18 16:22:20.000
lastmodifieddate: 2025.02.24 16:58:02.244
value:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount = config.onceCount;
    if (onceCount == undefined) onceCount = 500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  (gguid='" + config.gguid +
        "'  or groupname='设备自动上传' ) and ifnull(info2,'')=''  order by  " + runTask('imgOrderBy',{}) ;
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println(ret);
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };


}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;
}

//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid, ym) {
    return runTask("getPZHPrefix", { ym: ym, corpid: corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", { corpid: corpid }));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}



function back_ocr(config) {

    var ret = { ocrResult: null, needWriteback: false, pzh: '' };
    var corpid = config.corpid;
    var ym = config.ym;

    var ocrResult = config.ocr || '';
    println( ocrResult);
    if (ocrResult == '') {
        println("开始 OCR ");
        var t = runTask("autoOCR", { onlyID: config.id });
        println(t);
        t=JSON.parse(t);
        println( "t.succss="+ t.success);
        println(  t.ocrResult );
        println(t);
        ocrResult =   t.ocrResult ;
        
        ret.needWriteback = true;
        ret.ocrResult = JSON.stringify(ocrResult);
        println(ret);
    }else
    {
        println("无需OCR，直接解析");
        ocrResult = JSON.parse(ocrResult);
    }
     
 
    pushMessage('autoOCR', { action: 'info', message: `正在识别  ${ JSON.stringify(ocrResult) }  ` }, currentUserId( ) );


    //根据识别结果，拼凭证号


    if (ocrResult.凭证日期) {
        var d = string2DateString(ocrResult.凭证日期);
        println("凭证日期 " + d);
        println(d.substring(0, 10));
        println(yyyymmdd2Date(d.substring(0, 10)));

        var ym_t = formatDate(yyyymmdd2Date(d.substring(0, 10)), "yyyyMM");
        println("凭证年月:" + ym_t);
        if (ym_t) ym = ym_t;
    



    var pzh_len = getPZHLen(corpid);
    var pzh_prefix = getPZHPrefix(corpid, ym);

    if (ocrResult.凭证号) {
        var pzh = ocrResult.凭证号;
        if (pzh_len > 0) pzh = right('000000000000000000' + pzh, pzh_len);
        ret.pzh = pzh_prefix + pzh;

    } else {
        ret.pzh = '';
    }
    }else{
          ret.pzh = ocrResult.凭证号 || '';  
    }

    return ret;


}

function   影像主文档名称()
{
    return  getProperty( '/影像名称/主文档名称', '凭证') ;
}

function   get_auto_ocr()
{
    return  getProperty( '/图片上传后自动OCR识别', 0) ;
}

function set_auto_ocr(v)
{
    setProperty( '/图片上传后自动OCR识别', v); 
}


id: 6183205699328c3820c0cbef
pid: 6183205499328c3820c0c8d9
name: functionGroup
code: 60c7e1005db2f19751803b5320211104075046
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046
codepath: 6183205499328c3820c0c8d9
fullname: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046/functionGroup
fullcode: 6183205499328c3820c0c8d9.60c7e1005db2f19751803b5320211104075046
nodetype: column
createdate: 2021.06.15 07:06:40.000
lastmodifieddate: 2025.02.24 16:58:02.244
value:
{"全局函数":[{"source":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)\nfunction getPZFJ(id)","comment":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)","group":"","caption":"构建凭证附件清单","needRightControl":"false","func":"getPZFJ","funcTitle":"function getPZFJ","index":0},{"source":"function get_PZ_PDF_URL(id)","comment":"","group":"","caption":"","needRightControl":"","func":"get_PZ_PDF_URL","funcTitle":"function get_PZ_PDF_URL","index":1},{"source":"//@comment (group=,caption=凭证号前缀,needRightControl=false)\nfunction getPZHPrefix(corpid, ym)","comment":"//@comment (group=,caption=凭证号前缀,needRightControl=false)","group":"","caption":"凭证号前缀","needRightControl":"false","func":"getPZHPrefix","funcTitle":"function getPZHPrefix","index":2},{"source":"//@comment (group=,caption=凭证号长度,needRightControl=false)\nfunction getPZHLen(corpid)","comment":"//@comment (group=,caption=凭证号长度,needRightControl=false)","group":"","caption":"凭证号长度","needRightControl":"false","func":"getPZHLen","funcTitle":"function getPZHLen","index":3},{"source":"//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)\nfunction do_sh(id, sh)","comment":"//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)","group":"","caption":"凭证审核或取消审核","needRightControl":"false","func":"do_sh","funcTitle":"function do_sh","index":4},{"source":"function beWhere_code(st_code)","comment":"","group":"","caption":"","needRightControl":"","func":"beWhere_code","funcTitle":"function beWhere_code","index":5}]}


id: 673d7f0a993262d888067f27
pid: 673d7f0a993262d888067ef0
name: functionGroup
nodetype: column
createdate: 2024.11.20 14:26:21.432
lastmodifieddate: 2025.02.24 16:58:02.244
value:
{"全局函数":[{"source":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)\nfunction getImagePoolGGUID()","comment":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)","group":"","caption":"得到当前操作员待归档图片对应的GGUID","needRightControl":"false","func":"getImagePoolGGUID","funcTitle":"function getImagePoolGGUID","index":0},{"source":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)\nfunction loadImagePoolData(config)","comment":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)","group":"","caption":"得到待归档的图片清单","needRightControl":"true","func":"loadImagePoolData","funcTitle":"function loadImagePoolData","index":1},{"source":"function getTotalImageCount()","comment":"","group":"","caption":"","needRightControl":"","func":"getTotalImageCount","funcTitle":"function getTotalImageCount","index":2},{"source":"function getImagePoolBlockSize()","comment":"","group":"","caption":"","needRightControl":"","func":"getImagePoolBlockSize","funcTitle":"function getImagePoolBlockSize","index":3},{"source":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)\nfunction setImagePoolBlockSize(id, blockSize)","comment":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)","group":"","caption":"保存当前的缩略图大小","needRightControl":"false","func":"setImagePoolBlockSize","funcTitle":"function setImagePoolBlockSize","index":4}]}


id: 673d7f0a993262d888067f2a
pid: 673d7f0a993262d888067ef0
name: finalscript
nodetype: column
createdate: 2024.11.20 14:26:21.642
lastmodifieddate: 2025.02.24 16:58:02.244
value:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}



//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount = config.onceCount;
    if (onceCount == undefined) onceCount = 500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  (gguid='" + config.gguid +
        "'  or groupname='设备自动上传' ) and ifnull(info2,'')=''  order by  " + runTask('imgOrderBy',{}) ;
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println(ret);
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };


}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}



function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


id: 673d80d399328417b40d1bee
pid: 673d7f0a993262d888067ef0
name: functionlist
nodetype: column
createdate: 2024.11.20 14:26:21.749
lastmodifieddate: 2025.02.24 16:58:02.245
value:
["setImagePoolBlockSize","getImagePoolBlockSize","getTotalImageCount","loadImagePoolData","getImagePoolGGUID"]


id: 60c7e1005db2f19751803b53
pid: 60c4bd735db2478f9c5a1118
name: functionGroup
code: 60c7e1005db2f19751803b53
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118
codepath: 60c4bd735db2478f9c5a1118
fullname: /templateScriptOnServer-60c4bd735db2478f9c5a1118/functionGroup
fullcode: 60c4bd735db2478f9c5a1118.60c7e1005db2f19751803b53
nodetype: column
createdate: 2021.06.15 07:06:40.000
lastmodifieddate: 2025.02.24 16:58:02.245
value:
{"全局函数":[{"source":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)\nfunction getPZFJ(id)","comment":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)","group":"","caption":"构建凭证附件清单","needRightControl":"false","func":"getPZFJ","funcTitle":"function getPZFJ","index":0},{"source":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)\nfunction getImagePoolGGUID()","comment":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)","group":"","caption":"得到当前操作员待归档图片对应的GGUID","needRightControl":"false","func":"getImagePoolGGUID","funcTitle":"function getImagePoolGGUID","index":1},{"source":"function setImageGroupName( id , groupname)","comment":"","group":"","caption":"","needRightControl":"","func":"setImageGroupName","funcTitle":"function setImageGroupName","index":2},{"source":"function get_PZ_PDF_URL(id)","comment":"","group":"","caption":"","needRightControl":"","func":"get_PZ_PDF_URL","funcTitle":"function get_PZ_PDF_URL","index":3},{"source":"function back_setImageOrder(gguid, id, order)","comment":"","group":"","caption":"","needRightControl":"","func":"back_setImageOrder","funcTitle":"function back_setImageOrder","index":4},{"source":"function reOrderImage(ids)","comment":"","group":"","caption":"","needRightControl":"","func":"reOrderImage","funcTitle":"function reOrderImage","index":5},{"source":"//@comment (group=,caption=凭证号前缀,needRightControl=false)\nfunction getPZHPrefix(corpid, ym)","comment":"//@comment (group=,caption=凭证号前缀,needRightControl=false)","group":"","caption":"凭证号前缀","needRightControl":"false","func":"getPZHPrefix","funcTitle":"function getPZHPrefix","index":6},{"source":"//@comment (group=,caption=凭证号长度,needRightControl=false)\nfunction getPZHLen(corpid)","comment":"//@comment (group=,caption=凭证号长度,needRightControl=false)","group":"","caption":"凭证号长度","needRightControl":"false","func":"getPZHLen","funcTitle":"function getPZHLen","index":7},{"source":"//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)\nfunction do_sh(id, sh)","comment":"//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)","group":"","caption":"凭证审核或取消审核","needRightControl":"false","func":"do_sh","funcTitle":"function do_sh","index":8},{"source":"function back_repair(gguid, url, pzh)","comment":"","group":"","caption":"","needRightControl":"","func":"back_repair","funcTitle":"function back_repair","index":9},{"source":"//@comment (group=,caption=图片旋转,needRightControl=false)\nfunction do_imageRotate(id, rt)","comment":"//@comment (group=,caption=图片旋转,needRightControl=false)","group":"","caption":"图片旋转","needRightControl":"false","func":"do_imageRotate","funcTitle":"function do_imageRotate","index":10},{"source":"//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)\nfunction putImageBackToPool(id)","comment":"//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)","group":"","caption":"把凭证中的附件图片回归到待归档池中","needRightControl":"false","func":"putImageBackToPool","funcTitle":"function putImageBackToPool","index":11},{"source":"function getImagePoolBlockSize()","comment":"","group":"","caption":"","needRightControl":"","func":"getImagePoolBlockSize","funcTitle":"function getImagePoolBlockSize","index":12},{"source":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)\nfunction setImagePoolBlockSize(id, blockSize)","comment":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)","group":"","caption":"保存当前的缩略图大小","needRightControl":"false","func":"setImagePoolBlockSize","funcTitle":"function setImagePoolBlockSize","index":13},{"source":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)\nfunction loadImagePoolData(config)","comment":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)","group":"","caption":"得到待归档的图片清单","needRightControl":"true","func":"loadImagePoolData","funcTitle":"function loadImagePoolData","index":14},{"source":"function getTotalImageCount()","comment":"","group":"","caption":"","needRightControl":"","func":"getTotalImageCount","funcTitle":"function getTotalImageCount","index":15},{"source":"//@comment (group=,caption=追加图片到凭证中,needRightControl=false)\nfunction addImageToPZ(pzid, images)","comment":"//@comment (group=,caption=追加图片到凭证中,needRightControl=false)","group":"","caption":"追加图片到凭证中","needRightControl":"false","func":"addImageToPZ","funcTitle":"function addImageToPZ","index":16},{"source":"function   影像主文档名称()","comment":"","group":"","caption":"","needRightControl":"","func":"影像主文档名称","funcTitle":"function   影像主文档名称","index":17},{"source":"function back_imageCrop( id, config)","comment":"","group":"","caption":"","needRightControl":"","func":"back_imageCrop","funcTitle":"function back_imageCrop","index":18},{"source":"function back_imageRevertToOriginal( id)","comment":"","group":"","caption":"","needRightControl":"","func":"back_imageRevertToOriginal","funcTitle":"function back_imageRevertToOriginal","index":19}]}


id: 67bc26d399322addbec28f71
pid: 60c9bce19932d177d8ac5e09
name: 图片排序规则
code: imgOrderBy
namepath: /凭证数字化/设置相关
fullname: /凭证数字化/设置相关/图片排序规则
nodetype: leaf
createdate: 2025.02.24 16:11:37.297
lastmodifieddate: 2025.02.24 16:58:02.245
value:
/**
 * 脚本中心的脚本，以 main函数为执行入口，相关的参数放在arg中，它是一个JSON字符串化后的数据
 *
 */
function main(arg)
{
    var p=  getProperty('/图片池中图片排序规则','info1 asc, filename asc');

    return p; 


}


id: 60a31c3c5db27838e0c0129e
pid: templateScriptOnServer
name: templateScriptOnServer-60a31c3c5db27838e0c0129e
code: 60a31c3c5db27838e0c0129e
fullname: /templateScriptOnServer-60a31c3c5db27838e0c0129e
fullcode: 60a31c3c5db27838e0c0129e
nodetype: leaf
lastmodifieddate: 2025.02.24 16:58:02.656
value:
function getImageList1() {
    return getImageList("凭证");
}
function getImageList2() {
    return getImageList("附件");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function getImageList(groupName) {

    //排除掉回收站的图片
    var sql = "select * from  dzpz_pzfj  where  gguid='" + currentGUID() + "'  and groupname='" + 
               groupName + "'  order by "+ runTask('imgOrderBy',{})  ;
    println(sql);
    var ds = newDataStore("", sql); // info1 是客户端文件创建的时间，以它排序
    var n = ds.retrieve();

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    return { success: true, data: ret };

}


/**
 * 点击删除单据，在执行单据删除语句后（但尚未提交），系统在服务端触发本事件
 *
 *  可以在本事件中，注入一些操作，返回一组SQL，这此SQL与单据删除操作将在一个事务中执行。
 *
 * @notice 注意：本事件在服务端执行，不要试图访问任何前端UI信息。不要直接执行对数据库的写操作，如果需要
 * 请在返回值中返回这些语句，让系统把它们与单据删除并在一个事务中执行。
 *
 * @param gguid  要删除单据主记录的gguid ，等同于主表的id
 * @param session  一个JSON对象，用于在整个单据删除过程中的各个事件之间传递数据。各个事件
 * 脚本虽然写在一起，但它们是按顺序在服务器上分开独立执行的，各个事件可能并不是在同一个脚本
 * 引擎中执行，如果对session做了写的操作，必须在返回值中
 * 将它返回，系统将它做为参数传递到下一个事件中
 *
 * @return   返回值是这样的一个JSON对象
 * { success:true,
 *    message:'' ,
 *    sql: { "default" : [ sql1, sql2 ...] ,
 *            "dbpool2": [sql1, sql2 ...]
 *         }
 * }
 *   success=true 表示继续允许执行删除单据操作 ， 并且在执行单据删除后，执行一些SQL语句。sql定义的规则：
 *   { 连接池名称1: [ SQL数组] , 连接池名称2: [ SQL数组] ....  }
 *
 *
 * 如果 success 设置成false ,则在 message中放置错误提示信息，此时整个单据删除操作被立即终止
 *
 */
//@comment (group=单据,caption=单据删除语句执行后)
function afterBillDeleteOnServer(gguid, session) {

    //注意：此时单据尚未开始删除，仍可用 gguid 来查询单据数据

    var objectName = getStringFromSQL(`select objectname from app_archive where gguid='${gguid}'`);
    println(objectName + " 将被删除");
    deleteFileOnFileServer(1, objectName);
    var sql = `delete from app_archive where gguid='${gguid}'`;
    println(sql);

    return {
        success: true,
        message: "",
        session: session,
        sql: { "default": [sql] }  // 归档信息删除
    };

}


function back_repair(url, pzh) {
    var result = extractImagesFromPDF( safeURL(url), pzh, 4 * 1024); //小于 4k的忽略 ，pdf中每个图片右上角有一个凭证号的小图片，这个需要排除掉
    println("currentguid= "+ currentGUID(  ) );
    println(result);
    var imgs = result.imgs;
    for (var i = 0; i < imgs.length; i++) {
        uploadFile({
            file: imgs[i].path,
            serverIndex: 2,
            logTable: 'dzpz_pzfj',
            tableName: 'dzpz_pz',
            gguid: currentGUID(),
            groupName: i == 0 ? "凭证" : "附件",
            info1: imgs[i].createDate
        });
    }

    return imgs.length;  

}


id: 60d0840b0c749ebb22855746
pid: 6181e0bcc76eefddf45ea027
name: 单个凭证图片打包PDF
code: pz_image2pdf
namepath: /凭证数字化/打包下载
codepath: 60b71f5a5db22398a379d9ec.6181e0bcc76eefddf45ea027
fullname: /凭证数字化/打包下载/单个凭证图片打包PDF
fullcode: 60b71f5a5db22398a379d9ec.6181e0bcc76eefddf45ea027.pz_image2pdf
nodetype: leaf
createdate: 2021.06.21 20:34:35.000
lastmodifieddate: 2025.02.24 16:58:02.656
value:
function main(arg) {
    println(arg);
    var p = JSON.parse(arg);
    var id = p.id;
    var overwrite = p.overwrite;

    // info2 是手工调整顺序后的序号 ，如果没有手工调整顺序，那么info2应该都是null , 
    // 这样，如果手工调整了顺序，那么以手工调整后的顺序来排序，
    //否则以(groupname优先排序，它通常是“凭证”，“附件”) 凭证排在前，附件排在后 ，同类型（groupname）文件的按原始日期来排序，

    var tds = newDataStore("", "select pzh , corpid from dzpz_pz where id='" + id + "'");
    tds.retrieve();
    var pzh = tds.getString(0, "pzh");
    var corpid = tds.getString(0, "corpid");
    println("pzh=" + pzh);
    println("corpid=" + corpid);

    //避免出现一张凭证出现多条 app_archive记录的情况，导致后面压缩时，找不到pdf文件，如果有多条，只保留最后一条
    var tds2 = newDataStore("", "select * from app_archive where gguid='" + id + "' order by lastmodifieddate desc");
    tds2.setUpdateProperty("app_archive", "id", "*", "id");
    var n = tds2.retrieve();
    println("archive count:" + n);
    if (n > 1) {
        println('');
        for (var i = n - 1; i > 0; i--) {
            tds2.deleteRow(i);
        }
        if (!tds2.update(true)) println(tds2.getError().getMessage());
    }


    var url = getStringFromSQL("select url_img  from basic_corp_seal a , basic_corp b where a.gguid=b.gguid and a.groupname='电子印章' and b.code= '" + corpid + "' ");
    println(url);

    if (getIntFromSQL("select count(*) from dzpz_pzfj where gguid='" + id + "' ") == 0) {
        println({ sccess: false, message: "凭证归档信息丢失,禁止重新生成pdf " });

    }

    runTask("归档信息保存到文件中", { pzid: id });

    //把附件打包成一个PDF ,生成pdf不要加水印，水印是在下载时临时加上去的
    return createArchive("dzpz",
        id,
        runTask('imgOrderBy', {}),  //附件排序规则   "info2 asc , groupname , info1 asc "
        overwrite, //是否强行重新生成
        '', //水印 。生成pdf不要加水印，水印是在下载时临时加上去的
        {
            left: 20,
            top: 20,
            url: url
        },  //左上角加一个印章图片
        pzh //右上角把凭证号打上，便于查看
    );


}


id: 619a5456993208680e522c1d
pid: 619a5454993208680e522973
name: functionGroup
code: 60c7e1005db2f19751803b532021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullcode: 619a5454993208680e522973.60c7e1005db2f19751803b532021110407504620211121221446
nodetype: column
createdate: 2021.06.15 07:06:40.000
lastmodifieddate: 2025.02.24 16:58:02.656
fullname:
/templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/functionGroup

value:
{"全局函数":[{"source":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)\nfunction getPZFJ(id)","comment":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)","group":"","caption":"构建凭证附件清单","needRightControl":"false","func":"getPZFJ","funcTitle":"function getPZFJ","index":0},{"source":"//@comment (group=,caption=凭证号前缀,needRightControl=false)\nfunction  getPZHPrefix(corpid,ym)","comment":"//@comment (group=,caption=凭证号前缀,needRightControl=false)","group":"","caption":"凭证号前缀","needRightControl":"false","func":"getPZHPrefix","funcTitle":"function  getPZHPrefix","index":1},{"source":"//@comment (group=,caption=凭证号长度,needRightControl=false)\nfunction getPZHLen(corpid)","comment":"//@comment (group=,caption=凭证号长度,needRightControl=false)","group":"","caption":"凭证号长度","needRightControl":"false","func":"getPZHLen","funcTitle":"function getPZHLen","index":2},{"source":"//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)\nfunction do_sh(id, sh)","comment":"//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)","group":"","caption":"凭证审核或取消审核","needRightControl":"false","func":"do_sh","funcTitle":"function do_sh","index":3}]}


id: 673210859932478770cad599
pid: 673210829932478770cad29b
name: functionGroup
code: 60a3505f5db27838e0c0159220241111221118
nodetype: column
createdate: 2021.05.18 16:22:19.000
lastmodifieddate: 2025.02.24 16:58:02.657
value:
{"全局函数":[{"source":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)\nfunction getImagePoolGGUID()","comment":"//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)","group":"","caption":"得到当前操作员待归档图片对应的GGUID","needRightControl":"false","func":"getImagePoolGGUID","funcTitle":"function getImagePoolGGUID","index":0},{"source":"function getImagePoolBlockSize()","comment":"","group":"","caption":"","needRightControl":"","func":"getImagePoolBlockSize","funcTitle":"function getImagePoolBlockSize","index":1},{"source":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)\nfunction setImagePoolBlockSize(id, blockSize)","comment":"//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)","group":"","caption":"保存当前的缩略图大小","needRightControl":"false","func":"setImagePoolBlockSize","funcTitle":"function setImagePoolBlockSize","index":2},{"source":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)\nfunction loadImagePoolData(config)","comment":"//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)","group":"","caption":"得到待归档的图片清单","needRightControl":"true","func":"loadImagePoolData","funcTitle":"function loadImagePoolData","index":3},{"source":"function getTotalImageCount()","comment":"","group":"","caption":"","needRightControl":"","func":"getTotalImageCount","funcTitle":"function getTotalImageCount","index":4},{"source":"//@comment (group=,caption=保存监控目录设置,needRightControl=false)\nfunction setMonitePath(hostName, path)","comment":"//@comment (group=,caption=保存监控目录设置,needRightControl=false)","group":"","caption":"保存监控目录设置","needRightControl":"false","func":"setMonitePath","funcTitle":"function setMonitePath","index":5},{"source":"//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)\nfunction getMonitePath(hostName)","comment":"//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)","group":"","caption":"获取指定机器的监控目录","needRightControl":"false","func":"getMonitePath","funcTitle":"function getMonitePath","index":6},{"source":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)\nfunction getPZFJ(id)","comment":"//@comment (group=,caption=构建凭证附件清单,needRightControl=false)","group":"","caption":"构建凭证附件清单","needRightControl":"false","func":"getPZFJ","funcTitle":"function getPZFJ","index":7},{"source":"//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)\nfunction putImageBackToPool(id)","comment":"//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)","group":"","caption":"把凭证中的附件图片回归到待归档池中","needRightControl":"false","func":"putImageBackToPool","funcTitle":"function putImageBackToPool","index":8},{"source":"//@comment (group=,caption=追加图片到凭证中,needRightControl=false)\nfunction addImageToPZ(pzid, images)","comment":"//@comment (group=,caption=追加图片到凭证中,needRightControl=false)","group":"","caption":"追加图片到凭证中","needRightControl":"false","func":"addImageToPZ","funcTitle":"function addImageToPZ","index":9},{"source":"function deletePZAndPutBackToPool(id)","comment":"","group":"","caption":"","needRightControl":"","func":"deletePZAndPutBackToPool","funcTitle":"function deletePZAndPutBackToPool","index":10},{"source":"function moveImageToRecycle(id)","comment":"","group":"","caption":"","needRightControl":"","func":"moveImageToRecycle","funcTitle":"function moveImageToRecycle","index":11},{"source":"//@comment (group=,caption=凭证号前缀,needRightControl=false)\nfunction getPZHPrefix(corpid, ym)","comment":"//@comment (group=,caption=凭证号前缀,needRightControl=false)","group":"","caption":"凭证号前缀","needRightControl":"false","func":"getPZHPrefix","funcTitle":"function getPZHPrefix","index":12},{"source":"//@comment (group=,caption=凭证号长度,needRightControl=false)\nfunction getPZHLen(corpid)","comment":"//@comment (group=,caption=凭证号长度,needRightControl=false)","group":"","caption":"凭证号长度","needRightControl":"false","func":"getPZHLen","funcTitle":"function getPZHLen","index":13},{"source":"function getLastPZH(corpid, ym)","comment":"","group":"","caption":"","needRightControl":"","func":"getLastPZH","funcTitle":"function getLastPZH","index":14},{"source":"function do_imageRotate(id, rt)","comment":"","group":"","caption":"","needRightControl":"","func":"do_imageRotate","funcTitle":"function do_imageRotate","index":15},{"source":"function reorderImageFileIndex(imgs)","comment":"","group":"","caption":"","needRightControl":"","func":"reorderImageFileIndex","funcTitle":"function reorderImageFileIndex","index":16},{"source":"function back_ocr(config)","comment":"","group":"","caption":"","needRightControl":"","func":"back_ocr","funcTitle":"function back_ocr","index":17},{"source":"function   影像主文档名称()","comment":"","group":"","caption":"","needRightControl":"","func":"影像主文档名称","funcTitle":"function   影像主文档名称","index":18},{"source":"function   get_auto_ocr()","comment":"","group":"","caption":"","needRightControl":"","func":"get_auto_ocr","funcTitle":"function   get_auto_ocr","index":19},{"source":"function set_auto_ocr(v)","comment":"","group":"","caption":"","needRightControl":"","func":"set_auto_ocr","funcTitle":"function set_auto_ocr","index":20}]}


id: 619a5456993208680e522c15
pid: 619a5454993208680e522973
name: finalscript
code: 60c56f335db26ca8759b15662021110407504620211121221446
namepath: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446
codepath: 619a5454993208680e522973
fullname: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046clone20211121221446/finalscript
fullcode: 619a5454993208680e522973.60c56f335db26ca8759b15662021110407504620211121221446
nodetype: column
createdate: 2021.06.13 10:47:52.000
lastmodifieddate: 2025.02.24 16:58:02.657
value:
//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj  "+
             " where  gguid='" + id + "'  order by "+ runTask('imgOrderBy',{})  );
    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());
    var ret = [];
    for (var i = 0; i < n; i++) {
        var one= JSON.parse(ds.getJSONRow(i, true));
        one.url_img = one.url_img+"&imageForceWatermark=false"
        ret.push(one);
    }
    return ret;

}




//@comment (group=,caption=凭证号前缀,needRightControl=false)
function  getPZHPrefix(corpid,ym)
{
    return runTask("getPZHPrefix" ,{corpid:corpid, ym:ym});
    
}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid)
{
    return  parseInt( runTask("getPZHLen",{corpid:corpid}));
}



//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)
function do_sh(id, sh) {


    //if (!isRoleGrantedToUser(currentUserId(), "60c81b135db2d209d074b697")) return { success: false, message: "没有审核权限" };



    var dzpz_ds = newDataStore("", "select * from dzpz_pz where id='" + id + "'");
    dzpz_ds.setUpdateProperty("dzpz_pz", "id", "*", "id");
    dzpz_ds.retrieve();
    if (dzpz_ds.getRowCount() == 0) {
        return { success: false, message: "凭证不存在" };
    }
    if (sh) //做审核
    {
        var verifierid = dzpz_ds.getInt(0, "verifierid");
        if (verifierid != 0) return {
            success: true, verifierid: verifierid,
            verifiername: dzpz_ds.getString(0, "verifiername"),
            verifieddate: dzpz_ds.getString(0, "verifieddate"), message: "凭证已审核，不需要重复审核"
        };
        dzpz_ds.setValue(0, "verifierid", currentUserId());
        dzpz_ds.setValue(0, "verifiername", currentUserShowName());
        dzpz_ds.setValue(0, "verifieddate", newDate());

        if (!dzpz_ds.update(true)) return { success: false, message: dzpz_ds.getError().getMessage() };

        //审核后，归档
        runTask("pz_image2pdf" ,{id:id , 
            overwrite:true  //如果已存在，删除并重新生成
            });
            
        return {
            success: true,
            verifierid: dzpz_ds.getString(0, "verifierid"),
            verifiername: dzpz_ds.getString(0, "verifiername"),
            verifieddate: dzpz_ds.getString(0, "verifieddate")
        };

    } else {
        var verifierid = dzpz_ds.getInt(0, "verifierid");
        println(verifierid);
        if (verifierid == 0) return { success: true, message: "凭证尚未审核，不需要取消审核" };
        if (verifierid != currentUserId()) {
            if (!isRoleGrantedToUser(currentUserId(), "60c81b135db2d209d074b6a7")) {

                return { success: false, message: "必须由审核人或超级审核员来取消审核" };
            }
        }
        dzpz_ds.setValue(0, "verifierid", null);
        dzpz_ds.setValue(0, "verifiername", null);
        dzpz_ds.setValue(0, "verifieddate", null);

        if (!dzpz_ds.update(true)) return { success: false, message: dzpz_ds.getError().getMessage() };
        return { success: true };
    }

}


id: 6183205499328c3820c0c8d9
pid: templateScriptOnServer
name: templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046
code: 6183205499328c3820c0c8d9
fullname: /templateScriptOnServer-60c4bd735db2478f9c5a1118clone20211104075046
fullcode: 6183205499328c3820c0c8d9
nodetype: leaf
lastmodifieddate: 2025.02.24 16:58:02.657
value:
//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj " +
    " where  gguid='" + id + "'  order by "+runTask('imgOrderBy',{})  ); 
    var n = ds.retrieve();
    println(ds.getSelectLastRetrieved());
    var ret = [];
    for (var i = 0; i < n; i++) {
        var one = JSON.parse(ds.getJSONRow(i, true));
        one.url_img = one.url_img + "&imageForceWatermark=false"
        ret.push(one);
    }
    return ret;

}




function get_PZ_PDF_URL(id) {
    return  safeURL(  getStringFromSQL("select url_img from app_archive where gguid='" + id + "'") ) ;
}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid, ym) {
    return runTask("getPZHPrefix", { corpid: corpid, ym: ym });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", { corpid: corpid }));
}



//@comment (group=,caption=凭证审核或取消审核,needRightControl=false)
function do_sh(id, sh) {


    //if (!isRoleGrantedToUser(currentUserId(), "60c81b135db2d209d074b697")) return { success: false, message: "没有审核权限" };



    var dzpz_ds = newDataStore("", "select * from dzpz_pz where id='" + id + "'");
    dzpz_ds.setUpdateProperty("dzpz_pz", "id", "*", "id");
    dzpz_ds.retrieve();
    if (dzpz_ds.getRowCount() == 0) {
        return { success: false, message: "凭证不存在" };
    }
    if (sh) //做审核
    {
        var verifierid = dzpz_ds.getInt(0, "verifierid");
        if (verifierid != 0) return {
            success: true, verifierid: verifierid,
            verifiername: dzpz_ds.getString(0, "verifiername"),
            verifieddate: dzpz_ds.getString(0, "verifieddate"), message: "凭证已审核，不需要重复审核"
        };
        dzpz_ds.setValue(0, "verifierid", currentUserId());
        dzpz_ds.setValue(0, "verifiername", currentUserShowName());
        dzpz_ds.setValue(0, "verifieddate", newDate());

        if (!dzpz_ds.update(true)) return { success: false, message: dzpz_ds.getError().getMessage() };

        //审核后，归档
        runTask("pz_image2pdf", {
            id: id,
            overwrite: true  //如果已存在，删除并重新生成
        });

        return {
            success: true,
            verifierid: dzpz_ds.getString(0, "verifierid"),
            verifiername: dzpz_ds.getString(0, "verifiername"),
            verifieddate: dzpz_ds.getString(0, "verifieddate")
        };

    } else {
        var verifierid = dzpz_ds.getInt(0, "verifierid");
        println(verifierid);
        if (verifierid == 0) return { success: true, message: "凭证尚未审核，不需要取消审核" };
        if (verifierid != currentUserId()) {
            if (!isRoleGrantedToUser(currentUserId(), "60c81b135db2d209d074b6a7")) {

                return { success: false, message: "必须由审核人或超级审核员来取消审核" };
            }
        }
        dzpz_ds.setValue(0, "verifierid", null);
        dzpz_ds.setValue(0, "verifiername", null);
        dzpz_ds.setValue(0, "verifieddate", null);

        if (!dzpz_ds.update(true)) return { success: false, message: dzpz_ds.getError().getMessage() };
        return { success: true };
    }

}

function beWhere_code(st_code) {
    return "pzh in(select pzh from pzdjex where code='" + st_code + "')"
}


# app_script_history

id: 6506bfd59932de686bb62250
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 125.120.128.57
username: sa
createdate: 2023.09.17 17:16:52.000
script:
var pathToMonit = "";//当前监控的目录
var electron = null;
var pzh_prefix = ""; // 凭证号前缀
var pzh_len = 0; //凭证号长度
var lastPZH = "";
var fullScreenDiv = null;

/*
$(document).ready(function () {
    var script = $(`<script src="ui/imageEditor/filerobot-image-editor.min.js">
    
    </script>`);
    $(document.body).append(script);
});
*/

function formOpen() {

    book.sheet4.visible = false;

    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    book.sheet3.getBrick('cb_delete_pz').visible = false;

    //加载帐套信息及年月
    var corpid = book.sheet2.cells("corpid").getValueString();
    var ym = book.sheet2.cells("ym").getValue();
    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);

    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000001'.substring(8 - pzh_len, 8);
        lastPZH = v;
    });

    // smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
    // });

    book.getWorkSheet('凭证清单').cells("yue").setValue(getMonth(newDate()));

    book.sheet3.getBrick('FJ').config.promptInfoOnDelete = "确信要将图片从当前凭证中移除，并放回到图片池中吗?";
    book.sheet1.getBrick('imgPool').config.promptInfoOnDelete = "确信要将图片放入回收站吗?";

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage", function (msg) {
        msg = JSON.parse(msg);
        if (msg.cmd == "newFileUploaded") newImgCommingTipVisible(true); //通知有新文件上传了
        if (msg.cmd == "notifyNeedUploadFileCount") notifyNeedUploadFileCount(msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron = getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:30px; line-height:30px;width:100%; 
                                background-color:#af4040e0; 
                                color:white;font-weight:bold;font-size:20px;text-align:left;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:44px; top:0; text-align:right; 
                                    vertical-align:top; font-size:24px; color:#ffa0a0;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);


    setTimeout(function () {
        //调取缩略图大小

        var imgPool = book.sheet1.getBrick('imgPool');
        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout(function () {
        if (electron != null) {
            var hostName = electron.getHostName();
            pathToMonit = getMonitePath(hostName);

            //开启监控
            if (pathToMonit == '') pathToMonit = "c:\\凭证影像采集目录";

            moniteStart(pathToMonit);
            $.alert('请将扫描仪的图片目录指向：' + pathToMonit);
        }

        //显示总共图片数
        getTotalImageCount(function (ret) { book.sheet0.cells('imageCountTotal').setValue('共' + ret + '张') });

    }, 500);



    $(document).on('keydown', function (e) {
        console.info(" kkkkk down");
        if (e.ctrlKey) {
            // fullScreenViewImageOpen();
        }
    });


    $(document).on('keyup', function (e) {
        console.info(" kkkkk up");
        if (!e.ctrlKey) {

            // fullScreenViewImageClose();

        }
    });

    onPushMessage( "pz_ocr" , function(msg)
    {
        if( msg.action=='info')
        { 
            toastr.show( msg);
        }
    }) ;

}


// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function saveSelectionAndPZInfo() {

    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection = selection;
    g_pzMap = pzhMap;
}




//@comment (group=图片清单刷新,caption=还原选中及凭证标记,needRightControl=false)
function restoreSelectionAndPZInfo() {
    var selection = g_selection;
    var pzhMap = g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();

    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

function resetImageCountInfo() {

    setTimeout(function () {
        book.sheet0.cells("imageCount").setValue("前 " + book.sheet1.getBrick("imgPool").imageCount + " 张");
    }, 300);
}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "imgPool") {
        resetImageCountInfo()
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        book.sheet0.cells("imageCount").setValue(brick.imageCout + "张图片");


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数

                showInfoPane('*正在旋转图片...');
                setTimeout(function () {
                    //toastr.info(id);  // id 是当前操作的图片对应数据的ID
                    var ret = do_imageRotate(id, "90");
                    if (ret.success) {
                        //把数据中的图片替换，
                        for (let i = 0; i < brick.data.length; i++) {
                            if (brick.data[i].id == id) {
                                //属性从新的属性中替换 
                                for (let prop in brick.data[i]) {
                                    brick.data[i][prop] = ret.data[prop];
                                }
                                break;
                            }
                        }
                        //把缩略图的图片地址替换 ， 

                        let img = $('#' + id).find('.image');
                        img.attr("src", ret.data.url_thumbnail);
                        img.attr('largeimage', ret.data.url_img);
                        //把大图预览的地址替换掉
                        book.sheet0.cells("imgPreview").setValue(ret.data.url_img);
                        hideInfoPane();

                    }
                }, 10);
            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-plus",   // 字符图标
            "选中此前",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let selected = $('#' + id).parent().find('.brickSelected').length > 0; // 可以用 imgPool.isImageSelected( id) 替换，但此时本函数还没有提供，以后可以换成此函数

                let imgPool = book.sheet1.getBrick("imgPool");
                let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
                let found = false;
                for (let i = 0; i < imgs.length; i++) {
                    imgPool.setImageSelected(imgs[i].id, !selected);
                    if (imgs[i].id == id) return;

                }


            });


    }
}


/**
 * 图片控件中图片上的删除按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 * @param data  图片的信息
 *
 * @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行删除操作，否则表示终止删除操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上的删除按钮被点击)
function imageOnDelete(sheet, name, data) {

    if (name == 'FJ') {
        if (data.groupname == '凭证') {
            return { success: false, message: "这是凭证，不允许这样移除，请点击“删除凭证”" };
        } else {
            var ret = putImageBackToPool(data.id);
            if (ret.success) {
                smartRetrieve(book.sheet3, "one");
                cb_refresh_onClick();
            } else {
                return ret;
            }

        }
    }

    if (name == 'imgPool') {
        moveImageToRecycle(data.id);
        resetImageCountInfo();
    }
    return { success: true };
}
/**
 * 图片控件中上传按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 *
 @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行上传操作，否则表示终止上传操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上传按钮被点击)
function imageOnNewUpload(sheet, name) {


    if (name == 'imgPool') {
        toastr.info("请连接扫描仪，或将图片复制到监控的目录下，图片自动上传");
    }

    if (name == 'FJ') {
        var imgPool = book.sheet1.getBrick('imgPool');
        // 保存当前选中状态及设置的凭证号信息
        var selection = imgPool.getSelectedImageList();
        if (selection.length == 0) {
            toastr.error("至少选中一张图片");
            return { success: false }; // 此返回，阻止了默认的上传操作
        }


        var lastPZ = null;
        for (let i = 0; i < selection.length; i++) {
            var one = selection[i];
            var pzh = getPZH(one.id);
            if (pzh != '') {
                toastr.error("选中的图片中有标记为凭证的，禁止将凭证图片添加到当前凭证中");
                return { success: false }; // 此返回，阻止了默认的上传操作
            }
        }

        var ret = addImageToPZ($one_ds.getString(0, "id"), selection);
        if (ret.success) {
            //刷新图片区
            cb_refresh_onClick();
            //刷新凭证
            loadPZ($one_ds.getString(0, "id"), $one_ds.getString(0, "pzh"), $one_ds.getString(0, "verifiername") != "" ? 1 : 0);
        }

    }


    return { success: false }; // 此返回，阻止了默认的上传操作
}

//先定位 Id的序号， 然后返回它左边的图片的ID
function findLeftImageId(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    if (index > 0) return imgs[index - 1].id;
    return "";
}


//找到左边最近的一张凭证号
//如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
//否则在那个号上加1做为自已的凭证号
function incLeftNearestPZH(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    //再从index往左边查到第一张凭证
    for (let i = index - 1; i >= 0; i--) {
        let tid = imgs[i].id;
        let pzh = getPZH(tid);
        if (pzh == '') continue;
        if (i == index - 1) {
            return pzh; // 左边最近的一张凭证号就在自已的左边，那么就意味着自已与左边那张凭证号可能就是一张凭证的不同分页，所以直接返回凭证号
        } else {
            return stringInc(pzh);
        }

    }
    //到这里，都没有找到凭证号，那么直接返回凭证号前缀
    return stringInc(lastPZH);
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data, event) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data, event) {

    // book.sheet0.cells("imgPreview").setValue("");
}

/**
 * 图片控件中图片顺序变化了
 * @param sheet   所在Sheet
 * @param config  图片控件的配置信息
 *@param ids  调整顺序后的id清单
 *
 */
//@comment (group=图片控件,caption=顺序调整后)
function attachmentOrderChanged(sheet, config, ids) {

    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    reorderImageFileIndex(imgs);

}

/**
 * 图片控件中某个图片被单击
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 * @param event  事件对象
 *
 *
 */
//@comment (group=图片控件,caption=图片被单击)
function imageOnClick(sheet, name, data, event) {

    if (name == 'imgPool') {
        if (book.sheet0.cells("clickAction").getValue() == 2) imageOnDBLClick(sheet, name, data, event, false);
    }
}


var g_lastPZH = "";
/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data, event, showDlg) {

    if (showDlg == undefined) showDlg = true;

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = "";
    if (pzh == '') {

        //找到左边最近的一张凭证号
        //如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
        //否则在那个号上加1做为自已的凭证号
        pzh = incLeftNearestPZH(data.id);
        if (pzh > lastPZH) lastPZH = pzh;


    }

    let $setpzh = function (val) {
        if (val == '') {

            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
            return true;
        } else {
            if (val.length - pzh_prefix.length != pzh_len) {
                toastr.error("凭证号(不含前缀)长度必须是" + pzh_len + "位");
                return false;

            }
            g_lastPZH = val; //记下来
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
            return true;
        }
    }

    if (!showDlg) {
        $setpzh(pzh);
        return;
    }

    let dlg = inputBox("标记为凭证", "", pzh, "输入凭证号码",

        function (val) { //确认后的回调

            return $setpzh(val);

        }, false,/*不允许为空*/
        //下面是一些事件的切入
        {
            //输入面板初始化完成后
            onContentReady: function () {

                let input = dlg.$content.find('.name');
                input.on('keyup', function () {
                    if (input.val().indexOf(pzh_prefix) != 0) {
                        input.val(pzh_prefix);
                    }
                });
            }
        }
    );




}


function setLoadImagePoolDataOnceCount() {
    let onceCount = book.sheet0.cells("onceCount").getValueInt();
    if (onceCount < 0) onceCount = 100;
    if (onceCount > 2000) onceCount = 2000;
    setTimeout(function () {
        book.sheet0.cells("onceCount").setValue(onceCount);
        book.sheet1.getBrick("imgPool").config.onceCount = onceCount;
        cb_refresh_onClick();
    }, 1);

}

//@comment (group=凭证号,caption=得到图片的凭证号如果有的话,needRightControl=false)
function getPZH(id) {
    let obj = find_pzh(id, false);
    if (obj == null) return;
    let s = obj.text();
    s = s.replace(/\s/g, '');
    return s;
}

//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() { doSelect(true); }
function cb_selectnull_onClick() { doSelect(false); }

function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    if (!path.endsWith('凭证影像采集目录')) {

        $.alert("目录名必须是：“凭证影像采集目录”，盘符及上级目录随意。");
        return;
    }
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);

    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path) {
    pathToMonit = path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit + " 监控中...");
    electron.ipcSendMessage({ cmd: "moniteStart", path: path });
}

function cb_refresh_onClick() {
    newImgCommingTipVisible(false);

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit(restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");



}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v) {
    book.sheet0.getBrick('shineText').visible = v;

}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount(fc) {
    var info = fc == 0 ? "" : "【" + fc + "】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


//@comment (group=归档,caption=凭证归档,needRightControl=false)
function cb_auto_onClick() {

    var imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }

    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    let nn = imgs.length - selection.length;
    if (nn > 0) {
        $confirm("提示", "有" + nn + "张图片没有选中，确信要继续吗?", function () {
            do_pack(selection);
        });
    } else {
        do_pack(selection);
    }
}

var pzGroup = [];

//@comment (group=归档,caption=归档操作,needRightControl=false)
function do_pack(selection) {
    pzGroup = [];
    let pzh2Config = {}; //凭证号对应的配置信息 ， 辅助数据
    let lastPZ = null;
    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        let pzh = getPZH(one.id);
        if (pzh == '') {
            if (lastPZ != null) {
                lastPZ.fj.push(one.id);
            }
        } else {
            //新的凭证号
            if (pzh2Config[pzh] == null) {
                lastPZ = {};
                lastPZ.pzh = pzh;
                lastPZ.fj = []; //附件图片
                lastPZ.pz = []; //凭证图片
                pzh2Config[pzh] = lastPZ; //记下凭证号与配置对象的对应关系
                pzGroup.push(lastPZ); //加入到总配置中
            } else {
                //已经存在配置，说明它是该凭证号的更多的分页图片
                //需要检测，它的左边是不是也是同一个号的凭证
                lastPZ = pzh2Config[pzh];

                let leftID = findLeftImageId(one.id); //找到它左边那张图片的ID
                if (leftID == '') {
                    toastr.error("不可能出现的情况");
                    return;
                }
                let leftPZH = getPZH(leftID);
                if (leftPZH != pzh) {
                    $.alert(pzh + '有多张图片，请将它们移动到相邻位置，即同一张凭证的多个分页必须连续相邻，它们之间不要穿插附件图片或其它凭证号图片');
                    return;
                }

            }
            lastPZ.pz.push(one.id); //凭证图片，同一个凭证可能有多个图片 
        }
    }

    if (pzGroup.length == 0) {
        toastr.error("凭证归档操作，至少需要标记一张凭证，并选中它");
        return;
    }

    console.dir();


    do_pzgdqr();



}

//@comment (group=归档,caption=归档确认,needRightControl=false)
function do_pzgdqr() {

    // 整理归档配置信息用于显示
    book.sheet4.paintPermit = false;

    $gd_ds.reset();
    for (let i = 0; i < pzGroup.length; i++) {
        let one = pzGroup[i];
        let row = $gd_ds.insertRow(9999);
        $gd_ds.setValue(row, { pzh: one.pzh, pzs: one.pz.length, fjs: one.fj.length, hj: one.pz.length + one.fj.length });
    }
    book.sheet4.paintPermit = true;

    book.sheet4.popup('fa fa-cog', '归档确认', 450, 450, true, true, {
        action1: {
            text: '确认',
            btnClass: 'btn-green',
            action: function () {
                do_pzgd();
                return true;    //表示关闭弹窗
            }
        },
        cancel: {
            text: '关闭',
            btnClass: 'btn-red',
            action: function () {

                return true;
            }
        }

    });

}
//@comment (group=归档,caption=归档,needRightControl=false)
function do_pzgd() {
    showInfoPane('*正在归档...');
    setButtonsStatus(false); //禁用一些按钮点击
    //alert(JSON.stringify(pzGroup));
    runTask("归档",
        {
            corpid: book.sheet4.cells("corpid").getValueString(),
            ym: book.sheet4.cells("ym").getValueString(),
            pzGroup: pzGroup
        }, function (ret) {
            hideInfoPane();
            ret = JSON.parse(ret);

            if (ret.success) {

                setButtonsStatus(true); //启用一些按钮点击
                smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
                //重新检索图片区
                cb_refresh_onClick();
            } else {
                $.alert(ret.message);
            }

        });
}

function setButtonsStatus(b) {

    book.sheet0.getBrick('cb_auto').enabled = b;
}

//@comment (group=,caption=调取某个凭证,needRightControl=false)
function loadPZ(id, pzh, verified) {
    book.sheet3.cells("id").setValue(id);
    smartRetrieve(book.sheet3, "one");
    //附件图片清单
    //不能从 $one_ds中取数，因为上面的smartRetrieve 是异步的
    let action = (verified == 0) ? "edit" : "view";
    book.sheet3.getBrick('cb_delete_pz').visible = verified == 0;
    var FJ = book.sheet3.getBrick('FJ');
    FJ.config.action = action; //控制是否显示删除和新增按钮
    let data = getPZFJ(id); //得到凭证的所有图片
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet3.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=,caption=删除凭证，并把图片回归到池中,needRightControl=false)
function cb_delete_pz_onClick() {
    $confirm("提示", "确信删除本凭证，并将图片全部回归到待归档状态吗?", function () {
        book.sheet3.getBrick('cb_delete_pz').visible = false;
        var id = $one_ds.getString(0, "id");
        var ret = deletePZAndPutBackToPool(id);
        if (ret.success) {
            $one_ds.reset();
            reload_pzh_info(); //可能删除的就是最后一张凭证，所以要重新取一下
            var FJ = book.sheet3.getBrick('FJ');
            FJ.config.action = 'view';
            FJ.buildGridly([]);
            cb_refresh_onClick();//刷新池中图片

        } else {
            toastr.error(ret.message);
        }
    });

}



function cb_trash_onClick() {
    var url = runTask("urlForTrash", {});
    openInMainFrame(url, false, 'fa-trash', '图片回收站');

}

function cb_deleteSelection_onClick() {
    let imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    let selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }
    let nn = selection.length;
    $confirm("提示", "确信将选中的" + nn + "张图片移入回收站吗?", function () {
        showInfoPane('*正在移和回收站');
        setTimeout(function () {
            do_trush(selection);
            hideInfoPane();
        }, 100);
    });

}

function do_trush(selection) {

    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        moveImageToRecycle(one.id);

    }
    cb_refresh_onClick();

}

function cb_size_onClick() {
    let RPM = book.sheet0.RPM;
    let h = RPM.getRowHeight(1);
    if (h > 1) {
        RPM.setRowStretchHeight(1, 0);//弹性高度取消
        RPM.setRowHeight(1, 1);

        RPM.setRowHeight(2, 0);
        book.sheet0.getBrick('dbnav').visible = false;

    } else {

        RPM.setRowStretchHeight(1, 40);//弹性高度取消
        RPM.setRowHeight(1, 300);

        RPM.setRowHeight(2, 30);
        book.sheet0.getBrick('dbnav').visible = true;
    }
}


/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //通过别名来判断
    if (sheet.name == '凭证清单') {
        if (cell.alias == 'nian' || cell.alias == 'yue') {
            reload_pzh_info();
        };
    }



}

/**
 * 单元格因为被编辑而改变。当用户通过编辑单元的值而让单元格发生值改变时本事件被触发。
 * 注意，当使用脚本 sheet.cells(row,col).setValue ( value) 来改变单元格的值时，本事件并不触发
 * @param sheet
 * @param cell
 * @param newValue
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChangedByEdit(sheet, cell, newValue, innerRow) {

    if (cell.alias == 'onceCount') {
        setLoadImagePoolDataOnceCount();

    }


}



function reload_pzh_info() {
    var sheet = book.getWorkSheet('凭证清单');
    //加载帐套信息及年月
    var corpid = sheet.cells("corpid").getValueString();

    var nian = sheet.cells("nian").getValueString();
    var yue = sheet.cells("yue").getValueString();
    var ym = nian + right("00" + yue, 2);

    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);
    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000000'.substring(8 - pzh_len, 8);
        lastPZH = v;

    });

    smartRetrieve(sheet, "dzpz_pz"); //刷新凭证列表
}



function cb_ocr_onClick() {
    toastr.show("正在自动识别");
    var imgPool = book.sheet1.getBrick('imgPool');
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    asyncPool(4,  // 最多4个并发执行
        imgs, //需要处理的数据数组，每个元素可以是任意类型的数据
        function (one, array) // item表示当前处理的对象， array就是整个数据数组
        {
            console.info(one.url_img);
            //函数必须返回一个Promise对象
            return new Promise(function (resolve, reject) {

                back_ocr({ src: one.url_img, left: '50%', top: '20%', height: '20%', width: '50%' }, function (text) {
                    if (text != '') {
                        setPZH(one.id, text);

                    }
                    resolve(1);
                });





            });
        }).then(function () {  //此时，整个数据数组都已经迭代执行完成 ，通常在此善后
            console.info("over");
            toastr.hide();
            toastr.success("自动识别完成");
        });

}


id: 6506c4319932de686bb62256
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 125.120.128.57
username: sa
createdate: 2023.09.17 17:17:38.000
script:
var pathToMonit = "";//当前监控的目录
var electron = null;
var pzh_prefix = ""; // 凭证号前缀
var pzh_len = 0; //凭证号长度
var lastPZH = "";
var fullScreenDiv = null;

/*
$(document).ready(function () {
    var script = $(`<script src="ui/imageEditor/filerobot-image-editor.min.js">
    
    </script>`);
    $(document.body).append(script);
});
*/

function formOpen() {

    book.sheet4.visible = false;

    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    book.sheet3.getBrick('cb_delete_pz').visible = false;

    //加载帐套信息及年月
    var corpid = book.sheet2.cells("corpid").getValueString();
    var ym = book.sheet2.cells("ym").getValue();
    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);

    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000001'.substring(8 - pzh_len, 8);
        lastPZH = v;
    });

    // smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
    // });

    book.getWorkSheet('凭证清单').cells("yue").setValue(getMonth(newDate()));

    book.sheet3.getBrick('FJ').config.promptInfoOnDelete = "确信要将图片从当前凭证中移除，并放回到图片池中吗?";
    book.sheet1.getBrick('imgPool').config.promptInfoOnDelete = "确信要将图片放入回收站吗?";

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage", function (msg) {
        msg = JSON.parse(msg);
        if (msg.cmd == "newFileUploaded") newImgCommingTipVisible(true); //通知有新文件上传了
        if (msg.cmd == "notifyNeedUploadFileCount") notifyNeedUploadFileCount(msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron = getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:30px; line-height:30px;width:100%; 
                                background-color:#af4040e0; 
                                color:white;font-weight:bold;font-size:20px;text-align:left;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:44px; top:0; text-align:right; 
                                    vertical-align:top; font-size:24px; color:#ffa0a0;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);


    setTimeout(function () {
        //调取缩略图大小

        var imgPool = book.sheet1.getBrick('imgPool');
        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout(function () {
        if (electron != null) {
            var hostName = electron.getHostName();
            pathToMonit = getMonitePath(hostName);

            //开启监控
            if (pathToMonit == '') pathToMonit = "c:\\凭证影像采集目录";

            moniteStart(pathToMonit);
            $.alert('请将扫描仪的图片目录指向：' + pathToMonit);
        }

        //显示总共图片数
        getTotalImageCount(function (ret) { book.sheet0.cells('imageCountTotal').setValue('共' + ret + '张') });

    }, 500);



    $(document).on('keydown', function (e) {
        console.info(" kkkkk down");
        if (e.ctrlKey) {
            // fullScreenViewImageOpen();
        }
    });


    $(document).on('keyup', function (e) {
        console.info(" kkkkk up");
        if (!e.ctrlKey) {

            // fullScreenViewImageClose();

        }
    });

    onPushMessage( "pz_ocr" , function(msg)
    {
        if( msg.action=='info')
        { 
            toastr.show( msg);
        }
    }) ;

}


// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function saveSelectionAndPZInfo() {

    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection = selection;
    g_pzMap = pzhMap;
}




//@comment (group=图片清单刷新,caption=还原选中及凭证标记,needRightControl=false)
function restoreSelectionAndPZInfo() {
    var selection = g_selection;
    var pzhMap = g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();

    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

function resetImageCountInfo() {

    setTimeout(function () {
        book.sheet0.cells("imageCount").setValue("前 " + book.sheet1.getBrick("imgPool").imageCount + " 张");
    }, 300);
}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "imgPool") {
        resetImageCountInfo()
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        book.sheet0.cells("imageCount").setValue(brick.imageCout + "张图片");


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数

                showInfoPane('*正在旋转图片...');
                setTimeout(function () {
                    //toastr.info(id);  // id 是当前操作的图片对应数据的ID
                    var ret = do_imageRotate(id, "90");
                    if (ret.success) {
                        //把数据中的图片替换，
                        for (let i = 0; i < brick.data.length; i++) {
                            if (brick.data[i].id == id) {
                                //属性从新的属性中替换 
                                for (let prop in brick.data[i]) {
                                    brick.data[i][prop] = ret.data[prop];
                                }
                                break;
                            }
                        }
                        //把缩略图的图片地址替换 ， 

                        let img = $('#' + id).find('.image');
                        img.attr("src", ret.data.url_thumbnail);
                        img.attr('largeimage', ret.data.url_img);
                        //把大图预览的地址替换掉
                        book.sheet0.cells("imgPreview").setValue(ret.data.url_img);
                        hideInfoPane();

                    }
                }, 10);
            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-plus",   // 字符图标
            "选中此前",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let selected = $('#' + id).parent().find('.brickSelected').length > 0; // 可以用 imgPool.isImageSelected( id) 替换，但此时本函数还没有提供，以后可以换成此函数

                let imgPool = book.sheet1.getBrick("imgPool");
                let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
                let found = false;
                for (let i = 0; i < imgs.length; i++) {
                    imgPool.setImageSelected(imgs[i].id, !selected);
                    if (imgs[i].id == id) return;

                }


            });


    }
}


/**
 * 图片控件中图片上的删除按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 * @param data  图片的信息
 *
 * @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行删除操作，否则表示终止删除操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上的删除按钮被点击)
function imageOnDelete(sheet, name, data) {

    if (name == 'FJ') {
        if (data.groupname == '凭证') {
            return { success: false, message: "这是凭证，不允许这样移除，请点击“删除凭证”" };
        } else {
            var ret = putImageBackToPool(data.id);
            if (ret.success) {
                smartRetrieve(book.sheet3, "one");
                cb_refresh_onClick();
            } else {
                return ret;
            }

        }
    }

    if (name == 'imgPool') {
        moveImageToRecycle(data.id);
        resetImageCountInfo();
    }
    return { success: true };
}
/**
 * 图片控件中上传按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 *
 @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行上传操作，否则表示终止上传操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上传按钮被点击)
function imageOnNewUpload(sheet, name) {


    if (name == 'imgPool') {
        toastr.info("请连接扫描仪，或将图片复制到监控的目录下，图片自动上传");
    }

    if (name == 'FJ') {
        var imgPool = book.sheet1.getBrick('imgPool');
        // 保存当前选中状态及设置的凭证号信息
        var selection = imgPool.getSelectedImageList();
        if (selection.length == 0) {
            toastr.error("至少选中一张图片");
            return { success: false }; // 此返回，阻止了默认的上传操作
        }


        var lastPZ = null;
        for (let i = 0; i < selection.length; i++) {
            var one = selection[i];
            var pzh = getPZH(one.id);
            if (pzh != '') {
                toastr.error("选中的图片中有标记为凭证的，禁止将凭证图片添加到当前凭证中");
                return { success: false }; // 此返回，阻止了默认的上传操作
            }
        }

        var ret = addImageToPZ($one_ds.getString(0, "id"), selection);
        if (ret.success) {
            //刷新图片区
            cb_refresh_onClick();
            //刷新凭证
            loadPZ($one_ds.getString(0, "id"), $one_ds.getString(0, "pzh"), $one_ds.getString(0, "verifiername") != "" ? 1 : 0);
        }

    }


    return { success: false }; // 此返回，阻止了默认的上传操作
}

//先定位 Id的序号， 然后返回它左边的图片的ID
function findLeftImageId(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    if (index > 0) return imgs[index - 1].id;
    return "";
}


//找到左边最近的一张凭证号
//如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
//否则在那个号上加1做为自已的凭证号
function incLeftNearestPZH(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    //再从index往左边查到第一张凭证
    for (let i = index - 1; i >= 0; i--) {
        let tid = imgs[i].id;
        let pzh = getPZH(tid);
        if (pzh == '') continue;
        if (i == index - 1) {
            return pzh; // 左边最近的一张凭证号就在自已的左边，那么就意味着自已与左边那张凭证号可能就是一张凭证的不同分页，所以直接返回凭证号
        } else {
            return stringInc(pzh);
        }

    }
    //到这里，都没有找到凭证号，那么直接返回凭证号前缀
    return stringInc(lastPZH);
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data, event) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data, event) {

    // book.sheet0.cells("imgPreview").setValue("");
}

/**
 * 图片控件中图片顺序变化了
 * @param sheet   所在Sheet
 * @param config  图片控件的配置信息
 *@param ids  调整顺序后的id清单
 *
 */
//@comment (group=图片控件,caption=顺序调整后)
function attachmentOrderChanged(sheet, config, ids) {

    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    reorderImageFileIndex(imgs);

}

/**
 * 图片控件中某个图片被单击
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 * @param event  事件对象
 *
 *
 */
//@comment (group=图片控件,caption=图片被单击)
function imageOnClick(sheet, name, data, event) {

    if (name == 'imgPool') {
        if (book.sheet0.cells("clickAction").getValue() == 2) imageOnDBLClick(sheet, name, data, event, false);
    }
}


var g_lastPZH = "";
/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data, event, showDlg) {

    if (showDlg == undefined) showDlg = true;

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = "";
    if (pzh == '') {

        //找到左边最近的一张凭证号
        //如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
        //否则在那个号上加1做为自已的凭证号
        pzh = incLeftNearestPZH(data.id);
        if (pzh > lastPZH) lastPZH = pzh;


    }

    let $setpzh = function (val) {
        if (val == '') {

            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
            return true;
        } else {
            if (val.length - pzh_prefix.length != pzh_len) {
                toastr.error("凭证号(不含前缀)长度必须是" + pzh_len + "位");
                return false;

            }
            g_lastPZH = val; //记下来
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
            return true;
        }
    }

    if (!showDlg) {
        $setpzh(pzh);
        return;
    }

    let dlg = inputBox("标记为凭证", "", pzh, "输入凭证号码",

        function (val) { //确认后的回调

            return $setpzh(val);

        }, false,/*不允许为空*/
        //下面是一些事件的切入
        {
            //输入面板初始化完成后
            onContentReady: function () {

                let input = dlg.$content.find('.name');
                input.on('keyup', function () {
                    if (input.val().indexOf(pzh_prefix) != 0) {
                        input.val(pzh_prefix);
                    }
                });
            }
        }
    );




}


function setLoadImagePoolDataOnceCount() {
    let onceCount = book.sheet0.cells("onceCount").getValueInt();
    if (onceCount < 0) onceCount = 100;
    if (onceCount > 2000) onceCount = 2000;
    setTimeout(function () {
        book.sheet0.cells("onceCount").setValue(onceCount);
        book.sheet1.getBrick("imgPool").config.onceCount = onceCount;
        cb_refresh_onClick();
    }, 1);

}

//@comment (group=凭证号,caption=得到图片的凭证号如果有的话,needRightControl=false)
function getPZH(id) {
    let obj = find_pzh(id, false);
    if (obj == null) return;
    let s = obj.text();
    s = s.replace(/\s/g, '');
    return s;
}

//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() { doSelect(true); }
function cb_selectnull_onClick() { doSelect(false); }

function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    if (!path.endsWith('凭证影像采集目录')) {

        $.alert("目录名必须是：“凭证影像采集目录”，盘符及上级目录随意。");
        return;
    }
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);

    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path) {
    pathToMonit = path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit + " 监控中...");
    electron.ipcSendMessage({ cmd: "moniteStart", path: path });
}

function cb_refresh_onClick() {
    newImgCommingTipVisible(false);

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit(restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");



}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v) {
    book.sheet0.getBrick('shineText').visible = v;

}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount(fc) {
    var info = fc == 0 ? "" : "【" + fc + "】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


//@comment (group=归档,caption=凭证归档,needRightControl=false)
function cb_auto_onClick() {

    var imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }

    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    let nn = imgs.length - selection.length;
    if (nn > 0) {
        $confirm("提示", "有" + nn + "张图片没有选中，确信要继续吗?", function () {
            do_pack(selection);
        });
    } else {
        do_pack(selection);
    }
}

var pzGroup = [];

//@comment (group=归档,caption=归档操作,needRightControl=false)
function do_pack(selection) {
    pzGroup = [];
    let pzh2Config = {}; //凭证号对应的配置信息 ， 辅助数据
    let lastPZ = null;
    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        let pzh = getPZH(one.id);
        if (pzh == '') {
            if (lastPZ != null) {
                lastPZ.fj.push(one.id);
            }
        } else {
            //新的凭证号
            if (pzh2Config[pzh] == null) {
                lastPZ = {};
                lastPZ.pzh = pzh;
                lastPZ.fj = []; //附件图片
                lastPZ.pz = []; //凭证图片
                pzh2Config[pzh] = lastPZ; //记下凭证号与配置对象的对应关系
                pzGroup.push(lastPZ); //加入到总配置中
            } else {
                //已经存在配置，说明它是该凭证号的更多的分页图片
                //需要检测，它的左边是不是也是同一个号的凭证
                lastPZ = pzh2Config[pzh];

                let leftID = findLeftImageId(one.id); //找到它左边那张图片的ID
                if (leftID == '') {
                    toastr.error("不可能出现的情况");
                    return;
                }
                let leftPZH = getPZH(leftID);
                if (leftPZH != pzh) {
                    $.alert(pzh + '有多张图片，请将它们移动到相邻位置，即同一张凭证的多个分页必须连续相邻，它们之间不要穿插附件图片或其它凭证号图片');
                    return;
                }

            }
            lastPZ.pz.push(one.id); //凭证图片，同一个凭证可能有多个图片 
        }
    }

    if (pzGroup.length == 0) {
        toastr.error("凭证归档操作，至少需要标记一张凭证，并选中它");
        return;
    }

    console.dir();


    do_pzgdqr();



}

//@comment (group=归档,caption=归档确认,needRightControl=false)
function do_pzgdqr() {

    // 整理归档配置信息用于显示
    book.sheet4.paintPermit = false;

    $gd_ds.reset();
    for (let i = 0; i < pzGroup.length; i++) {
        let one = pzGroup[i];
        let row = $gd_ds.insertRow(9999);
        $gd_ds.setValue(row, { pzh: one.pzh, pzs: one.pz.length, fjs: one.fj.length, hj: one.pz.length + one.fj.length });
    }
    book.sheet4.paintPermit = true;

    book.sheet4.popup('fa fa-cog', '归档确认', 450, 450, true, true, {
        action1: {
            text: '确认',
            btnClass: 'btn-green',
            action: function () {
                do_pzgd();
                return true;    //表示关闭弹窗
            }
        },
        cancel: {
            text: '关闭',
            btnClass: 'btn-red',
            action: function () {

                return true;
            }
        }

    });

}
//@comment (group=归档,caption=归档,needRightControl=false)
function do_pzgd() {
    showInfoPane('*正在归档...');
    setButtonsStatus(false); //禁用一些按钮点击
    //alert(JSON.stringify(pzGroup));
    runTask("归档",
        {
            corpid: book.sheet4.cells("corpid").getValueString(),
            ym: book.sheet4.cells("ym").getValueString(),
            pzGroup: pzGroup
        }, function (ret) {
            hideInfoPane();
            ret = JSON.parse(ret);

            if (ret.success) {

                setButtonsStatus(true); //启用一些按钮点击
                smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
                //重新检索图片区
                cb_refresh_onClick();
            } else {
                $.alert(ret.message);
            }

        });
}

function setButtonsStatus(b) {

    book.sheet0.getBrick('cb_auto').enabled = b;
}

//@comment (group=,caption=调取某个凭证,needRightControl=false)
function loadPZ(id, pzh, verified) {
    book.sheet3.cells("id").setValue(id);
    smartRetrieve(book.sheet3, "one");
    //附件图片清单
    //不能从 $one_ds中取数，因为上面的smartRetrieve 是异步的
    let action = (verified == 0) ? "edit" : "view";
    book.sheet3.getBrick('cb_delete_pz').visible = verified == 0;
    var FJ = book.sheet3.getBrick('FJ');
    FJ.config.action = action; //控制是否显示删除和新增按钮
    let data = getPZFJ(id); //得到凭证的所有图片
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet3.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=,caption=删除凭证，并把图片回归到池中,needRightControl=false)
function cb_delete_pz_onClick() {
    $confirm("提示", "确信删除本凭证，并将图片全部回归到待归档状态吗?", function () {
        book.sheet3.getBrick('cb_delete_pz').visible = false;
        var id = $one_ds.getString(0, "id");
        var ret = deletePZAndPutBackToPool(id);
        if (ret.success) {
            $one_ds.reset();
            reload_pzh_info(); //可能删除的就是最后一张凭证，所以要重新取一下
            var FJ = book.sheet3.getBrick('FJ');
            FJ.config.action = 'view';
            FJ.buildGridly([]);
            cb_refresh_onClick();//刷新池中图片

        } else {
            toastr.error(ret.message);
        }
    });

}



function cb_trash_onClick() {
    var url = runTask("urlForTrash", {});
    openInMainFrame(url, false, 'fa-trash', '图片回收站');

}

function cb_deleteSelection_onClick() {
    let imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    let selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }
    let nn = selection.length;
    $confirm("提示", "确信将选中的" + nn + "张图片移入回收站吗?", function () {
        showInfoPane('*正在移和回收站');
        setTimeout(function () {
            do_trush(selection);
            hideInfoPane();
        }, 100);
    });

}

function do_trush(selection) {

    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        moveImageToRecycle(one.id);

    }
    cb_refresh_onClick();

}

function cb_size_onClick() {
    let RPM = book.sheet0.RPM;
    let h = RPM.getRowHeight(1);
    if (h > 1) {
        RPM.setRowStretchHeight(1, 0);//弹性高度取消
        RPM.setRowHeight(1, 1);

        RPM.setRowHeight(2, 0);
        book.sheet0.getBrick('dbnav').visible = false;

    } else {

        RPM.setRowStretchHeight(1, 40);//弹性高度取消
        RPM.setRowHeight(1, 300);

        RPM.setRowHeight(2, 30);
        book.sheet0.getBrick('dbnav').visible = true;
    }
}


/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //通过别名来判断
    if (sheet.name == '凭证清单') {
        if (cell.alias == 'nian' || cell.alias == 'yue') {
            reload_pzh_info();
        };
    }



}

/**
 * 单元格因为被编辑而改变。当用户通过编辑单元的值而让单元格发生值改变时本事件被触发。
 * 注意，当使用脚本 sheet.cells(row,col).setValue ( value) 来改变单元格的值时，本事件并不触发
 * @param sheet
 * @param cell
 * @param newValue
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChangedByEdit(sheet, cell, newValue, innerRow) {

    if (cell.alias == 'onceCount') {
        setLoadImagePoolDataOnceCount();

    }


}



function reload_pzh_info() {
    var sheet = book.getWorkSheet('凭证清单');
    //加载帐套信息及年月
    var corpid = sheet.cells("corpid").getValueString();

    var nian = sheet.cells("nian").getValueString();
    var yue = sheet.cells("yue").getValueString();
    var ym = nian + right("00" + yue, 2);

    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);
    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000000'.substring(8 - pzh_len, 8);
        lastPZH = v;

    });

    smartRetrieve(sheet, "dzpz_pz"); //刷新凭证列表
}



function cb_ocr_onClick() {
    toastr.show("正在自动识别");
    var imgPool = book.sheet1.getBrick('imgPool');
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    asyncPool(4,  // 最多4个并发执行
        imgs, //需要处理的数据数组，每个元素可以是任意类型的数据
        function (one, array) // item表示当前处理的对象， array就是整个数据数组
        {
            console.info(one.url_img);
            //函数必须返回一个Promise对象
            return new Promise(function (resolve, reject) {

                back_ocr({ src: one.url_img, left: '50%', top: '20%', height: '25%', width: '50%' }, function (text) {
                    if (text != '') {
                        setPZH(one.id, text);

                    }
                    resolve(1);
                });





            });
        }).then(function () {  //此时，整个数据数组都已经迭代执行完成 ，通常在此善后
            console.info("over");
            toastr.hide();
            toastr.success("自动识别完成");
        });

}


id: 65129d659932f2713a061c85
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 16:59:54.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf('\\n20');
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+3 ,7).replace(/-/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061c8e
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:01:06.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf('\\n20');
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+3 ,7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061c97
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:02:01.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf('n20');
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+3 ,7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061ca0
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:03:09.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf("\\n20");
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+3 ,7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061ca9
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:04:53.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf("\n20");
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+3 ,7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061cb2
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:05:40.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf("20");
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+3 ,7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061cbb
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:05:46.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf("20");
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+2 ,7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65129d659932f2713a061cc4
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 17:06:00.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    t=t.replace(/\s/g , '');
   var p= t.indexOf("20");
   println(p);
    ym ="";
   if( p>0)
   {   ym=  t.substring(p+2 ,p+2+7).replace(/[-]/g,'');
      
   }
      p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.substring(0,4) 
    
    return  ym + right('0000'+p ,4) ; 


}


id: 65126db2993204acd61efc32
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 14:19:16.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    var p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.indexOf('号');
    if( p<0) return ''; 
    t= t.substring(0,p);
    t=t.replace(/\s/g , '');
    return  right('0000'+t ,5) ; 


}


id: 65126db2993204acd61efc3a
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 14:19:44.000
script:
var pathToMonit = "";//当前监控的目录
var electron = null;
var pzh_prefix = ""; // 凭证号前缀
var pzh_len = 0; //凭证号长度
var lastPZH = "";
var fullScreenDiv = null;

/*
$(document).ready(function () {
    var script = $(`<script src="ui/imageEditor/filerobot-image-editor.min.js">
    
    </script>`);
    $(document.body).append(script);
});
*/

function formOpen() {

    book.sheet4.visible = false;

    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    book.sheet3.getBrick('cb_delete_pz').visible = false;

    //加载帐套信息及年月
    var corpid = book.sheet2.cells("corpid").getValueString();
    var ym = book.sheet2.cells("ym").getValue();
    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);

    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000001'.substring(8 - pzh_len, 8);
        lastPZH = v;
    });

    // smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
    // });

    book.getWorkSheet('凭证清单').cells("yue").setValue(getMonth(newDate()));

    book.sheet3.getBrick('FJ').config.promptInfoOnDelete = "确信要将图片从当前凭证中移除，并放回到图片池中吗?";
    book.sheet1.getBrick('imgPool').config.promptInfoOnDelete = "确信要将图片放入回收站吗?";

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage", function (msg) {
        msg = JSON.parse(msg);
        if (msg.cmd == "newFileUploaded") newImgCommingTipVisible(true); //通知有新文件上传了
        if (msg.cmd == "notifyNeedUploadFileCount") notifyNeedUploadFileCount(msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron = getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:30px; line-height:30px;width:100%; 
                                background-color:#af4040e0; 
                                color:white;font-weight:bold;font-size:20px;text-align:left;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:44px; top:0; text-align:right; 
                                    vertical-align:top; font-size:24px; color:#ffa0a0;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);


    setTimeout(function () {
        //调取缩略图大小

        var imgPool = book.sheet1.getBrick('imgPool');
        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout(function () {
        if (electron != null) {
            var hostName = electron.getHostName();
            pathToMonit = getMonitePath(hostName);

            //开启监控
            if (pathToMonit == '') pathToMonit = "c:\\凭证影像采集目录";

            moniteStart(pathToMonit);
            $.alert('请将扫描仪的图片目录指向：' + pathToMonit);
        }

        //显示总共图片数
        getTotalImageCount(function (ret) { book.sheet0.cells('imageCountTotal').setValue('共' + ret + '张') });

    }, 500);



    $(document).on('keydown', function (e) {
        console.info(" kkkkk down");
        if (e.ctrlKey) {
            // fullScreenViewImageOpen();
        }
    });


    $(document).on('keyup', function (e) {
        console.info(" kkkkk up");
        if (!e.ctrlKey) {

            // fullScreenViewImageClose();

        }
    });

    onPushMessage( "pz_ocr" , function(msg)
    {
        if( msg.action=='info')
        { 
            toastr.show( msg);
        }
    }) ;

}


// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function saveSelectionAndPZInfo() {

    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection = selection;
    g_pzMap = pzhMap;
}




//@comment (group=图片清单刷新,caption=还原选中及凭证标记,needRightControl=false)
function restoreSelectionAndPZInfo() {
    var selection = g_selection;
    var pzhMap = g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();

    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

function resetImageCountInfo() {

    setTimeout(function () {
        book.sheet0.cells("imageCount").setValue("前 " + book.sheet1.getBrick("imgPool").imageCount + " 张");
    }, 300);
}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "imgPool") {
        resetImageCountInfo()
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        book.sheet0.cells("imageCount").setValue(brick.imageCout + "张图片");


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数

                showInfoPane('*正在旋转图片...');
                setTimeout(function () {
                    //toastr.info(id);  // id 是当前操作的图片对应数据的ID
                    var ret = do_imageRotate(id, "90");
                    if (ret.success) {
                        //把数据中的图片替换，
                        for (let i = 0; i < brick.data.length; i++) {
                            if (brick.data[i].id == id) {
                                //属性从新的属性中替换 
                                for (let prop in brick.data[i]) {
                                    brick.data[i][prop] = ret.data[prop];
                                }
                                break;
                            }
                        }
                        //把缩略图的图片地址替换 ， 

                        let img = $('#' + id).find('.image');
                        img.attr("src", ret.data.url_thumbnail);
                        img.attr('largeimage', ret.data.url_img);
                        //把大图预览的地址替换掉
                        book.sheet0.cells("imgPreview").setValue(ret.data.url_img);
                        hideInfoPane();

                    }
                }, 10);
            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-plus",   // 字符图标
            "选中此前",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let selected = $('#' + id).parent().find('.brickSelected').length > 0; // 可以用 imgPool.isImageSelected( id) 替换，但此时本函数还没有提供，以后可以换成此函数

                let imgPool = book.sheet1.getBrick("imgPool");
                let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
                let found = false;
                for (let i = 0; i < imgs.length; i++) {
                    imgPool.setImageSelected(imgs[i].id, !selected);
                    if (imgs[i].id == id) return;

                }


            });


    }
}


/**
 * 图片控件中图片上的删除按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 * @param data  图片的信息
 *
 * @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行删除操作，否则表示终止删除操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上的删除按钮被点击)
function imageOnDelete(sheet, name, data) {

    if (name == 'FJ') {
        if (data.groupname == '凭证') {
            return { success: false, message: "这是凭证，不允许这样移除，请点击“删除凭证”" };
        } else {
            var ret = putImageBackToPool(data.id);
            if (ret.success) {
                smartRetrieve(book.sheet3, "one");
                cb_refresh_onClick();
            } else {
                return ret;
            }

        }
    }

    if (name == 'imgPool') {
        moveImageToRecycle(data.id);
        resetImageCountInfo();
    }
    return { success: true };
}
/**
 * 图片控件中上传按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 *
 @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行上传操作，否则表示终止上传操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上传按钮被点击)
function imageOnNewUpload(sheet, name) {


    if (name == 'imgPool') {
        toastr.info("请连接扫描仪，或将图片复制到监控的目录下，图片自动上传");
    }

    if (name == 'FJ') {
        var imgPool = book.sheet1.getBrick('imgPool');
        // 保存当前选中状态及设置的凭证号信息
        var selection = imgPool.getSelectedImageList();
        if (selection.length == 0) {
            toastr.error("至少选中一张图片");
            return { success: false }; // 此返回，阻止了默认的上传操作
        }


        var lastPZ = null;
        for (let i = 0; i < selection.length; i++) {
            var one = selection[i];
            var pzh = getPZH(one.id);
            if (pzh != '') {
                toastr.error("选中的图片中有标记为凭证的，禁止将凭证图片添加到当前凭证中");
                return { success: false }; // 此返回，阻止了默认的上传操作
            }
        }

        var ret = addImageToPZ($one_ds.getString(0, "id"), selection);
        if (ret.success) {
            //刷新图片区
            cb_refresh_onClick();
            //刷新凭证
            loadPZ($one_ds.getString(0, "id"), $one_ds.getString(0, "pzh"), $one_ds.getString(0, "verifiername") != "" ? 1 : 0);
        }

    }


    return { success: false }; // 此返回，阻止了默认的上传操作
}

//先定位 Id的序号， 然后返回它左边的图片的ID
function findLeftImageId(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    if (index > 0) return imgs[index - 1].id;
    return "";
}


//找到左边最近的一张凭证号
//如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
//否则在那个号上加1做为自已的凭证号
function incLeftNearestPZH(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    //再从index往左边查到第一张凭证
    for (let i = index - 1; i >= 0; i--) {
        let tid = imgs[i].id;
        let pzh = getPZH(tid);
        if (pzh == '') continue;
        if (i == index - 1) {
            return pzh; // 左边最近的一张凭证号就在自已的左边，那么就意味着自已与左边那张凭证号可能就是一张凭证的不同分页，所以直接返回凭证号
        } else {
            return stringInc(pzh);
        }

    }
    //到这里，都没有找到凭证号，那么直接返回凭证号前缀
    return stringInc(lastPZH);
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data, event) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data, event) {

    // book.sheet0.cells("imgPreview").setValue("");
}

/**
 * 图片控件中图片顺序变化了
 * @param sheet   所在Sheet
 * @param config  图片控件的配置信息
 *@param ids  调整顺序后的id清单
 *
 */
//@comment (group=图片控件,caption=顺序调整后)
function attachmentOrderChanged(sheet, config, ids) {

    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    reorderImageFileIndex(imgs);

}

/**
 * 图片控件中某个图片被单击
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 * @param event  事件对象
 *
 *
 */
//@comment (group=图片控件,caption=图片被单击)
function imageOnClick(sheet, name, data, event) {

    if (name == 'imgPool') {
        if (book.sheet0.cells("clickAction").getValue() == 2) imageOnDBLClick(sheet, name, data, event, false);
    }
}


var g_lastPZH = "";
/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data, event, showDlg) {

    if (showDlg == undefined) showDlg = true;

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = "";
    if (pzh == '') {

        //找到左边最近的一张凭证号
        //如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
        //否则在那个号上加1做为自已的凭证号
        pzh = incLeftNearestPZH(data.id);
        if (pzh > lastPZH) lastPZH = pzh;


    }

    let $setpzh = function (val) {
        if (val == '') {

            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
            return true;
        } else {
            if (val.length - pzh_prefix.length != pzh_len) {
                toastr.error("凭证号(不含前缀)长度必须是" + pzh_len + "位");
                return false;

            }
            g_lastPZH = val; //记下来
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
            return true;
        }
    }

    if (!showDlg) {
        $setpzh(pzh);
        return;
    }

    let dlg = inputBox("标记为凭证", "", pzh, "输入凭证号码",

        function (val) { //确认后的回调

            return $setpzh(val);

        }, false,/*不允许为空*/
        //下面是一些事件的切入
        {
            //输入面板初始化完成后
            onContentReady: function () {

                let input = dlg.$content.find('.name');
                input.on('keyup', function () {
                    if (input.val().indexOf(pzh_prefix) != 0) {
                        input.val(pzh_prefix);
                    }
                });
            }
        }
    );




}


function setLoadImagePoolDataOnceCount() {
    let onceCount = book.sheet0.cells("onceCount").getValueInt();
    if (onceCount < 0) onceCount = 100;
    if (onceCount > 2000) onceCount = 2000;
    setTimeout(function () {
        book.sheet0.cells("onceCount").setValue(onceCount);
        book.sheet1.getBrick("imgPool").config.onceCount = onceCount;
        cb_refresh_onClick();
    }, 1);

}

//@comment (group=凭证号,caption=得到图片的凭证号如果有的话,needRightControl=false)
function getPZH(id) {
    let obj = find_pzh(id, false);
    if (obj == null) return;
    let s = obj.text();
    s = s.replace(/\s/g, '');
    return s;
}

//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() { doSelect(true); }
function cb_selectnull_onClick() { doSelect(false); }

function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    if (!path.endsWith('凭证影像采集目录')) {

        $.alert("目录名必须是：“凭证影像采集目录”，盘符及上级目录随意。");
        return;
    }
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);

    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path) {
    pathToMonit = path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit + " 监控中...");
    electron.ipcSendMessage({ cmd: "moniteStart", path: path });
}

function cb_refresh_onClick() {
    newImgCommingTipVisible(false);

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit(restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");



}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v) {
    book.sheet0.getBrick('shineText').visible = v;

}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount(fc) {
    var info = fc == 0 ? "" : "【" + fc + "】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


//@comment (group=归档,caption=凭证归档,needRightControl=false)
function cb_auto_onClick() {

    var imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }

    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    let nn = imgs.length - selection.length;
    if (nn > 0) {
        $confirm("提示", "有" + nn + "张图片没有选中，确信要继续吗?", function () {
            do_pack(selection);
        });
    } else {
        do_pack(selection);
    }
}

var pzGroup = [];

//@comment (group=归档,caption=归档操作,needRightControl=false)
function do_pack(selection) {
    pzGroup = [];
    let pzh2Config = {}; //凭证号对应的配置信息 ， 辅助数据
    let lastPZ = null;
    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        let pzh = getPZH(one.id);
        if (pzh == '') {
            if (lastPZ != null) {
                lastPZ.fj.push(one.id);
            }
        } else {
            //新的凭证号
            if (pzh2Config[pzh] == null) {
                lastPZ = {};
                lastPZ.pzh = pzh;
                lastPZ.fj = []; //附件图片
                lastPZ.pz = []; //凭证图片
                pzh2Config[pzh] = lastPZ; //记下凭证号与配置对象的对应关系
                pzGroup.push(lastPZ); //加入到总配置中
            } else {
                //已经存在配置，说明它是该凭证号的更多的分页图片
                //需要检测，它的左边是不是也是同一个号的凭证
                lastPZ = pzh2Config[pzh];

                let leftID = findLeftImageId(one.id); //找到它左边那张图片的ID
                if (leftID == '') {
                    toastr.error("不可能出现的情况");
                    return;
                }
                let leftPZH = getPZH(leftID);
                if (leftPZH != pzh) {
                    $.alert(pzh + '有多张图片，请将它们移动到相邻位置，即同一张凭证的多个分页必须连续相邻，它们之间不要穿插附件图片或其它凭证号图片');
                    return;
                }

            }
            lastPZ.pz.push(one.id); //凭证图片，同一个凭证可能有多个图片 
        }
    }

    if (pzGroup.length == 0) {
        toastr.error("凭证归档操作，至少需要标记一张凭证，并选中它");
        return;
    }

    console.dir();


    do_pzgdqr();



}

//@comment (group=归档,caption=归档确认,needRightControl=false)
function do_pzgdqr() {

    // 整理归档配置信息用于显示
    book.sheet4.paintPermit = false;

    $gd_ds.reset();
    for (let i = 0; i < pzGroup.length; i++) {
        let one = pzGroup[i];
        let row = $gd_ds.insertRow(9999);
        $gd_ds.setValue(row, { pzh: one.pzh, pzs: one.pz.length, fjs: one.fj.length, hj: one.pz.length + one.fj.length });
    }
    book.sheet4.paintPermit = true;

    book.sheet4.popup('fa fa-cog', '归档确认', 450, 450, true, true, {
        action1: {
            text: '确认',
            btnClass: 'btn-green',
            action: function () {
                do_pzgd();
                return true;    //表示关闭弹窗
            }
        },
        cancel: {
            text: '关闭',
            btnClass: 'btn-red',
            action: function () {

                return true;
            }
        }

    });

}
//@comment (group=归档,caption=归档,needRightControl=false)
function do_pzgd() {
    showInfoPane('*正在归档...');
    setButtonsStatus(false); //禁用一些按钮点击
    //alert(JSON.stringify(pzGroup));
    runTask("归档",
        {
            corpid: book.sheet4.cells("corpid").getValueString(),
            ym: book.sheet4.cells("ym").getValueString(),
            pzGroup: pzGroup
        }, function (ret) {
            hideInfoPane();
            ret = JSON.parse(ret);

            if (ret.success) {

                setButtonsStatus(true); //启用一些按钮点击
                smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
                //重新检索图片区
                cb_refresh_onClick();
            } else {
                $.alert(ret.message);
            }

        });
}

function setButtonsStatus(b) {

    book.sheet0.getBrick('cb_auto').enabled = b;
}

//@comment (group=,caption=调取某个凭证,needRightControl=false)
function loadPZ(id, pzh, verified) {
    book.sheet3.cells("id").setValue(id);
    smartRetrieve(book.sheet3, "one");
    //附件图片清单
    //不能从 $one_ds中取数，因为上面的smartRetrieve 是异步的
    let action = (verified == 0) ? "edit" : "view";
    book.sheet3.getBrick('cb_delete_pz').visible = verified == 0;
    var FJ = book.sheet3.getBrick('FJ');
    FJ.config.action = action; //控制是否显示删除和新增按钮
    let data = getPZFJ(id); //得到凭证的所有图片
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet3.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=,caption=删除凭证，并把图片回归到池中,needRightControl=false)
function cb_delete_pz_onClick() {
    $confirm("提示", "确信删除本凭证，并将图片全部回归到待归档状态吗?", function () {
        book.sheet3.getBrick('cb_delete_pz').visible = false;
        var id = $one_ds.getString(0, "id");
        var ret = deletePZAndPutBackToPool(id);
        if (ret.success) {
            $one_ds.reset();
            reload_pzh_info(); //可能删除的就是最后一张凭证，所以要重新取一下
            var FJ = book.sheet3.getBrick('FJ');
            FJ.config.action = 'view';
            FJ.buildGridly([]);
            cb_refresh_onClick();//刷新池中图片

        } else {
            toastr.error(ret.message);
        }
    });

}



function cb_trash_onClick() {
    var url = runTask("urlForTrash", {});
    openInMainFrame(url, false, 'fa-trash', '图片回收站');

}

function cb_deleteSelection_onClick() {
    let imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    let selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }
    let nn = selection.length;
    $confirm("提示", "确信将选中的" + nn + "张图片移入回收站吗?", function () {
        showInfoPane('*正在移和回收站');
        setTimeout(function () {
            do_trush(selection);
            hideInfoPane();
        }, 100);
    });

}

function do_trush(selection) {

    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        moveImageToRecycle(one.id);

    }
    cb_refresh_onClick();

}

function cb_size_onClick() {
    let RPM = book.sheet0.RPM;
    let h = RPM.getRowHeight(1);
    if (h > 1) {
        RPM.setRowStretchHeight(1, 0);//弹性高度取消
        RPM.setRowHeight(1, 1);

        RPM.setRowHeight(2, 0);
        book.sheet0.getBrick('dbnav').visible = false;

    } else {

        RPM.setRowStretchHeight(1, 40);//弹性高度取消
        RPM.setRowHeight(1, 300);

        RPM.setRowHeight(2, 30);
        book.sheet0.getBrick('dbnav').visible = true;
    }
}


/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //通过别名来判断
    if (sheet.name == '凭证清单') {
        if (cell.alias == 'nian' || cell.alias == 'yue') {
            reload_pzh_info();
        };
    }



}

/**
 * 单元格因为被编辑而改变。当用户通过编辑单元的值而让单元格发生值改变时本事件被触发。
 * 注意，当使用脚本 sheet.cells(row,col).setValue ( value) 来改变单元格的值时，本事件并不触发
 * @param sheet
 * @param cell
 * @param newValue
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChangedByEdit(sheet, cell, newValue, innerRow) {

    if (cell.alias == 'onceCount') {
        setLoadImagePoolDataOnceCount();

    }


}



function reload_pzh_info() {
    var sheet = book.getWorkSheet('凭证清单');
    //加载帐套信息及年月
    var corpid = sheet.cells("corpid").getValueString();

    var nian = sheet.cells("nian").getValueString();
    var yue = sheet.cells("yue").getValueString();
    var ym = nian + right("00" + yue, 2);

    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);
    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000000'.substring(8 - pzh_len, 8);
        lastPZH = v;

    });

    smartRetrieve(sheet, "dzpz_pz"); //刷新凭证列表
}



function cb_ocr_onClick() {
    toastr.show("正在自动识别");
    var imgPool = book.sheet1.getBrick('imgPool');
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    asyncPool(4,  // 最多4个并发执行
        imgs, //需要处理的数据数组，每个元素可以是任意类型的数据
        function (one, array) // item表示当前处理的对象， array就是整个数据数组
        {
            console.info(one.url_img);
            //函数必须返回一个Promise对象
            return new Promise(function (resolve, reject) {

                back_ocr({ src: one.url_img, left: '50%', top: '5%', height: '25%', width: '50%' }, function (text) {
                    if (text != '') {
                        setPZH(one.id, text);

                    }
                    resolve(1);
                });





            });
        }).then(function () {  //此时，整个数据数组都已经迭代执行完成 ，通常在此善后
            console.info("over");
            toastr.hide();
            toastr.success("自动识别完成");
        });

}


id: 6512793b9932f2713a061c32
scriptid: 60a321f05db27838e0c014bf
tablename: app_script
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 16:47:09.000
script:
//@comment (group=,caption=得到当前操作员待归档图片对应的GGUID,needRightControl=false)
function getImagePoolGGUID() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).gguid;

}

function getImagePoolBlockSize() {
    var ret = runTask("get_dzpz_imgpool_id_of_current_user", {});
    return JSON.parse(ret).blockSize;

}


//@comment (group=,caption=保存当前的缩略图大小,needRightControl=false)
function setImagePoolBlockSize(id, blockSize) {
    runSQL("", " update  dzpz_imgpool set blocksize=" + blockSize + " where gguid='" + id + "'  ");
}


//@comment (group=,caption=得到待归档的图片清单,needRightControl=true)
function loadImagePoolData(config) {
    var onceCount =  config.onceCount; 
    if( onceCount==undefined) onceCount=500;
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select * from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''  order by info1 asc, filename asc ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。
    ds.setOnceRetrieveCount(onceCount);

    var n = ds.retrieve();
    println( ds.getSelectLastRetrieved());

    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }

    println( ret); 
    return { success: true, totalCount: ds.getDBRowCount(), data: ret };
    

}

function getTotalImageCount() {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));

    //排除掉回收站的图片
    var sql = "select count(*) as c from " + config.logTable + "  where  gguid='" + config.gguid +
        "'  and ifnull(info2,'')=''    ";
    println(sql);
    var ds = newDataStore(config.dbpool, sql); // info1 是客户端文件创建的时间，以它排序厅。


    ds.retrieve();
    println(ds.getSelectLastRetrieved());

    return ds.getInt(0, "c");

}

//@comment (group=,caption=保存监控目录设置,needRightControl=false)
function setMonitePath(hostName, path) {
    var ds = newDataStore("", "select * from dzpz_client");
    ds.setUpdateProperty("dzpz_client", "id", "*", "id");
    ds.retrieve(" hostname='" + hostName + "'");
    if (ds.getRowCount() == 0) {
        var newid = newGUID();
        ds.insertRow(0);
        ds.setValue(0, "id", newid);
        ds.setValue(0, "gguid", newid);
        ds.setValue(0, "billno", newid);
        ds.setValue(0, "userid", 1);
        ds.setValue(0, "username", '管理员');
        ds.setValue(0, "billtype", '');
        ds.setValue(0, "hostname", hostName);
    }
    ds.setValue(0, "path", path);
    ds.update(true);
    println(ds.getError().getMessage());

}


//@comment (group=,caption=获取指定机器的监控目录,needRightControl=false)
function getMonitePath(hostName) {
    return getStringFromSQL("select path from dzpz_client where  hostname='" + hostName + "'");
}


//@comment (group=,caption=构建凭证附件清单,needRightControl=false)
function getPZFJ(id) {
    // 在图片池中，info2 表示是否是垃圾箱， 在附件表中，info2记录的是手工调整后的顺序号
    var ds = newDataStore("", "select id , url_img , url_thumbnail ,groupname , info1 from  dzpz_pzfj where  gguid='" + id + "'  order by info2 asc,groupname , info1 asc ");
    var n = ds.retrieve();
    var ret = [];
    for (var i = 0; i < n; i++) {
        ret.push(JSON.parse(ds.getJSONRow(i, true)));
    }
    return ret;

}



//@comment (group=,caption=把凭证中的附件图片回归到待归档池中,needRightControl=false)
function putImageBackToPool(id) {
    println(id);
    return JSON.parse(runTask("凭证附件移除", { id: id }));
}


//@comment (group=,caption=追加图片到凭证中,needRightControl=false)
function addImageToPZ(pzid, images) {
    return JSON.parse(runTask("追加图片到凭证中", { pzid: pzid, images: images }));
}

function deletePZAndPutBackToPool(id) {
    return JSON.parse(runTask("删除凭证所有图片回归池中", { id: id }));
}

function moveImageToRecycle(id) {
    var config = JSON.parse(runTask("get_dzpz_imgpool_id_of_current_user", {}));
    runSQL(config.dbpool, " update " + config.logTable + " set info2='回收站' where id='" + id + "'  ", true);


}

//@comment (group=,caption=凭证号前缀,needRightControl=false)
function getPZHPrefix(corpid,ym) {
    return runTask("getPZHPrefix", { ym: ym ,corpid:corpid });

}
//@comment (group=,caption=凭证号长度,needRightControl=false)
function getPZHLen(corpid) {
    return parseInt(runTask("getPZHLen", {corpid:corpid}));
}

function getLastPZH(corpid, ym) {
    var t = getStringFromSQL("select max(pzh) from dzpz_pz where corpid='" + corpid + "' and ym=" + ym);
    return t;
}


function do_imageRotate(id, rt) {
    var ret = imageRotate("", "dzpz_imgpool_fileupload", id, rt);
    println(JSON.stringify(ret));
    return ret;
}


function reorderImageFileIndex(imgs) {

}


function back_ocr(config)
{
    config.src= config.src.replace(/电子凭证/g , ''); //把其中的汉字去掉，这个引发一个异常
    pushMessage( 'pz_ocr'  , { action:'info', message: config.src}  ,currentUserId( )  ) ;
    var ret= OCR(config);
    println( ret);
    var t= ret.text ||'';
    if(t=='') return ''; 

    //下面的算法， 根据每家凭证号的特点需要定制
    var p= t.indexOf('第');
    if( p<0) return ''; 
    t= t.substring(p+1);
    p= t.indexOf('号');
    if( p<0) return ''; 
    t= t.substring(0,p);
    t=t.replace(/\s/g , '');
    return  right('0000'+t ,4) ; 


}


id: 6512793b9932f2713a061c44
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 16:48:10.000
script:
var pathToMonit = "";//当前监控的目录
var electron = null;
var pzh_prefix = ""; // 凭证号前缀
var pzh_len = 0; //凭证号长度
var lastPZH = "";
var fullScreenDiv = null;

/*
$(document).ready(function () {
    var script = $(`<script src="ui/imageEditor/filerobot-image-editor.min.js">
    
    </script>`);
    $(document.body).append(script);
});
*/

function formOpen() {

    book.sheet4.visible = false;

    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    book.sheet3.getBrick('cb_delete_pz').visible = false;

    //加载帐套信息及年月
    var corpid = book.sheet2.cells("corpid").getValueString();
    var ym = book.sheet2.cells("ym").getValue();
    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);

    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000001'.substring(8 - pzh_len, 8);
        lastPZH = v;
    });

    // smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
    // });

    book.getWorkSheet('凭证清单').cells("yue").setValue(getMonth(newDate()));

    book.sheet3.getBrick('FJ').config.promptInfoOnDelete = "确信要将图片从当前凭证中移除，并放回到图片池中吗?";
    book.sheet1.getBrick('imgPool').config.promptInfoOnDelete = "确信要将图片放入回收站吗?";

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage", function (msg) {
        msg = JSON.parse(msg);
        if (msg.cmd == "newFileUploaded") newImgCommingTipVisible(true); //通知有新文件上传了
        if (msg.cmd == "notifyNeedUploadFileCount") notifyNeedUploadFileCount(msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron = getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:30px; line-height:30px;width:100%; 
                                background-color:#af4040e0; 
                                color:white;font-weight:bold;font-size:20px;text-align:left;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:44px; top:0; text-align:right; 
                                    vertical-align:top; font-size:24px; color:#ffa0a0;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);


    setTimeout(function () {
        //调取缩略图大小

        var imgPool = book.sheet1.getBrick('imgPool');
        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout(function () {
        if (electron != null) {
            var hostName = electron.getHostName();
            pathToMonit = getMonitePath(hostName);

            //开启监控
            if (pathToMonit == '') pathToMonit = "c:\\凭证影像采集目录";

            moniteStart(pathToMonit);
            $.alert('请将扫描仪的图片目录指向：' + pathToMonit);
        }

        //显示总共图片数
        getTotalImageCount(function (ret) { book.sheet0.cells('imageCountTotal').setValue('共' + ret + '张') });

    }, 500);



    $(document).on('keydown', function (e) {
        console.info(" kkkkk down");
        if (e.ctrlKey) {
            // fullScreenViewImageOpen();
        }
    });


    $(document).on('keyup', function (e) {
        console.info(" kkkkk up");
        if (!e.ctrlKey) {

            // fullScreenViewImageClose();

        }
    });

    onPushMessage( "pz_ocr" , function(msg)
    {
        if( msg.action=='info')
        { 
            toastr.show( msg);
        }
    }) ;

}


// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function saveSelectionAndPZInfo() {

    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection = selection;
    g_pzMap = pzhMap;
}




//@comment (group=图片清单刷新,caption=还原选中及凭证标记,needRightControl=false)
function restoreSelectionAndPZInfo() {
    var selection = g_selection;
    var pzhMap = g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();

    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

function resetImageCountInfo() {

    setTimeout(function () {
        book.sheet0.cells("imageCount").setValue("前 " + book.sheet1.getBrick("imgPool").imageCount + " 张");
    }, 300);
}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "imgPool") {
        resetImageCountInfo()
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        book.sheet0.cells("imageCount").setValue(brick.imageCout + "张图片");


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数

                showInfoPane('*正在旋转图片...');
                setTimeout(function () {
                    //toastr.info(id);  // id 是当前操作的图片对应数据的ID
                    var ret = do_imageRotate(id, "90");
                    if (ret.success) {
                        //把数据中的图片替换，
                        for (let i = 0; i < brick.data.length; i++) {
                            if (brick.data[i].id == id) {
                                //属性从新的属性中替换 
                                for (let prop in brick.data[i]) {
                                    brick.data[i][prop] = ret.data[prop];
                                }
                                break;
                            }
                        }
                        //把缩略图的图片地址替换 ， 

                        let img = $('#' + id).find('.image');
                        img.attr("src", ret.data.url_thumbnail);
                        img.attr('largeimage', ret.data.url_img);
                        //把大图预览的地址替换掉
                        book.sheet0.cells("imgPreview").setValue(ret.data.url_img);
                        hideInfoPane();

                    }
                }, 10);
            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-plus",   // 字符图标
            "选中此前",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let selected = $('#' + id).parent().find('.brickSelected').length > 0; // 可以用 imgPool.isImageSelected( id) 替换，但此时本函数还没有提供，以后可以换成此函数

                let imgPool = book.sheet1.getBrick("imgPool");
                let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
                let found = false;
                for (let i = 0; i < imgs.length; i++) {
                    imgPool.setImageSelected(imgs[i].id, !selected);
                    if (imgs[i].id == id) return;

                }


            });


    }
}


/**
 * 图片控件中图片上的删除按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 * @param data  图片的信息
 *
 * @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行删除操作，否则表示终止删除操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上的删除按钮被点击)
function imageOnDelete(sheet, name, data) {

    if (name == 'FJ') {
        if (data.groupname == '凭证') {
            return { success: false, message: "这是凭证，不允许这样移除，请点击“删除凭证”" };
        } else {
            var ret = putImageBackToPool(data.id);
            if (ret.success) {
                smartRetrieve(book.sheet3, "one");
                cb_refresh_onClick();
            } else {
                return ret;
            }

        }
    }

    if (name == 'imgPool') {
        moveImageToRecycle(data.id);
        resetImageCountInfo();
    }
    return { success: true };
}
/**
 * 图片控件中上传按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 *
 @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行上传操作，否则表示终止上传操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上传按钮被点击)
function imageOnNewUpload(sheet, name) {


    if (name == 'imgPool') {
        toastr.info("请连接扫描仪，或将图片复制到监控的目录下，图片自动上传");
    }

    if (name == 'FJ') {
        var imgPool = book.sheet1.getBrick('imgPool');
        // 保存当前选中状态及设置的凭证号信息
        var selection = imgPool.getSelectedImageList();
        if (selection.length == 0) {
            toastr.error("至少选中一张图片");
            return { success: false }; // 此返回，阻止了默认的上传操作
        }


        var lastPZ = null;
        for (let i = 0; i < selection.length; i++) {
            var one = selection[i];
            var pzh = getPZH(one.id);
            if (pzh != '') {
                toastr.error("选中的图片中有标记为凭证的，禁止将凭证图片添加到当前凭证中");
                return { success: false }; // 此返回，阻止了默认的上传操作
            }
        }

        var ret = addImageToPZ($one_ds.getString(0, "id"), selection);
        if (ret.success) {
            //刷新图片区
            cb_refresh_onClick();
            //刷新凭证
            loadPZ($one_ds.getString(0, "id"), $one_ds.getString(0, "pzh"), $one_ds.getString(0, "verifiername") != "" ? 1 : 0);
        }

    }


    return { success: false }; // 此返回，阻止了默认的上传操作
}

//先定位 Id的序号， 然后返回它左边的图片的ID
function findLeftImageId(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    if (index > 0) return imgs[index - 1].id;
    return "";
}


//找到左边最近的一张凭证号
//如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
//否则在那个号上加1做为自已的凭证号
function incLeftNearestPZH(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    //再从index往左边查到第一张凭证
    for (let i = index - 1; i >= 0; i--) {
        let tid = imgs[i].id;
        let pzh = getPZH(tid);
        if (pzh == '') continue;
        if (i == index - 1) {
            return pzh; // 左边最近的一张凭证号就在自已的左边，那么就意味着自已与左边那张凭证号可能就是一张凭证的不同分页，所以直接返回凭证号
        } else {
            return stringInc(pzh);
        }

    }
    //到这里，都没有找到凭证号，那么直接返回凭证号前缀
    return stringInc(lastPZH);
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data, event) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data, event) {

    // book.sheet0.cells("imgPreview").setValue("");
}

/**
 * 图片控件中图片顺序变化了
 * @param sheet   所在Sheet
 * @param config  图片控件的配置信息
 *@param ids  调整顺序后的id清单
 *
 */
//@comment (group=图片控件,caption=顺序调整后)
function attachmentOrderChanged(sheet, config, ids) {

    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    reorderImageFileIndex(imgs);

}

/**
 * 图片控件中某个图片被单击
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 * @param event  事件对象
 *
 *
 */
//@comment (group=图片控件,caption=图片被单击)
function imageOnClick(sheet, name, data, event) {

    if (name == 'imgPool') {
        if (book.sheet0.cells("clickAction").getValue() == 2) imageOnDBLClick(sheet, name, data, event, false);
    }
}


var g_lastPZH = "";
/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data, event, showDlg) {

    if (showDlg == undefined) showDlg = true;

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = "";
    if (pzh == '') {

        //找到左边最近的一张凭证号
        //如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
        //否则在那个号上加1做为自已的凭证号
        pzh = incLeftNearestPZH(data.id);
        if (pzh > lastPZH) lastPZH = pzh;


    }

    let $setpzh = function (val) {
        if (val == '') {

            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
            return true;
        } else {
            if (val.length - pzh_prefix.length != pzh_len) {
                toastr.error("凭证号(不含前缀)长度必须是" + pzh_len + "位");
                return false;

            }
            g_lastPZH = val; //记下来
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
            return true;
        }
    }

    if (!showDlg) {
        $setpzh(pzh);
        return;
    }

    let dlg = inputBox("标记为凭证", "", pzh, "输入凭证号码",

        function (val) { //确认后的回调

            return $setpzh(val);

        }, false,/*不允许为空*/
        //下面是一些事件的切入
        {
            //输入面板初始化完成后
            onContentReady: function () {

                let input = dlg.$content.find('.name');
                input.on('keyup', function () {
                    if (input.val().indexOf(pzh_prefix) != 0) {
                        input.val(pzh_prefix);
                    }
                });
            }
        }
    );




}


function setLoadImagePoolDataOnceCount() {
    let onceCount = book.sheet0.cells("onceCount").getValueInt();
    if (onceCount < 0) onceCount = 100;
    if (onceCount > 2000) onceCount = 2000;
    setTimeout(function () {
        book.sheet0.cells("onceCount").setValue(onceCount);
        book.sheet1.getBrick("imgPool").config.onceCount = onceCount;
        cb_refresh_onClick();
    }, 1);

}

//@comment (group=凭证号,caption=得到图片的凭证号如果有的话,needRightControl=false)
function getPZH(id) {
    let obj = find_pzh(id, false);
    if (obj == null) return;
    let s = obj.text();
    s = s.replace(/\s/g, '');
    return s;
}

//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() { doSelect(true); }
function cb_selectnull_onClick() { doSelect(false); }

function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    if (!path.endsWith('凭证影像采集目录')) {

        $.alert("目录名必须是：“凭证影像采集目录”，盘符及上级目录随意。");
        return;
    }
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);

    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path) {
    pathToMonit = path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit + " 监控中...");
    electron.ipcSendMessage({ cmd: "moniteStart", path: path });
}

function cb_refresh_onClick() {
    newImgCommingTipVisible(false);

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit(restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");



}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v) {
    book.sheet0.getBrick('shineText').visible = v;

}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount(fc) {
    var info = fc == 0 ? "" : "【" + fc + "】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


//@comment (group=归档,caption=凭证归档,needRightControl=false)
function cb_auto_onClick() {

    var imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }

    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    let nn = imgs.length - selection.length;
    if (nn > 0) {
        $confirm("提示", "有" + nn + "张图片没有选中，确信要继续吗?", function () {
            do_pack(selection);
        });
    } else {
        do_pack(selection);
    }
}

var pzGroup = [];

//@comment (group=归档,caption=归档操作,needRightControl=false)
function do_pack(selection) {
    pzGroup = [];
    let pzh2Config = {}; //凭证号对应的配置信息 ， 辅助数据
    let lastPZ = null;
    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        let pzh = getPZH(one.id);
        if (pzh == '') {
            if (lastPZ != null) {
                lastPZ.fj.push(one.id);
            }
        } else {
            //新的凭证号
            if (pzh2Config[pzh] == null) {
                lastPZ = {};
                lastPZ.pzh = pzh;
                lastPZ.fj = []; //附件图片
                lastPZ.pz = []; //凭证图片
                pzh2Config[pzh] = lastPZ; //记下凭证号与配置对象的对应关系
                pzGroup.push(lastPZ); //加入到总配置中
            } else {
                //已经存在配置，说明它是该凭证号的更多的分页图片
                //需要检测，它的左边是不是也是同一个号的凭证
                lastPZ = pzh2Config[pzh];

                let leftID = findLeftImageId(one.id); //找到它左边那张图片的ID
                if (leftID == '') {
                    toastr.error("不可能出现的情况");
                    return;
                }
                let leftPZH = getPZH(leftID);
                if (leftPZH != pzh) {
                    $.alert(pzh + '有多张图片，请将它们移动到相邻位置，即同一张凭证的多个分页必须连续相邻，它们之间不要穿插附件图片或其它凭证号图片');
                    return;
                }

            }
            lastPZ.pz.push(one.id); //凭证图片，同一个凭证可能有多个图片 
        }
    }

    if (pzGroup.length == 0) {
        toastr.error("凭证归档操作，至少需要标记一张凭证，并选中它");
        return;
    }

    console.dir();


    do_pzgdqr();



}

//@comment (group=归档,caption=归档确认,needRightControl=false)
function do_pzgdqr() {

    // 整理归档配置信息用于显示
    book.sheet4.paintPermit = false;

    $gd_ds.reset();
    for (let i = 0; i < pzGroup.length; i++) {
        let one = pzGroup[i];
        let row = $gd_ds.insertRow(9999);
        $gd_ds.setValue(row, { pzh: one.pzh, pzs: one.pz.length, fjs: one.fj.length, hj: one.pz.length + one.fj.length });
    }
    book.sheet4.paintPermit = true;

    book.sheet4.popup('fa fa-cog', '归档确认', 450, 450, true, true, {
        action1: {
            text: '确认',
            btnClass: 'btn-green',
            action: function () {
                do_pzgd();
                return true;    //表示关闭弹窗
            }
        },
        cancel: {
            text: '关闭',
            btnClass: 'btn-red',
            action: function () {

                return true;
            }
        }

    });

}
//@comment (group=归档,caption=归档,needRightControl=false)
function do_pzgd() {
    showInfoPane('*正在归档...');
    setButtonsStatus(false); //禁用一些按钮点击
    //alert(JSON.stringify(pzGroup));
    runTask("归档",
        {
            corpid: book.sheet4.cells("corpid").getValueString(),
            ym: book.sheet4.cells("ym").getValueString(),
            pzGroup: pzGroup
        }, function (ret) {
            hideInfoPane();
            ret = JSON.parse(ret);

            if (ret.success) {

                setButtonsStatus(true); //启用一些按钮点击
                smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
                //重新检索图片区
                cb_refresh_onClick();
            } else {
                $.alert(ret.message);
            }

        });
}

function setButtonsStatus(b) {

    book.sheet0.getBrick('cb_auto').enabled = b;
}

//@comment (group=,caption=调取某个凭证,needRightControl=false)
function loadPZ(id, pzh, verified) {
    book.sheet3.cells("id").setValue(id);
    smartRetrieve(book.sheet3, "one");
    //附件图片清单
    //不能从 $one_ds中取数，因为上面的smartRetrieve 是异步的
    let action = (verified == 0) ? "edit" : "view";
    book.sheet3.getBrick('cb_delete_pz').visible = verified == 0;
    var FJ = book.sheet3.getBrick('FJ');
    FJ.config.action = action; //控制是否显示删除和新增按钮
    let data = getPZFJ(id); //得到凭证的所有图片
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet3.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=,caption=删除凭证，并把图片回归到池中,needRightControl=false)
function cb_delete_pz_onClick() {
    $confirm("提示", "确信删除本凭证，并将图片全部回归到待归档状态吗?", function () {
        book.sheet3.getBrick('cb_delete_pz').visible = false;
        var id = $one_ds.getString(0, "id");
        var ret = deletePZAndPutBackToPool(id);
        if (ret.success) {
            $one_ds.reset();
            reload_pzh_info(); //可能删除的就是最后一张凭证，所以要重新取一下
            var FJ = book.sheet3.getBrick('FJ');
            FJ.config.action = 'view';
            FJ.buildGridly([]);
            cb_refresh_onClick();//刷新池中图片

        } else {
            toastr.error(ret.message);
        }
    });

}



function cb_trash_onClick() {
    var url = runTask("urlForTrash", {});
    openInMainFrame(url, false, 'fa-trash', '图片回收站');

}

function cb_deleteSelection_onClick() {
    let imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    let selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }
    let nn = selection.length;
    $confirm("提示", "确信将选中的" + nn + "张图片移入回收站吗?", function () {
        showInfoPane('*正在移和回收站');
        setTimeout(function () {
            do_trush(selection);
            hideInfoPane();
        }, 100);
    });

}

function do_trush(selection) {

    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        moveImageToRecycle(one.id);

    }
    cb_refresh_onClick();

}

function cb_size_onClick() {
    let RPM = book.sheet0.RPM;
    let h = RPM.getRowHeight(1);
    if (h > 1) {
        RPM.setRowStretchHeight(1, 0);//弹性高度取消
        RPM.setRowHeight(1, 1);

        RPM.setRowHeight(2, 0);
        book.sheet0.getBrick('dbnav').visible = false;

    } else {

        RPM.setRowStretchHeight(1, 40);//弹性高度取消
        RPM.setRowHeight(1, 300);

        RPM.setRowHeight(2, 30);
        book.sheet0.getBrick('dbnav').visible = true;
    }
}


/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //通过别名来判断
    if (sheet.name == '凭证清单') {
        if (cell.alias == 'nian' || cell.alias == 'yue') {
            reload_pzh_info();
        };
    }



}

/**
 * 单元格因为被编辑而改变。当用户通过编辑单元的值而让单元格发生值改变时本事件被触发。
 * 注意，当使用脚本 sheet.cells(row,col).setValue ( value) 来改变单元格的值时，本事件并不触发
 * @param sheet
 * @param cell
 * @param newValue
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChangedByEdit(sheet, cell, newValue, innerRow) {

    if (cell.alias == 'onceCount') {
        setLoadImagePoolDataOnceCount();

    }


}



function reload_pzh_info() {
    var sheet = book.getWorkSheet('凭证清单');
    //加载帐套信息及年月
    var corpid = sheet.cells("corpid").getValueString();

    var nian = sheet.cells("nian").getValueString();
    var yue = sheet.cells("yue").getValueString();
    var ym = nian + right("00" + yue, 2);

    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);
    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000000'.substring(8 - pzh_len, 8);
        lastPZH = v;

    });

    smartRetrieve(sheet, "dzpz_pz"); //刷新凭证列表
}



function cb_ocr_onClick() {
    toastr.show("正在自动识别");
    var imgPool = book.sheet1.getBrick('imgPool');
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    asyncPool(4,  // 最多4个并发执行
        imgs, //需要处理的数据数组，每个元素可以是任意类型的数据
        function (one, array) // item表示当前处理的对象， array就是整个数据数组
        {
            console.info(one.url_img);
            //函数必须返回一个Promise对象
            return new Promise(function (resolve, reject) {

                back_ocr({ src: one.url_img, left: '50%', top: '0', height: '25%', width: '50%' }, function (text) {
                    if (text != '') {
                        setPZH(one.id, text);

                    }
                    resolve(1);
                });





            });
        }).then(function () {  //此时，整个数据数组都已经迭代执行完成 ，通常在此善后
            console.info("over");
            toastr.hide();
            toastr.success("自动识别完成");
        });

}


id: 6512793b9932f2713a061c4a
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 16:48:17.000
script:
var pathToMonit = "";//当前监控的目录
var electron = null;
var pzh_prefix = ""; // 凭证号前缀
var pzh_len = 0; //凭证号长度
var lastPZH = "";
var fullScreenDiv = null;

/*
$(document).ready(function () {
    var script = $(`<script src="ui/imageEditor/filerobot-image-editor.min.js">
    
    </script>`);
    $(document.body).append(script);
});
*/

function formOpen() {

    book.sheet4.visible = false;

    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    book.sheet3.getBrick('cb_delete_pz').visible = false;

    //加载帐套信息及年月
    var corpid = book.sheet2.cells("corpid").getValueString();
    var ym = book.sheet2.cells("ym").getValue();
    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);

    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000001'.substring(8 - pzh_len, 8);
        lastPZH = v;
    });

    // smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
    // });

    book.getWorkSheet('凭证清单').cells("yue").setValue(getMonth(newDate()));

    book.sheet3.getBrick('FJ').config.promptInfoOnDelete = "确信要将图片从当前凭证中移除，并放回到图片池中吗?";
    book.sheet1.getBrick('imgPool').config.promptInfoOnDelete = "确信要将图片放入回收站吗?";

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage", function (msg) {
        msg = JSON.parse(msg);
        if (msg.cmd == "newFileUploaded") newImgCommingTipVisible(true); //通知有新文件上传了
        if (msg.cmd == "notifyNeedUploadFileCount") notifyNeedUploadFileCount(msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron = getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:30px; line-height:30px;width:100%; 
                                background-color:#af4040e0; 
                                color:white;font-weight:bold;font-size:20px;text-align:left;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:44px; top:0; text-align:right; 
                                    vertical-align:top; font-size:24px; color:#ffa0a0;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);


    setTimeout(function () {
        //调取缩略图大小

        var imgPool = book.sheet1.getBrick('imgPool');
        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout(function () {
        if (electron != null) {
            var hostName = electron.getHostName();
            pathToMonit = getMonitePath(hostName);

            //开启监控
            if (pathToMonit == '') pathToMonit = "c:\\凭证影像采集目录";

            moniteStart(pathToMonit);
            $.alert('请将扫描仪的图片目录指向：' + pathToMonit);
        }

        //显示总共图片数
        getTotalImageCount(function (ret) { book.sheet0.cells('imageCountTotal').setValue('共' + ret + '张') });

    }, 500);



    $(document).on('keydown', function (e) {
        console.info(" kkkkk down");
        if (e.ctrlKey) {
            // fullScreenViewImageOpen();
        }
    });


    $(document).on('keyup', function (e) {
        console.info(" kkkkk up");
        if (!e.ctrlKey) {

            // fullScreenViewImageClose();

        }
    });

    onPushMessage( "pz_ocr" , function(msg)
    {
        if( msg.action=='info')
        { 
            toastr.show( msg);
        }
    }) ;

}


// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function saveSelectionAndPZInfo() {

    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection = selection;
    g_pzMap = pzhMap;
}




//@comment (group=图片清单刷新,caption=还原选中及凭证标记,needRightControl=false)
function restoreSelectionAndPZInfo() {
    var selection = g_selection;
    var pzhMap = g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();

    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

function resetImageCountInfo() {

    setTimeout(function () {
        book.sheet0.cells("imageCount").setValue("前 " + book.sheet1.getBrick("imgPool").imageCount + " 张");
    }, 300);
}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "imgPool") {
        resetImageCountInfo()
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        book.sheet0.cells("imageCount").setValue(brick.imageCout + "张图片");


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数

                showInfoPane('*正在旋转图片...');
                setTimeout(function () {
                    //toastr.info(id);  // id 是当前操作的图片对应数据的ID
                    var ret = do_imageRotate(id, "90");
                    if (ret.success) {
                        //把数据中的图片替换，
                        for (let i = 0; i < brick.data.length; i++) {
                            if (brick.data[i].id == id) {
                                //属性从新的属性中替换 
                                for (let prop in brick.data[i]) {
                                    brick.data[i][prop] = ret.data[prop];
                                }
                                break;
                            }
                        }
                        //把缩略图的图片地址替换 ， 

                        let img = $('#' + id).find('.image');
                        img.attr("src", ret.data.url_thumbnail);
                        img.attr('largeimage', ret.data.url_img);
                        //把大图预览的地址替换掉
                        book.sheet0.cells("imgPreview").setValue(ret.data.url_img);
                        hideInfoPane();

                    }
                }, 10);
            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-plus",   // 字符图标
            "选中此前",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let selected = $('#' + id).parent().find('.brickSelected').length > 0; // 可以用 imgPool.isImageSelected( id) 替换，但此时本函数还没有提供，以后可以换成此函数

                let imgPool = book.sheet1.getBrick("imgPool");
                let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
                let found = false;
                for (let i = 0; i < imgs.length; i++) {
                    imgPool.setImageSelected(imgs[i].id, !selected);
                    if (imgs[i].id == id) return;

                }


            });


    }
}


/**
 * 图片控件中图片上的删除按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 * @param data  图片的信息
 *
 * @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行删除操作，否则表示终止删除操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上的删除按钮被点击)
function imageOnDelete(sheet, name, data) {

    if (name == 'FJ') {
        if (data.groupname == '凭证') {
            return { success: false, message: "这是凭证，不允许这样移除，请点击“删除凭证”" };
        } else {
            var ret = putImageBackToPool(data.id);
            if (ret.success) {
                smartRetrieve(book.sheet3, "one");
                cb_refresh_onClick();
            } else {
                return ret;
            }

        }
    }

    if (name == 'imgPool') {
        moveImageToRecycle(data.id);
        resetImageCountInfo();
    }
    return { success: true };
}
/**
 * 图片控件中上传按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 *
 @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行上传操作，否则表示终止上传操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上传按钮被点击)
function imageOnNewUpload(sheet, name) {


    if (name == 'imgPool') {
        toastr.info("请连接扫描仪，或将图片复制到监控的目录下，图片自动上传");
    }

    if (name == 'FJ') {
        var imgPool = book.sheet1.getBrick('imgPool');
        // 保存当前选中状态及设置的凭证号信息
        var selection = imgPool.getSelectedImageList();
        if (selection.length == 0) {
            toastr.error("至少选中一张图片");
            return { success: false }; // 此返回，阻止了默认的上传操作
        }


        var lastPZ = null;
        for (let i = 0; i < selection.length; i++) {
            var one = selection[i];
            var pzh = getPZH(one.id);
            if (pzh != '') {
                toastr.error("选中的图片中有标记为凭证的，禁止将凭证图片添加到当前凭证中");
                return { success: false }; // 此返回，阻止了默认的上传操作
            }
        }

        var ret = addImageToPZ($one_ds.getString(0, "id"), selection);
        if (ret.success) {
            //刷新图片区
            cb_refresh_onClick();
            //刷新凭证
            loadPZ($one_ds.getString(0, "id"), $one_ds.getString(0, "pzh"), $one_ds.getString(0, "verifiername") != "" ? 1 : 0);
        }

    }


    return { success: false }; // 此返回，阻止了默认的上传操作
}

//先定位 Id的序号， 然后返回它左边的图片的ID
function findLeftImageId(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    if (index > 0) return imgs[index - 1].id;
    return "";
}


//找到左边最近的一张凭证号
//如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
//否则在那个号上加1做为自已的凭证号
function incLeftNearestPZH(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    //再从index往左边查到第一张凭证
    for (let i = index - 1; i >= 0; i--) {
        let tid = imgs[i].id;
        let pzh = getPZH(tid);
        if (pzh == '') continue;
        if (i == index - 1) {
            return pzh; // 左边最近的一张凭证号就在自已的左边，那么就意味着自已与左边那张凭证号可能就是一张凭证的不同分页，所以直接返回凭证号
        } else {
            return stringInc(pzh);
        }

    }
    //到这里，都没有找到凭证号，那么直接返回凭证号前缀
    return stringInc(lastPZH);
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data, event) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data, event) {

    // book.sheet0.cells("imgPreview").setValue("");
}

/**
 * 图片控件中图片顺序变化了
 * @param sheet   所在Sheet
 * @param config  图片控件的配置信息
 *@param ids  调整顺序后的id清单
 *
 */
//@comment (group=图片控件,caption=顺序调整后)
function attachmentOrderChanged(sheet, config, ids) {

    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    reorderImageFileIndex(imgs);

}

/**
 * 图片控件中某个图片被单击
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 * @param event  事件对象
 *
 *
 */
//@comment (group=图片控件,caption=图片被单击)
function imageOnClick(sheet, name, data, event) {

    if (name == 'imgPool') {
        if (book.sheet0.cells("clickAction").getValue() == 2) imageOnDBLClick(sheet, name, data, event, false);
    }
}


var g_lastPZH = "";
/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data, event, showDlg) {

    if (showDlg == undefined) showDlg = true;

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = "";
    if (pzh == '') {

        //找到左边最近的一张凭证号
        //如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
        //否则在那个号上加1做为自已的凭证号
        pzh = incLeftNearestPZH(data.id);
        if (pzh > lastPZH) lastPZH = pzh;


    }

    let $setpzh = function (val) {
        if (val == '') {

            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
            return true;
        } else {
            if (val.length - pzh_prefix.length != pzh_len) {
                toastr.error("凭证号(不含前缀)长度必须是" + pzh_len + "位");
                return false;

            }
            g_lastPZH = val; //记下来
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
            return true;
        }
    }

    if (!showDlg) {
        $setpzh(pzh);
        return;
    }

    let dlg = inputBox("标记为凭证", "", pzh, "输入凭证号码",

        function (val) { //确认后的回调

            return $setpzh(val);

        }, false,/*不允许为空*/
        //下面是一些事件的切入
        {
            //输入面板初始化完成后
            onContentReady: function () {

                let input = dlg.$content.find('.name');
                input.on('keyup', function () {
                    if (input.val().indexOf(pzh_prefix) != 0) {
                        input.val(pzh_prefix);
                    }
                });
            }
        }
    );




}


function setLoadImagePoolDataOnceCount() {
    let onceCount = book.sheet0.cells("onceCount").getValueInt();
    if (onceCount < 0) onceCount = 100;
    if (onceCount > 2000) onceCount = 2000;
    setTimeout(function () {
        book.sheet0.cells("onceCount").setValue(onceCount);
        book.sheet1.getBrick("imgPool").config.onceCount = onceCount;
        cb_refresh_onClick();
    }, 1);

}

//@comment (group=凭证号,caption=得到图片的凭证号如果有的话,needRightControl=false)
function getPZH(id) {
    let obj = find_pzh(id, false);
    if (obj == null) return;
    let s = obj.text();
    s = s.replace(/\s/g, '');
    return s;
}

//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() { doSelect(true); }
function cb_selectnull_onClick() { doSelect(false); }

function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    if (!path.endsWith('凭证影像采集目录')) {

        $.alert("目录名必须是：“凭证影像采集目录”，盘符及上级目录随意。");
        return;
    }
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);

    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path) {
    pathToMonit = path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit + " 监控中...");
    electron.ipcSendMessage({ cmd: "moniteStart", path: path });
}

function cb_refresh_onClick() {
    newImgCommingTipVisible(false);

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit(restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");



}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v) {
    book.sheet0.getBrick('shineText').visible = v;

}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount(fc) {
    var info = fc == 0 ? "" : "【" + fc + "】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


//@comment (group=归档,caption=凭证归档,needRightControl=false)
function cb_auto_onClick() {

    var imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }

    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    let nn = imgs.length - selection.length;
    if (nn > 0) {
        $confirm("提示", "有" + nn + "张图片没有选中，确信要继续吗?", function () {
            do_pack(selection);
        });
    } else {
        do_pack(selection);
    }
}

var pzGroup = [];

//@comment (group=归档,caption=归档操作,needRightControl=false)
function do_pack(selection) {
    pzGroup = [];
    let pzh2Config = {}; //凭证号对应的配置信息 ， 辅助数据
    let lastPZ = null;
    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        let pzh = getPZH(one.id);
        if (pzh == '') {
            if (lastPZ != null) {
                lastPZ.fj.push(one.id);
            }
        } else {
            //新的凭证号
            if (pzh2Config[pzh] == null) {
                lastPZ = {};
                lastPZ.pzh = pzh;
                lastPZ.fj = []; //附件图片
                lastPZ.pz = []; //凭证图片
                pzh2Config[pzh] = lastPZ; //记下凭证号与配置对象的对应关系
                pzGroup.push(lastPZ); //加入到总配置中
            } else {
                //已经存在配置，说明它是该凭证号的更多的分页图片
                //需要检测，它的左边是不是也是同一个号的凭证
                lastPZ = pzh2Config[pzh];

                let leftID = findLeftImageId(one.id); //找到它左边那张图片的ID
                if (leftID == '') {
                    toastr.error("不可能出现的情况");
                    return;
                }
                let leftPZH = getPZH(leftID);
                if (leftPZH != pzh) {
                    $.alert(pzh + '有多张图片，请将它们移动到相邻位置，即同一张凭证的多个分页必须连续相邻，它们之间不要穿插附件图片或其它凭证号图片');
                    return;
                }

            }
            lastPZ.pz.push(one.id); //凭证图片，同一个凭证可能有多个图片 
        }
    }

    if (pzGroup.length == 0) {
        toastr.error("凭证归档操作，至少需要标记一张凭证，并选中它");
        return;
    }

    console.dir();


    do_pzgdqr();



}

//@comment (group=归档,caption=归档确认,needRightControl=false)
function do_pzgdqr() {

    // 整理归档配置信息用于显示
    book.sheet4.paintPermit = false;

    $gd_ds.reset();
    for (let i = 0; i < pzGroup.length; i++) {
        let one = pzGroup[i];
        let row = $gd_ds.insertRow(9999);
        $gd_ds.setValue(row, { pzh: one.pzh, pzs: one.pz.length, fjs: one.fj.length, hj: one.pz.length + one.fj.length });
    }
    book.sheet4.paintPermit = true;

    book.sheet4.popup('fa fa-cog', '归档确认', 450, 450, true, true, {
        action1: {
            text: '确认',
            btnClass: 'btn-green',
            action: function () {
                do_pzgd();
                return true;    //表示关闭弹窗
            }
        },
        cancel: {
            text: '关闭',
            btnClass: 'btn-red',
            action: function () {

                return true;
            }
        }

    });

}
//@comment (group=归档,caption=归档,needRightControl=false)
function do_pzgd() {
    showInfoPane('*正在归档...');
    setButtonsStatus(false); //禁用一些按钮点击
    //alert(JSON.stringify(pzGroup));
    runTask("归档",
        {
            corpid: book.sheet4.cells("corpid").getValueString(),
            ym: book.sheet4.cells("ym").getValueString(),
            pzGroup: pzGroup
        }, function (ret) {
            hideInfoPane();
            ret = JSON.parse(ret);

            if (ret.success) {

                setButtonsStatus(true); //启用一些按钮点击
                smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
                //重新检索图片区
                cb_refresh_onClick();
            } else {
                $.alert(ret.message);
            }

        });
}

function setButtonsStatus(b) {

    book.sheet0.getBrick('cb_auto').enabled = b;
}

//@comment (group=,caption=调取某个凭证,needRightControl=false)
function loadPZ(id, pzh, verified) {
    book.sheet3.cells("id").setValue(id);
    smartRetrieve(book.sheet3, "one");
    //附件图片清单
    //不能从 $one_ds中取数，因为上面的smartRetrieve 是异步的
    let action = (verified == 0) ? "edit" : "view";
    book.sheet3.getBrick('cb_delete_pz').visible = verified == 0;
    var FJ = book.sheet3.getBrick('FJ');
    FJ.config.action = action; //控制是否显示删除和新增按钮
    let data = getPZFJ(id); //得到凭证的所有图片
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet3.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=,caption=删除凭证，并把图片回归到池中,needRightControl=false)
function cb_delete_pz_onClick() {
    $confirm("提示", "确信删除本凭证，并将图片全部回归到待归档状态吗?", function () {
        book.sheet3.getBrick('cb_delete_pz').visible = false;
        var id = $one_ds.getString(0, "id");
        var ret = deletePZAndPutBackToPool(id);
        if (ret.success) {
            $one_ds.reset();
            reload_pzh_info(); //可能删除的就是最后一张凭证，所以要重新取一下
            var FJ = book.sheet3.getBrick('FJ');
            FJ.config.action = 'view';
            FJ.buildGridly([]);
            cb_refresh_onClick();//刷新池中图片

        } else {
            toastr.error(ret.message);
        }
    });

}



function cb_trash_onClick() {
    var url = runTask("urlForTrash", {});
    openInMainFrame(url, false, 'fa-trash', '图片回收站');

}

function cb_deleteSelection_onClick() {
    let imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    let selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }
    let nn = selection.length;
    $confirm("提示", "确信将选中的" + nn + "张图片移入回收站吗?", function () {
        showInfoPane('*正在移和回收站');
        setTimeout(function () {
            do_trush(selection);
            hideInfoPane();
        }, 100);
    });

}

function do_trush(selection) {

    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        moveImageToRecycle(one.id);

    }
    cb_refresh_onClick();

}

function cb_size_onClick() {
    let RPM = book.sheet0.RPM;
    let h = RPM.getRowHeight(1);
    if (h > 1) {
        RPM.setRowStretchHeight(1, 0);//弹性高度取消
        RPM.setRowHeight(1, 1);

        RPM.setRowHeight(2, 0);
        book.sheet0.getBrick('dbnav').visible = false;

    } else {

        RPM.setRowStretchHeight(1, 40);//弹性高度取消
        RPM.setRowHeight(1, 300);

        RPM.setRowHeight(2, 30);
        book.sheet0.getBrick('dbnav').visible = true;
    }
}


/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //通过别名来判断
    if (sheet.name == '凭证清单') {
        if (cell.alias == 'nian' || cell.alias == 'yue') {
            reload_pzh_info();
        };
    }



}

/**
 * 单元格因为被编辑而改变。当用户通过编辑单元的值而让单元格发生值改变时本事件被触发。
 * 注意，当使用脚本 sheet.cells(row,col).setValue ( value) 来改变单元格的值时，本事件并不触发
 * @param sheet
 * @param cell
 * @param newValue
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChangedByEdit(sheet, cell, newValue, innerRow) {

    if (cell.alias == 'onceCount') {
        setLoadImagePoolDataOnceCount();

    }


}



function reload_pzh_info() {
    var sheet = book.getWorkSheet('凭证清单');
    //加载帐套信息及年月
    var corpid = sheet.cells("corpid").getValueString();

    var nian = sheet.cells("nian").getValueString();
    var yue = sheet.cells("yue").getValueString();
    var ym = nian + right("00" + yue, 2);

    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);
    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000000'.substring(8 - pzh_len, 8);
        lastPZH = v;

    });

    smartRetrieve(sheet, "dzpz_pz"); //刷新凭证列表
}



function cb_ocr_onClick() {
    toastr.show("正在自动识别");
    var imgPool = book.sheet1.getBrick('imgPool');
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    asyncPool(4,  // 最多4个并发执行
        imgs, //需要处理的数据数组，每个元素可以是任意类型的数据
        function (one, array) // item表示当前处理的对象， array就是整个数据数组
        {
            console.info(one.url_img);
            //函数必须返回一个Promise对象
            return new Promise(function (resolve, reject) {

                back_ocr({ src: one.url_img, left: '50%', top: '0px', height: '25%', width: '50%' }, function (text) {
                    if (text != '') {
                        setPZH(one.id, text);

                    }
                    resolve(1);
                });





            });
        }).then(function () {  //此时，整个数据数组都已经迭代执行完成 ，通常在此善后
            console.info("over");
            toastr.hide();
            toastr.success("自动识别完成");
        });

}


id: 6512793b9932f2713a061c50
scriptid: 60a321f05db27838e0c014c3
tablename: app_template
clientip: 39.170.92.207
username: sa
createdate: 2023.09.26 16:48:45.000
script:
var pathToMonit = "";//当前监控的目录
var electron = null;
var pzh_prefix = ""; // 凭证号前缀
var pzh_len = 0; //凭证号长度
var lastPZH = "";
var fullScreenDiv = null;

/*
$(document).ready(function () {
    var script = $(`<script src="ui/imageEditor/filerobot-image-editor.min.js">
    
    </script>`);
    $(document.body).append(script);
});
*/

function formOpen() {

    book.sheet4.visible = false;

    book.showTabOnWhere = "none";
    newImgCommingTipVisible(false);

    book.sheet3.getBrick('cb_delete_pz').visible = false;

    //加载帐套信息及年月
    var corpid = book.sheet2.cells("corpid").getValueString();
    var ym = book.sheet2.cells("ym").getValue();
    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);

    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000001'.substring(8 - pzh_len, 8);
        lastPZH = v;
    });

    // smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
    // });

    book.getWorkSheet('凭证清单').cells("yue").setValue(getMonth(newDate()));

    book.sheet3.getBrick('FJ').config.promptInfoOnDelete = "确信要将图片从当前凭证中移除，并放回到图片池中吗?";
    book.sheet1.getBrick('imgPool').config.promptInfoOnDelete = "确信要将图片放入回收站吗?";

    //收到来自服务器推送的消息
    onPushMessage("electronPushMessage", function (msg) {
        msg = JSON.parse(msg);
        if (msg.cmd == "newFileUploaded") newImgCommingTipVisible(true); //通知有新文件上传了
        if (msg.cmd == "notifyNeedUploadFileCount") notifyNeedUploadFileCount(msg.fileCount); //通知还有多少个文件等待上传
    });

    //获取当前的electron接口对象
    electron = getElectron(); //getElectron是系统全局功能函数

    book.sheet1.getBrick('imgPool').selectionMode = 'multi'; //图片设置成多选模式

    // 追加一些CSS类 ，用于凭证号标记
    $(document.body).append(`<style>
                        .pzh {position:absolute;left:0;bottom:0px; 
                                height:30px; line-height:30px;width:100%; 
                                background-color:#af4040e0; 
                                color:white;font-weight:bold;font-size:20px;text-align:left;}
                        .delete_pzh { position:absolute; right:0; width:40px; height:44px; top:0; text-align:right; 
                                    vertical-align:top; font-size:24px; color:#ffa0a0;padding-right:5px;}      
                        .delete_pzh:hover { color:white;}      
                          
                        </style>
                    `);


    //注册调整缩略图大小的事件
    $('#blockSize').on('input', resetImgPoolBlockSize);


    setTimeout(function () {
        //调取缩略图大小

        var imgPool = book.sheet1.getBrick('imgPool');
        let blockSize = getImagePoolBlockSize();
        if (blockSize != imgPool.config.blockSize) {
            $('#blockSize').val(blockSize);
            resetImgPoolBlockSize(false);
        }
    }, 1000);

    //调取图片目录设置，注意适当延时
    setTimeout(function () {
        if (electron != null) {
            var hostName = electron.getHostName();
            pathToMonit = getMonitePath(hostName);

            //开启监控
            if (pathToMonit == '') pathToMonit = "c:\\凭证影像采集目录";

            moniteStart(pathToMonit);
            $.alert('请将扫描仪的图片目录指向：' + pathToMonit);
        }

        //显示总共图片数
        getTotalImageCount(function (ret) { book.sheet0.cells('imageCountTotal').setValue('共' + ret + '张') });

    }, 500);



    $(document).on('keydown', function (e) {
        console.info(" kkkkk down");
        if (e.ctrlKey) {
            // fullScreenViewImageOpen();
        }
    });


    $(document).on('keyup', function (e) {
        console.info(" kkkkk up");
        if (!e.ctrlKey) {

            // fullScreenViewImageClose();

        }
    });

    onPushMessage( "pz_ocr" , function(msg)
    {
        if( msg.action=='info')
        { 
            toastr.show( msg);
        }
    }) ;

}


// 先保存当前选中状态及设置的凭证号信息

var g_selection;
var g_pzMap;
//@comment (group=图片清单刷新,caption=保存选中状态及凭证标记信息,needRightControl=false)
function saveSelectionAndPZInfo() {

    var imgPool = book.sheet1.getBrick('imgPool');

    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    // 保存设置的凭证号信息
    var pzhMap = {};
    var pzhs = imgPool.dom.find('.pzh');
    for (let i = 0; i < pzhs.length; i++) {
        let id = $(pzhs[i]).parent().attr('id');
        let pzh = $(pzhs[i]).find('.no').text();
        pzhMap[id] = pzh;

    }
    g_selection = selection;
    g_pzMap = pzhMap;
}




//@comment (group=图片清单刷新,caption=还原选中及凭证标记,needRightControl=false)
function restoreSelectionAndPZInfo() {
    var selection = g_selection;
    var pzhMap = g_pzMap;
    var imgPool = book.sheet1.getBrick('imgPool');

    //恢复选中状态
    for (let i = 0; i < selection.length; i++) {
        imgPool.setImageSelected(selection[i].id, true);
    }
    //恢复凭证号
    for (let id in pzhMap) {
        var pzh = pzhMap[id];
        find_pzh(id, true).find('.no').text(pzh);
    }

}

//@comment (group=图片控件,caption=重设小图大小,needRightControl=false)
function resetImgPoolBlockSize(needSaveSetting) {
    if (needSaveSetting == null) needSaveSetting = true;
    var imgPool = book.sheet1.getBrick('imgPool');

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    let v = $('#blockSize').val();

    imgPool.config.blockSize = parseInt(v);
    imgPool.rebuildGridly();

    //恢复选中状态
    restoreSelectionAndPZInfo();

    if (needSaveSetting) {
        setTimeout(function () {
            setImagePoolBlockSize(imgPool.getConfig("gguid"), v);
        }, 1000);
    }



}

function resetImageCountInfo() {

    setTimeout(function () {
        book.sheet0.cells("imageCount").setValue("前 " + book.sheet1.getBrick("imgPool").imageCount + " 张");
    }, 300);
}

/**
 * 图片控件初始化完成
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片控件初始化完成)
function imageGridlyInited(sheet, name, data) {


    if (name == "imgPool") {
        resetImageCountInfo()
        //图片都初始化后， 定制右上角的工具栏，最多可加5个工具按 钮
        let brick = sheet.getBrick(name);

        book.sheet0.cells("imageCount").setValue(brick.imageCout + "张图片");


        brick.addToolButton(2  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-repeat",   // 字符图标
            "旋转图片",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {  //点击后的回调函数

                showInfoPane('*正在旋转图片...');
                setTimeout(function () {
                    //toastr.info(id);  // id 是当前操作的图片对应数据的ID
                    var ret = do_imageRotate(id, "90");
                    if (ret.success) {
                        //把数据中的图片替换，
                        for (let i = 0; i < brick.data.length; i++) {
                            if (brick.data[i].id == id) {
                                //属性从新的属性中替换 
                                for (let prop in brick.data[i]) {
                                    brick.data[i][prop] = ret.data[prop];
                                }
                                break;
                            }
                        }
                        //把缩略图的图片地址替换 ， 

                        let img = $('#' + id).find('.image');
                        img.attr("src", ret.data.url_thumbnail);
                        img.attr('largeimage', ret.data.url_img);
                        //把大图预览的地址替换掉
                        book.sheet0.cells("imgPreview").setValue(ret.data.url_img);
                        hideInfoPane();

                    }
                }, 10);
            }
        );


        brick.addToolButton(3  //在从右往左数第2个工作栏位置添加一个工具按钮
            , "fa-plus",   // 字符图标
            "选中此前",  // 鼠标悬停的提示信息
            "green", //按钮背景色
            function (id) {
                let selected = $('#' + id).parent().find('.brickSelected').length > 0; // 可以用 imgPool.isImageSelected( id) 替换，但此时本函数还没有提供，以后可以换成此函数

                let imgPool = book.sheet1.getBrick("imgPool");
                let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
                let found = false;
                for (let i = 0; i < imgs.length; i++) {
                    imgPool.setImageSelected(imgs[i].id, !selected);
                    if (imgs[i].id == id) return;

                }


            });


    }
}


/**
 * 图片控件中图片上的删除按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 * @param data  图片的信息
 *
 * @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行删除操作，否则表示终止删除操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上的删除按钮被点击)
function imageOnDelete(sheet, name, data) {

    if (name == 'FJ') {
        if (data.groupname == '凭证') {
            return { success: false, message: "这是凭证，不允许这样移除，请点击“删除凭证”" };
        } else {
            var ret = putImageBackToPool(data.id);
            if (ret.success) {
                smartRetrieve(book.sheet3, "one");
                cb_refresh_onClick();
            } else {
                return ret;
            }

        }
    }

    if (name == 'imgPool') {
        moveImageToRecycle(data.id);
        resetImageCountInfo();
    }
    return { success: true };
}
/**
 * 图片控件中上传按钮被点击
 * @param sheet   所在Sheet
 * @param name  图片控件的名称
 *
 @returns  {object}    返回一个对象 ， 其中  success= boolean 表示继续执行上传操作，否则表示终止上传操作
 *    如果需要显示一个提示信息，则在 属性 message 中指定
 */
//@comment (group=图片控件,caption=图片上传按钮被点击)
function imageOnNewUpload(sheet, name) {


    if (name == 'imgPool') {
        toastr.info("请连接扫描仪，或将图片复制到监控的目录下，图片自动上传");
    }

    if (name == 'FJ') {
        var imgPool = book.sheet1.getBrick('imgPool');
        // 保存当前选中状态及设置的凭证号信息
        var selection = imgPool.getSelectedImageList();
        if (selection.length == 0) {
            toastr.error("至少选中一张图片");
            return { success: false }; // 此返回，阻止了默认的上传操作
        }


        var lastPZ = null;
        for (let i = 0; i < selection.length; i++) {
            var one = selection[i];
            var pzh = getPZH(one.id);
            if (pzh != '') {
                toastr.error("选中的图片中有标记为凭证的，禁止将凭证图片添加到当前凭证中");
                return { success: false }; // 此返回，阻止了默认的上传操作
            }
        }

        var ret = addImageToPZ($one_ds.getString(0, "id"), selection);
        if (ret.success) {
            //刷新图片区
            cb_refresh_onClick();
            //刷新凭证
            loadPZ($one_ds.getString(0, "id"), $one_ds.getString(0, "pzh"), $one_ds.getString(0, "verifiername") != "" ? 1 : 0);
        }

    }


    return { success: false }; // 此返回，阻止了默认的上传操作
}

//先定位 Id的序号， 然后返回它左边的图片的ID
function findLeftImageId(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    if (index > 0) return imgs[index - 1].id;
    return "";
}


//找到左边最近的一张凭证号
//如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
//否则在那个号上加1做为自已的凭证号
function incLeftNearestPZH(id) {
    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    //找到自已的索引号
    let index = 0;
    for (let i = 0; i < imgs.length; i++) {
        if (imgs[i].id == id) {
            index = i;
            break;
        }
    }

    //再从index往左边查到第一张凭证
    for (let i = index - 1; i >= 0; i--) {
        let tid = imgs[i].id;
        let pzh = getPZH(tid);
        if (pzh == '') continue;
        if (i == index - 1) {
            return pzh; // 左边最近的一张凭证号就在自已的左边，那么就意味着自已与左边那张凭证号可能就是一张凭证的不同分页，所以直接返回凭证号
        } else {
            return stringInc(pzh);
        }

    }
    //到这里，都没有找到凭证号，那么直接返回凭证号前缀
    return stringInc(lastPZH);
}

/**
 * 图片控件中鼠标进入某个图片区域
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=鼠标进入图片区域)
function imageOnMouseEnter(sheet, name, data, event) {
    //console.dir(data);
    var url = data.url_img;
    book.sheet0.cells("imgPreview").setValue(url);
}
//@comment (group=图片控件,caption=鼠标从图片移开,needRightControl=false)
function imageOnMouseOut(sheet, name, data, event) {

    // book.sheet0.cells("imgPreview").setValue("");
}

/**
 * 图片控件中图片顺序变化了
 * @param sheet   所在Sheet
 * @param config  图片控件的配置信息
 *@param ids  调整顺序后的id清单
 *
 */
//@comment (group=图片控件,caption=顺序调整后)
function attachmentOrderChanged(sheet, config, ids) {

    let imgPool = book.sheet1.getBrick("imgPool");
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    reorderImageFileIndex(imgs);

}

/**
 * 图片控件中某个图片被单击
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 * @param event  事件对象
 *
 *
 */
//@comment (group=图片控件,caption=图片被单击)
function imageOnClick(sheet, name, data, event) {

    if (name == 'imgPool') {
        if (book.sheet0.cells("clickAction").getValue() == 2) imageOnDBLClick(sheet, name, data, event, false);
    }
}


var g_lastPZH = "";
/**
 * 图片控件中某个图片被双击了
 * @param sheet   所在Sheet
 * @param config  图片控件的名称
 *@param data  该图片的详细信息
 *
 */
//@comment (group=图片控件,caption=图片被双击)
function imageOnDBLClick(sheet, name, data, event, showDlg) {

    if (showDlg == undefined) showDlg = true;

    //因为 mouseOut 会把大图清除掉，所以这里重新再设置上
    setTimeout(function () {
        var url = data.url_img;
        book.sheet0.cells("imgPreview").setValue(url);

    }, 200);

    var pzh = '';
    try {

        pzh = find_pzh(data.id, false).find('.no').text();
    } catch (err) {

    }

    if (pzh == undefined) pzh = "";
    if (pzh == '') {

        //找到左边最近的一张凭证号
        //如果该凭证与自已相临，那么就同号，因为可能是同一个凭证的不同分页
        //否则在那个号上加1做为自已的凭证号
        pzh = incLeftNearestPZH(data.id);
        if (pzh > lastPZH) lastPZH = pzh;


    }

    let $setpzh = function (val) {
        if (val == '') {

            var p = find_pzh(data.id, false);
            if (p) p.remove();
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, false);
            return true;
        } else {
            if (val.length - pzh_prefix.length != pzh_len) {
                toastr.error("凭证号(不含前缀)长度必须是" + pzh_len + "位");
                return false;

            }
            g_lastPZH = val; //记下来
            find_pzh(data.id, true).find('.no').text(val);
            book.sheet1.getBrick("imgPool").setImageSelected(data.id, true);
            return true;
        }
    }

    if (!showDlg) {
        $setpzh(pzh);
        return;
    }

    let dlg = inputBox("标记为凭证", "", pzh, "输入凭证号码",

        function (val) { //确认后的回调

            return $setpzh(val);

        }, false,/*不允许为空*/
        //下面是一些事件的切入
        {
            //输入面板初始化完成后
            onContentReady: function () {

                let input = dlg.$content.find('.name');
                input.on('keyup', function () {
                    if (input.val().indexOf(pzh_prefix) != 0) {
                        input.val(pzh_prefix);
                    }
                });
            }
        }
    );




}


function setLoadImagePoolDataOnceCount() {
    let onceCount = book.sheet0.cells("onceCount").getValueInt();
    if (onceCount < 0) onceCount = 100;
    if (onceCount > 2000) onceCount = 2000;
    setTimeout(function () {
        book.sheet0.cells("onceCount").setValue(onceCount);
        book.sheet1.getBrick("imgPool").config.onceCount = onceCount;
        cb_refresh_onClick();
    }, 1);

}

//@comment (group=凭证号,caption=得到图片的凭证号如果有的话,needRightControl=false)
function getPZH(id) {
    let obj = find_pzh(id, false);
    if (obj == null) return;
    let s = obj.text();
    s = s.replace(/\s/g, '');
    return s;
}

//@comment (group=凭证号,caption=设置图片的凭证号,needRightControl=false)
function setPZH(id, pzh, needDeleteButton) {
    if (needDeleteButton == undefined) needDeleteButton = true
    find_pzh(id, true, needDeleteButton).find('.no').text(pzh);
}

//@comment (group=凭证号,caption=查找或创建凭证号标记对象,needRightControl=false)
function find_pzh(id, create_if_not_exists, needDeleteButton) {

    if (needDeleteButton == undefined) needDeleteButton = true;

    var d = $('#' + id);
    if (!d) {
        $.alert(id + "不存在");
        return null;
    }

    var ret = d.find('.pzh');
    if (ret.length == 0) {
        if (create_if_not_exists) //如果需要创建，则创建它
        {
            d.append(`<div class="pzh" >
                        <div class="no"></div>
                        <div class="delete_pzh"  ${needDeleteButton ? "" : " style='display:none' "} ><i class="fa fa-close" onclick="removePZH('${id}');  event.preventDefault(); event.stopPropagation();"> </i></div>
                      </div>`);
        }
        ret = d.find('.pzh');
    }
    return ret;

}

//@comment (group=图片控件,caption=移除图片看的凭证号标记,needRightControl=false)
function removePZH(id) {
    var p = find_pzh(id, false);
    if (p) p.remove();
}

function cb_selectall_onClick() { doSelect(true); }
function cb_selectnull_onClick() { doSelect(false); }

function doSelect(b) {
    var imgPool = book.sheet1.getBrick('imgPool');
    if (b) {
        imgPool.selectAll();
    } else {
        imgPool.unSelectAll();
    }
}


function cb_path_onClick() {
    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    var path = electron.showOpenDialogSync('');
    if (path == '') return;
    if (!path.endsWith('凭证影像采集目录')) {

        $.alert("目录名必须是：“凭证影像采集目录”，盘符及上级目录随意。");
        return;
    }
    var hostName = electron.getHostName();
    setMonitePath(hostName, path);

    moniteStart(path);


}

//@comment (group=上传相关,caption=开始文件变化监控,needRightControl=false)
function moniteStart(path) {
    pathToMonit = path;
    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit);

    if (electron == null) {
        toastr.error("此功能仅能在客户端APP中执行");
        return;
    }

    book.sheet0.cells('stateBar').setValue("图片目录 " + pathToMonit + " 监控中...");
    electron.ipcSendMessage({ cmd: "moniteStart", path: path });
}

function cb_refresh_onClick() {
    newImgCommingTipVisible(false);

    // 先保存当前选中状态及设置的凭证号信息
    saveSelectionAndPZInfo();

    var imgPool = book.sheet1.getBrick('imgPool');
    imgPool.reInit(restoreSelectionAndPZInfo); //重新初始化 ,并在初始化完成后， 恢复选中状态

    toastr.info("重新加载完成");



}

//@comment (group=上传相关,caption=上传好一个文件后，通知有新文件,needRightControl=false)
//@comment (group=上传相关,caption=上传好一个文件后通知有新文件,needRightControl=false)
function newImgCommingTipVisible(v) {
    book.sheet0.getBrick('shineText').visible = v;

}

//@comment (group=上传相关,caption=刷新当前还有多少文件要上传的提示,needRightControl=false)
function notifyNeedUploadFileCount(fc) {
    var info = fc == 0 ? "" : "【" + fc + "】个文件正准备上传";
    book.sheet0.cells("stateInfo2").setValue(info);
}


//@comment (group=归档,caption=凭证归档,needRightControl=false)
function cb_auto_onClick() {

    var imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    var selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }

    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    let nn = imgs.length - selection.length;
    if (nn > 0) {
        $confirm("提示", "有" + nn + "张图片没有选中，确信要继续吗?", function () {
            do_pack(selection);
        });
    } else {
        do_pack(selection);
    }
}

var pzGroup = [];

//@comment (group=归档,caption=归档操作,needRightControl=false)
function do_pack(selection) {
    pzGroup = [];
    let pzh2Config = {}; //凭证号对应的配置信息 ， 辅助数据
    let lastPZ = null;
    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        let pzh = getPZH(one.id);
        if (pzh == '') {
            if (lastPZ != null) {
                lastPZ.fj.push(one.id);
            }
        } else {
            //新的凭证号
            if (pzh2Config[pzh] == null) {
                lastPZ = {};
                lastPZ.pzh = pzh;
                lastPZ.fj = []; //附件图片
                lastPZ.pz = []; //凭证图片
                pzh2Config[pzh] = lastPZ; //记下凭证号与配置对象的对应关系
                pzGroup.push(lastPZ); //加入到总配置中
            } else {
                //已经存在配置，说明它是该凭证号的更多的分页图片
                //需要检测，它的左边是不是也是同一个号的凭证
                lastPZ = pzh2Config[pzh];

                let leftID = findLeftImageId(one.id); //找到它左边那张图片的ID
                if (leftID == '') {
                    toastr.error("不可能出现的情况");
                    return;
                }
                let leftPZH = getPZH(leftID);
                if (leftPZH != pzh) {
                    $.alert(pzh + '有多张图片，请将它们移动到相邻位置，即同一张凭证的多个分页必须连续相邻，它们之间不要穿插附件图片或其它凭证号图片');
                    return;
                }

            }
            lastPZ.pz.push(one.id); //凭证图片，同一个凭证可能有多个图片 
        }
    }

    if (pzGroup.length == 0) {
        toastr.error("凭证归档操作，至少需要标记一张凭证，并选中它");
        return;
    }

    console.dir();


    do_pzgdqr();



}

//@comment (group=归档,caption=归档确认,needRightControl=false)
function do_pzgdqr() {

    // 整理归档配置信息用于显示
    book.sheet4.paintPermit = false;

    $gd_ds.reset();
    for (let i = 0; i < pzGroup.length; i++) {
        let one = pzGroup[i];
        let row = $gd_ds.insertRow(9999);
        $gd_ds.setValue(row, { pzh: one.pzh, pzs: one.pz.length, fjs: one.fj.length, hj: one.pz.length + one.fj.length });
    }
    book.sheet4.paintPermit = true;

    book.sheet4.popup('fa fa-cog', '归档确认', 450, 450, true, true, {
        action1: {
            text: '确认',
            btnClass: 'btn-green',
            action: function () {
                do_pzgd();
                return true;    //表示关闭弹窗
            }
        },
        cancel: {
            text: '关闭',
            btnClass: 'btn-red',
            action: function () {

                return true;
            }
        }

    });

}
//@comment (group=归档,caption=归档,needRightControl=false)
function do_pzgd() {
    showInfoPane('*正在归档...');
    setButtonsStatus(false); //禁用一些按钮点击
    //alert(JSON.stringify(pzGroup));
    runTask("归档",
        {
            corpid: book.sheet4.cells("corpid").getValueString(),
            ym: book.sheet4.cells("ym").getValueString(),
            pzGroup: pzGroup
        }, function (ret) {
            hideInfoPane();
            ret = JSON.parse(ret);

            if (ret.success) {

                setButtonsStatus(true); //启用一些按钮点击
                smartRetrieve(book.sheet2, "dzpz_pz"); //刷新凭证列表
                //重新检索图片区
                cb_refresh_onClick();
            } else {
                $.alert(ret.message);
            }

        });
}

function setButtonsStatus(b) {

    book.sheet0.getBrick('cb_auto').enabled = b;
}

//@comment (group=,caption=调取某个凭证,needRightControl=false)
function loadPZ(id, pzh, verified) {
    book.sheet3.cells("id").setValue(id);
    smartRetrieve(book.sheet3, "one");
    //附件图片清单
    //不能从 $one_ds中取数，因为上面的smartRetrieve 是异步的
    let action = (verified == 0) ? "edit" : "view";
    book.sheet3.getBrick('cb_delete_pz').visible = verified == 0;
    var FJ = book.sheet3.getBrick('FJ');
    FJ.config.action = action; //控制是否显示删除和新增按钮
    let data = getPZFJ(id); //得到凭证的所有图片
    FJ.buildGridly(data, function () {
        let shortPZH = pzh.substring(pzh_prefix.length);
        //加载图片完成后， 如果是凭证，那么加上凭证号信息
        for (let i = 0; i < data.length; i++) {
            if (data[i].groupname == '凭证') {
                setPZH(data[i].id, shortPZH, false);
            }
        }

    });
    book.sheet3.yOffset = 0; //垂直卷滚条归位
}


//@comment (group=,caption=删除凭证，并把图片回归到池中,needRightControl=false)
function cb_delete_pz_onClick() {
    $confirm("提示", "确信删除本凭证，并将图片全部回归到待归档状态吗?", function () {
        book.sheet3.getBrick('cb_delete_pz').visible = false;
        var id = $one_ds.getString(0, "id");
        var ret = deletePZAndPutBackToPool(id);
        if (ret.success) {
            $one_ds.reset();
            reload_pzh_info(); //可能删除的就是最后一张凭证，所以要重新取一下
            var FJ = book.sheet3.getBrick('FJ');
            FJ.config.action = 'view';
            FJ.buildGridly([]);
            cb_refresh_onClick();//刷新池中图片

        } else {
            toastr.error(ret.message);
        }
    });

}



function cb_trash_onClick() {
    var url = runTask("urlForTrash", {});
    openInMainFrame(url, false, 'fa-trash', '图片回收站');

}

function cb_deleteSelection_onClick() {
    let imgPool = book.sheet1.getBrick('imgPool');
    // 保存当前选中状态及设置的凭证号信息
    let selection = imgPool.getSelectedImageList();
    if (selection.length == 0) {
        toastr.error("至少选中一张图片");
        return;
    }
    let nn = selection.length;
    $confirm("提示", "确信将选中的" + nn + "张图片移入回收站吗?", function () {
        showInfoPane('*正在移和回收站');
        setTimeout(function () {
            do_trush(selection);
            hideInfoPane();
        }, 100);
    });

}

function do_trush(selection) {

    for (let i = 0; i < selection.length; i++) {
        let one = selection[i];
        moveImageToRecycle(one.id);

    }
    cb_refresh_onClick();

}

function cb_size_onClick() {
    let RPM = book.sheet0.RPM;
    let h = RPM.getRowHeight(1);
    if (h > 1) {
        RPM.setRowStretchHeight(1, 0);//弹性高度取消
        RPM.setRowHeight(1, 1);

        RPM.setRowHeight(2, 0);
        book.sheet0.getBrick('dbnav').visible = false;

    } else {

        RPM.setRowStretchHeight(1, 40);//弹性高度取消
        RPM.setRowHeight(1, 300);

        RPM.setRowHeight(2, 30);
        book.sheet0.getBrick('dbnav').visible = true;
    }
}


/**
 * 单元格的值发生了改变
 * @param sheet  所在的工作表
 * @param cell  单元格对象
 * @param oldValue  原先的值
 * @param newValue 变化后的值
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChanged(sheet, cell, oldValue, newValue, innerRow) {

    //通过别名来判断
    if (sheet.name == '凭证清单') {
        if (cell.alias == 'nian' || cell.alias == 'yue') {
            reload_pzh_info();
        };
    }



}

/**
 * 单元格因为被编辑而改变。当用户通过编辑单元的值而让单元格发生值改变时本事件被触发。
 * 注意，当使用脚本 sheet.cells(row,col).setValue ( value) 来改变单元格的值时，本事件并不触发
 * @param sheet
 * @param cell
 * @param newValue
 * @param innerRow   当单元格没有绑定数据库或绑定到单行数据库时，本参数无意义。如果绑定一个
 * 多行数据库，则表示该单元所绑定的字段的第 innerRow行发生变化
 */
function cellValueChangedByEdit(sheet, cell, newValue, innerRow) {

    if (cell.alias == 'onceCount') {
        setLoadImagePoolDataOnceCount();

    }


}



function reload_pzh_info() {
    var sheet = book.getWorkSheet('凭证清单');
    //加载帐套信息及年月
    var corpid = sheet.cells("corpid").getValueString();

    var nian = sheet.cells("nian").getValueString();
    var yue = sheet.cells("yue").getValueString();
    var ym = nian + right("00" + yue, 2);

    //得到年月后，获取凭证号相关设置
    pzh_len = getPZHLen(corpid);
    pzh_prefix = getPZHPrefix(corpid, ym);
    getLastPZH(corpid, ym, function (v) {
        if (v == '') v = pzh_prefix + '00000000'.substring(8 - pzh_len, 8);
        lastPZH = v;

    });

    smartRetrieve(sheet, "dzpz_pz"); //刷新凭证列表
}



function cb_ocr_onClick() {
    toastr.show("正在自动识别");
    var imgPool = book.sheet1.getBrick('imgPool');
    let imgs = imgPool.getCurrentSortedImageList();//得到当前排序后的图片清单
    asyncPool(4,  // 最多4个并发执行
        imgs, //需要处理的数据数组，每个元素可以是任意类型的数据
        function (one, array) // item表示当前处理的对象， array就是整个数据数组
        {
            console.info(one.url_img);
            //函数必须返回一个Promise对象
            return new Promise(function (resolve, reject) {

                back_ocr({ src: one.url_img, left: '40%', top: '0px', height: '25%', width: '50%' }, function (text) {
                    if (text != '') {
                        setPZH(one.id, text);

                    }
                    resolve(1);
                });





            });
        }).then(function () {  //此时，整个数据数组都已经迭代执行完成 ，通常在此善后
            console.info("over");
            toastr.hide();
            toastr.success("自动识别完成");
        });

}


