Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
64d956f9
提交
64d956f9
authored
7月 05, 2022
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(自查模块): 优化了发起自查业务时间
优化了发起自查业务时间
上级
7a3ced7a
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
84 行增加
和
8 行删除
+84
-8
SplitListUtils.java
...src/main/java/com/tykj/dev/misc/utils/SplitListUtils.java
+54
-0
SelfCheckController.java
.../dev/device/selfcheck/controller/SelfCheckController.java
+30
-8
没有找到文件。
dev-misc/src/main/java/com/tykj/dev/misc/utils/SplitListUtils.java
0 → 100644
浏览文件 @
64d956f9
package
com
.
tykj
.
dev
.
misc
.
utils
;
import
com.beust.jcommander.internal.Lists
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
/**
* @author zsp
* @version 1.0
* @date 2022/7/5 9:23
*/
public
class
SplitListUtils
{
/**
* 拆分集合
*
* @param <T> 泛型对象
* @param resList 需要拆分的集合
* @param subListLength 每个子集合的元素个数
* @return 返回拆分后的各个集合组成的列表
**/
public
static
<
T
>
List
<
List
<
T
>>
split
(
List
<
T
>
resList
,
int
subListLength
)
{
if
(
CollectionUtils
.
isEmpty
(
resList
)
||
subListLength
<=
0
)
{
return
Lists
.
newArrayList
();
}
List
<
List
<
T
>>
ret
=
Lists
.
newArrayList
();
int
size
=
resList
.
size
();
if
(
size
<=
subListLength
)
{
// 数据量不足 subListLength 指定的大小
ret
.
add
(
resList
);
}
else
{
int
pre
=
size
/
subListLength
;
int
last
=
size
%
subListLength
;
// 前面pre个集合,每个大小都是 subListLength 个元素
for
(
int
i
=
0
;
i
<
pre
;
i
++)
{
List
<
T
>
itemList
=
Lists
.
newArrayList
();
for
(
int
j
=
0
;
j
<
subListLength
;
j
++)
{
itemList
.
add
(
resList
.
get
(
i
*
subListLength
+
j
));
}
ret
.
add
(
itemList
);
}
// last的进行处理
if
(
last
>
0
)
{
List
<
T
>
itemList
=
Lists
.
newArrayList
();
for
(
int
i
=
0
;
i
<
last
;
i
++)
{
itemList
.
add
(
resList
.
get
(
pre
*
subListLength
+
i
));
}
ret
.
add
(
itemList
);
}
}
return
ret
;
}
}
dev-selfcheck/src/main/java/com/tykj/dev/device/selfcheck/controller/SelfCheckController.java
浏览文件 @
64d956f9
...
@@ -41,10 +41,7 @@ import com.tykj.dev.misc.base.BusinessEnum;
...
@@ -41,10 +41,7 @@ import com.tykj.dev.misc.base.BusinessEnum;
import
com.tykj.dev.misc.base.StatusEnum
;
import
com.tykj.dev.misc.base.StatusEnum
;
import
com.tykj.dev.misc.exception.ApiException
;
import
com.tykj.dev.misc.exception.ApiException
;
import
com.tykj.dev.misc.qrcode.vo.TaskData
;
import
com.tykj.dev.misc.qrcode.vo.TaskData
;
import
com.tykj.dev.misc.utils.JacksonUtil
;
import
com.tykj.dev.misc.utils.*
;
import
com.tykj.dev.misc.utils.ResultUtil
;
import
com.tykj.dev.misc.utils.StringSplitUtil
;
import
com.tykj.dev.misc.utils.TaskDisposeUtil
;
import
com.tykj.dev.socket.MyWebSocket
;
import
com.tykj.dev.socket.MyWebSocket
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -57,6 +54,7 @@ import org.springframework.http.ResponseEntity;
...
@@ -57,6 +54,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.jdbc.core.BatchPreparedStatementSetter
;
import
org.springframework.jdbc.core.BatchPreparedStatementSetter
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.StopWatch
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -65,6 +63,7 @@ import java.sql.PreparedStatement;
...
@@ -65,6 +63,7 @@ import java.sql.PreparedStatement;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -339,7 +338,7 @@ public class SelfCheckController {
...
@@ -339,7 +338,7 @@ public class SelfCheckController {
@ApiOperation
(
value
=
"发起自查业务"
,
notes
=
"可以通过这个接口发起自查业务"
)
@ApiOperation
(
value
=
"发起自查业务"
,
notes
=
"可以通过这个接口发起自查业务"
)
@PostMapping
(
value
=
"/addBill"
)
@PostMapping
(
value
=
"/addBill"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResponseEntity
addSelfExaminationBill
(
@RequestBody
@Validated
SelfCheckSaveVo
selfCheckSaveVo
)
{
public
ResponseEntity
addSelfExaminationBill
(
@RequestBody
@Validated
SelfCheckSaveVo
selfCheckSaveVo
)
throws
InterruptedException
{
//当前登录的用户ID
//当前登录的用户ID
Integer
currentUserId
=
userUtils
.
getCurrentUserId
();
Integer
currentUserId
=
userUtils
.
getCurrentUserId
();
//当前登录的单位ID
//当前登录的单位ID
...
@@ -411,7 +410,9 @@ public class SelfCheckController {
...
@@ -411,7 +410,9 @@ public class SelfCheckController {
// executor.execute(()->{
// executor.execute(()->{
// historyDeviceBillService.batchSave(historyDeviceBillList);
// historyDeviceBillService.batchSave(historyDeviceBillList);
// });
// });
historyDeviceBillService
.
batchSave
(
historyDeviceBillList
);
//批量保存
batchSave
(
historyDeviceBillList
);
// historyDeviceBillService.batchSave(historyDeviceBillList);
}
}
}
else
{
}
else
{
// 是0 和1
// 是0 和1
...
@@ -433,7 +434,9 @@ public class SelfCheckController {
...
@@ -433,7 +434,9 @@ public class SelfCheckController {
historyDeviceBillList
.
add
(
historyDeviceBill
);
historyDeviceBillList
.
add
(
historyDeviceBill
);
});
});
//保存
//保存
historyDeviceBillService
.
batchSave
(
historyDeviceBillList
);
batchSave
(
historyDeviceBillList
);
// historyDeviceBillService.batchSave(historyDeviceBillList);
// executor.execute(()->{
// executor.execute(()->{
// historyDeviceBillService.batchSave(historyDeviceBillList);
// historyDeviceBillService.batchSave(historyDeviceBillList);
// });
// });
...
@@ -456,7 +459,9 @@ public class SelfCheckController {
...
@@ -456,7 +459,9 @@ public class SelfCheckController {
historyDeviceBillList
.
add
(
historyDeviceBill
);
historyDeviceBillList
.
add
(
historyDeviceBill
);
});
});
//保存
//保存
historyDeviceBillService
.
batchSave
(
historyDeviceBillList
);
batchSave
(
historyDeviceBillList
);
// historyDeviceBillService.batchSave(historyDeviceBillList);
// executor.execute(()->{
// executor.execute(()->{
// historyDeviceBillService.batchSave(historyDeviceBillList);
// historyDeviceBillService.batchSave(historyDeviceBillList);
// });
// });
...
@@ -567,6 +572,23 @@ public class SelfCheckController {
...
@@ -567,6 +572,23 @@ public class SelfCheckController {
return
ResultUtil
.
success
(
selfExaminationBillEntity1
);
return
ResultUtil
.
success
(
selfExaminationBillEntity1
);
}
}
private
void
batchSave
(
List
<
HistoryDeviceBill
>
historyDeviceBillList
)
throws
InterruptedException
{
StopWatch
stopWatch
=
new
StopWatch
(
"保存历史存单时间"
);
stopWatch
.
start
();
List
<
List
<
HistoryDeviceBill
>>
split
=
SplitListUtils
.
split
(
historyDeviceBillList
,
200
);
CountDownLatch
countDownLatch
=
new
CountDownLatch
(
split
.
size
());
for
(
int
i
=
0
;
i
<
split
.
size
();
i
++)
{
int
finalI
=
i
;
executor
.
execute
(()->{
historyDeviceBillService
.
batchSave
(
split
.
get
(
finalI
));
countDownLatch
.
countDown
();
});
}
countDownLatch
.
await
();
stopWatch
.
stop
();
log
.
info
(
"保存历史存单时间:{}"
,
stopWatch
.
getTotalTimeMillis
()+
"ms"
);
}
@ApiOperation
(
value
=
"自查审核"
,
notes
=
"可以通过这个接口自查审核"
)
@ApiOperation
(
value
=
"自查审核"
,
notes
=
"可以通过这个接口自查审核"
)
@PostMapping
(
value
=
"/selfExaminationConfirm"
)
@PostMapping
(
value
=
"/selfExaminationConfirm"
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论