Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
6129e836
Commit
6129e836
authored
Dec 23, 2024
by
chenzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工行代扣接口批次号生成规则修改
parent
541f326c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
16 deletions
+68
-16
IcbcWithholdController.java
...ot/module/hygf/biz/controller/IcbcWithholdController.java
+3
-3
IcbcWithholdServiceImpl.java
...module/hygf/biz/service/impl/IcbcWithholdServiceImpl.java
+65
-13
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/IcbcWithholdController.java
View file @
6129e836
...
...
@@ -48,7 +48,7 @@ public class IcbcWithholdController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/save"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增 聚富通代扣信息表"
,
notes
=
"新增 聚富通代扣信息表"
)
public
ResponseModel
save
(
@RequestBody
IcbcWithhold
model
)
{
public
ResponseModel
save
(
@RequestBody
IcbcWithhold
model
)
throws
Exception
{
icbcWithholdServiceImpl
.
saveRecord
(
model
);
return
CommonResponseNewUtil
.
success
();
}
...
...
@@ -192,9 +192,9 @@ public class IcbcWithholdController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
" 聚富通代扣信息回盘文件获取"
,
notes
=
" 聚富通代扣信息回盘文件获取"
)
@GetMapping
(
value
=
"/updateWithholdStatus"
)
public
void
updateWithholdStatus
(
)
throws
Exception
{
public
ResponseModel
updateWithholdStatus
(
)
throws
Exception
{
icbcWithholdServiceImpl
.
updateWithholdStatus
();
return
CommonResponseNewUtil
.
success
();
}
/**
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/IcbcWithholdServiceImpl.java
View file @
6129e836
...
...
@@ -58,6 +58,7 @@ import java.nio.file.Paths;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
java.util.zip.ZipEntry
;
...
...
@@ -90,7 +91,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
@Value
(
"${icbc.Withhold.sftpUserName}"
)
public
String
sftpUserName
;
private
static
final
DateTimeFormatter
DATE_FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
private
static
int
sequence
=
0
;
// 当天的序列号
private
static
final
AtomicInteger
sequence
=
new
AtomicInteger
(
0
);
private
static
String
uploadPath
=
"/JftFeeWithhold/upload"
;
// 上传地址
private
static
String
downLoadPath
=
"/JftFeeWithhold/download"
;
// 下载地址
private
static
String
file
=
""
;
...
...
@@ -126,7 +127,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
int
billNo
=
0
;
int
totalAmt
=
0
;
//生成批次号 若已从保存生成取原有批次号
String
batchNo
=
StringUtil
.
isEmpty
(
model
.
getBatchNo
())?
generateBatch
Number
():
model
.
getBatchNo
();
String
batchNo
=
StringUtil
.
isEmpty
(
model
.
getBatchNo
())?
checkBatcn
Number
():
model
.
getBatchNo
();
String
loopField
=
""
;
//判断接口调用来源 不为空时说明是先保存后在列表按钮上生成 可直取冗余数据
if
(
StringUtils
.
isNotEmpty
(
model
.
getIcbcRecordInfos
())){
...
...
@@ -213,8 +214,8 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
* 生成文件
*
*/
public
void
saveRecord
(
IcbcWithhold
model
)
{
String
batch
=
generateBatch
Number
();
public
void
saveRecord
(
IcbcWithhold
model
)
throws
Exception
{
String
batch
=
checkBatcn
Number
();
model
.
getRecordDTOS
().
forEach
(
e
->{
e
.
setSequenceNbr
(
null
);
e
.
setBatchNo
(
batch
);
...
...
@@ -262,21 +263,72 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
}
public
synchronized
String
generateBatchNumber
()
{
// public synchronized String generateBatchNumber() {
// LocalDate currentDate = LocalDate.now();
// // 如果是新的一天,重置序列号
// if (!currentDate.equals(lastDate)) {
// sequence = 0;
// lastDate = currentDate;
// }
// // 生成8位日期
// String datePart = currentDate.format(DATE_FORMATTER);
// // 生成5位序列号
// String sequencePart = String.format("%05d", sequence++);
// // 拼接成完整的批次号
// return checkBatcnNumber(sequencePart,datePart,partnerIdentification);
// }
public
String
checkBatcnNumber
()
throws
Exception
{
LocalDate
currentDate
=
LocalDate
.
now
();
// 如果是新的一天,重置序列号
String
datePart
=
currentDate
.
format
(
DATE_FORMATTER
);
if
(!
currentDate
.
equals
(
lastDate
))
{
sequence
=
0
;
sequence
.
set
(
0
);
// 重置序列号从0开始
lastDate
=
currentDate
;
}
// 生成8位日期
String
datePart
=
currentDate
.
format
(
DATE_FORMATTER
);
// 生成5位序列号
String
sequencePart
=
String
.
format
(
"%05d"
,
sequence
++);
// 拼接成完整的批次号
return
datePart
+
partnerIdentification
+
sequencePart
;
// 定义序列号的最大值,这里设为五位数的最大值99999
int
maxSequence
=
99999
;
// 设置最大尝试次数,防止无限循环
int
maxAttempts
=
10000
;
// 构建批次号前缀,由日期部分和合作伙伴识别码组成
String
batchNoPrefix
=
datePart
+
partnerIdentification
;
// 使用 AtomicInteger 来管理序列号,保证线程安全
AtomicInteger
attemptCounter
=
new
AtomicInteger
(
0
);
// 尝试生成唯一批次号,最多进行 maxAttempts 次尝试
while
(
attemptCounter
.
incrementAndGet
()
<=
maxAttempts
)
{
// 获取当前序列号,并原子性地递增计数器
int
currentSequence
=
sequence
.
getAndIncrement
();
// 如果序列号超过了设定的最大值,则重置计数器
if
(
currentSequence
>
maxSequence
)
{
sequence
.
set
(
0
);
// 重置序列号从0开始
currentSequence
=
sequence
.
getAndIncrement
();
// 再次获取新的序列号
}
// 格式化序列号为固定长度的字符串,不足的部分用零填充
String
sequencePart
=
String
.
format
(
"%05d"
,
currentSequence
);
// 组合完整的批次号
String
batchNo
=
batchNoPrefix
+
sequencePart
;
// 查询数据库以确认该批次号是否已经被占用
LambdaQueryWrapper
<
IcbcWithhold
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IcbcWithhold:
:
getBatchNo
,
batchNo
);
List
<
IcbcWithhold
>
existingRecord
=
this
.
getBaseMapper
().
selectList
(
wrapper
);
// 如果没有找到重复记录,则说明此批次号可用,直接返回
if
(
CollectionUtil
.
isEmpty
(
existingRecord
))
{
return
batchNo
;
// 当找到唯一批次号时返回
}
}
// 如果经过多次尝试后仍然未能生成唯一的批次号,则抛出异常
throw
new
Exception
(
" 如果经过多次尝试后仍然未能生成唯一的批次号"
);
}
public
static
void
writeStringToFile
(
String
content
,
String
filename
)
throws
IOException
{
createDirectoryIfNotExists
(
filename
);
try
(
BufferedWriter
writer
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
filename
),
"GBK"
)))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment