Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
f93069a0
Commit
f93069a0
authored
Dec 07, 2024
by
honghy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
海运已装单添加底色
parent
9af4107e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
32 deletions
+142
-32
CustomsTypeEnum.java
.../iocoder/yudao/module/shipment/enums/CustomsTypeEnum.java
+21
-0
ShipmentLoadExcelExportListener2.java
...e/shipment/listener/ShipmentLoadExcelExportListener2.java
+96
-28
CustomLoadMergeStrategyNew.java
...dao/module/shipment/utils/CustomLoadMergeStrategyNew.java
+25
-4
No files found.
yudao-module-shipment/yudao-module-shipment-core/src/main/java/cn/iocoder/yudao/module/shipment/enums/CustomsTypeEnum.java
0 → 100644
View file @
f93069a0
package
cn
.
iocoder
.
yudao
.
module
.
shipment
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 报关方式枚举
*
* @author jayden
*/
@Getter
@AllArgsConstructor
public
enum
CustomsTypeEnum
{
CUSTOMS_TYPE_1
(
"我司全代"
,
1
),
CUSTOMS_TYPE_2
(
"自单代报"
,
2
),
CUSTOMS_TYPE_3
(
"混合报关"
,
3
);
private
final
String
name
;
private
final
Integer
value
;
}
yudao-module-shipment/yudao-module-shipment-core/src/main/java/cn/iocoder/yudao/module/shipment/listener/ShipmentLoadExcelExportListener2.java
View file @
f93069a0
...
...
@@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.shipment.listener;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.iocoder.yudao.framework.apollo.core.event.export.ShipmentLoadExcelExportPushEvent
;
import
cn.iocoder.yudao.framework.apollo.core.event.export.ShipmentLoadExcelExportPushEvent2
;
import
cn.iocoder.yudao.framework.apollo.core.event.export.ShipmentPreloadExcelExportPushEvent
;
import
cn.iocoder.yudao.framework.common.util.date.DateUtils
;
import
cn.iocoder.yudao.framework.common.util.number.NumberUtils
;
import
cn.iocoder.yudao.framework.dict.core.dto.DictDataRespDTO
;
...
...
@@ -18,14 +16,14 @@ import cn.iocoder.yudao.module.infra.service.file.FileService;
import
cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderGuanlian.OrderGuanlianDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderLocation.OrderLocationDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseIn.OrderWarehouseInDO
;
import
cn.iocoder.yudao.module.order.dto.OrderBackInfoDto
;
import
cn.iocoder.yudao.module.order.service.order.*
;
import
cn.iocoder.yudao.module.order.service.order.OrderGuanlianService
;
import
cn.iocoder.yudao.module.order.service.order.OrderItemService
;
import
cn.iocoder.yudao.module.order.service.order.OrderQueryService
;
import
cn.iocoder.yudao.module.order.service.order.OrderService
;
import
cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService
;
import
cn.iocoder.yudao.module.order.vo.order.OrderWarehouseInDetailsVO
;
import
cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackItemDo
;
import
cn.iocoder.yudao.module.order.vo.orderWarehouseIn.OrderWarehouseInBackVO
;
import
cn.iocoder.yudao.module.product.dal.dataobject.product.ProductAttrDO
;
import
cn.iocoder.yudao.module.product.dal.dataobject.product.ProductDO
;
import
cn.iocoder.yudao.module.product.dal.dataobject.productbrank.ProductBrankDO
;
...
...
@@ -35,24 +33,23 @@ import cn.iocoder.yudao.module.product.service.productbrank.ProductBrankService;
import
cn.iocoder.yudao.module.shipment.dal.dataobject.BoxApprovalDO
;
import
cn.iocoder.yudao.module.shipment.dal.dataobject.BoxDO
;
import
cn.iocoder.yudao.module.shipment.dto.LoadDto
;
import
cn.iocoder.yudao.module.shipment.
dto.PreloadDto
;
import
cn.iocoder.yudao.module.shipment.
enums.CustomsTypeEnum
;
import
cn.iocoder.yudao.module.shipment.service.box.BoxService
;
import
cn.iocoder.yudao.module.shipment.service.boxApproval.BoxApprovalService
;
import
cn.iocoder.yudao.module.shipment.service.boxPreloadGoods.BoxPreloadGoodsService
;
import
cn.iocoder.yudao.module.shipment.utils.CustomCellWriteHandler
;
import
cn.iocoder.yudao.module.shipment.utils.CustomLoadMergeStrategyNew
;
import
cn.iocoder.yudao.module.shipment.utils.CustomMergeStrategy
;
import
cn.iocoder.yudao.module.shipment.vo.boxPreloadGoods.BoxPreloadGoodsBackVO
;
import
cn.iocoder.yudao.module.system.framework.ue.UeProperties
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.alibaba.excel.write.metadata.WriteTable
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.IndexedColors
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -61,7 +58,6 @@ import javax.annotation.Resource;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
...
...
@@ -69,7 +65,6 @@ import java.util.*;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
error
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
excel
.
constant
.
ExportConstant
.
DATA_FORMAT
;
import
static
cn
.
iocoder
.
yudao
.
module
.
shipment
.
enums
.
ErrorCodeConstants
.
HAVE_NOT_PRELOAD_GOODS
;
...
...
@@ -187,6 +182,7 @@ public class ShipmentLoadExcelExportListener2 {
int
allTotalNum
=
0
;
BigDecimal
allTotalVolume
=
new
BigDecimal
(
0
);
BigDecimal
allTotalWeight
=
new
BigDecimal
(
0
);
BigDecimal
allTotalWorth
=
new
BigDecimal
(
0
);
List
<
Long
>
secCount
=
goodsItemList
.
stream
().
map
(
BoxPreloadGoodsBackVO:
:
getSecId
).
distinct
().
sorted
().
collect
(
Collectors
.
toList
());
AtomicInteger
colorRowNum
=
new
AtomicInteger
(
6
);
if
(!
CollectionUtils
.
isEmpty
(
secCount
))
{
...
...
@@ -217,10 +213,14 @@ public class ShipmentLoadExcelExportListener2 {
int
totalNum
=
0
;
BigDecimal
totalVolume
=
new
BigDecimal
(
0
);
BigDecimal
totalWeight
=
new
BigDecimal
(
0
);
BigDecimal
totalWorth
=
new
BigDecimal
(
0
);
List
<
Integer
>
mergeCountList
=
new
ArrayList
();
List
<
Integer
>
colorRowList
=
new
ArrayList
<>();
List
<
Integer
>
colorRowList2
=
new
ArrayList
<>();
Map
<
String
,
Integer
>
numMap
=
new
HashMap
();
Map
<
String
,
Integer
>
colorMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
colorMap2
=
new
HashMap
<>();
Long
part
=
secCount
.
get
(
i
);
int
colorIndex
=
0
;
...
...
@@ -228,11 +228,64 @@ public class ShipmentLoadExcelExportListener2 {
Map
<
Long
,
List
<
BoxPreloadGoodsBackVO
>>
orderMap
=
goodsItemList
.
stream
().
filter
(
item
->
item
.
getSecId
().
longValue
()==
part
.
longValue
()
&&
StringUtils
.
isNotBlank
(
item
.
getWarehouseInInfo
()))
.
collect
(
Collectors
.
groupingBy
(
BoxPreloadGoodsBackVO:
:
getOrderId
,
LinkedHashMap:
:
new
,
Collectors
.
toList
()));
for
(
Map
.
Entry
<
Long
,
List
<
BoxPreloadGoodsBackVO
>>
entry
:
orderMap
.
entrySet
())
{
boolean
prodAttrTag
=
false
;
Long
orderId
=
entry
.
getKey
();
OrderBackInfoDto
orderInfo
=
orderQueryService
.
info
(
orderId
);
List
<
BoxPreloadGoodsBackVO
>
boxPreload
=
entry
.
getValue
();
List
<
OrderItemDO
>
orderItems
=
boxPreload
.
stream
().
map
(
item
->
orderItemService
.
getOrderItem
(
item
.
getOrderItemId
())).
collect
(
Collectors
.
toList
());
for
(
OrderItemDO
orderItem
:
orderItems
)
{
String
attrNames
=
getAttrNameByIds
(
orderItem
.
getProdAttrIds
(),
idNameMap
);
if
(
attrNames
.
contains
(
"危险品"
)){
prodAttrTag
=
true
;
}
}
for
(
OrderItemDO
item
:
orderItems
)
{
LoadDto
preloadDto
=
new
LoadDto
();
String
attrNames
=
getAttrNameByIds
(
item
.
getProdAttrIds
(),
idNameMap
);
preloadDto
.
setProdAttr
(
attrNames
);
// 当订单的报关方式=混合报关,订单的底色为蓝色,#0000FF
// 当订单的报关方式=自单代报,订单的底色为橙色, #FF7F00
// 当订单的商品包含了特性=危险品DG,订单的底色为黄色, #FFFF00
// 当订单的商品包含了特性=危险品DG&订单的报关方式=自单代报/混合报关,底色为绿色,#00FF00
if
(
orderInfo
.
getCustomsType
()!=
null
){
preloadDto
.
setCustomsType
(
DictFrameworkUtils
.
getDictDataFromCache
(
"customs_type"
,
orderInfo
.
getCustomsType
()+
""
).
getLabel
());
if
(
CustomsTypeEnum
.
CUSTOMS_TYPE_3
.
getValue
().
equals
(
orderInfo
.
getCustomsType
())){
Integer
color
=
Integer
.
valueOf
(
IndexedColors
.
BLUE1
.
index
);
if
(
prodAttrTag
){
color
=
Integer
.
valueOf
(
IndexedColors
.
ROYAL_BLUE
.
index
);
}
int
andIncrement2
=
colorRowNum
.
get
();
colorMap2
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
color
));
colorMap
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
color
));
colorRowList
.
add
(
andIncrement2
);
colorRowList2
.
add
(
andIncrement2
);
}
else
if
(
CustomsTypeEnum
.
CUSTOMS_TYPE_2
.
getValue
().
equals
(
orderInfo
.
getCustomsType
())){
Integer
color
=
Integer
.
valueOf
(
IndexedColors
.
ORANGE
.
index
);
if
(
prodAttrTag
){
color
=
Integer
.
valueOf
(
IndexedColors
.
GREEN
.
index
);
}
int
andIncrement2
=
colorRowNum
.
get
();
colorMap2
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
color
));
colorMap
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
color
));
colorRowList
.
add
(
andIncrement2
);
colorRowList2
.
add
(
andIncrement2
);
}
else
{
if
(
prodAttrTag
){
int
andIncrement2
=
colorRowNum
.
get
();
colorMap2
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorMap
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorRowList
.
add
(
andIncrement2
);
colorRowList2
.
add
(
andIncrement2
);
}
else
if
(
prodAttrTag
){
int
andIncrement2
=
colorRowNum
.
get
();
colorMap2
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorMap
.
put
(
String
.
valueOf
(
andIncrement2
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorRowList
.
add
(
andIncrement2
);
colorRowList2
.
add
(
andIncrement2
);
}
}
}
List
<
OrderWarehouseInDO
>
orderWarehouseInDOS
=
orderWarehouseInService
.
selectList
(
OrderWarehouseInDO:
:
getOrderItemId
,
item
.
getOrderItemId
());
boolean
addColorFlag
=
true
;
for
(
OrderWarehouseInDO
orderWarehouseInDO
:
orderWarehouseInDOS
)
{
...
...
@@ -246,7 +299,6 @@ public class ShipmentLoadExcelExportListener2 {
}
int
mergeCount
=
1
;
int
mixedMergeCount
=
1
;
LoadDto
preloadDto
=
new
LoadDto
();
preloadDto
.
setOrderNo
(
orderInfo
.
getOrderNo
());
if
(
numMap
.
get
(
orderInfo
.
getOrderNo
())
!=
null
)
{
preloadDto
.
setId
(
String
.
valueOf
(
numMap
.
get
(
orderInfo
.
getOrderNo
())));
...
...
@@ -291,18 +343,16 @@ public class ShipmentLoadExcelExportListener2 {
return
DictFrameworkUtils
.
getDictDataFromCache
(
"warehousing_specification_type"
,
j
.
getSpecificationType
()
+
""
).
getLabel
();
}).
distinct
().
collect
(
Collectors
.
joining
(
"/"
));
String
packagingType
=
orderWarehouseInDOS
.
stream
().
map
(
j
->
{
return
DictFrameworkUtils
.
getDictDataFromCache
(
"packaging_type"
,
j
.
getUnit
()).
getLabel
();
return
DictFrameworkUtils
.
getDictDataFromCache
(
"packaging_type"
,
j
.
getUnit
()).
getLabel
()
+
"/"
+
DictFrameworkUtils
.
getDictDataFromCache
(
"packaging_type"
,
j
.
getUnit
()).
getLabelEn
()
;
}).
distinct
().
collect
(
Collectors
.
joining
(
"/"
));
preloadDto
.
setUnit
(
warehousingSpecificationType
);
preloadDto
.
setPackageType
(
packagingType
);
}
preloadDto
.
setSumVolume
(
item
.
getWarehouseInInfoVO
().
getVolume
());
preloadDto
.
setProdAttr
(
getAttrNameByIds
(
item
.
getProdAttrIds
(),
idNameMap
));
preloadDto
.
setUsageIds
(
getUsageMsg
(
item
.
getUsageIds
()));
preloadDto
.
setSumWeight
(
item
.
getWarehouseInInfoVO
().
getWeight
());
if
(
orderInfo
.
getCustomsType
()!=
null
){
preloadDto
.
setCustomsType
(
DictFrameworkUtils
.
getDictDataFromCache
(
"customs_type"
,
orderInfo
.
getCustomsType
()+
""
).
getLabel
());
}
totalWorth
=
totalWorth
.
add
(
item
.
getWorth
());
preloadDto
.
setWorth
(
item
.
getWorth
());
preloadDto
.
setQuantity
(
item
.
getWarehouseInInfoVO
().
getQuantityAll
());
list
.
add
(
preloadDto
);
...
...
@@ -352,42 +402,60 @@ public class ShipmentLoadExcelExportListener2 {
}
}
}
colorRowNum
.
getAndAdd
(
2
);
int
andIncrement
=
colorRowNum
.
getAndIncrement
();
colorMap2
.
put
(
String
.
valueOf
(
andIncrement
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorMap
.
put
(
String
.
valueOf
(
andIncrement
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorRowList
.
add
(
andIncrement
);
colorRowList2
.
add
(
andIncrement
);
colorRowNum
.
getAndAdd
(
1
);
LoadDto
preloadDto
=
new
LoadDto
();
preloadDto
.
setId
(
"TOTAL"
);
preloadDto
.
setSumNum
(
totalNum
);
preloadDto
.
setSumVolume
(
totalVolume
);
preloadDto
.
setSumWeight
(
totalWeight
);
preloadDto
.
setWorth
(
totalWorth
);
list
.
add
(
preloadDto
);
allTotalNum
=
allTotalNum
+
totalNum
;
allTotalVolume
=
allTotalVolume
.
add
(
totalVolume
);
allTotalWeight
=
allTotalWeight
.
add
(
totalWeight
);
allTotalWorth
=
allTotalWorth
.
add
(
totalWorth
);
if
(
i
==
secCount
.
size
()-
1
){
LoadDto
preloadDto1
=
new
LoadDto
();
preloadDto1
.
setId
(
"IN TOTAL"
);
preloadDto1
.
setProdAttr
(
"合计"
);
preloadDto1
.
setSumNum
(
allTotalNum
);
preloadDto1
.
setSumVolume
(
allTotalVolume
);
preloadDto1
.
setSumWeight
(
allTotalWeight
);
preloadDto1
.
setWorth
(
allTotalWorth
);
list
.
add
(
preloadDto1
);
colorMap2
.
put
(
String
.
valueOf
(
andIncrement
+
1
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorMap
.
put
(
String
.
valueOf
(
andIncrement
+
1
),
Integer
.
valueOf
(
IndexedColors
.
YELLOW
.
index
));
colorRowList
.
add
(
andIncrement
+
1
);
colorRowList2
.
add
(
andIncrement
+
1
);
}
WriteTable
writeTable
=
EasyExcel
.
writerTable
(
i
)
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
0
,
1
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
1
,
1
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
2
,
1
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
0
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
1
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
2
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
3
,
colorMap
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
4
,
colorMap
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
5
,
colorMap
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
6
,
colorMap
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
7
,
colorMap
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
8
,
2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
9
,
1
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
10
,
2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
11
,
2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
12
,
1
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
8
,
2
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
9
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
10
,
2
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
11
,
2
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
12
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
13
,
colorMap
))
.
registerWriteHandler
(
new
CustomCellWriteHandler
(
colorRowList
,
14
,
colorMap
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
17
,
1
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
18
,
2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
15
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
16
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
17
,
1
,
colorRowList2
,
colorMap2
))
.
registerWriteHandler
(
new
CustomLoadMergeStrategyNew
(
list
,
mergeCountList
,
18
,
2
,
colorRowList2
,
colorMap2
))
.
automaticMergeHead
(
true
).
head
(
headList
).
needHead
(
true
).
build
();
excelWriter
.
write
(
list
,
sheet
,
writeTable
);
}
...
...
yudao-module-shipment/yudao-module-shipment-core/src/main/java/cn/iocoder/yudao/module/shipment/utils/CustomLoadMergeStrategyNew.java
View file @
f93069a0
package
cn
.
iocoder
.
yudao
.
module
.
shipment
.
utils
;
import
cn.iocoder.yudao.module.shipment.dto.AirLoadDto
;
import
cn.iocoder.yudao.module.shipment.dto.LoadDto
;
import
com.alibaba.excel.metadata.CellData
;
import
com.alibaba.excel.metadata.Head
;
import
com.alibaba.excel.write.merge.AbstractMergeStrategy
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
com.alibaba.excel.write.metadata.holder.WriteSheetHolder
;
import
com.alibaba.excel.write.metadata.holder.WriteTableHolder
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -41,14 +42,33 @@ public class CustomLoadMergeStrategyNew extends AbstractMergeStrategy {
// 需要开始合并单元格的首行index
private
Integer
rowIndex
;
private
List
<
Integer
>
colorRowList
;
private
Map
<
String
,
Integer
>
colorMap
;
// exportDataList为待合并目标列的值 partMerge为另外一种合并方式计算好的合并行数,mergeType 合并类型 1为订单维度合并 2为入仓记录维度的合并
public
CustomLoadMergeStrategyNew
(
List
<
LoadDto
>
exportDataList
,
List
<
Integer
>
partMergeList
,
Integer
targetColumnIndex
,
int
mergeType
)
{
public
CustomLoadMergeStrategyNew
(
List
<
LoadDto
>
exportDataList
,
List
<
Integer
>
partMergeList
,
Integer
targetColumnIndex
,
int
mergeType
,
List
<
Integer
>
colorRowList
,
Map
<
String
,
Integer
>
colorMap
)
{
this
.
exportFieldGroupCountList
=
getGroupCountList
(
exportDataList
,
targetColumnIndex
);
this
.
partMergeList
=
partMergeList
;
this
.
mergeType
=
mergeType
;
this
.
targetColumnIndex
=
targetColumnIndex
;
this
.
colorRowList
=
colorRowList
;
this
.
colorMap
=
colorMap
;
}
@Override
public
void
afterCellDispose
(
WriteSheetHolder
writeSheetHolder
,
WriteTableHolder
writeTableHolder
,
List
<
CellData
>
cellDataList
,
Cell
cell
,
Head
head
,
Integer
relativeRowIndex
,
Boolean
isHead
)
{
Workbook
workbook
=
writeSheetHolder
.
getSheet
().
getWorkbook
();
if
(
colorRowList
.
contains
(
cell
.
getRowIndex
())
&&
cell
.
getColumnIndex
()
==
targetColumnIndex
)
{
CellStyle
cellStyle
=
workbook
.
createCellStyle
();
cellStyle
.
setFillForegroundColor
(
IndexedColors
.
fromInt
(
colorMap
.
get
(
String
.
valueOf
(
cell
.
getRowIndex
()))).
index
);
cellStyle
.
setFillPattern
(
FillPatternType
.
SOLID_FOREGROUND
);
cell
.
setCellStyle
(
cellStyle
);
}
if
(!
isHead
)
{
this
.
merge
(
writeSheetHolder
.
getSheet
(),
cell
,
head
,
relativeRowIndex
);
}
}
@Override
protected
void
merge
(
Sheet
sheet
,
Cell
cell
,
Head
head
,
Integer
relativeRowIndex
)
{
...
...
@@ -56,6 +76,7 @@ public class CustomLoadMergeStrategyNew extends AbstractMergeStrategy {
if
(
null
==
rowIndex
)
{
rowIndex
=
cell
.
getRowIndex
();
}
// 仅从首行以及目标列的单元格开始合并,忽略其他
if
(
cell
.
getRowIndex
()
==
rowIndex
&&
cell
.
getColumnIndex
()
==
targetColumnIndex
)
{
if
(
mergeType
==
1
)
{
...
...
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