Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
tasktime
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
任建彩
tasktime
Commits
f8e8451a
提交
f8e8451a
authored
9月 10, 2021
作者:
任建宇
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
11
上级
a38c85b5
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
34 行增加
和
6 行删除
+34
-6
ImportExcelUtil.java
olive-console/src/main/java/com/utils/ImportExcelUtil.java
+24
-4
TaskDao.java
...nsole/src/main/java/com/zrqx/olive/ttask/dao/TaskDao.java
+1
-1
TaskServiceImpl.java
...ava/com/zrqx/olive/ttask/service/imp/TaskServiceImpl.java
+9
-1
没有找到文件。
olive-console/src/main/java/com/utils/ImportExcelUtil.java
浏览文件 @
f8e8451a
...
...
@@ -544,7 +544,7 @@ public class ImportExcelUtil {
* @throws BaseException
* 如果文件不是Excel文件、目标对象不包含解析所需的参数设置或解析过程中发生错误,抛出该异常
*/
public
static
<
T
>
List
<
T
>
importExcel
(
InputStream
excel
,
Class
<
T
>
targetClass
,
String
fileName
)
public
static
<
T
>
List
<
T
>
importExcel
(
InputStream
excel
,
Class
<
T
>
targetClass
,
String
fileName
,
Map
<
String
,
String
>
columnMap
)
throws
BaseException
{
if
(!
StringUtils
.
endsWithIgnoreCase
(
fileName
,
ExcelParseMode
.
XLS
)
&&
!
StringUtils
.
endsWithIgnoreCase
(
fileName
,
ExcelParseMode
.
XLSX
))
{
...
...
@@ -628,10 +628,13 @@ public class ImportExcelUtil {
// 如果最大行大于实际行数或小于0(小于0表示使用实际行数),则最大行使用实际行数
// maxRow = sheet.getLastRowNum() + 1 < maxRow || maxRow < 0 ?
// sheet.getLastRowNum() + 1 : maxRow;
int
q
=
0
;
// 遍历行
// for(int i = minRow - 1; i < maxRow; i++){
//判断所有列的数据值
StringBuffer
buffer
=
new
StringBuffer
();
for
(
int
i
=
1
;
i
<
sheet
.
getLastRowNum
()
+
1
;
i
++)
{
System
.
out
.
println
(
sheet
.
getLastRowNum
());
// 读取行
Row
row
=
sheet
.
getRow
(
i
);
...
...
@@ -677,18 +680,33 @@ public class ImportExcelUtil {
for
(
int
j
=
0
;
j
<
colNum
;
j
++)
{
// 获取单元格
Cell
cell
=
row
.
getCell
(
j
);
if
(
cell
==
null
)
{
continue
;
}
// 读取单元格数据并设置到新对象的对应属性中
// if(fieldMap.containsKey(cell.getColumnIndex())){
String
key
=
sheet
.
getRow
(
0
).
getCell
(
cell
.
getColumnIndex
()).
toString
().
trim
();
if
(
fieldMap
.
get
(
key
)
!=
null
)
{
System
.
out
.
println
(
i
);
q
=
i
;
System
.
out
.
println
(++
q
);
System
.
out
.
println
(
key
);
Field
f
=
fieldMap
.
get
(
key
);
System
.
out
.
println
(
f
.
getName
());
System
.
out
.
println
(
cell
.
getStringCellValue
());
f
.
setAccessible
(
true
);
try
{
//不能为空值的map
if
(
columnMap
.
get
(
f
.
getName
())
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
cell
.
getStringCellValue
()))
{
buffer
.
append
(++
q
+
f
.
getName
()
+
"不能为空 \n"
);
}
}
if
(
f
.
getType
()
==
String
.
class
)
{
cell
.
setCellType
(
CellType
.
STRING
);
f
.
set
(
obj
,
cell
.
getStringCellValue
());
...
...
@@ -720,7 +738,9 @@ public class ImportExcelUtil {
}*/
}
}
if
(
StringUtils
.
isNotBlank
(
buffer
))
{
throw
new
BaseException
(
3
,
buffer
.
toString
()
);
}
return
objectList
;
}
...
...
olive-console/src/main/java/com/zrqx/olive/ttask/dao/TaskDao.java
浏览文件 @
f8e8451a
...
...
@@ -65,7 +65,7 @@ public interface TaskDao extends BaseMapper<Task> {
+
" AND task_status != 0 "
+
"</if>"
+
"<if test = 'request.taskStatus == 5'> "
+
" AND complete
Time()
> #{request.endTime} "
+
" AND complete
_Time
> #{request.endTime} "
+
"</if>"
+
"<if test = 'request.taskStatus == 1'> "
+
" AND task_status = #{request.taskStatus} "
...
...
olive-console/src/main/java/com/zrqx/olive/ttask/service/imp/TaskServiceImpl.java
浏览文件 @
f8e8451a
...
...
@@ -47,10 +47,13 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
static
com
.
constants
.
Constants
.
ARTICLE_BANNER_LIMIT
;
...
...
@@ -110,8 +113,13 @@ public class TaskServiceImpl extends ServiceImpl<TaskDao, Task> implements TaskS
@Override
public
CommonResult
<
Object
>
imporTask
(
MultipartFile
file
,
TaskForm
taskRequest
)
throws
BaseException
,
IOException
{
Map
<
String
,
String
>
columnMap
=
new
HashMap
<
String
,
String
>();
columnMap
.
put
(
"moduleName"
,
"moduleName"
);
columnMap
.
put
(
"taskName"
,
"taskName"
);
columnMap
.
put
(
"hours"
,
"hours"
);
List
<
ExcelTaskVo
>
list
=
ImportExcelUtil
.
importExcel
(
file
.
getInputStream
(),
ExcelTaskVo
.
class
,
file
.
getOriginalFilename
());
file
.
getOriginalFilename
()
,
columnMap
);
for
(
ExcelTaskVo
excelTaskVo
:
list
)
{
// 处理项目工时
QueryWrapper
<
Team
>
qw1
=
new
QueryWrapper
<>();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论