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
88ba0e63
Commit
88ba0e63
authored
Nov 20, 2024
by
温志超
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
8cf6efcb
b58c6c95
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
240 additions
and
2 deletions
+240
-2
KanbanTaskController.java
...com/ximai/mes/kanban/controller/KanbanTaskController.java
+11
-0
TaskPlanQuery.java
...ain/java/com/ximai/mes/kanban/dto/task/TaskPlanQuery.java
+8
-0
TaskPlanStatDto.java
...n/java/com/ximai/mes/kanban/dto/task/TaskPlanStatDto.java
+88
-0
KanbanTaskService.java
.../java/com/ximai/mes/kanban/service/KanbanTaskService.java
+105
-1
ProTaskWorkunitDto.java
...n/java/com/ximai/mes/pro/dto/task/ProTaskWorkunitDto.java
+4
-1
ProTaskWorkunitMapper.java
.../com/ximai/mes/pro/mapper/task/ProTaskWorkunitMapper.java
+24
-0
No files found.
mes/src/main/java/com/ximai/mes/kanban/controller/KanbanTaskController.java
View file @
88ba0e63
...
...
@@ -2,6 +2,9 @@ package com.ximai.mes.kanban.controller;
import
com.ximai.common.core.domain.AjaxResult
;
import
com.ximai.mes.kanban.dto.abnormal.AbnormalMonthStatDto
;
import
com.ximai.mes.kanban.dto.equipment.EquipmentQuery
;
import
com.ximai.mes.kanban.dto.task.TaskPlanQuery
;
import
com.ximai.mes.kanban.dto.task.TaskPlanStatDto
;
import
com.ximai.mes.kanban.dto.task.TaskStatDto
;
import
com.ximai.mes.kanban.service.KanbanTaskService
;
import
io.swagger.annotations.Api
;
...
...
@@ -9,6 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -31,4 +35,11 @@ public class KanbanTaskController {
return
AjaxResult
.
success
(
rst
);
}
@ApiOperation
(
"生产计划看板"
)
@PostMapping
(
"/taskPlanStat"
)
public
AjaxResult
<
TaskPlanStatDto
>
taskPlanStat
(
@RequestBody
TaskPlanQuery
taskPlanQuery
)
{
TaskPlanStatDto
rst
=
kanbanTaskService
.
taskPlanStat
(
taskPlanQuery
);
return
AjaxResult
.
success
(
rst
);
}
}
mes/src/main/java/com/ximai/mes/kanban/dto/task/TaskPlanQuery.java
0 → 100644
View file @
88ba0e63
package
com
.
ximai
.
mes
.
kanban
.
dto
.
task
;
import
lombok.Data
;
@Data
public
class
TaskPlanQuery
{
String
lineName
;
}
mes/src/main/java/com/ximai/mes/kanban/dto/task/TaskPlanStatDto.java
0 → 100644
View file @
88ba0e63
package
com
.
ximai
.
mes
.
kanban
.
dto
.
task
;
import
com.ximai.mes.pro.domain.task.ProTaskWorkunit
;
import
com.ximai.mes.pro.dto.task.ProTaskWorkunitDto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
* 生产计划看板
*/
@Data
public
class
TaskPlanStatDto
{
@ApiModelProperty
(
"按日统计加工产品"
)
List
<
TaskPlanDay
>
taskPlanDayList
;
@Data
public
static
class
TaskPlanDay
{
@ApiModelProperty
(
"开始日期"
)
private
String
startDate
;
@ApiModelProperty
(
"产品列表"
)
private
List
<
ProductTaskInfo
>
productList
;
}
@Data
public
static
class
ProductTaskInfo
{
@ApiModelProperty
(
"产品编号"
)
private
String
itemCode
;
@ApiModelProperty
(
"计划数"
)
private
BigDecimal
planQuantity
;
@ApiModelProperty
(
"工序列表"
)
private
List
<
ProcessTaskInfo
>
processList
;
}
@Data
public
static
class
ProcessTaskInfo
{
@ApiModelProperty
(
"工序名称"
)
private
String
processName
;
/**
* 进行中0,完成1,超期未完成2
*/
@ApiModelProperty
(
"状态,进行中0,完成1,超期未完成2"
)
private
int
state
;
@ApiModelProperty
(
"报工"
)
private
BigDecimal
reportQuantity
=
BigDecimal
.
ZERO
;
@ApiModelProperty
(
"合格数"
)
private
BigDecimal
qualifyQuantity
=
BigDecimal
.
ZERO
;
@ApiModelProperty
(
"合格率"
)
private
BigDecimal
qualifiedRate
=
BigDecimal
.
ZERO
;
@ApiModelProperty
(
"计划数"
)
private
BigDecimal
planQuantity
=
BigDecimal
.
ZERO
;
}
@Data
public
static
class
TaskWorkunitGroup
{
String
startDate
;
String
itemCode
;
List
<
ProTaskWorkunitDto
>
taskWorkunitList
;
}
@Data
@AllArgsConstructor
public
static
class
TaskWorkunitProcessKey
{
String
processName
;
int
idx
;
}
}
mes/src/main/java/com/ximai/mes/kanban/service/KanbanTaskService.java
View file @
88ba0e63
package
com
.
ximai
.
mes
.
kanban
.
service
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.ximai.common.utils.data.StringUtils
;
import
com.ximai.mes.constant.TaskWorkunitStatusEnum
;
import
com.ximai.mes.kanban.dto.task.TaskPlanQuery
;
import
com.ximai.mes.kanban.dto.task.TaskPlanStatDto
;
import
com.ximai.mes.kanban.dto.task.TaskStatDto
;
import
com.ximai.mes.pro.domain.ProFeedback
;
import
com.ximai.mes.pro.domain.proWorkOrder.ProWorkorder
;
...
...
@@ -36,7 +40,6 @@ public class KanbanTaskService {
private
ProTaskWorkunitMapper
taskWorkunitMapper
;
@ApiOperation
(
"工序当月统计"
)
@PostMapping
(
"/currentMonthStat"
)
public
TaskStatDto
currentMonthStat
()
{
LocalDateTime
monthFirstDay
=
LocalDateTime
.
now
().
withDayOfMonth
(
1
).
with
(
LocalTime
.
MIN
);
LocalDateTime
nextMonth
=
monthFirstDay
.
plusMonths
(
1
);
...
...
@@ -227,5 +230,106 @@ public class KanbanTaskService {
return
rst
;
}
@ApiOperation
(
"工序计划统计"
)
public
TaskPlanStatDto
taskPlanStat
(
TaskPlanQuery
taskPlanQuery
)
{
TaskPlanStatDto
rst
=
new
TaskPlanStatDto
();
List
<
TaskPlanStatDto
.
TaskPlanDay
>
taskPlanDayList
=
new
ArrayList
<>();
QueryWrapper
<
ProTaskWorkunit
>
query
=
new
QueryWrapper
<>();
LocalDateTime
curr
=
LocalDateTime
.
now
().
with
(
LocalTime
.
MIN
);
query
.
le
(
"ptw.schedule_start_date"
,
curr
.
plusDays
(
3
));
query
.
gt
(
"ptw.schedule_start_date"
,
curr
.
plusDays
(-
3
));
query
.
eq
(
StringUtils
.
isNotEmpty
(
taskPlanQuery
.
getLineName
()),
"wu.line_name"
,
taskPlanQuery
.
getLineName
());
query
.
orderByDesc
(
"ordinal"
,
"schedule_start_date"
);
List
<
ProTaskWorkunitDto
>
dataList
=
taskWorkunitMapper
.
selectTaskWorkUnitWithKanban
(
query
);
//合并相同批号任务
Map
<
String
,
List
<
ProTaskWorkunitDto
>>
dataMap
=
dataList
.
stream
().
collect
(
Collectors
.
groupingBy
(
s
->
s
.
getTaskBatch
()));
//转换数据-》获取首工序最早开始时间
List
<
TaskPlanStatDto
.
TaskWorkunitGroup
>
taskWorkunitGroupList
=
new
ArrayList
<>();
dataMap
.
forEach
((
k
,
v
)->{
TaskPlanStatDto
.
TaskWorkunitGroup
temp
=
new
TaskPlanStatDto
.
TaskWorkunitGroup
();
temp
.
setTaskWorkunitList
(
v
);
temp
.
setItemCode
(
v
.
get
(
0
).
getItemCode
());
temp
.
setStartDate
(
DateUtil
.
format
(
v
.
get
(
0
).
getScheduleStartDate
(),
"yyyy-MM-dd"
));
taskWorkunitGroupList
.
add
(
temp
);
});
//按时间分组数据
Map
<
String
,
List
<
TaskPlanStatDto
.
TaskWorkunitGroup
>>
taskWorkunitGroupMap
=
taskWorkunitGroupList
.
stream
().
collect
(
Collectors
.
groupingBy
(
s
->
s
.
getStartDate
()));
taskWorkunitGroupMap
=
MapUtil
.
sort
(
taskWorkunitGroupMap
);
taskWorkunitGroupMap
.
forEach
((
k
,
v
)->{
TaskPlanStatDto
.
TaskPlanDay
taskPlanDay
=
new
TaskPlanStatDto
.
TaskPlanDay
();
taskPlanDay
.
setStartDate
(
k
);
List
<
TaskPlanStatDto
.
ProductTaskInfo
>
productList
=
new
ArrayList
<>();
//按产品分组
Map
<
String
,
List
<
TaskPlanStatDto
.
TaskWorkunitGroup
>>
taskWorkunitGroupMap2
=
v
.
stream
().
collect
(
Collectors
.
groupingBy
(
s
->
s
.
getItemCode
()));
taskWorkunitGroupMap2
.
forEach
((
k2
,
v2
)->{
TaskPlanStatDto
.
ProductTaskInfo
productTaskInfo
=
new
TaskPlanStatDto
.
ProductTaskInfo
();
productTaskInfo
.
setItemCode
(
k2
);
List
<
ProTaskWorkunitDto
>
tempTaskWorkunitList
=
new
ArrayList
<>();
for
(
TaskPlanStatDto
.
TaskWorkunitGroup
taskWorkunitGroup
:
v2
)
{
tempTaskWorkunitList
.
addAll
(
taskWorkunitGroup
.
getTaskWorkunitList
());
}
//按工序分组任务
Map
<
TaskPlanStatDto
.
TaskWorkunitProcessKey
,
List
<
ProTaskWorkunitDto
>>
taskWorkunitMap
=
tempTaskWorkunitList
.
stream
().
collect
(
Collectors
.
groupingBy
(
s
->{
return
new
TaskPlanStatDto
.
TaskWorkunitProcessKey
(
s
.
getProcessName
(),
s
.
getIdx
());
}));
taskWorkunitMap
=
MapUtil
.
sort
(
taskWorkunitMap
,
Comparator
.
comparing
(
TaskPlanStatDto
.
TaskWorkunitProcessKey
::
getIdx
));
List
<
TaskPlanStatDto
.
ProcessTaskInfo
>
processList
=
new
ArrayList
<>();
taskWorkunitMap
.
forEach
((
k3
,
v3
)->{
BigDecimal
reportQuantity
=
BigDecimal
.
ZERO
;
BigDecimal
qualifyQuantity
=
BigDecimal
.
ZERO
;
BigDecimal
planQuantity
=
BigDecimal
.
ZERO
;
int
state
=
0
;
for
(
ProTaskWorkunitDto
workunit:
v3
){
reportQuantity
=
reportQuantity
.
add
(
workunit
.
getQuantityProduced
());
qualifyQuantity
=
qualifyQuantity
.
add
(
workunit
.
getQuantityQualify
());
planQuantity
=
planQuantity
.
add
(
workunit
.
getQuantity
());
}
TaskPlanStatDto
.
ProcessTaskInfo
processTaskInfo
=
new
TaskPlanStatDto
.
ProcessTaskInfo
();
processTaskInfo
.
setState
(
this
.
getWorkunitState
(
v3
));
processTaskInfo
.
setProcessName
(
k3
.
getProcessName
());
processTaskInfo
.
setQualifyQuantity
(
qualifyQuantity
);
processTaskInfo
.
setReportQuantity
(
reportQuantity
);
processTaskInfo
.
setPlanQuantity
(
planQuantity
);
if
(
reportQuantity
.
compareTo
(
BigDecimal
.
ZERO
)>
0
){
processTaskInfo
.
setQualifiedRate
(
qualifyQuantity
.
divide
(
reportQuantity
,
2
,
BigDecimal
.
ROUND_DOWN
).
multiply
(
new
BigDecimal
(
"100"
)));
}
processList
.
add
(
processTaskInfo
);
});
productTaskInfo
.
setPlanQuantity
(
processList
.
get
(
0
).
getPlanQuantity
());
productTaskInfo
.
setProcessList
(
processList
);
productList
.
add
(
productTaskInfo
);
});
taskPlanDay
.
setProductList
(
productList
);
taskPlanDayList
.
add
(
taskPlanDay
);
});
rst
.
setTaskPlanDayList
(
taskPlanDayList
);
return
rst
;
}
private
int
getWorkunitState
(
List
<
ProTaskWorkunitDto
>
list
){
Set
<
String
>
temp
=
new
HashSet
<>();
list
.
forEach
(
s
->{
if
(
s
.
getStatus
().
equals
(
TaskWorkunitStatusEnum
.
FINISHED
.
getStatus
())
||
s
.
getQuantity
().
compareTo
(
s
.
getQuantityProduced
())<=
0
){
if
(
s
.
getActualEndDate
()==
null
){
temp
.
add
(
"finish"
);
}
else
if
(
s
.
getActualEndDate
().
compareTo
(
s
.
getScheduleEndDate
())<=
0
){
temp
.
add
(
"finish"
);
}
else
{
temp
.
add
(
"expireFinish"
);
}
}
else
{
temp
.
add
(
"other"
);
}
});
if
(
temp
.
contains
(
"other"
)){
return
0
;
}
else
if
(
temp
.
contains
(
"expireFinish"
)){
return
2
;
}
return
1
;
}
}
mes/src/main/java/com/ximai/mes/pro/dto/task/ProTaskWorkunitDto.java
View file @
88ba0e63
...
...
@@ -47,7 +47,7 @@ public class ProTaskWorkunitDto extends BaseEntity {
* 顺序号
*/
@Excel
(
name
=
"顺序号"
)
private
Long
idx
;
private
int
idx
;
/**
* 工作单元ID
...
...
@@ -218,6 +218,9 @@ public class ProTaskWorkunitDto extends BaseEntity {
@ApiModelProperty
(
"工时单位"
)
private
String
stdWorkingTimeUom
;
@ApiModelProperty
(
"产线名"
)
private
String
lineName
;
@ApiModelProperty
(
"单价"
)
private
BigDecimal
unitPrice
;
}
mes/src/main/java/com/ximai/mes/pro/mapper/task/ProTaskWorkunitMapper.java
View file @
88ba0e63
...
...
@@ -188,4 +188,28 @@ public interface ProTaskWorkunitMapper extends BaseMapper<ProTaskWorkunit> {
@Select
(
value
=
"select workunit_id,count(*) ct from pro_task_workunit t1 where t1.`status` = 'BEGINNING' group by workunit_id"
)
List
<
WorkunitProcessingDto
>
selectWorkunitProcessing
();
/**
* 计划看板专用
* @param query
* @return
*/
@Select
(
value
=
"select t.task_id, t.task_code, t.task_batch, t.workstation_id\n"
+
"\t, t.workstation_code, t.process_id, t.process_code, t.process_name, t.item_id\n"
+
"\t, wo.product_code as item_code, wo.product_name as item_name, wo.customer_project_no, wo.order_code, t.specification\n"
+
"\t, t.unit_of_measure, ptw.task_workunit_id, ptw.quantity, ptw.create_by, t.quantity_wait\n"
+
"\t, ptw.quantity_produced\n"
+
"\t, ptw.schedule_start_date, t.duration, ptw.schedule_end_date\n"
+
"\t, t.ordinal as idx, t.create_time, t.update_by\n"
+
"\t, t.update_time, ptw.STATUS, ptw.quantity_qualify, ptw.remark, ptw.quantity_unqualify\n"
+
"\t, wo.workorder_code, wu.line_name\n"
+
"\t, ptw.STATUS "
+
"from pro_task_workunit ptw\n"
+
"\tleft join pro_task t on ptw.task_id = t.task_id\n"
+
"\tleft join pro_task_workorder tw on t.task_id = tw.task_id\n"
+
"\tleft join pro_workorder wo on wo.workorder_id = tw.workorder_id\n"
+
"\tleft join pro_process p on t.process_id = p.process_id\n"
+
"\tleft join md_workunit wu on wu.workunit_id = ptw.workunit_id "
+
"${ew.customSqlSegment} "
)
List
<
ProTaskWorkunitDto
>
selectTaskWorkUnitWithKanban
(
@Param
(
"ew"
)
QueryWrapper
<
ProTaskWorkunit
>
query
);
}
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