Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mes
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
ximai
mes
Commits
821302bc
Commit
821302bc
authored
Sep 04, 2024
by
李驰骋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
排产调整
parent
29b72ed0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
316 additions
and
348 deletions
+316
-348
BaseController.java
...java/com/ximai/common/core/controller/BaseController.java
+1
-1
PageParams.java
...rc/main/java/com/ximai/common/core/domain/PageParams.java
+9
-41
DictUtils.java
common/src/main/java/com/ximai/common/utils/DictUtils.java
+4
-0
mapper.xml.vm
generator/src/main/resources/vm/xml/mapper.xml.vm
+6
-6
ProWorkorderController.java
...s/pro/controller/proWorkOrder/ProWorkorderController.java
+23
-3
ProTaskController.java
.../com/ximai/mes/pro/controller/task/ProTaskController.java
+1
-5
ProProductQrcodeRule.java
...n/java/com/ximai/mes/pro/domain/ProProductQrcodeRule.java
+10
-0
ProWorkorder.java
...a/com/ximai/mes/pro/domain/proWorkOrder/ProWorkorder.java
+33
-37
WorkorderScheduleParams.java
...om/ximai/mes/pro/domain/task/WorkorderScheduleParams.java
+6
-2
ProWorkorderQuery.java
...n/java/com/ximai/mes/pro/domain/vo/ProWorkorderQuery.java
+0
-9
AlgorithmDataSource.java
.../java/com/ximai/mes/pro/schedule/AlgorithmDataSource.java
+5
-3
AlgorithmDataSourceImpl.java
.../ximai/mes/pro/schedule/impl/AlgorithmDataSourceImpl.java
+14
-13
AlgorithmResultProcessImpl.java
...mai/mes/pro/schedule/impl/AlgorithmResultProcessImpl.java
+1
-0
BaoshenScheduleAlgorithmAdapter.java
...es/pro/schedule/impl/BaoshenScheduleAlgorithmAdapter.java
+6
-5
IScheduleAlgorithmAdapter.java
...imai/mes/pro/schedule/impl/IScheduleAlgorithmAdapter.java
+3
-1
IProProductQrcodeRuleService.java
...m/ximai/mes/pro/service/IProProductQrcodeRuleService.java
+7
-0
ProProductQrcodeRuleServiceImpl.java
...mes/pro/service/impl/ProProductQrcodeRuleServiceImpl.java
+22
-0
ProWorkorderServiceImpl.java
...ro/service/impl/proWorkOrder/ProWorkorderServiceImpl.java
+0
-8
ProTaskServiceImpl.java
...m/ximai/mes/pro/service/impl/task/ProTaskServiceImpl.java
+3
-5
IProTaskService.java
.../java/com/ximai/mes/pro/service/task/IProTaskService.java
+2
-1
ProProductQrcodeRecordMapper.xml
...ain/resources/mapper/pro/ProProductQrcodeRecordMapper.xml
+129
-0
BaoshenScheduleAlgorithmAdapterTest.java
.../bs/mes/schedule/BaoshenScheduleAlgorithmAdapterTest.java
+31
-30
ApiExcetlTest.java
mes/src/test/java/com/bs/mes/schedule/api/ApiExcetlTest.java
+0
-50
CalendarManagerTest.java
...est/java/com/bs/mes/schedule/api/CalendarManagerTest.java
+0
-128
No files found.
common/src/main/java/com/ximai/common/core/controller/BaseController.java
View file @
821302bc
...
...
@@ -55,7 +55,7 @@ public class BaseController {
}
protected
static
void
startPage
(
final
PageParams
pageParams
)
{
PageUtils
.
startPage
();
PageUtils
.
startPage
(
pageParams
);
}
/**
...
...
common/src/main/java/com/ximai/common/core/domain/PageParams.java
View file @
821302bc
package
com
.
ximai
.
common
.
core
.
domain
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
PageParams
{
/**
* 当前记录起始索引
*/
public
static
Integer
pageNum
;
@ApiModelProperty
(
"页数"
)
public
Integer
pageNum
;
/**
* 每页显示记录数
*/
@ApiModelProperty
(
"分页SIZE"
)
public
Integer
pageSize
;
/**
* 排序列
*/
@ApiModelProperty
(
"排序列"
)
public
String
orderByColumn
;
/**
* 排序的方向 "desc" 或者 "asc".
*/
@ApiModelProperty
(
"排序方向"
)
public
String
isAsc
;
/**
* 分页参数合理化
*/
public
Boolean
reasonable
;
public
static
Integer
getPageNum
()
{
return
pageNum
;
}
public
static
void
setPageNum
(
Integer
pageNum
)
{
PageParams
.
pageNum
=
pageNum
;
}
public
Integer
getPageSize
()
{
return
pageSize
;
}
public
void
setPageSize
(
Integer
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
public
String
getOrderByColumn
()
{
return
orderByColumn
;
}
public
void
setOrderByColumn
(
String
orderByColumn
)
{
this
.
orderByColumn
=
orderByColumn
;
}
public
String
getIsAsc
()
{
return
isAsc
;
}
public
void
setIsAsc
(
String
isAsc
)
{
this
.
isAsc
=
isAsc
;
}
public
Boolean
getReasonable
()
{
return
reasonable
;
}
public
void
setReasonable
(
Boolean
reasonable
)
{
this
.
reasonable
=
reasonable
;
}
}
common/src/main/java/com/ximai/common/utils/DictUtils.java
View file @
821302bc
package
com
.
ximai
.
common
.
utils
;
import
java.util.Calendar
;
import
java.util.Collection
;
import
java.util.List
;
import
cn.hutool.core.date.DateUtil
;
import
com.ximai.common.constant.Constants
;
import
com.ximai.common.core.domain.entity.SysDictData
;
import
com.ximai.common.core.redis.RedisCache
;
...
...
@@ -179,4 +182,5 @@ public class DictUtils
{
return
Constants
.
SYS_DICT_KEY
+
configKey
;
}
}
generator/src/main/resources/vm/xml/mapper.xml.vm
View file @
821302bc
...
...
@@ -5,15 +5,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper
namespace=
"${packageName}.mapper${childPackageName}.${ClassName}Mapper"
>
<resultMap
type=
"${ClassName}"
id=
"${ClassName}Result"
>
#foreach ($column in $columns)
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
#end
#foreach ($column in $columns)
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
#end
</resultMap>
<resultMap
type=
"${packageName}.dto${childPackageName}.${ClassName}Dto"
id=
"${ClassName}Result2"
>
#foreach ($column in $columns)
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
#end
#foreach ($column in $columns)
<result
property=
"${column.javaField}"
column=
"${column.columnName}"
/>
#end
</resultMap>
#if($table.sub)
...
...
mes/src/main/java/com/ximai/mes/pro/controller/proWorkOrder/ProWorkorderController.java
View file @
821302bc
...
...
@@ -97,10 +97,30 @@ public class ProWorkorderController extends BaseController {
@ApiOperation
(
"工单查询"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
<
ProWorkorder
>
list
(
ProWorkorderQuery
proWorkorder
)
{
startPage
();
List
<
ProWorkorder
>
list
=
proWorkorderService
.
selectProWorkorderList
(
proWorkorder
);
// List<ProWorkorder> workorderList = list.stream().filter(x -> x.getStatus() != WorkorderStatusEnum.CLOSE.getValue()).collect(Collectors.toList());
return
getDataTable
(
list
);
return
getManualDataTable
(
list
);
}
/**
* 查询待排产生产工单列表
*/
@ApiOperation
(
"查询待排产生产工单列表"
)
@GetMapping
(
"/scheduleList"
)
public
TableDataInfo
<
ProWorkorder
>
scheduleList
(
ProWorkorderQuery
proWorkorder
)
{
QueryWrapper
<
ProWorkorder
>
query
=
new
QueryWrapper
<>();
query
.
like
(
StringUtils
.
isNotEmpty
(
proWorkorder
.
getWorkorderCode
()),
"t1.workorder_code"
,
proWorkorder
.
getWorkorderCode
());
query
.
like
(
StringUtils
.
isNotEmpty
(
proWorkorder
.
getProductCode
()),
"t1.product_code"
,
proWorkorder
.
getProductCode
());
query
.
like
(
StringUtils
.
isNotEmpty
(
proWorkorder
.
getProductName
()),
"t1.product_name"
,
proWorkorder
.
getProductName
());
query
.
in
(
StringUtils
.
isNotEmpty
(
proWorkorder
.
getStatusArr
()),
"t1.status"
,
proWorkorder
.
getStatusArr
());
query
.
in
(
StringUtils
.
isNotEmpty
(
proWorkorder
.
getStatusArr
()),
"t1.status"
,
new
String
[]{
WorkorderStatusEnum
.
PREPARE
.
getValue
(),
WorkorderStatusEnum
.
PUBLISHED
.
getValue
()});
query
.
gt
(
"t1.quantity-t1.quantity_scheduled"
,
0
);
List
<
ProWorkorder
>
list
=
proWorkorderService
.
selectListByQw
(
query
);
return
getManualDataTable
(
list
);
}
...
...
mes/src/main/java/com/ximai/mes/pro/controller/task/ProTaskController.java
View file @
821302bc
...
...
@@ -334,11 +334,7 @@ public class ProTaskController extends BaseController {
@Log
(
title
=
"生产任务排产"
,
businessType
=
BusinessType
.
OTHER
)
@PostMapping
(
"/schedule"
)
public
AjaxResult
schedule
(
@ApiParam
(
value
=
"工单属性集合"
,
required
=
true
)
@RequestBody
List
<
WorkorderScheduleParams
>
params
)
{
List
<
String
>
arrangeCodes
=
params
.
stream
().
map
(
WorkorderScheduleParams:
:
getArrangeCode
).
collect
(
Collectors
.
toList
());
QueryWrapper
<
ProWorkorder
>
queryWrapper
=
new
QueryWrapper
<
ProWorkorder
>();
queryWrapper
.
in
(
"arrange_code"
,
arrangeCodes
);
List
<
ProWorkorder
>
list
=
proWorkorderService
.
selectListByQw
(
queryWrapper
);
proTaskService
.
schedule
(
list
.
stream
().
map
(
ProWorkorder:
:
getWorkorderId
).
collect
(
Collectors
.
toList
()));
proTaskService
.
schedule
(
params
);
return
AjaxResult
.
success
();
}
...
...
mes/src/main/java/com/ximai/mes/pro/domain/ProProductQrcodeRule.java
View file @
821302bc
package
com
.
ximai
.
mes
.
pro
.
domain
;
import
cn.hutool.core.date.DateUtil
;
import
io.swagger.annotations.ApiModelProperty
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
com.ximai.common.core.domain.BaseEntity
;
import
org.apache.commons.lang3.StringUtils
;
import
java.time.LocalDateTime
;
/**
* 产品二维码规则对象 pro_product_qrcode_rule
...
...
@@ -56,5 +60,11 @@ public class ProProductQrcodeRule extends BaseEntity {
private
Integer
currentSerial
;
public
String
buildQrcode
(){
String
rst
=
this
.
getPrefix
()
+
DateUtil
.
format
(
LocalDateTime
.
now
(),
this
.
getDatePattern
())
+
StringUtils
.
leftPad
(
currentSerial
+
""
,
serialLen
,
"0"
);
return
rst
;
}
}
mes/src/main/java/com/ximai/mes/pro/domain/proWorkOrder/ProWorkorder.java
View file @
821302bc
...
...
@@ -111,21 +111,6 @@ public class ProWorkorder extends TreeEntity {
*/
@Excel
(
name
=
"产品名称"
)
private
String
productName
;
//产品分类
@TableField
(
exist
=
false
)
private
String
itemTypeName
;
@TableField
(
exist
=
false
)
private
Long
itemTypeId
;
@TableField
(
exist
=
false
)
private
double
processingRatio
;
@TableField
(
exist
=
false
)
private
Double
feedBackedQuantity
;
/**
* 规格型号
*/
...
...
@@ -135,7 +120,7 @@ public class ProWorkorder extends TreeEntity {
/**
* 单位
*/
@
Excel
(
name
=
"单位"
)
@
ApiModelProperty
(
"单位"
)
private
String
unitOfMeasure
;
/**
...
...
@@ -160,7 +145,7 @@ public class ProWorkorder extends TreeEntity {
/**
* 已生产数量
*/
@
Excel
(
name
=
"已生产数量"
)
@
ApiModelProperty
(
"已生产数量"
)
private
BigDecimal
quantityProduced
;
@ApiModelProperty
(
"合格数量"
)
...
...
@@ -178,7 +163,7 @@ public class ProWorkorder extends TreeEntity {
/**
* 已排产数量
*/
@
Excel
(
name
=
"已排产数量"
)
@
ApiModelProperty
(
"已排产数量"
)
private
BigDecimal
quantityScheduled
;
/**
...
...
@@ -237,25 +222,6 @@ public class ProWorkorder extends TreeEntity {
*/
@Excel
(
name
=
"单据状态"
)
private
String
status
;
@TableField
(
exist
=
false
)
private
Long
taskId
;
@TableField
(
exist
=
false
)
private
String
combinationCode
;
@TableField
(
exist
=
false
)
private
String
workorderIds
;
@TableField
(
exist
=
false
)
private
List
<
ProTask
>
tasks
;
@TableField
(
exist
=
false
)
private
List
<
ProTaskVo
>
taskVos
;
@TableField
(
exist
=
false
)
private
List
<
ProTaskWorkunit
>
proTaskWorkunits
;
/**
* 任务清单组键值
*/
...
...
@@ -364,5 +330,35 @@ public class ProWorkorder extends TreeEntity {
@TableField
(
exist
=
false
)
private
Date
combinationStartTime
;
//产品分类
@TableField
(
exist
=
false
)
private
String
itemTypeName
;
@TableField
(
exist
=
false
)
private
Long
itemTypeId
;
@TableField
(
exist
=
false
)
private
double
processingRatio
;
@TableField
(
exist
=
false
)
private
Double
feedBackedQuantity
;
@TableField
(
exist
=
false
)
private
Long
taskId
;
@TableField
(
exist
=
false
)
private
String
combinationCode
;
@TableField
(
exist
=
false
)
private
String
workorderIds
;
@TableField
(
exist
=
false
)
private
List
<
ProTask
>
tasks
;
@TableField
(
exist
=
false
)
private
List
<
ProTaskVo
>
taskVos
;
@TableField
(
exist
=
false
)
private
List
<
ProTaskWorkunit
>
proTaskWorkunits
;
}
mes/src/main/java/com/ximai/mes/pro/domain/task/WorkorderScheduleParams.java
View file @
821302bc
...
...
@@ -3,11 +3,15 @@ package com.ximai.mes.pro.domain.task;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
@Data
public
class
WorkorderScheduleParams
{
@ApiModelProperty
(
"工单ID"
)
Long
workorderId
;
@ApiModelProperty
(
"编排单号"
)
String
arrangeCode
;
@ApiModelProperty
(
"本次排产数量"
)
BigDecimal
scheduleQuantity
;
}
mes/src/main/java/com/ximai/mes/pro/domain/vo/ProWorkorderQuery.java
View file @
821302bc
...
...
@@ -173,8 +173,6 @@ public class ProWorkorderQuery extends BaseEntity {
@TableField
(
exist
=
false
)
private
String
itemTypeName
;
/**
* 需求日期
*/
...
...
@@ -226,15 +224,8 @@ public class ProWorkorderQuery extends BaseEntity {
*/
private
Long
attr4
;
private
Long
taskId
;
private
Long
taskWorkunitId
;
private
String
parentId
;
@ApiModelProperty
(
hidden
=
true
)
@TableField
(
exist
=
false
)
private
List
<
ProTask
>
tasks
;
@TableField
(
exist
=
false
)
private
List
<
Long
>
workorderIds
;
...
...
mes/src/main/java/com/ximai/mes/pro/schedule/AlgorithmDataSource.java
View file @
821302bc
package
com
.
ximai
.
mes
.
pro
.
schedule
;
import
com.ximai.mes.pro.domain.task.WorkorderScheduleParams
;
import
java.time.LocalDateTime
;
import
java.util.List
;
...
...
@@ -14,7 +16,7 @@ public interface AlgorithmDataSource {
* @param orderIds 工单ID
* @return
*/
public
List
<
Resource
>
getResource
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
);
public
List
<
Resource
>
getResource
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
);
/**
* 获取工单工序作务数据
...
...
@@ -23,7 +25,7 @@ public interface AlgorithmDataSource {
* @param resources 资源ID
* @return
*/
public
List
<
Job
>
getJob
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
,
List
<
Resource
>
resources
);
public
List
<
Job
>
getJob
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
,
List
<
Resource
>
resources
);
/**
* 获取日历数据
...
...
@@ -32,7 +34,7 @@ public interface AlgorithmDataSource {
* @param resources 资源ID
* @return
*/
public
List
<
Calendar
>
getCalendar
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
,
List
<
Resource
>
resources
);
public
List
<
Calendar
>
getCalendar
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
,
List
<
Resource
>
resources
);
}
mes/src/main/java/com/ximai/mes/pro/schedule/impl/AlgorithmDataSourceImpl.java
View file @
821302bc
...
...
@@ -15,6 +15,7 @@ import com.ximai.mes.pro.domain.productionSolution.ProProductionSolution;
import
com.ximai.mes.pro.domain.productionSolution.ProProductionSolutionProcess
;
import
com.ximai.mes.pro.domain.productionSolution.ProProductionSolutionSpecificationSheet
;
import
com.ximai.mes.pro.domain.task.ProTaskWorkunit
;
import
com.ximai.mes.pro.domain.task.WorkorderScheduleParams
;
import
com.ximai.mes.pro.schedule.*
;
import
com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderProcessService
;
import
com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService
;
...
...
@@ -63,7 +64,7 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Override
public
List
<
Resource
>
getResource
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
)
{
public
List
<
Resource
>
getResource
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
)
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
QueryWrapper
<
MdWorkunitVo
>
query
=
new
QueryWrapper
<
MdWorkunitVo
>();
...
...
@@ -98,25 +99,25 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
}
@Override
public
List
<
Job
>
getJob
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
,
List
<
Resource
>
resources
)
{
public
List
<
Job
>
getJob
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
,
List
<
Resource
>
resources
)
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
List
<
Job
>
algJobs
=
new
ArrayList
<
Job
>();
//查询相关工单,工单编排单号也需一并查询出来
QueryWrapper
<
ProWorkorder
>
queryWrapper
=
new
QueryWrapper
<
ProWorkorder
>();
queryWrapper
.
in
(
"workorder_id"
,
orderIds
);
queryWrapper
.
in
(
"workorder_id"
,
workorderScheduleParams
.
stream
().
map
(
s
->
s
.
getWorkorderId
()).
collect
(
Collectors
.
toList
())
);
List
<
ProWorkorder
>
workorderList
=
proWorkorderService
.
selectListByQw
(
queryWrapper
);
Map
<
String
,
List
<
ProWorkorder
>>
workorderMap
=
workorderList
.
stream
().
collect
(
Collectors
.
groupingBy
(
s
->
s
.
getArrangeCode
()
));
Map
<
Long
,
WorkorderScheduleParams
>
workorderScheduleParamsMap
=
workorderScheduleParams
.
stream
().
collect
(
Collectors
.
toMap
(
s
->
s
.
getWorkorderId
(),
s
->
s
));
List
<
ScheduleJobGroup
>
scheduleJobGroupList
=
new
ArrayList
<
ScheduleJobGroup
>();
for
(
String
arrangeCode
:
workorderMap
.
keySet
())
{
List
<
ProWorkorder
>
list
=
workorderMap
.
get
(
arrangeCode
);
for
(
ProWorkorder
workorder
:
workorderList
)
{
ScheduleJobGroup
scheduleJobGroup
=
new
ScheduleJobGroup
();
List
<
ProWorkorder
>
list
=
new
ArrayList
<>();
list
.
add
(
workorder
);
scheduleJobGroup
.
setWorkorderList
(
list
);
BigDecimal
total
=
list
.
stream
().
map
(
ProWorkorder:
:
getQuantity
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
LocalDateTime
recentDate
=
list
.
stream
().
map
(
s
->
DateUtil
.
toLocalDateTime
(
s
.
getRequestDate
())).
min
(
Comparator
.
comparing
(
LocalDateTime:
:
toLocalDate
)).
get
();
scheduleJobGroup
.
setQuantity
(
total
);
scheduleJobGroup
.
setArrangeCode
(
arrangeCode
);
scheduleJobGroup
.
setQuantity
(
workorderScheduleParamsMap
.
get
(
workorder
.
getWorkorderId
()).
getScheduleQuantity
());
scheduleJobGroup
.
setDemandDate
(
recentDate
);
scheduleJobGroup
.
setWorkorderCode
(
workorder
.
getWorkorderCode
());
scheduleJobGroupList
.
add
(
scheduleJobGroup
);
}
//按交期近,数量少排序
...
...
@@ -142,7 +143,7 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
ProProductionSolutionSpecificationSheet
specificationSheet
=
proProductionSolutionSpecificationSheetService
.
selectSpecificationSheetByProductionSolutionId
(
productionSolution
.
getProductionSolutionId
());
// 工序分组 生成Job及Task
Job
job
=
new
Job
(
scheduleJobGroup
.
get
Arrange
Code
(),
Duration
.
between
(
schedulingStartedDate
,
DateUtil
.
date
(
scheduleJobGroup
.
getDemandDate
()).
toLocalDateTime
()))
{{
Job
job
=
new
Job
(
scheduleJobGroup
.
get
Workorder
Code
(),
Duration
.
between
(
schedulingStartedDate
,
DateUtil
.
date
(
scheduleJobGroup
.
getDemandDate
()).
toLocalDateTime
()))
{{
setFixed
(
false
);
}};
JobExtent
jobExtent
=
new
JobExtent
();
...
...
@@ -200,7 +201,7 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
}
@Override
public
List
<
Calendar
>
getCalendar
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
,
List
<
Resource
>
resources
)
{
public
List
<
Calendar
>
getCalendar
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
,
List
<
Resource
>
resources
)
{
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
Map
<
Long
,
Resource
>
resourceMap
=
resources
.
stream
().
collect
(
Collectors
.
toMap
(
s
->
s
.
getId
(),
s
->
s
));
...
...
@@ -254,8 +255,8 @@ public class AlgorithmDataSourceImpl implements AlgorithmDataSource {
LocalDateTime
demandDate
;
//总数量
BigDecimal
quantity
;
//
编排
单号
String
arrange
Code
;
//
工单
单号
String
workorder
Code
;
}
}
mes/src/main/java/com/ximai/mes/pro/schedule/impl/AlgorithmResultProcessImpl.java
View file @
821302bc
...
...
@@ -102,6 +102,7 @@ public class AlgorithmResultProcessImpl implements AlgorithmResultProcess {
proWorkorderUpdate
.
setStatus
(
WorkorderStatusEnum
.
ISSUED
.
getValue
());
proWorkorderUpdate
.
setArrangeCode
(
workorder
.
getArrangeCode
());
proWorkorderUpdate
.
setWorkorderId
(
workorder
.
getWorkorderId
());
proWorkorderUpdate
.
setQuantityScheduled
(
proWorkorderUpdate
.
getQuantityScheduled
().
add
(
task
.
getOrderQuantity
()));
proWorkorderService
.
updateProWorkorder
(
proWorkorderUpdate
);
j
++;
}
...
...
mes/src/main/java/com/ximai/mes/pro/schedule/impl/BaoshenScheduleAlgorithmAdapter.java
View file @
821302bc
...
...
@@ -2,6 +2,7 @@ package com.ximai.mes.pro.schedule.impl;
import
cn.hutool.core.date.StopWatch
;
import
com.ximai.common.exception.ServiceException
;
import
com.ximai.mes.pro.domain.task.WorkorderScheduleParams
;
import
com.ximai.mes.pro.schedule.*
;
import
com.ximai.mes.pro.schedule.Calendar
;
import
com.ximai.mes.pro.schedule.strategy.EquipmentSelectionStrategy
;
...
...
@@ -27,7 +28,7 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
protected
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Override
public
List
<
ScheduledResult
>
schedule
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
)
{
public
List
<
ScheduledResult
>
schedule
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
)
{
logger
.
info
(
"----------排产开始----------"
);
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
...
...
@@ -35,9 +36,9 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
StopWatch
stopWatch2
=
new
StopWatch
();
stopWatch2
.
start
();
List
<
Resource
>
algResources
=
algorithmDataSource
.
getResource
(
schedulingStartedDate
,
orderId
s
);
List
<
Job
>
algJobs
=
algorithmDataSource
.
getJob
(
schedulingStartedDate
,
orderId
s
,
algResources
);
List
<
Calendar
>
algCalendar
=
algorithmDataSource
.
getCalendar
(
schedulingStartedDate
,
orderId
s
,
algResources
);
List
<
Resource
>
algResources
=
algorithmDataSource
.
getResource
(
schedulingStartedDate
,
workorderScheduleParam
s
);
List
<
Job
>
algJobs
=
algorithmDataSource
.
getJob
(
schedulingStartedDate
,
workorderScheduleParam
s
,
algResources
);
List
<
Calendar
>
algCalendar
=
algorithmDataSource
.
getCalendar
(
schedulingStartedDate
,
workorderScheduleParam
s
,
algResources
);
stopWatch2
.
stop
();
logger
.
info
(
String
.
format
(
"排产数据加载总耗时:%s"
,
stopWatch2
.
getTotalTimeSeconds
()));
if
(
algorithmExtendDataSources
!=
null
){
...
...
@@ -45,7 +46,7 @@ public class BaoshenScheduleAlgorithmAdapter implements IScheduleAlgorithmAdapte
setJobs
(
algJobs
);
setCalendars
(
algCalendar
);
setResources
(
algResources
);
setWorkorderIds
(
orderIds
);
setWorkorderIds
(
workorderScheduleParams
.
stream
().
map
(
s
->
s
.
getWorkorderId
()).
collect
(
Collectors
.
toList
())
);
}};
algorithmExtendDataSources
.
forEach
(
s
->{
s
.
extendData
(
algorithmDataContext
);
...
...
mes/src/main/java/com/ximai/mes/pro/schedule/impl/IScheduleAlgorithmAdapter.java
View file @
821302bc
package
com
.
ximai
.
mes
.
pro
.
schedule
.
impl
;
import
com.ximai.mes.pro.domain.task.WorkorderScheduleParams
;
import
java.time.LocalDateTime
;
import
java.util.List
;
...
...
@@ -11,6 +13,6 @@ public interface IScheduleAlgorithmAdapter {
* @param orderIds 工单集合
* @return
*/
List
<
ScheduledResult
>
schedule
(
LocalDateTime
schedulingStartedDate
,
List
<
Long
>
orderId
s
);
List
<
ScheduledResult
>
schedule
(
LocalDateTime
schedulingStartedDate
,
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
);
}
mes/src/main/java/com/ximai/mes/pro/service/IProProductQrcodeRuleService.java
View file @
821302bc
...
...
@@ -86,4 +86,11 @@ public interface IProProductQrcodeRuleService
* @return 结果
*/
public
int
deleteProProductQrcodeRuleByRuleId
(
Long
ruleId
);
/**
* 获取产品序列编码
* @param rule
* @return
*/
public
String
buildQrcode
(
ProProductQrcodeRule
rule
);
}
mes/src/main/java/com/ximai/mes/pro/service/impl/ProProductQrcodeRuleServiceImpl.java
View file @
821302bc
package
com
.
ximai
.
mes
.
pro
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.ximai.common.utils.data.DateUtils
;
...
...
@@ -133,4 +134,25 @@ public class ProProductQrcodeRuleServiceImpl implements IProProductQrcodeRuleSer
public
int
deleteProProductQrcodeRuleByRuleId
(
Long
ruleId
)
{
return
proProductQrcodeRuleMapper
.
deleteProProductQrcodeRuleByRuleId
(
ruleId
);
}
@Override
public
String
buildQrcode
(
ProProductQrcodeRule
rule
)
{
String
rst
=
rule
.
buildQrcode
();
//当前流水+1
rule
.
setCurrentSerial
(
rule
.
getCurrentSerial
()+
1
);
proProductQrcodeRuleMapper
.
updateById
(
rule
);
return
rst
;
}
public
List
<
String
>
buildQrcode
(
ProProductQrcodeRule
rule
,
Integer
quantity
)
{
List
<
String
>
rst
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
quantity
;
i
++){
String
temp
=
rule
.
buildQrcode
();
rst
.
add
(
temp
);
rule
.
setCurrentSerial
(
rule
.
getCurrentSerial
()+
1
);
}
proProductQrcodeRuleMapper
.
updateById
(
rule
);
return
rst
;
}
}
mes/src/main/java/com/ximai/mes/pro/service/impl/proWorkOrder/ProWorkorderServiceImpl.java
View file @
821302bc
...
...
@@ -581,14 +581,6 @@ public class ProWorkorderServiceImpl implements IProWorkorderService {
rst
.
add
(
workorderVo
);
});
ProProductionSolutionProcessVo
processVo
=
solutionProcessMapper
.
selectObjByTwIdAndPIdAndWoId
(
proWorkorder
.
getTaskWorkunitId
(),
proWorkorder
.
getProcessId
());
if
(
processVo
!=
null
)
{
for
(
ProWorkorderVo
proWorkorderVo
:
rst
)
{
proWorkorderVo
.
setUnitOfConvert
(
processVo
.
getUnitConvert
()
==
null
||
processVo
.
getUnitConvert
().
doubleValue
()
==
0
?
"1"
:
processVo
.
getUnitConvert
().
toString
());
}
}
return
rst
;
}
...
...
mes/src/main/java/com/ximai/mes/pro/service/impl/task/ProTaskServiceImpl.java
View file @
821302bc
...
...
@@ -1843,7 +1843,7 @@ public class ProTaskServiceImpl implements IProTaskService {
@Transactional
@Override
public
void
schedule
(
List
<
Long
>
orderId
s
)
{
public
void
schedule
(
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
)
{
BaoshenScheduleAlgorithmAdapter
baoshenScheduleAlgorithmAdapter
=
new
BaoshenScheduleAlgorithmAdapter
();
baoshenScheduleAlgorithmAdapter
.
setAlgorithmDataSource
(
algorithmDataSource
);
baoshenScheduleAlgorithmAdapter
.
setAlgorithmResultProcess
(
algorithmResultProcess
);
...
...
@@ -1853,18 +1853,16 @@ public class ProTaskServiceImpl implements IProTaskService {
baoshenScheduleAlgorithmAdapter
.
setEquipmentSelectionStrategy
(
defaultStrategy
);
baoshenScheduleAlgorithmAdapter
.
setAlgorithmExtendDataSources
(
new
ArrayList
<
AlgorithmExtendDataSource
>()
{
private
static
final
long
serialVersionUID
=
-
4466020352312471396L
;
{
add
(
equipmentNewestTaskAlgorithmData
);
add
(
scheduleSetupRuleAlgorithmData
);
}
});
List
<
ScheduledResult
>
scheduledResults
=
baoshenScheduleAlgorithmAdapter
.
schedule
(
LocalDateTime
.
now
(),
orderId
s
);
baoshenScheduleAlgorithmAdapter
.
schedule
(
LocalDateTime
.
now
(),
workorderScheduleParam
s
);
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
// closeSapWorkorderUpdate(orderIds);
stopWatch
.
stop
();
logger
.
info
(
String
.
format
(
"排产结果发送SAP耗时:%s"
,
stopWatch
.
getTotalTimeSeconds
()));
...
...
mes/src/main/java/com/ximai/mes/pro/service/task/IProTaskService.java
View file @
821302bc
...
...
@@ -5,6 +5,7 @@ import com.ximai.mes.pro.domain.GanttTask;
import
com.ximai.mes.pro.domain.ProFeedback
;
import
com.ximai.mes.pro.domain.task.ProTask
;
import
com.ximai.mes.pro.domain.task.ProTaskWorkunit
;
import
com.ximai.mes.pro.domain.task.WorkorderScheduleParams
;
import
com.ximai.mes.pro.domain.vo.ProPackagePrintResult
;
import
com.ximai.mes.pro.domain.vo.ProTaskQuery
;
import
com.ximai.mes.pro.domain.vo.ProTaskVo
;
...
...
@@ -178,7 +179,7 @@ public interface IProTaskService {
/**
* 工单排产
*/
void
schedule
(
List
<
Long
>
orderId
s
);
void
schedule
(
List
<
WorkorderScheduleParams
>
workorderScheduleParam
s
);
/**
* 查询设备关联最新任务号
...
...
mes/src/main/resources/mapper/pro/ProProductQrcodeRecordMapper.xml
0 → 100644
View file @
821302bc
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.ximai.mes.pro.mapper.ProProductQrcodeRecordMapper"
>
<resultMap
type=
"ProProductQrcodeRecord"
id=
"ProProductQrcodeRecordResult"
>
<result
property=
"recordId"
column=
"record_id"
/>
<result
property=
"itemId"
column=
"item_id"
/>
<result
property=
"itemCode"
column=
"item_code"
/>
<result
property=
"workOrderId"
column=
"work_order_id"
/>
<result
property=
"workOrderNo"
column=
"work_order_no"
/>
<result
property=
"printTime"
column=
"print_time"
/>
<result
property=
"qrcode"
column=
"qrcode"
/>
<result
property=
"clientCode"
column=
"client_code"
/>
<result
property=
"clientName"
column=
"client_name"
/>
<result
property=
"itemDesc"
column=
"item_desc"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
</resultMap>
<resultMap
type=
"com.ximai.mes.pro.dto.ProProductQrcodeRecordDto"
id=
"ProProductQrcodeRecordResult2"
>
<result
property=
"recordId"
column=
"record_id"
/>
<result
property=
"itemId"
column=
"item_id"
/>
<result
property=
"itemCode"
column=
"item_code"
/>
<result
property=
"workOrderId"
column=
"work_order_id"
/>
<result
property=
"workOrderNo"
column=
"work_order_no"
/>
<result
property=
"printTime"
column=
"print_time"
/>
<result
property=
"qrcode"
column=
"qrcode"
/>
<result
property=
"clientCode"
column=
"client_code"
/>
<result
property=
"clientName"
column=
"client_name"
/>
<result
property=
"itemDesc"
column=
"item_desc"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"updateBy"
column=
"update_by"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
</resultMap>
<sql
id=
"selectProProductQrcodeRecordVo"
>
select record_id, item_id, item_code, work_order_id, work_order_no, print_time, qrcode, client_code, client_name, item_desc, create_by, create_time, update_by, update_time from pro_product_qrcode_record
</sql>
<select
id=
"selectProProductQrcodeRecordList"
parameterType=
"ProProductQrcodeRecord"
resultMap=
"ProProductQrcodeRecordResult2"
>
<include
refid=
"selectProProductQrcodeRecordVo"
/>
<where>
<if
test=
"itemId != null "
>
and item_id = #{itemId}
</if>
<if
test=
"itemCode != null and itemCode != ''"
>
and item_code = #{itemCode}
</if>
<if
test=
"workOrderId != null "
>
and work_order_id = #{workOrderId}
</if>
<if
test=
"workOrderNo != null and workOrderNo != ''"
>
and work_order_no = #{workOrderNo}
</if>
<if
test=
"printTime != null "
>
and print_time = #{printTime}
</if>
<if
test=
"qrcode != null and qrcode != ''"
>
and qrcode = #{qrcode}
</if>
<if
test=
"clientCode != null and clientCode != ''"
>
and client_code = #{clientCode}
</if>
<if
test=
"clientName != null and clientName != ''"
>
and client_name like concat('%', #{clientName}, '%')
</if>
<if
test=
"itemDesc != null and itemDesc != ''"
>
and item_desc = #{itemDesc}
</if>
</where>
</select>
<select
id=
"selectProProductQrcodeRecordByRecordId"
parameterType=
"Long"
resultMap=
"ProProductQrcodeRecordResult2"
>
<include
refid=
"selectProProductQrcodeRecordVo"
/>
where record_id = #{recordId}
</select>
<insert
id=
"insertProProductQrcodeRecord"
parameterType=
"ProProductQrcodeRecord"
useGeneratedKeys=
"true"
keyProperty=
"recordId"
>
insert into pro_product_qrcode_record
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"itemId != null"
>
item_id,
</if>
<if
test=
"itemCode != null"
>
item_code,
</if>
<if
test=
"workOrderId != null"
>
work_order_id,
</if>
<if
test=
"workOrderNo != null"
>
work_order_no,
</if>
<if
test=
"printTime != null"
>
print_time,
</if>
<if
test=
"qrcode != null"
>
qrcode,
</if>
<if
test=
"clientCode != null"
>
client_code,
</if>
<if
test=
"clientName != null"
>
client_name,
</if>
<if
test=
"itemDesc != null"
>
item_desc,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateBy != null"
>
update_by,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"itemId != null"
>
#{itemId},
</if>
<if
test=
"itemCode != null"
>
#{itemCode},
</if>
<if
test=
"workOrderId != null"
>
#{workOrderId},
</if>
<if
test=
"workOrderNo != null"
>
#{workOrderNo},
</if>
<if
test=
"printTime != null"
>
#{printTime},
</if>
<if
test=
"qrcode != null"
>
#{qrcode},
</if>
<if
test=
"clientCode != null"
>
#{clientCode},
</if>
<if
test=
"clientName != null"
>
#{clientName},
</if>
<if
test=
"itemDesc != null"
>
#{itemDesc},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"updateBy != null"
>
#{updateBy},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
</trim>
</insert>
<update
id=
"updateProProductQrcodeRecord"
parameterType=
"ProProductQrcodeRecord"
>
update pro_product_qrcode_record
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"itemId != null"
>
item_id = #{itemId},
</if>
<if
test=
"itemCode != null"
>
item_code = #{itemCode},
</if>
<if
test=
"workOrderId != null"
>
work_order_id = #{workOrderId},
</if>
<if
test=
"workOrderNo != null"
>
work_order_no = #{workOrderNo},
</if>
<if
test=
"printTime != null"
>
print_time = #{printTime},
</if>
<if
test=
"qrcode != null"
>
qrcode = #{qrcode},
</if>
<if
test=
"clientCode != null"
>
client_code = #{clientCode},
</if>
<if
test=
"clientName != null"
>
client_name = #{clientName},
</if>
<if
test=
"itemDesc != null"
>
item_desc = #{itemDesc},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
<if
test=
"updateBy != null"
>
update_by = #{updateBy},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
</trim>
where record_id = #{recordId}
</update>
<delete
id=
"deleteProProductQrcodeRecordByRecordId"
parameterType=
"Long"
>
delete from pro_product_qrcode_record where record_id = #{recordId}
</delete>
<delete
id=
"deleteProProductQrcodeRecordByRecordIds"
parameterType=
"String"
>
delete from pro_product_qrcode_record where record_id in
<foreach
item=
"recordId"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{recordId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
mes/src/test/java/com/bs/mes/schedule/BaoshenScheduleAlgorithmAdapterTest.java
View file @
821302bc
This diff is collapsed.
Click to expand it.
mes/src/test/java/com/bs/mes/schedule/api/ApiExcetlTest.java
deleted
100644 → 0
View file @
29b72ed0
package
com
.
bs
.
mes
.
schedule
.
api
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.junit.Test
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
public
class
ApiExcetlTest
{
@Test
public
void
test2
()
{
// 创建一个新的工作簿
Workbook
workbook
=
new
XSSFWorkbook
();
// 创建一个工作表
Sheet
sheet
=
workbook
.
createSheet
(
"ExampleSheet"
);
// 创建行(0基索引)
Row
row
=
sheet
.
createRow
(
0
);
// 创建单元格并设置值
Cell
cell
=
row
.
createCell
(
0
);
cell
.
setCellValue
(
"服务启用"
);
cell
=
row
.
createCell
(
1
);
cell
.
setCellValue
(
"接口服务描述"
);
cell
=
row
.
createCell
(
2
);
cell
.
setCellValue
(
"接口地址"
);
cell
=
row
.
createCell
(
3
);
cell
.
setCellValue
(
"api地址"
);
// 写入到文件
try
(
FileOutputStream
outputStream
=
new
FileOutputStream
(
"C:\\Users\\1\\Desktop\\example.xlsx"
))
{
workbook
.
write
(
outputStream
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
// 清理资源
try
{
workbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
mes/src/test/java/com/bs/mes/schedule/api/CalendarManagerTest.java
deleted
100644 → 0
View file @
29b72ed0
package
com
.
bs
.
mes
.
schedule
.
api
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.junit.Test
;
import
java.io.BufferedReader
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.*
;
public
class
CalendarManagerTest
{
@Test
public
void
addOaccupiedCalendar
()
{
List
<
Map
<
String
,
String
>>
list
=
new
ArrayList
<>();
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
FileReader
(
"C:\\Users\\1\\Desktop\\default.md"
)))
{
// int row = 0;
String
line
;
Boolean
flag1
=
null
;
Map
<
String
,
String
>
map
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
flag1
==
null
||
flag1
)
{
map
=
new
HashMap
<>();
flag1
=
false
;
}
if
(
line
.
contains
(
"接口地址"
))
{
String
replace
=
line
.
replace
(
"**接口地址**:"
,
""
).
replace
(
"<p>"
,
""
).
replace
(
"</p>"
,
""
).
replace
(
"`"
,
""
);
map
.
put
(
"apiaddr"
,
replace
);
}
if
(
line
.
contains
(
"**请求方式**:"
))
{
String
replace
=
line
.
replace
(
"**请求方式**:"
,
""
).
replace
(
"<p>"
,
""
).
replace
(
"</p>"
,
""
).
replace
(
"`"
,
""
);
map
.
put
(
"apimethod"
,
replace
);
}
if
(
line
.
contains
(
"**接口描述**:"
))
{
String
replace
=
line
.
replace
(
"**接口描述**:"
,
""
).
replace
(
"<p>"
,
""
).
replace
(
"<p />"
,
""
).
replace
(
"</p>"
,
""
).
replace
(
"`"
,
""
);
map
.
put
(
"apidesc"
,
replace
);
}
if
(
map
.
size
()
==
3
)
{
flag1
=
true
;
list
.
add
(
map
);
}
// row++;
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
excel
(
list
);
}
public
void
excel
(
List
<
Map
<
String
,
String
>>
list
)
{
Set
<
String
>
objects
=
new
HashSet
<>();
List
<
Map
<
String
,
String
>>
objects1
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
entry
:
list
)
{
if
(
objects
.
add
(
entry
.
get
(
"apiaddr"
)))
{
objects1
.
add
(
entry
);
}
}
// 创建一个新的工作簿
Workbook
workbook
=
new
XSSFWorkbook
();
// 创建一个工作表
Sheet
sheet
=
workbook
.
createSheet
(
"接口"
);
// 创建行(0基索引)
Row
row
=
sheet
.
createRow
(
0
);
// 创建单元格并设置值
Cell
cell
=
row
.
createCell
(
0
);
cell
.
setCellValue
(
"服务启用"
);
cell
=
row
.
createCell
(
3
);
cell
.
setCellValue
(
"接口服务描述"
);
cell
=
row
.
createCell
(
1
);
cell
.
setCellValue
(
"接口地址"
);
cell
=
row
.
createCell
(
2
);
cell
.
setCellValue
(
"api地址"
);
int
rowIndex
=
1
;
for
(
Map
<
String
,
String
>
dataRow
:
objects1
)
{
// 创建行(0基索引)
row
=
sheet
.
createRow
(
rowIndex
);
// 创建单元格并设置值
cell
=
row
.
createCell
(
0
);
cell
.
setCellValue
(
"是"
);
cell
=
row
.
createCell
(
3
);
cell
.
setCellValue
(
dataRow
.
get
(
"apidesc"
));
cell
=
row
.
createCell
(
1
);
cell
.
setCellValue
(
"http://192.168.3.91:8080"
);
cell
=
row
.
createCell
(
2
);
cell
.
setCellValue
(
dataRow
.
get
(
"apiaddr"
));
rowIndex
++;
}
// 写入到文件
try
(
FileOutputStream
outputStream
=
new
FileOutputStream
(
"C:\\Users\\1\\Desktop\\对外提供接口地址.xlsx"
))
{
workbook
.
write
(
outputStream
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
// 清理资源
try
{
workbook
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
\ 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