Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
klck
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
位宇华
klck
Commits
60620422
Commit
60620422
authored
Jul 02, 2024
by
刘_震
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
电力汇总-代码重构与优化
parent
f990a2e2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
15 deletions
+42
-15
ruoyi-wages/src/main/java/com/ruoyi/system/controller/PowerWagesController.java
...ava/com/ruoyi/system/controller/PowerWagesController.java
+2
-3
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/PowerWagesComMapper.java
...ain/java/com/ruoyi/system/mapper/PowerWagesComMapper.java
+2
-0
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/PowerWagesDeMapper.java
...main/java/com/ruoyi/system/mapper/PowerWagesDeMapper.java
+1
-1
ruoyi-wages/src/main/java/com/ruoyi/system/service/PowerWagesService.java
...main/java/com/ruoyi/system/service/PowerWagesService.java
+1
-1
ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/PowerWagesServiceImpl.java
.../com/ruoyi/system/service/impl/PowerWagesServiceImpl.java
+30
-8
ruoyi-wages/src/main/resources/mapper/system/PowerWagesComMapper.xml
.../src/main/resources/mapper/system/PowerWagesComMapper.xml
+4
-0
ruoyi-wages/src/main/resources/mapper/system/PowerWagesDeMapper.xml
...s/src/main/resources/mapper/system/PowerWagesDeMapper.xml
+2
-2
No files found.
ruoyi-wages/src/main/java/com/ruoyi/system/controller/PowerWagesController.java
View file @
60620422
...
...
@@ -52,9 +52,8 @@ public class PowerWagesController {
@PostMapping
(
"/cExcel"
)
public
AjaxResult
readCExcel
(
@RequestParam
(
"file"
)
MultipartFile
file
,
String
date
,
String
mineId
,
String
type
)
{
Boolean
analyzed
=
powerWagesService
.
readCExcel
(
file
,
date
,
mineId
,
type
);
String
mineId
)
{
Boolean
analyzed
=
powerWagesService
.
readCExcel
(
file
,
date
,
mineId
);
if
(!
analyzed
)
{
return
AjaxResult
.
error
(
"解析失败"
);
}
else
{
...
...
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/PowerWagesComMapper.java
View file @
60620422
...
...
@@ -26,4 +26,6 @@ public interface PowerWagesComMapper {
PowerWagesComparation
selectByCId
(
Integer
comparisonId
);
List
<
PowerWagesComparation
>
selectByMineIdAndDate
(
@Param
(
"mineId"
)
String
mineId
,
@Param
(
"date"
)
String
date
);
void
deleteByDateAndMineIdAndType
(
@Param
(
"mineId"
)
String
mineId
,
@Param
(
"date"
)
String
date
,
@Param
(
"type"
)
String
type
);
}
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/PowerWagesDeMapper.java
View file @
60620422
...
...
@@ -22,5 +22,5 @@ public interface PowerWagesDeMapper {
List
<
PowerWagesDetails
>
selectByCId
(
int
comparisonId
);
void
deleteByDateAndMineId
(
@Param
(
"mineId"
)
String
mineId
,
@Param
(
"date"
)
String
date
);
void
deleteByDateAndMineId
AndComparisonId
(
@Param
(
"mineId"
)
String
mineId
,
@Param
(
"date"
)
String
date
,
@Param
(
"comparisonId"
)
Integer
comparisonId
);
}
ruoyi-wages/src/main/java/com/ruoyi/system/service/PowerWagesService.java
View file @
60620422
...
...
@@ -18,7 +18,7 @@ public interface PowerWagesService {
Boolean
readDExcel
(
MultipartFile
file
,
String
date
,
String
mineId
);
Boolean
readCExcel
(
MultipartFile
file
,
String
date
,
String
mineId
,
String
type
);
Boolean
readCExcel
(
MultipartFile
file
,
String
date
,
String
mineId
);
void
add
(
PowerDAO
dao
);
...
...
ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/PowerWagesServiceImpl.java
View file @
60620422
...
...
@@ -45,7 +45,7 @@ public class PowerWagesServiceImpl implements PowerWagesService {
@Override
public
Boolean
readDExcel
(
MultipartFile
file
,
String
date
,
String
mineId
)
{
try
{
String
type
=
"1"
;
//定义需要解析的sheet名
List
<
String
>
sheetList
=
Arrays
.
asList
(
"电量数据专业化公司"
,
"外界电量数据"
);
// 定义需要过滤的关键词列表
...
...
@@ -53,11 +53,21 @@ public class PowerWagesServiceImpl implements PowerWagesService {
List
<
String
>
filterList2
=
Arrays
.
asList
(
"20000"
,
"30000"
,
"40000"
);
// 获取上传文件的输入流
for
(
int
i
=
0
;
i
<
sheetList
.
size
();
i
++)
{
type
=
type
+
i
;
String
type
=
""
;
switch
(
sheetList
.
get
(
i
)){
case
"电量数据专业化公司"
:
type
=
"1"
;
break
;
case
"外界电量数据"
:
type
=
"2"
;
break
;
}
PowerWagesComparation
comparation
=
ceMapper
.
select
(
type
,
date
,
mineId
);
if
(
comparation
!=
null
)
{
//获取对应表的id
Integer
comparisonId
=
comparation
.
getComparisonId
();
deMapper
.
deleteByDateAndMineIdAndComparisonId
(
mineId
,
date
,
comparisonId
);
InputStream
inputStream
=
file
.
getInputStream
();
System
.
err
.
println
(
sheetList
.
get
(
i
));
List
<
PowerWagesDetails
>
PowerList
=
EasyExcel
...
...
@@ -86,12 +96,23 @@ public class PowerWagesServiceImpl implements PowerWagesService {
}
@Override
public
Boolean
readCExcel
(
MultipartFile
file
,
String
date
,
String
mineId
,
String
type
)
{
public
Boolean
readCExcel
(
MultipartFile
file
,
String
date
,
String
mineId
)
{
try
{
//定义需要解析的sheet名
List
<
String
>
sheetList
=
Arrays
.
asList
(
"电量数据专业化公司"
,
"外界电量数据"
);
// 获取上传文件的输入流
for
(
int
i
=
0
;
i
<
sheetList
.
size
();
i
++)
{
String
type
=
""
;
switch
(
sheetList
.
get
(
i
)){
case
"电量数据专业化公司"
:
type
=
"1"
;
break
;
case
"外界电量数据"
:
type
=
"2"
;
break
;
}
ceMapper
.
deleteByDateAndMineIdAndType
(
mineId
,
date
,
type
);
InputStream
inputStream
=
file
.
getInputStream
();
System
.
err
.
println
(
sheetList
.
get
(
i
));
List
<
PowerWagesComparation
>
powerList
=
EasyExcel
...
...
@@ -102,7 +123,7 @@ public class PowerWagesServiceImpl implements PowerWagesService {
.
doReadSync
();
inputStream
.
close
();
PowerWagesComparation
comparation
=
powerList
.
get
(
0
);
type
=
type
+
i
;
comparation
.
setType
(
type
);
comparation
.
setMineId
(
mineId
);
comparation
.
setImportTime
(
date
);
...
...
@@ -120,7 +141,6 @@ public class PowerWagesServiceImpl implements PowerWagesService {
String
type
=
dao
.
getType
();
String
importTime
=
dao
.
getImportTime
();
String
mineId
=
dao
.
getMineId
();
PowerWagesDetails
powerWagesDetails
=
new
PowerWagesDetails
();
List
<
Power
>
powerDetails
=
dao
.
getPowerDetails
();
//如何这个集合的长度>1,说明导入的是详细表
if
(
powerDetails
.
size
()
>
1
)
{
...
...
@@ -128,13 +148,15 @@ public class PowerWagesServiceImpl implements PowerWagesService {
if
(
comparation
!=
null
)
{
//获取对应表的id
Integer
comparisonId
=
comparation
.
getComparisonId
();
deMapper
.
deleteByDateAndMineIdAndComparisonId
(
mineId
,
importTime
,
comparisonId
);
deMapper
.
add
(
powerDetails
,
comparisonId
,
importTime
,
mineId
);
}
}
else
{
PowerWagesComparation
comparation
=
ceMapper
.
select
(
type
,
importTime
,
mineId
);
if
(
comparation
==
null
)
{
ceMapper
.
add
(
powerDetails
,
mineId
,
importTime
,
type
);
}
Integer
comparisonId
=
comparation
.
getComparisonId
();
deMapper
.
deleteByDateAndMineIdAndComparisonId
(
mineId
,
importTime
,
comparisonId
);
ceMapper
.
deleteByDateAndMineIdAndType
(
mineId
,
importTime
,
type
);
ceMapper
.
add
(
powerDetails
,
mineId
,
importTime
,
type
);
}
}
...
...
ruoyi-wages/src/main/resources/mapper/system/PowerWagesComMapper.xml
View file @
60620422
...
...
@@ -335,6 +335,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</foreach>
</insert>
<delete
id=
"deleteByDateAndMineIdAndType"
>
delete from power_wages_comparation
where mine_id = #{mineId} and import_time = #{date} and type = #{type}
</delete>
<select
id=
"select"
resultType=
"com.ruoyi.system.model.wages.dao.PowerWagesComparation"
>
select comparisonId, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19,
...
...
ruoyi-wages/src/main/resources/mapper/system/PowerWagesDeMapper.xml
View file @
60620422
...
...
@@ -475,9 +475,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{mineId},#{importTime},#{comparisonId})
</foreach>
</insert>
<delete
id=
"deleteByDateAndMineId"
>
<delete
id=
"deleteByDateAndMineId
AndComparisonId
"
>
delete from power_wages_details
where mine_id = #{mineId} and import_time = #{date}
where mine_id = #{mineId} and import_time = #{date}
and comparison_id = #{comparisonId}
</delete>
<select
id=
"selectByMineIdAndDate"
resultMap=
"PowerWagesDetailsResult"
>
select id, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
...
...
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