Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gf_back
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
tianchao
gf_back
Commits
d70be0a6
Commit
d70be0a6
authored
Jun 27, 2024
by
ZWT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
都删了
parent
00a47d37
Changes
18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
0 additions
and
1834 deletions
+0
-1834
C00-common/pps-common/src/main/java/pps/core/common/cache/TaskLockCache.java
...on/src/main/java/pps/core/common/cache/TaskLockCache.java
+0
-89
C00-common/pps-common/src/main/java/pps/core/common/cache/ThirdPartyConfigCache.java
...ain/java/pps/core/common/cache/ThirdPartyConfigCache.java
+0
-71
C00-common/pps-common/src/main/java/pps/core/common/constant/BusinessConstant.java
.../main/java/pps/core/common/constant/BusinessConstant.java
+0
-237
C00-common/pps-common/src/main/java/pps/core/common/excel/TimeRangeImpl.java
...on/src/main/java/pps/core/common/excel/TimeRangeImpl.java
+0
-30
C00-common/pps-common/src/main/java/pps/core/common/excel/config/CascadeWriteHandler.java
...ava/pps/core/common/excel/config/CascadeWriteHandler.java
+0
-145
C00-common/pps-common/src/main/java/pps/core/common/excel/config/ExcelDynamicSelect.java
...java/pps/core/common/excel/config/ExcelDynamicSelect.java
+0
-16
C00-common/pps-common/src/main/java/pps/core/common/excel/config/ExcelSelected.java
...main/java/pps/core/common/excel/config/ExcelSelected.java
+0
-35
C00-common/pps-common/src/main/java/pps/core/common/excel/config/ExcelSelectedResolve.java
...va/pps/core/common/excel/config/ExcelSelectedResolve.java
+0
-56
C00-common/pps-common/src/main/java/pps/core/common/excel/config/SelectedSheetWriteHandler.java
...s/core/common/excel/config/SelectedSheetWriteHandler.java
+0
-104
C00-common/pps-common/src/main/java/pps/core/common/excel/listener/ExcelListener.java
...in/java/pps/core/common/excel/listener/ExcelListener.java
+0
-85
C00-common/pps-common/src/main/java/pps/core/common/excel/util/EasyExcelUtil.java
...c/main/java/pps/core/common/excel/util/EasyExcelUtil.java
+0
-346
C00-common/pps-common/src/main/java/pps/core/common/excel/util/ExcelStyleTool.java
.../main/java/pps/core/common/excel/util/ExcelStyleTool.java
+0
-144
C00-common/pps-common/src/main/java/pps/core/common/excel/util/ValidationUtil.java
.../main/java/pps/core/common/excel/util/ValidationUtil.java
+0
-57
C00-common/pps-common/src/main/java/pps/core/common/utils/BaseUtils.java
...common/src/main/java/pps/core/common/utils/BaseUtils.java
+0
-246
C00-common/pps-common/src/main/java/pps/core/common/utils/BigDecimalUtil.java
...n/src/main/java/pps/core/common/utils/BigDecimalUtil.java
+0
-16
C00-common/pps-common/src/main/java/pps/core/common/utils/CollectorsUtil.java
...n/src/main/java/pps/core/common/utils/CollectorsUtil.java
+0
-141
C02-system/pps-cloud-system/src/main/java/pps/cloud/system/service/SysOrganizationCloudService.java
...pps/cloud/system/service/SysOrganizationCloudService.java
+0
-3
C02-system/pps-core-system/src/main/java/pps/core/system/service/SysOrganizationCloudServiceImpl.java
.../core/system/service/SysOrganizationCloudServiceImpl.java
+0
-13
No files found.
C00-common/pps-common/src/main/java/pps/core/common/cache/TaskLockCache.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.cache
;
import
lombok.Data
;
import
xstartup.base.XContext
;
import
xstartup.cache.XCacheLife
;
import
xstartup.cache.XCacheObject
;
import
xstartup.cache.XSingleCache
;
/**
* 定时任务Redis锁
*
* @author ZWT
* @date 2023/12/21 14:36
*/
@Data
public
class
TaskLockCache
implements
XCacheObject
,
XCacheLife
{
/**
* Redis Key
*/
private
String
redisKey
;
/**
* Redis Value
*/
private
String
redisValue
;
/**
* 检查缓存是否存在指定的code
*
* @param context 上下文
* @param redisKey redis键
* @return {@link TaskLockCache}
*/
public
static
TaskLockCache
exist
(
XContext
context
,
String
redisKey
)
{
return
XSingleCache
.
get
(
Tool
.
class
).
find
(
context
,
redisKey
,
TaskLockCache
.
class
);
}
/**
* 删去
*
* @param context 上下文
* @param redisKey redis键
*/
public
static
void
delete
(
XContext
context
,
String
redisKey
)
{
XSingleCache
.
get
(
Tool
.
class
).
delete
(
context
,
redisKey
,
TaskLockCache
.
class
);
}
/**
* 设置缓存
*
* @param context 上下文
* @param cache 隐藏物
*/
public
static
void
set
(
XContext
context
,
TaskLockCache
cache
)
{
XSingleCache
.
get
(
Tool
.
class
).
set
(
context
,
cache
);
}
/**
* 获取持续时间
*
* @return {@link Integer}
*/
@Override
public
Integer
getDuration
()
{
return
600
;
}
/**
* 获取缓存密钥
*
* @return {@link String}
*/
@Override
public
String
getCacheKey
()
{
return
this
.
redisKey
;
}
/**
* 工具
*
* @author ZWT
* @date 2023/12/21
*/
static
class
Tool
extends
XSingleCache
<
TaskLockCache
>
{
@Override
protected
TaskLockCache
restore
(
XContext
context
,
String
cacheKey
)
{
return
null
;
}
}
}
C00-common/pps-common/src/main/java/pps/core/common/cache/ThirdPartyConfigCache.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.cache
;
import
lombok.Data
;
import
xstartup.base.XContext
;
import
xstartup.cache.XCacheLife
;
import
xstartup.cache.XCacheObject
;
import
xstartup.cache.XSingleCache
;
import
java.util.Date
;
/**
* 第三方Token查询缓存
*
* @author ZWT
* @date 2023/12/12
*/
@Data
public
class
ThirdPartyConfigCache
implements
XCacheObject
,
XCacheLife
{
private
String
codeKey
;
private
String
code
;
private
Integer
validity
;
private
Date
currentDate
;
/**
* 检查缓存是否存在指定的code
*
* @param context 上下文
* @param code 密码
* @return {@link ThirdPartyConfigCache}
*/
public
static
ThirdPartyConfigCache
exist
(
XContext
context
,
String
code
)
{
return
XSingleCache
.
get
(
Tool
.
class
).
find
(
context
,
code
,
ThirdPartyConfigCache
.
class
);
}
/**
* 删去
*
* @param context 上下文
* @param loginName 登录名
*/
public
static
void
delete
(
XContext
context
,
String
loginName
)
{
XSingleCache
.
get
(
Tool
.
class
).
delete
(
context
,
loginName
,
ThirdPartyConfigCache
.
class
);
}
/**
* 设置缓存
*
* @param context 上下文
* @param cache 隐藏物
*/
public
static
void
set
(
XContext
context
,
ThirdPartyConfigCache
cache
)
{
XSingleCache
.
get
(
Tool
.
class
).
set
(
context
,
cache
);
}
@Override
public
Integer
getDuration
()
{
return
validity
*
60
;
}
@Override
public
String
getCacheKey
()
{
return
this
.
codeKey
;
}
static
class
Tool
extends
XSingleCache
<
ThirdPartyConfigCache
>
{
@Override
protected
ThirdPartyConfigCache
restore
(
XContext
context
,
String
cacheKey
)
{
return
null
;
}
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/constant/BusinessConstant.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.constant
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
java.math.BigDecimal
;
/**
* 业务操作常量
*
* @author ZWT
* @date 2023/09/05 14:40
*/
public
class
BusinessConstant
{
/**
* 初始父级组织机构ID
*/
public
static
final
String
PARENT_OU_ID
=
"00000000-0000-0000-0000-000000000000"
;
/**
* 线路标志id
*/
public
static
final
String
LINE_FLAG_ID
=
"000"
;
/**
* 光伏电站
*/
public
static
final
String
PHOTOVOLTAIC_POWER_STATION
=
"photovoltaic_power_station"
;
/**
* 井口
*/
public
static
final
String
WELLHEAD
=
"wellhead"
;
/**
* 光伏发电
*/
public
static
final
String
PHOTOVOLTAIC
=
"gf"
;
/**
* 储能发电
*/
public
static
final
String
STORED_ENERGY
=
"cn"
;
/**
* 柴油发电
*/
public
static
final
String
DIESEL_POWER
=
"cf"
;
/**
* 间抽井
*/
public
static
final
String
INTERVAL_PUMPING_WELL
=
"INTERVAL"
;
/**
* 连抽井
*/
public
static
final
String
CONTINUOUS_PUMPING_WELL
=
"CONTINUOUS"
;
/**
* 字符串一
*/
public
static
final
String
STRING_ONE
=
"1"
;
/**
* 已优化
*/
public
static
final
String
OPTIMIZED_C
=
"已优化"
;
/**
* 未优化
*/
public
static
final
String
NO_OPTIMIZATION_C
=
"未优化"
;
/*------------------------------数字------------------------------*/
/**
* 1
*/
public
static
final
Integer
ONE
=
1
;
/**
* 0
*/
public
static
final
Integer
ZERO
=
0
;
/**
* 2
*/
public
static
final
Integer
TWO
=
2
;
/**
* 3
*/
public
static
final
Integer
THREE
=
3
;
/**
* 4
*/
public
static
final
Integer
FOUR
=
4
;
/**
* 10
*/
public
static
final
Integer
TEN
=
10
;
/**
* 0.25
*/
public
static
final
BigDecimal
BIG_DECIMAL_0_25
=
BigDecimal
.
valueOf
(
0.25
);
/**
* 0.35
*/
public
static
final
BigDecimal
BIG_DECIMAL_0_35
=
BigDecimal
.
valueOf
(
0.35
);
/**
* 6.67
*/
public
static
final
BigDecimal
BIG_DECIMAL_6_67
=
BigDecimal
.
valueOf
(
6.67
);
/**
* 60
*/
public
static
final
BigDecimal
BIG_DECIMAL_60
=
BigDecimal
.
valueOf
(
60
);
/**
* 100
*/
public
static
final
BigDecimal
BIG_DECIMAL_100
=
BigDecimal
.
valueOf
(
100
);
/**
* 10000
*/
public
static
final
BigDecimal
BIG_DECIMAL_10000
=
BigDecimal
.
valueOf
(
10000
);
/*------------------------------日期------------------------------*/
/**
* 日期格式化到天
*/
public
static
final
String
DATE_FORMAT_DAY
=
"yyyy-MM-dd"
;
/**
* 日期格式全部
*/
public
static
final
String
DATE_FORMAT_ALL
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* 日期格式到小时
*/
public
static
final
String
DATE_FORMAT_HOUR
=
"yyyy-MM-dd HH:00:00"
;
/**
* 日期格式化到天(年月日)
*/
public
static
final
String
DATE_FORMAT_DAY_C
=
"yyyy年MM月dd日"
;
/**
* 时间格式
*/
public
static
final
String
TIME_FORMAT
=
"HH:mm:ss"
;
/**
* 分钟格式
*/
public
static
final
String
MINUTES_FORMAT
=
"HH:mm"
;
/**
* 初始化秒
*/
public
static
final
String
INITIALIZATION_SECOND
=
":00"
;
/**
* 一天结束时间
*/
public
static
final
String
END_OF_DAY_TIME
=
"24:00"
;
/**
* 一天开始时间
*/
public
static
final
String
START_OF_DAY_TIME
=
"00:00"
;
/**
* 日期标志
*/
public
static
final
DateTime
DATE_FLAG
=
DateUtil
.
parse
(
"1970-01-02 00:00:00"
,
"yyyy-MM-dd HH:mm:ss"
);
/**
* 日期标志开始
*/
public
static
final
DateTime
DATE_FLAG_BEGIN
=
DateUtil
.
parse
(
"1970-01-01 00:00:00"
,
"yyyy-MM-dd HH:mm:ss"
);
/*------------------------------字典------------------------------*/
/**
* 线路类型
*/
public
static
final
String
LINE_TYPE
=
"line_type"
;
/**
* 电网类型
*/
public
static
final
String
GRID_TYPE
=
"grid_type"
;
/**
* 间开类型
*/
public
static
final
String
INTERVAL_TYPE
=
"interval_type"
;
/**
* 单位级别
*/
public
static
final
String
UNIT_LEVEL
=
"UNIT_LEVEL"
;
/**
* 运行类型
*/
public
static
final
String
RUN_TYPE
=
"run_type"
;
/**
* 时段类型
*/
public
static
final
String
TIME_FRAME
=
"time_frame"
;
/**
* 校准策略
*/
public
static
final
String
CALIBRATION_STRATEGY
=
"calibration_strategy"
;
/**
* 发电类型
*/
public
static
final
String
GENERATION_TYPE
=
"generation_type"
;
}
C00-common/pps-common/src/main/java/pps/core/common/excel/TimeRangeImpl.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateUtil
;
import
pps.core.common.constant.BusinessConstant
;
import
pps.core.common.excel.config.ExcelDynamicSelect
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 时段范围下拉
*
* @author ZWT
* @date 2024/05/13
*/
public
class
TimeRangeImpl
implements
ExcelDynamicSelect
{
@Override
public
String
[]
getSource
()
{
List
<
String
>
collect
=
DateUtil
.
rangeToList
(
DateUtil
.
beginOfDay
(
DateUtil
.
date
()),
DateUtil
.
endOfDay
(
DateUtil
.
date
()),
DateField
.
MINUTE
,
30
)
.
stream
()
.
map
(
d
->
d
.
toString
(
BusinessConstant
.
MINUTES_FORMAT
))
.
collect
(
Collectors
.
toList
());
collect
.
add
(
BusinessConstant
.
END_OF_DAY_TIME
);
return
collect
.
toArray
(
new
String
[
0
]);
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/config/CascadeWriteHandler.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.config
;
import
com.alibaba.excel.write.handler.SheetWriteHandler
;
import
com.alibaba.excel.write.metadata.holder.WriteSheetHolder
;
import
com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddressList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
/**
* 级联写入处理程序
*
* @author ZWT
* @date 2024/05/07
*/
public
class
CascadeWriteHandler
implements
SheetWriteHandler
{
/**
* 大类的字符串集合
*/
private
List
<
String
>
largeList
;
/**
* 大类和小类的对应关系的map集合
*/
private
Map
<
String
,
List
<
String
>>
siteMap
;
public
CascadeWriteHandler
(
List
<
String
>
largeList
,
Map
<
String
,
List
<
String
>>
siteMap
)
{
this
.
largeList
=
largeList
;
this
.
siteMap
=
siteMap
;
}
@Override
public
void
beforeSheetCreate
(
WriteWorkbookHolder
writeWorkbookHolder
,
WriteSheetHolder
writeSheetHolder
)
{
}
@Override
public
void
afterSheetCreate
(
WriteWorkbookHolder
writeWorkbookHolder
,
WriteSheetHolder
writeSheetHolder
)
{
//获取工作簿
Sheet
sheet
=
writeSheetHolder
.
getSheet
();
Workbook
book
=
writeWorkbookHolder
.
getWorkbook
();
//创建一个专门用来存放地区信息的隐藏sheet页
//因此不能在现实页之前创建,否则无法隐藏。
Sheet
hideSheet
=
book
.
createSheet
(
"site"
);
book
.
setSheetHidden
(
book
.
getSheetIndex
(
hideSheet
),
true
);
// 将具体的数据写入到每一行中,行开头为父级区域,后面是子区域。
int
rowId
=
0
;
Row
provinceRow
=
hideSheet
.
createRow
(
rowId
++);
provinceRow
.
createCell
(
0
).
setCellValue
(
"大类列表"
);
for
(
int
i
=
0
;
i
<
largeList
.
size
();
i
++)
{
Cell
proviCell
=
provinceRow
.
createCell
(
i
+
1
);
proviCell
.
setCellValue
(
largeList
.
get
(
i
));
}
Iterator
<
String
>
keyIterator
=
this
.
siteMap
.
keySet
().
iterator
();
while
(
keyIterator
.
hasNext
())
{
String
key
=
keyIterator
.
next
();
List
<
String
>
son
=
siteMap
.
get
(
key
);
Row
row
=
hideSheet
.
createRow
(
rowId
++);
row
.
createCell
(
0
).
setCellValue
(
key
);
for
(
int
i
=
0
;
i
<
son
.
size
();
i
++)
{
Cell
cell
=
row
.
createCell
(
i
+
1
);
cell
.
setCellValue
(
son
.
get
(
i
));
}
// 添加名称管理器
String
range
=
getRange
(
1
,
rowId
,
son
.
size
());
Name
name
=
book
.
createName
();
name
.
setNameName
(
key
);
String
formula
=
"site!"
+
range
;
name
.
setRefersToFormula
(
formula
);
}
///开始设置(大类小类)下拉框
DataValidationHelper
dvHelper
=
sheet
.
getDataValidationHelper
();
// 大类规则
DataValidationConstraint
expConstraint
=
dvHelper
.
createExplicitListConstraint
(
largeList
.
toArray
(
new
String
[]{}));
CellRangeAddressList
expRangeAddressList
=
new
CellRangeAddressList
(
1
,
999
,
0
,
0
);
setValidation
(
sheet
,
dvHelper
,
expConstraint
,
expRangeAddressList
,
"提示"
,
"你输入的值未在备选列表中,请下拉选择合适的值"
);
// 小类规则(各单元格按个设置)
// "INDIRECT($A$" + 2 + ")" 表示规则数据会从名称管理器中获取key与单元格 A2 值相同的数据,如果A2是浙江省,那么此处就是浙江省下面的市
// 为了让每个单元格的公式能动态适应,使用循环挨个给公式。
// 循环几次,就有几个单元格生效,次数要和上面的大类影响行数一一对应,要不然最后几个没对上的单元格实现不了级联
for
(
int
i
=
2
;
i
<
1000
;
i
++)
{
CellRangeAddressList
rangeAddressList
=
new
CellRangeAddressList
(
i
-
1
,
i
-
1
,
1
,
1
);
DataValidationConstraint
formula
=
dvHelper
.
createFormulaListConstraint
(
"INDIRECT($A$"
+
i
+
")"
);
setValidation
(
sheet
,
dvHelper
,
formula
,
rangeAddressList
,
"提示"
,
"你输入的值未在备选列表中,请下拉选择合适的值"
);
}
}
/**
* 设置验证规则
*
* @param sheet sheet对象
* @param helper 验证助手
* @param constraint createExplicitListConstraint
* @param addressList 验证位置对象
* @param msgHead 错误提示头
* @param msgContext 错误提示内容
*/
private
void
setValidation
(
Sheet
sheet
,
DataValidationHelper
helper
,
DataValidationConstraint
constraint
,
CellRangeAddressList
addressList
,
String
msgHead
,
String
msgContext
)
{
DataValidation
dataValidation
=
helper
.
createValidation
(
constraint
,
addressList
);
dataValidation
.
setErrorStyle
(
DataValidation
.
ErrorStyle
.
STOP
);
dataValidation
.
setShowErrorBox
(
true
);
dataValidation
.
setSuppressDropDownArrow
(
true
);
dataValidation
.
createErrorBox
(
msgHead
,
msgContext
);
sheet
.
addValidationData
(
dataValidation
);
}
/**
* @param offset 偏移量,如果给0,表示从A列开始,1,就是从B列
* @param rowId 第几行
* @param colCount 一共多少列
* @return 如果给入参 1,1,10. 表示从B1-K1。最终返回 $B$1:$K$1
* @author denggonghai 2016年8月31日 下午5:17:49
*/
public
String
getRange
(
int
offset
,
int
rowId
,
int
colCount
)
{
char
start
=
(
char
)
(
'A'
+
offset
);
if
(
colCount
<=
25
)
{
char
end
=
(
char
)
(
start
+
colCount
-
1
);
return
"$"
+
start
+
"$"
+
rowId
+
":$"
+
end
+
"$"
+
rowId
;
}
else
{
char
endPrefix
=
'A'
;
char
endSuffix
;
// 26-51之间,包括边界(仅两次字母表计算)
if
((
colCount
-
25
)
/
26
==
0
||
colCount
==
51
)
{
// 边界值
if
((
colCount
-
25
)
%
26
==
0
)
{
endSuffix
=
(
char
)
(
'A'
+
25
);
}
else
{
endSuffix
=
(
char
)
(
'A'
+
(
colCount
-
25
)
%
26
-
1
);
}
}
else
{
// 51以上
if
((
colCount
-
25
)
%
26
==
0
)
{
endSuffix
=
(
char
)
(
'A'
+
25
);
endPrefix
=
(
char
)
(
endPrefix
+
(
colCount
-
25
)
/
26
-
1
);
}
else
{
endSuffix
=
(
char
)
(
'A'
+
(
colCount
-
25
)
%
26
-
1
);
endPrefix
=
(
char
)
(
endPrefix
+
(
colCount
-
25
)
/
26
);
}
}
return
"$"
+
start
+
"$"
+
rowId
+
":$"
+
endPrefix
+
endSuffix
+
"$"
+
rowId
;
}
}
}
C00-common/pps-common/src/main/java/pps/core/common/excel/config/ExcelDynamicSelect.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.config
;
/**
* excel动态选择
*
* @author ZWT
* @date 2024/05/07
*/
public
interface
ExcelDynamicSelect
{
/**
* 获取动态生成的下拉框可选数据
*
* @return 动态生成的下拉框可选数据
*/
String
[]
getSource
();
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/config/ExcelSelected.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.config
;
import
java.lang.annotation.*
;
/**
* 标注导出的列为下拉框类型,并为下拉框设置内容
*
* @author ZWT
* @date 2024/05/07
*/
@Documented
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
FIELD
)
public
@interface
ExcelSelected
{
/**
* 固定下拉内容
*/
String
[]
source
()
default
{};
/**
* 动态下拉内容
*/
Class
<?
extends
ExcelDynamicSelect
>[]
sourceClass
()
default
{};
/**
* 设置下拉框的起始行,默认为第二行
*/
int
firstRow
()
default
1
;
/**
* 设置下拉框的结束行,默认为最后一行
*/
int
lastRow
()
default
0x10000
;
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/config/ExcelSelectedResolve.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.config
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
/**
* excel选定解析
*
* @author ZWT
* @date 2024/05/07
*/
@Data
@Slf4j
public
class
ExcelSelectedResolve
{
/**
* 下拉内容
*/
private
String
[]
source
;
/**
* 设置下拉框的起始行,默认为第二行
*/
private
int
firstRow
;
/**
* 设置下拉框的结束行,默认为最后一行
*/
private
int
lastRow
;
public
String
[]
resolveSelectedSource
(
ExcelSelected
excelSelected
)
{
if
(
excelSelected
==
null
)
{
return
null
;
}
// 获取固定下拉框的内容
String
[]
source
=
excelSelected
.
source
();
if
(
source
.
length
>
0
)
{
return
source
;
}
// 获取动态下拉框的内容
Class
<?
extends
ExcelDynamicSelect
>[]
classes
=
excelSelected
.
sourceClass
();
if
(
classes
.
length
>
0
)
{
try
{
ExcelDynamicSelect
excelDynamicSelect
=
classes
[
0
].
newInstance
();
String
[]
dynamicSelectSource
=
excelDynamicSelect
.
getSource
();
if
(
dynamicSelectSource
!=
null
&&
dynamicSelectSource
.
length
>
0
)
{
return
dynamicSelectSource
;
}
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
log
.
error
(
"解析动态下拉框数据异常"
,
e
);
}
}
return
null
;
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/config/SelectedSheetWriteHandler.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.config
;
import
com.alibaba.excel.write.handler.SheetWriteHandler
;
import
com.alibaba.excel.write.metadata.holder.WriteSheetHolder
;
import
com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddressList
;
import
java.util.Map
;
/**
* 选定工作表写入处理程序
*
* @author ZWT
* @date 2024/05/07
*/
@Data
@AllArgsConstructor
public
class
SelectedSheetWriteHandler
implements
SheetWriteHandler
{
/**
* 设置阈值,避免生成的导入模板下拉值获取不到,可自行设置数量大小
*/
private
static
final
Integer
LIMIT_NUMBER
=
25
;
private
final
Map
<
Integer
,
ExcelSelectedResolve
>
selectedMap
;
/**
* Called before create the sheet
*/
@Override
public
void
beforeSheetCreate
(
WriteWorkbookHolder
writeWorkbookHolder
,
WriteSheetHolder
writeSheetHolder
)
{
}
/**
* Called after the sheet is created
*/
@Override
public
void
afterSheetCreate
(
WriteWorkbookHolder
writeWorkbookHolder
,
WriteSheetHolder
writeSheetHolder
)
{
// 这里可以对cell进行任何操作
Sheet
sheet
=
writeSheetHolder
.
getSheet
();
DataValidationHelper
helper
=
sheet
.
getDataValidationHelper
();
selectedMap
.
forEach
((
k
,
v
)
->
{
// 设置下拉列表的行: 首行,末行,首列,末列
CellRangeAddressList
rangeList
=
new
CellRangeAddressList
(
v
.
getFirstRow
(),
v
.
getLastRow
(),
k
,
k
);
// 如果下拉值总数大于25,则使用一个新sheet存储,避免生成的导入模板下拉值获取不到
if
(
v
.
getSource
().
length
>
LIMIT_NUMBER
)
{
//定义sheet的名称
//1.创建一个隐藏的sheet 名称为 hidden + k
String
sheetName
=
"hidden"
+
k
;
Workbook
workbook
=
writeWorkbookHolder
.
getWorkbook
();
Sheet
hiddenSheet
=
workbook
.
createSheet
(
sheetName
);
for
(
int
i
=
0
,
length
=
v
.
getSource
().
length
;
i
<
length
;
i
++)
{
// 开始的行数i,列数k
hiddenSheet
.
createRow
(
i
).
createCell
(
k
).
setCellValue
(
v
.
getSource
()[
i
]);
}
Name
category1Name
=
workbook
.
createName
();
category1Name
.
setNameName
(
sheetName
);
String
excelLine
=
getExcelLine
(
k
);
// =hidden!$H:$1:$H$50 sheet为hidden的 H1列开始H50行数据获取下拉数组
String
refers
=
"="
+
sheetName
+
"!$"
+
excelLine
+
"$1:$"
+
excelLine
+
"$"
+
(
v
.
getSource
().
length
+
1
);
// 将刚才设置的sheet引用到你的下拉列表中
DataValidationConstraint
constraint
=
helper
.
createFormulaListConstraint
(
refers
);
DataValidation
dataValidation
=
helper
.
createValidation
(
constraint
,
rangeList
);
writeSheetHolder
.
getSheet
().
addValidationData
(
dataValidation
);
// 设置存储下拉列值得sheet为隐藏
int
hiddenIndex
=
workbook
.
getSheetIndex
(
sheetName
);
if
(!
workbook
.
isSheetHidden
(
hiddenIndex
))
{
workbook
.
setSheetHidden
(
hiddenIndex
,
true
);
}
}
// 设置下拉列表的值
DataValidationConstraint
constraint
=
helper
.
createExplicitListConstraint
(
v
.
getSource
());
// 设置约束
DataValidation
validation
=
helper
.
createValidation
(
constraint
,
rangeList
);
// 阻止输入非下拉选项的值
validation
.
setErrorStyle
(
DataValidation
.
ErrorStyle
.
STOP
);
validation
.
setShowErrorBox
(
true
);
// validation.setSuppressDropDownArrow(true);
validation
.
createErrorBox
(
"提示"
,
"请输入下拉选项中的内容"
);
sheet
.
addValidationData
(
validation
);
});
}
/**
* 返回excel列标A-Z-AA-ZZ
*
* @param num 列数
* @return java.lang.String
*/
private
String
getExcelLine
(
int
num
)
{
String
line
=
""
;
int
first
=
num
/
26
;
int
second
=
num
%
26
;
if
(
first
>
0
)
{
line
=
(
char
)
(
'A'
+
first
-
1
)
+
""
;
}
line
+=
(
char
)
(
'A'
+
second
)
+
""
;
return
line
;
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/listener/ExcelListener.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.listener
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.excel.exception.ExcelAnalysisException
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 出色倾听者
*
* @author ZWT
* @date 2024/05/09
*/
@Slf4j
public
class
ExcelListener
<
T
>
extends
AnalysisEventListener
<
T
>
{
/**
* 可以通过实例获取该值
*/
private
List
<
T
>
dataList
=
new
ArrayList
<>();
/**
* 表头map(单行表头),列号-->列名
*/
private
Map
<
Integer
,
String
>
headMap
=
new
LinkedHashMap
<>();
/**
* 读取行数最大值(含表头)<br>
* limit: -1 默认 不限制 <br>
* 0 不限制 <br>
* n 限制行数 <br>
*/
private
int
limit
=
-
1
;
public
ExcelListener
()
{
}
public
ExcelListener
(
int
limit
)
{
this
.
limit
=
limit
;
}
@Override
public
void
invokeHeadMap
(
Map
<
Integer
,
String
>
headMap
,
AnalysisContext
context
)
{
this
.
headMap
.
putAll
(
headMap
);
}
@Override
public
void
invoke
(
T
object
,
AnalysisContext
context
)
{
Integer
rowNumber
=
context
.
readSheetHolder
().
getApproximateTotalRowNumber
();
if
(
this
.
limit
>
0
&&
rowNumber
>
this
.
limit
)
{
throw
new
ExcelAnalysisException
(
"导入数据内容超出总行数["
+
this
.
limit
+
"]条限制"
);
}
//数据存储到list,供批量处理,或后续自己业务逻辑处理。
log
.
info
(
"解析到一条数据:{}"
,
JSONUtil
.
toJsonStr
(
object
));
dataList
.
add
(
object
);
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
//非必要语句,查看导入的数据
}
/************************************** get && set ***********************************************************/
public
List
<
T
>
getDataList
()
{
return
dataList
;
}
public
void
setDataList
(
List
<
T
>
dataList
)
{
this
.
dataList
=
dataList
;
}
public
Map
<
Integer
,
String
>
getHeadMap
()
{
return
headMap
;
}
public
void
setHeadMap
(
Map
<
Integer
,
String
>
headMap
)
{
this
.
headMap
=
headMap
;
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/util/EasyExcelUtil.java
deleted
100644 → 0
View file @
00a47d37
This diff is collapsed.
Click to expand it.
C00-common/pps-common/src/main/java/pps/core/common/excel/util/ExcelStyleTool.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.util
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.alibaba.excel.write.metadata.style.WriteCellStyle
;
import
com.alibaba.excel.write.metadata.style.WriteFont
;
import
com.alibaba.excel.write.style.HorizontalCellStyleStrategy
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
java.util.List
;
/**
* excel样式工具
*
* @author ZWT
* @date 2024/03/04
*/
public
class
ExcelStyleTool
{
/**
* 写入sheet页
*
* @param excelWriter 优秀作家
* @param sheetNo 图纸编号
* @param sheetName 图纸名称
* @param clazz 拍手
* @param data 数据
*/
public
static
void
writeSheet
(
ExcelWriter
excelWriter
,
Integer
sheetNo
,
String
sheetName
,
Class
<?>
clazz
,
List
data
)
{
WriteSheet
writeSheet
=
new
WriteSheet
();
writeSheet
.
setClazz
(
clazz
);
writeSheet
.
setSheetNo
(
sheetNo
);
writeSheet
.
setSheetName
(
sheetName
);
excelWriter
.
write
(
data
,
writeSheet
);
}
/**
* 设置自定义样式
*
* @return {@link HorizontalCellStyleStrategy}
*/
public
static
HorizontalCellStyleStrategy
getStyleStrategy
()
{
//头的策略 样式调整
WriteCellStyle
headWriteCellStyle
=
new
WriteCellStyle
();
//设置头部样式
setRowStyle
(
headWriteCellStyle
,
true
,
true
);
//设置细边框
setBorder
(
headWriteCellStyle
);
//表头字体样式
WriteFont
headWriteFont
=
getHeadFont
(
IndexedColors
.
SKY_BLUE
.
getIndex
());
headWriteCellStyle
.
setWriteFont
(
headWriteFont
);
//内容的策略
WriteCellStyle
contentStyle
=
new
WriteCellStyle
();
//设置内容样式
setRowStyle
(
headWriteCellStyle
,
false
,
false
);
//设置边框
setBorder
(
contentStyle
);
//内容字体
contentStyle
.
setWriteFont
(
setContentFont
());
//这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
return
new
HorizontalCellStyleStrategy
(
headWriteCellStyle
,
contentStyle
);
}
/*-------------------------- 私有方法 --------------------------*/
/**
* 获取表头字体
*
* @param color
* @return
*/
private
static
WriteFont
getHeadFont
(
Short
color
)
{
//表头字体样式
WriteFont
headWriteFont
=
new
WriteFont
();
//头字号
headWriteFont
.
setFontHeightInPoints
((
short
)
12
);
//字体样式
headWriteFont
.
setFontName
(
"微软雅黑"
);
//字体颜色
headWriteFont
.
setColor
(
color
);
//字体加粗
headWriteFont
.
setBold
(
true
);
return
headWriteFont
;
}
/**
* 设置内容字体
*
* @return {@link WriteFont}
*/
private
static
WriteFont
setContentFont
()
{
//内容字体
WriteFont
contentWriteFont
=
new
WriteFont
();
//内容字号
contentWriteFont
.
setFontHeightInPoints
((
short
)
11
);
//字体样式
contentWriteFont
.
setFontName
(
"宋体"
);
return
contentWriteFont
;
}
/**
* 设置行样式
*
* @param cellStyle
* @param wrappedFlag 自动换行标识,true:开启自动换行
* @param centerFlag 水平居中开关,true:开启水平居中
*/
private
static
void
setRowStyle
(
WriteCellStyle
cellStyle
,
boolean
wrappedFlag
,
boolean
centerFlag
)
{
//行背景:白色
cellStyle
.
setFillForegroundColor
(
IndexedColors
.
WHITE
.
getIndex
());
if
(
wrappedFlag
)
{
//设置自动换行
cellStyle
.
setWrapped
(
true
);
}
if
(
centerFlag
)
{
//设置水平对齐方式
cellStyle
.
setHorizontalAlignment
(
HorizontalAlignment
.
CENTER
);
}
//设置垂直对齐方式
cellStyle
.
setVerticalAlignment
(
VerticalAlignment
.
CENTER
);
}
/**
* 设置边框
*
* @param cellStyle 单元格样式
*/
private
static
void
setBorder
(
WriteCellStyle
cellStyle
)
{
//设置细边框
cellStyle
.
setBorderBottom
(
BorderStyle
.
THIN
);
cellStyle
.
setBorderLeft
(
BorderStyle
.
THIN
);
cellStyle
.
setBorderRight
(
BorderStyle
.
THIN
);
cellStyle
.
setBorderTop
(
BorderStyle
.
THIN
);
//设置边框颜色 25灰度
cellStyle
.
setBottomBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
cellStyle
.
setTopBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
cellStyle
.
setLeftBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
cellStyle
.
setRightBorderColor
(
IndexedColors
.
BLACK
.
getIndex
());
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/excel/util/ValidationUtil.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.excel.util
;
import
jakarta.validation.ConstraintViolation
;
import
jakarta.validation.Validation
;
import
jakarta.validation.Validator
;
import
jakarta.validation.ValidatorFactory
;
import
xstartup.base.exception.XServiceException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
/**
* 验证util
*
* @author ZWT
* @date 2024/05/10
*/
public
class
ValidationUtil
{
static
Validator
validator
;
static
{
ValidatorFactory
validatorFactory
=
Validation
.
buildDefaultValidatorFactory
();
validator
=
validatorFactory
.
getValidator
();
}
public
static
Validator
getValidator
()
{
return
validator
;
}
/**
* 进行验证
*
* @param var1 var1
* @param var2 var2
*/
public
static
<
T
>
void
doValidate
(
List
<
T
>
var1
,
Class
<?>...
var2
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
int
rowNum
=
1
;
for
(
T
var0
:
var1
)
{
rowNum
++;
// 跳过标题行, 此为excel的行号
List
<
String
>
errMsg
=
new
ArrayList
<>();
Set
<
ConstraintViolation
<
T
>>
validateRstSet
=
validator
.
validate
(
var0
,
var2
);
for
(
ConstraintViolation
<
T
>
constraintViolation
:
validateRstSet
)
{
errMsg
.
add
(
constraintViolation
.
getMessage
());
}
if
(
errMsg
.
size
()
>
0
)
{
stringBuilder
.
append
(
"第"
).
append
(
rowNum
).
append
(
"行,"
).
append
(
errMsg
).
append
(
';'
);
}
}
if
(
stringBuilder
.
length
()
>
0
)
{
// 组装异常数据
throw
new
XServiceException
(
stringBuilder
.
toString
());
}
}
}
C00-common/pps-common/src/main/java/pps/core/common/utils/BaseUtils.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.utils
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.text.CharSequenceUtil
;
import
cn.hutool.core.util.IdUtil
;
import
pps.core.common.constant.BusinessConstant
;
import
pps.core.common.entity.BaseModel
;
import
pps.core.common.session.PpsUserSession
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* 封装工具类
*
* @author ZWT
* @date 2023/08/25 16:08
*/
public
class
BaseUtils
{
/**
* 按每800个一组分割
*/
public
static
final
Integer
BATCH_SIZE
=
800
;
/**
* 计算批次数
*/
public
static
Integer
countStep
(
Integer
totalSize
)
{
return
(
totalSize
+
BATCH_SIZE
-
1
)
/
BATCH_SIZE
;
}
/**
* 分批处理
*
* @param list 列表
* @return {@link List}<{@link List}<{@link E}>>
*/
public
static
<
E
>
List
<
List
<
E
>>
getSubList
(
List
<
E
>
list
)
{
return
Stream
.
iterate
(
0
,
n
->
n
+
1
)
.
limit
(
countStep
(
list
.
size
()))
.
parallel
()
.
map
(
a
->
list
.
stream
().
skip
(
a
*
BaseUtils
.
BATCH_SIZE
)
.
limit
(
BATCH_SIZE
).
parallel
()
.
collect
(
Collectors
.
toList
()))
.
collect
(
Collectors
.
toList
());
}
/**
* 设置实体默认值
*
* @param model 实体
* @param session 会话
*/
public
static
void
setBaseModelDefault
(
BaseModel
model
,
PpsUserSession
session
)
{
String
id
=
model
.
getId
();
Date
now
=
new
Date
();
String
userId
=
session
.
getId
();
String
userName
=
session
.
getUserName
();
if
(
CharSequenceUtil
.
isEmpty
(
id
))
{
model
.
setCreateById
(
userId
);
model
.
setCreateByName
(
userName
);
model
.
setCreateTime
(
now
);
}
model
.
setModifyById
(
userId
);
model
.
setModifyByName
(
userName
);
model
.
setModifyTime
(
now
);
}
/**
* 创建基础模型默认值
*
* @param model 模型
* @param session 一场
*/
public
static
void
createBaseModelDefault
(
BaseModel
model
,
PpsUserSession
session
)
{
Date
now
=
DateUtil
.
date
();
model
.
setId
(
IdUtil
.
simpleUUID
());
model
.
setIsDeleted
(
1
);
String
userId
=
session
.
getId
();
String
userName
=
session
.
getUserName
();
model
.
setCreateById
(
userId
);
model
.
setCreateByName
(
userName
);
model
.
setCreateTime
(
now
);
model
.
setModifyById
(
userId
);
model
.
setModifyByName
(
userName
);
model
.
setModifyTime
(
now
);
}
/**
* 设置实体默认值(定时任务)
*
* @param model 模型
*/
public
static
void
setBaseModelDefaultForJob
(
BaseModel
model
)
{
DateTime
beginOfDay
=
DateUtil
.
beginOfDay
(
DateTime
.
now
());
model
.
setId
(
BaseUtils
.
getUUID
());
model
.
setCreateById
(
"Task"
);
model
.
setCreateByName
(
"Task"
);
model
.
setCreateTime
(
beginOfDay
);
model
.
setModifyById
(
"Task"
);
model
.
setModifyByName
(
"Task"
);
model
.
setModifyTime
(
beginOfDay
);
}
/**
* 获取uuid
*
* @return {@link String}
*/
public
static
String
getUUID
()
{
return
CharSequenceUtil
.
replace
(
UUID
.
randomUUID
().
toString
(),
"-"
,
""
);
}
/**
* 获取周执行周期
*
* @param date 日期
* @return {@link String}
*/
public
static
String
getExecutionCycleForWeek
(
DateTime
date
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
stringBuilder
.
append
(
date
.
year
())
.
append
(
"年第"
)
.
append
(
date
.
weekOfYear
())
.
append
(
'周'
);
return
stringBuilder
.
toString
();
}
/**
* 获取校准执行周期
*
* @param date 日期
* @param offset 抵消
* @return {@link String}
*/
public
static
String
getExecutionCycleForCalibration
(
Date
date
,
int
offset
)
{
String
stringBuilder
=
DateUtil
.
format
(
date
,
BusinessConstant
.
DATE_FORMAT_DAY_C
)
+
'-'
+
DateUtil
.
format
(
DateUtil
.
offsetDay
(
date
,
offset
-
1
),
BusinessConstant
.
DATE_FORMAT_DAY_C
);
return
stringBuilder
;
}
/**
* 获取校准执行周期
*
* @param startDate 开始日期
* @param endDate 结束日期
* @return {@link String}
*/
public
static
String
getExecutionCycleForCalibration
(
Date
startDate
,
Date
endDate
)
{
String
stringBuilder
=
DateUtil
.
format
(
startDate
,
BusinessConstant
.
DATE_FORMAT_DAY_C
)
+
'-'
+
DateUtil
.
format
(
endDate
,
BusinessConstant
.
DATE_FORMAT_DAY_C
);
return
stringBuilder
;
}
/**
* 获取时差分钟
*
* @param optimizeTime 优化后时间
* @param originalTime 原始时间
* @return int
*/
public
static
int
getTimeDifferenceMinute
(
DateTime
optimizeTime
,
DateTime
originalTime
)
{
int
between
=
(
int
)
optimizeTime
.
between
(
originalTime
,
DateUnit
.
MINUTE
);
if
(
optimizeTime
.
compareTo
(
originalTime
)
<
0
)
{
between
=
~
between
+
1
;
}
return
between
;
}
/**
* 获取结束时间字符串
*
* @param endTimeOptimize 结束时间优化
* @return {@link String}
*/
public
static
String
getEndTimeString
(
DateTime
endTimeOptimize
)
{
String
endTimeString
;
if
(
endTimeOptimize
.
compareTo
(
BusinessConstant
.
DATE_FLAG
)
>
0
)
{
endTimeString
=
BusinessConstant
.
END_OF_DAY_TIME
;
}
else
{
endTimeString
=
endTimeOptimize
.
toString
(
BusinessConstant
.
MINUTES_FORMAT
);
}
return
endTimeString
;
}
/**
* 获取月份字符串
*
* @param monthNum 月份
* @return {@link String}
*/
public
static
String
getMonthString
(
int
monthNum
)
{
String
month
;
if
(
monthNum
<
BusinessConstant
.
TEN
)
{
month
=
"0"
+
monthNum
;
}
else
{
month
=
String
.
valueOf
(
monthNum
);
}
return
month
;
}
/**
* 除法
*
* @param one 一
* @param two 二
* @return {@link BigDecimal }
*/
public
static
BigDecimal
divide
(
BigDecimal
one
,
BigDecimal
two
)
{
BigDecimal
result
;
if
(
two
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
result
=
one
.
divide
(
two
,
2
,
RoundingMode
.
HALF_UP
);
}
else
{
result
=
BigDecimal
.
ZERO
;
}
return
result
;
}
/**
* 计算率
*
* @param one 一
* @param two 二
* @return {@link BigDecimal }
*/
public
static
BigDecimal
getRate
(
BigDecimal
one
,
BigDecimal
two
)
{
BigDecimal
rate
;
if
(
two
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
rate
=
one
.
divide
(
two
,
4
,
RoundingMode
.
HALF_UP
)
.
multiply
(
BusinessConstant
.
BIG_DECIMAL_100
);
}
else
{
rate
=
BigDecimal
.
ZERO
;
}
return
rate
;
}
}
\ No newline at end of file
C00-common/pps-common/src/main/java/pps/core/common/utils/BigDecimalUtil.java
View file @
d70be0a6
package
pps.core.common.utils
;
import
pps.core.common.constant.BusinessConstant
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.text.DecimalFormat
;
import
java.util.regex.Pattern
;
...
...
@@ -63,19 +60,6 @@ public class BigDecimalUtil {
return
org
.
setScale
(
num
,
BigDecimal
.
ROUND_HALF_UP
);
}
/**
* 获取百分比字符串
*
* @param total
* @param part
* @return
*/
public
static
String
getPercentStr
(
int
total
,
int
part
)
{
if
(
total
==
0
)
return
"100%"
;
if
(
part
==
0
)
return
"0%"
;
return
new
BigDecimal
(
part
).
divide
(
new
BigDecimal
(
total
),
2
,
RoundingMode
.
HALF_UP
).
multiply
(
BusinessConstant
.
BIG_DECIMAL_100
)
+
"%"
;
}
/**
* 空值转换
*/
...
...
C00-common/pps-common/src/main/java/pps/core/common/utils/CollectorsUtil.java
deleted
100644 → 0
View file @
00a47d37
package
pps.core.common.utils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Collections
;
import
java.util.Set
;
import
java.util.function.BiConsumer
;
import
java.util.function.BinaryOperator
;
import
java.util.function.Function
;
import
java.util.function.Supplier
;
import
java.util.stream.Collector
;
/**
* 收集器util
*
* @author ZWT
* @date 2024/06/03
*/
public
class
CollectorsUtil
{
static
final
Set
<
Collector
.
Characteristics
>
CH_NOID
=
Collections
.
emptySet
();
private
CollectorsUtil
()
{
}
@SuppressWarnings
(
"unchecked"
)
private
static
<
I
,
R
>
Function
<
I
,
R
>
castingIdentity
()
{
return
i
->
(
R
)
i
;
}
//求和方法
public
static
<
T
>
Collector
<
T
,
?,
BigDecimal
>
summingBigDecimal
(
ToBigDecimalFunction
<?
super
T
>
mapper
)
{
return
new
CollectorImpl
<>(
()
->
new
BigDecimal
[]{
BigDecimal
.
ZERO
},
(
a
,
t
)
->
{
a
[
0
]
=
a
[
0
].
add
(
mapper
.
applyAsBigDecimal
(
t
));
},
(
a
,
b
)
->
{
a
[
0
]
=
a
[
0
].
add
(
b
[
0
]);
return
a
;
},
a
->
a
[
0
],
CH_NOID
);
}
//求最大值
public
static
<
T
>
Collector
<
T
,
?,
BigDecimal
>
maxBy
(
ToBigDecimalFunction
<?
super
T
>
mapper
)
{
return
new
CollectorImpl
<>(
()
->
new
BigDecimal
[]{
new
BigDecimal
(
Long
.
MIN_VALUE
)},
(
a
,
t
)
->
{
a
[
0
]
=
a
[
0
].
max
(
mapper
.
applyAsBigDecimal
(
t
));
},
(
a
,
b
)
->
{
a
[
0
]
=
a
[
0
].
max
(
b
[
0
]);
return
a
;
},
a
->
a
[
0
],
CH_NOID
);
}
//求最小值
public
static
<
T
>
Collector
<
T
,
?,
BigDecimal
>
minBy
(
ToBigDecimalFunction
<?
super
T
>
mapper
)
{
return
new
CollectorImpl
<>(
()
->
new
BigDecimal
[]{
new
BigDecimal
(
Long
.
MAX_VALUE
)},
(
a
,
t
)
->
{
a
[
0
]
=
a
[
0
].
min
(
mapper
.
applyAsBigDecimal
(
t
));
},
(
a
,
b
)
->
{
a
[
0
]
=
a
[
0
].
min
(
b
[
0
]);
return
a
;
},
a
->
a
[
0
],
CH_NOID
);
}
/**
* 求平均值
*
* @param mapper
* @param newScale 保留newScale位小数
* @param roundingMode 舍去规则(0 <= roundingMode <= 7)
* @param <T>
* @return
*/
public
static
<
T
>
Collector
<
T
,
?,
BigDecimal
>
averagingBigDecimal
(
ToBigDecimalFunction
<?
super
T
>
mapper
,
int
newScale
,
int
roundingMode
)
{
return
new
CollectorImpl
<>(
()
->
new
BigDecimal
[]{
BigDecimal
.
ZERO
,
BigDecimal
.
ZERO
},
(
a
,
t
)
->
{
a
[
0
]
=
a
[
0
].
add
(
mapper
.
applyAsBigDecimal
(
t
));
a
[
1
]
=
a
[
1
].
add
(
BigDecimal
.
ONE
);
},
(
a
,
b
)
->
{
a
[
0
]
=
a
[
0
].
add
(
b
[
0
]);
return
a
;
},
a
->
a
[
0
].
divide
(
a
[
1
],
RoundingMode
.
HALF_UP
).
setScale
(
newScale
,
roundingMode
),
CH_NOID
);
}
static
class
CollectorImpl
<
T
,
A
,
R
>
implements
Collector
<
T
,
A
,
R
>
{
private
final
Supplier
<
A
>
supplier
;
private
final
BiConsumer
<
A
,
T
>
accumulator
;
private
final
BinaryOperator
<
A
>
combiner
;
private
final
Function
<
A
,
R
>
finisher
;
private
final
Set
<
Characteristics
>
characteristics
;
CollectorImpl
(
Supplier
<
A
>
supplier
,
BiConsumer
<
A
,
T
>
accumulator
,
BinaryOperator
<
A
>
combiner
,
Function
<
A
,
R
>
finisher
,
Set
<
Characteristics
>
characteristics
)
{
this
.
supplier
=
supplier
;
this
.
accumulator
=
accumulator
;
this
.
combiner
=
combiner
;
this
.
finisher
=
finisher
;
this
.
characteristics
=
characteristics
;
}
CollectorImpl
(
Supplier
<
A
>
supplier
,
BiConsumer
<
A
,
T
>
accumulator
,
BinaryOperator
<
A
>
combiner
,
Set
<
Characteristics
>
characteristics
)
{
this
(
supplier
,
accumulator
,
combiner
,
castingIdentity
(),
characteristics
);
}
@Override
public
BiConsumer
<
A
,
T
>
accumulator
()
{
return
accumulator
;
}
@Override
public
Supplier
<
A
>
supplier
()
{
return
supplier
;
}
@Override
public
BinaryOperator
<
A
>
combiner
()
{
return
combiner
;
}
@Override
public
Function
<
A
,
R
>
finisher
()
{
return
finisher
;
}
@Override
public
Set
<
Characteristics
>
characteristics
()
{
return
characteristics
;
}
}
}
\ No newline at end of file
C02-system/pps-cloud-system/src/main/java/pps/cloud/system/service/SysOrganizationCloudService.java
View file @
d70be0a6
...
...
@@ -22,8 +22,5 @@ public interface SysOrganizationCloudService {
@XText
(
"根据组织机构id获取所有的子级组织机构列表"
)
XListResult
<
GetSysOrganizationViewOutput
>
getAllListByOuId
(
XContext
context
,
GetAllOuListByOuIdInput
input
);
@XText
(
"查采油厂列表"
)
XListResult
<
GetSysOrganizationViewOutput
>
getPlantList
(
XContext
context
);
}
C02-system/pps-core-system/src/main/java/pps/core/system/service/SysOrganizationCloudServiceImpl.java
View file @
d70be0a6
package
pps.core.system.service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.util.CollectionUtils
;
import
pps.cloud.system.service.SysOrganizationCloudService
;
import
pps.cloud.system.service.data.sys_organization.*
;
import
pps.core.common.constant.BusinessConstant
;
import
pps.core.system.entity.*
;
import
pps.core.system.mapper.*
;
import
xstartup.annotation.XService
;
...
...
@@ -125,15 +123,4 @@ public class SysOrganizationCloudServiceImpl implements SysOrganizationCloudServ
List
<
GetSysOrganizationViewOutput
>
viewList
=
XCopyUtils
.
copyNewList
(
list
,
GetSysOrganizationViewOutput
.
class
);
return
XListResult
.
success
(
viewList
);
}
@Override
public
XListResult
<
GetSysOrganizationViewOutput
>
getPlantList
(
XContext
context
)
{
SysOrganizationMapper
mapper
=
context
.
getBean
(
SysOrganizationMapper
.
class
);
List
<
SysOrganizationEnt
>
plant
=
mapper
.
selectList
(
new
LambdaQueryWrapper
<
SysOrganizationEnt
>()
.
eq
(
SysOrganizationEnt:
:
getIsDeleted
,
BusinessConstant
.
ONE
)
.
eq
(
SysOrganizationEnt:
:
getOuLevel
,
"PLANT"
)
.
orderByAsc
(
SysOrganizationEnt:
:
getCreateTime
)
);
return
XListResult
.
success
(
XCopyUtils
.
copyNewList
(
plant
,
GetSysOrganizationViewOutput
.
class
));
}
}
\ No newline at end of file
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