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
44b45a50
Commit
44b45a50
authored
Jun 11, 2024
by
liuzeheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
颜色标识
parent
b99c08a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
1 deletion
+83
-1
ShipmentLoadExcelExportListener.java
...le/shipment/listener/ShipmentLoadExcelExportListener.java
+83
-1
No files found.
yudao-module-shipment/yudao-module-shipment-core/src/main/java/cn/iocoder/yudao/module/shipment/listener/ShipmentLoadExcelExportListener.java
View file @
44b45a50
...
...
@@ -5,6 +5,7 @@ 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.ShipmentPreloadExcelExportPushEvent
;
import
cn.iocoder.yudao.framework.common.util.date.DateUtils
;
import
cn.iocoder.yudao.framework.common.util.json.JsonUtils
;
import
cn.iocoder.yudao.framework.common.util.number.NumberUtils
;
import
cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX
;
...
...
@@ -20,7 +21,9 @@ import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseIn.OrderWareho
import
cn.iocoder.yudao.module.order.dto.OrderBackInfoDto
;
import
cn.iocoder.yudao.module.order.service.order.*
;
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.OrderWarehouseInBackItemVO
;
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.productbrank.ProductBrankDO
;
...
...
@@ -33,6 +36,7 @@ import cn.iocoder.yudao.module.shipment.dto.PreloadDto;
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.CustomMergeStrategy
;
import
cn.iocoder.yudao.module.shipment.vo.boxPreloadGoods.BoxPreloadGoodsBackVO
;
import
cn.iocoder.yudao.module.system.framework.ue.UeProperties
;
...
...
@@ -40,6 +44,7 @@ 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
;
...
...
@@ -57,6 +62,7 @@ import java.math.BigDecimal;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
pojo
.
CommonResult
.
error
;
...
...
@@ -110,6 +116,18 @@ public class ShipmentLoadExcelExportListener {
@Resource
private
ProductAttrService
productAttrService
;
private
static
List
<
Integer
>
colorList
=
new
ArrayList
<>();
static
{
colorList
.
add
(
22
);
colorList
.
add
(
41
);
colorList
.
add
(
42
);
colorList
.
add
(
43
);
colorList
.
add
(
44
);
colorList
.
add
(
45
);
colorList
.
add
(
46
);
colorList
.
add
(
47
);
}
/**
* 订单导出监听
*
...
...
@@ -253,6 +271,13 @@ public class ShipmentLoadExcelExportListener {
Long
part
=
secCount
.
get
(
i
);
List
<
Integer
>
mergeCountList
=
new
ArrayList
();
List
<
Integer
>
colorRowList
=
new
ArrayList
<>();
AtomicInteger
colorRowNum
=
new
AtomicInteger
(
6
);
Map
<
String
,
Integer
>
colorMap
=
new
HashMap
<>();
Map
<
String
,
Integer
>
mergePkgCountMap
=
new
LinkedHashMap
<>();
int
colorIndex
=
0
;
//以订单ID分组
Map
<
Long
,
List
<
BoxPreloadGoodsBackVO
>>
orderMap
=
goodsItemList
.
stream
().
filter
(
item
->
item
.
getSecId
().
longValue
()
==
...
...
@@ -261,13 +286,70 @@ public class ShipmentLoadExcelExportListener {
.
collect
(
Collectors
.
groupingBy
(
BoxPreloadGoodsBackVO:
:
getOrderId
,
LinkedHashMap:
:
new
,
Collectors
.
toList
()));
for
(
Map
.
Entry
<
Long
,
List
<
BoxPreloadGoodsBackVO
>>
entry
:
orderMap
.
entrySet
())
{
Long
orderId
=
entry
.
getKey
();
Long
pkgId
=
entry
.
getValue
().
get
(
0
).
getPkgId
();
//OrderBackInfoDto orderInfo = orderQueryService.info(orderId);
//OrderDO orderDO = orderService.selectOne(OrderDO::getOrderId, orderId);
List
<
OrderWarehouseInBackItemVO
>
orderWarehouseInBackItemVOS
=
orderWarehouseInService
.
getOrderWarehouseInListOrderByInTime
(
orderId
);
for
(
OrderWarehouseInBackItemVO
item
:
orderWarehouseInBackItemVOS
)
{
int
andIncrement
=
colorRowNum
.
getAndIncrement
();
if
(
StringUtils
.
isNotBlank
(
item
.
getOrderWarehouseInDetails
()))
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
item
.
getOrderWarehouseInDetails
());
if
(
jsonArray
.
size
()
>
0
)
{
colorMap
.
put
(
String
.
valueOf
(
andIncrement
),
colorList
.
get
(
colorIndex
));
colorRowList
.
add
(
andIncrement
);
//这里加1是为了设置颜色时过滤掉入仓记录那条
}
}
int
mergeCount
=
1
;
if
(
StringUtils
.
isNotBlank
(
item
.
getOrderWarehouseInDetails
()))
{
item
.
setOrderWarehouseInDetailsVOList
(
JsonUtils
.
parseArray
(
item
.
getOrderWarehouseInDetails
(),
OrderWarehouseInDetailsVO
.
class
));
}
if
(
CollectionUtil
.
isNotEmpty
(
item
.
getOrderWarehouseInDetailsVOList
()))
{
mergeCount
=
mergeCount
+
item
.
getOrderWarehouseInDetailsVOList
().
size
();
List
<
OrderWarehouseInDetailsVO
>
orderWarehouseInDetailsVOList
=
item
.
getOrderWarehouseInDetailsVOList
();
for
(
int
j
=
0
;
j
<
orderWarehouseInDetailsVOList
.
size
();
j
++)
{
int
andIncrement1
=
colorRowNum
.
getAndIncrement
();
colorMap
.
put
(
String
.
valueOf
(
andIncrement1
),
colorList
.
get
(
colorIndex
));
colorRowList
.
add
(
andIncrement1
);
}
}
mergeCountList
.
add
(
mergeCount
);
if
(
colorIndex
==
7
)
{
colorIndex
=
0
;
}
else
{
colorIndex
++;
}
//合包那几个列合并单元格计算
if
(
pkgId
.
longValue
()
!=
0L
)
{
if
(
mergePkgCountMap
.
get
(
String
.
valueOf
(
pkgId
))
==
null
)
{
mergePkgCountMap
.
put
(
String
.
valueOf
(
pkgId
),
mergeCount
);
}
else
{
Integer
sumMergePkgCount
=
mergePkgCountMap
.
get
(
String
.
valueOf
(
pkgId
))
+
mergeCount
;
mergePkgCountMap
.
put
(
String
.
valueOf
(
pkgId
),
sumMergePkgCount
);
}
}
else
{
mergePkgCountMap
.
put
(
String
.
valueOf
(
item
.
getId
()),
mergeCount
);
}
}
}
//registerWriteHandler(new XXXStrategy(需要的参数))
//自定义单元格合并策略
WriteTable
writeTable
=
EasyExcel
.
writerTable
(
i
)
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
0
,
true
))
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
1
,
true
))
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
2
,
true
))
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
7
,
true
))
//2024-06-11 begin
.
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 CustomMergeStrategy(orderMap, null, null, 7, true)) //end
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
10
,
true
))
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
12
,
true
))
.
registerWriteHandler
(
new
CustomMergeStrategy
(
orderMap
,
null
,
null
,
13
,
true
))
...
...
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