甘特图显示
This commit is contained in:
parent
b6857c4a2f
commit
07c3e8b7b6
@ -90,4 +90,11 @@ public class UserConstants
|
|||||||
*/
|
*/
|
||||||
public static final String MAINTEN_TYPE_REGULAR="REGULAR";
|
public static final String MAINTEN_TYPE_REGULAR="REGULAR";
|
||||||
public static final String MAINTEN_TYPE_USAGE="USAGE";
|
public static final String MAINTEN_TYPE_USAGE="USAGE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 甘特图中的TASK类型
|
||||||
|
*/
|
||||||
|
public static final String GANTT_TASK_TYPE_TASK="task";
|
||||||
|
public static final String GANTT_TASK_TYPE_PROJECT="project";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.ktg.mes.pro.controller;
|
package com.ktg.mes.pro.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.ktg.common.constant.UserConstants;
|
import com.ktg.common.constant.UserConstants;
|
||||||
import com.ktg.mes.pro.domain.ProProcess;
|
import com.ktg.mes.pro.domain.*;
|
||||||
import com.ktg.mes.pro.domain.ProWorkorder;
|
|
||||||
import com.ktg.mes.pro.service.IProProcessService;
|
import com.ktg.mes.pro.service.IProProcessService;
|
||||||
import com.ktg.mes.pro.service.IProWorkorderService;
|
import com.ktg.mes.pro.service.IProWorkorderService;
|
||||||
import com.ktg.system.strategy.AutoCodeUtil;
|
import com.ktg.system.strategy.AutoCodeUtil;
|
||||||
@ -23,7 +24,6 @@ import com.ktg.common.annotation.Log;
|
|||||||
import com.ktg.common.core.controller.BaseController;
|
import com.ktg.common.core.controller.BaseController;
|
||||||
import com.ktg.common.core.domain.AjaxResult;
|
import com.ktg.common.core.domain.AjaxResult;
|
||||||
import com.ktg.common.enums.BusinessType;
|
import com.ktg.common.enums.BusinessType;
|
||||||
import com.ktg.mes.pro.domain.ProTask;
|
|
||||||
import com.ktg.mes.pro.service.IProTaskService;
|
import com.ktg.mes.pro.service.IProTaskService;
|
||||||
import com.ktg.common.utils.poi.ExcelUtil;
|
import com.ktg.common.utils.poi.ExcelUtil;
|
||||||
import com.ktg.common.core.page.TableDataInfo;
|
import com.ktg.common.core.page.TableDataInfo;
|
||||||
@ -94,9 +94,62 @@ public class ProTaskController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('pro:protask:list')")
|
@PreAuthorize("@ss.hasPermi('pro:protask:list')")
|
||||||
@GetMapping("/listGanttTaskList")
|
@GetMapping("/listGanttTaskList")
|
||||||
public AjaxResult getGanttTaskList(ProTask proTask){
|
public AjaxResult getGanttTaskList(ProWorkorder proWorkorder){
|
||||||
|
GanttTask ganttTask = new GanttTask();
|
||||||
|
List<GanttData> ganttData = new ArrayList<GanttData>();
|
||||||
|
List<GanttLink> ganttLinks = new ArrayList<GanttLink>();
|
||||||
|
|
||||||
return AjaxResult.success();
|
//查询所有的WorkOrder
|
||||||
|
List<ProWorkorder> workorders = proWorkorderService.selectProWorkorderList(proWorkorder);
|
||||||
|
|
||||||
|
//为每个workOrder生成type=project的GanttData
|
||||||
|
//为每个proTask生产type=task的GanttData
|
||||||
|
ProTask param = new ProTask();
|
||||||
|
if(CollUtil.isNotEmpty(workorders)){
|
||||||
|
for (ProWorkorder workorder: workorders
|
||||||
|
) {
|
||||||
|
//先添加当前的生产工单TASK
|
||||||
|
GanttData wdata = new GanttData();
|
||||||
|
wdata.setId("MO"+workorder.getWorkorderId().toString());
|
||||||
|
wdata.setText(new StringBuilder().append(workorder.getProductName()).append(workorder.getQuantity().stripTrailingZeros().toPlainString()).append(workorder.getUnitOfMeasure()).toString());//默认使用“[产品]+[数量]+[单位]”格式。
|
||||||
|
wdata.setProduct(workorder.getProductName());
|
||||||
|
wdata.setQuantity(workorder.getQuantity());
|
||||||
|
if(workorder.getParentId().longValue()!=0L){
|
||||||
|
wdata.setParent("MO"+workorder.getParentId().toString());
|
||||||
|
}
|
||||||
|
wdata.setProgress(0f);
|
||||||
|
wdata.setDuration(0L);
|
||||||
|
wdata.setType(UserConstants.GANTT_TASK_TYPE_PROJECT);
|
||||||
|
ganttData.add(wdata);
|
||||||
|
|
||||||
|
//查询当前生产工单下所有的生产任务
|
||||||
|
param.setWorkorderId(workorder.getWorkorderId());
|
||||||
|
List<ProTask> proTasks = proTaskService.selectProTaskList(param);
|
||||||
|
if(CollUtil.isNotEmpty(proTasks)){
|
||||||
|
for (ProTask task:proTasks
|
||||||
|
) {
|
||||||
|
GanttData data = new GanttData();
|
||||||
|
data.setId(task.getTaskId().toString());//使用生产任务的ID作为甘特图TASK的ID
|
||||||
|
data.setText(new StringBuilder().append(task.getItemName()).append(task.getQuantity().stripTrailingZeros().toPlainString()).append(task.getUnitOfMeasure()).toString()); //默认使用“[产品]+[数量]+[单位]”格式。
|
||||||
|
data.setColor(task.getColorCode());
|
||||||
|
data.setDuration(task.getDuration());
|
||||||
|
data.setStart_date(task.getStartTime());
|
||||||
|
data.setParent("MO"+workorder.getWorkorderId().toString());//这里要设置为"MO+生产工单ID"的格式
|
||||||
|
data.setProduct(task.getItemName());
|
||||||
|
data.setQuantity(task.getQuantity());
|
||||||
|
data.setProcess(task.getProcessName());
|
||||||
|
data.setWorkstation(task.getWorkstationName());
|
||||||
|
data.setProgress(0f);
|
||||||
|
data.setType(UserConstants.GANTT_TASK_TYPE_TASK);
|
||||||
|
ganttData.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ganttTask.setData(ganttData);
|
||||||
|
ganttTask.setLinks(ganttLinks);
|
||||||
|
return AjaxResult.success(ganttTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
184
ktg-mes/src/main/java/com/ktg/mes/pro/domain/GanttData.java
Normal file
184
ktg-mes/src/main/java/com/ktg/mes/pro/domain/GanttData.java
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
package com.ktg.mes.pro.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class GanttData {
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TASK 类型:project;task
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务名称
|
||||||
|
*/
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作站名称
|
||||||
|
*/
|
||||||
|
private String workstation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产的产品
|
||||||
|
*/
|
||||||
|
private String product;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排产数量
|
||||||
|
*/
|
||||||
|
private BigDecimal quantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产进度
|
||||||
|
*/
|
||||||
|
private float progress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TASK的颜色
|
||||||
|
*/
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工序
|
||||||
|
*/
|
||||||
|
private String process;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父TASK ID
|
||||||
|
*/
|
||||||
|
private String parent;
|
||||||
|
|
||||||
|
|
||||||
|
/** 开始生产时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date start_date;
|
||||||
|
|
||||||
|
/** 生产时长 */
|
||||||
|
private Long duration;
|
||||||
|
|
||||||
|
/** 完成生产时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date end_date;
|
||||||
|
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorkstation() {
|
||||||
|
return workstation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorkstation(String workstation) {
|
||||||
|
this.workstation = workstation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct(String product) {
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(BigDecimal quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(String color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProcess() {
|
||||||
|
return process;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcess(String process) {
|
||||||
|
this.process = process;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(String parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Long getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(Long duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStart_date() {
|
||||||
|
return start_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStart_date(Date start_date) {
|
||||||
|
this.start_date = start_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEnd_date() {
|
||||||
|
return end_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnd_date(Date end_date) {
|
||||||
|
this.end_date = end_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getProgress() {
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgress(float progress) {
|
||||||
|
this.progress = progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
67
ktg-mes/src/main/java/com/ktg/mes/pro/domain/GanttLink.java
Normal file
67
ktg-mes/src/main/java/com/ktg/mes/pro/domain/GanttLink.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package com.ktg.mes.pro.domain;
|
||||||
|
|
||||||
|
public class GanttLink {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
private String target;
|
||||||
|
|
||||||
|
private Long type;
|
||||||
|
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(String target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Long type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(String color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GanttLink{" +
|
||||||
|
"id='" + id + '\'' +
|
||||||
|
", source='" + source + '\'' +
|
||||||
|
", target='" + target + '\'' +
|
||||||
|
", type=" + type +
|
||||||
|
", color='" + color + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
32
ktg-mes/src/main/java/com/ktg/mes/pro/domain/GanttTask.java
Normal file
32
ktg-mes/src/main/java/com/ktg/mes/pro/domain/GanttTask.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package com.ktg.mes.pro.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.ktg.common.annotation.Excel;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GanttTask {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private List<GanttData> data;
|
||||||
|
|
||||||
|
private List<GanttLink> links;
|
||||||
|
|
||||||
|
public List<GanttData> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(List<GanttData> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GanttLink> getLinks() {
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinks(List<GanttLink> links) {
|
||||||
|
this.links = links;
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectProTaskVo">
|
<sql id="selectProTaskVo">
|
||||||
select task_id, task_code, task_name, workorder_id, workorder_code, workorder_name, workstation_id, workstation_code, workstation_name, item_id, item_code, item_name, specification, unit_of_measure, quantity, quantity_produced, quantity_changed, client_id, client_code, client_name, client_nick, start_time, duration, end_time, color_code, request_date, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from pro_task
|
select task_id, task_code, task_name, workorder_id, workorder_code, workorder_name, workstation_id, workstation_code, workstation_name,process_id,process_code,process_name, item_id, item_code, item_name, specification, unit_of_measure, quantity, quantity_produced, quantity_changed, client_id, client_code, client_name, client_nick, start_time, duration, end_time, color_code, request_date, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from pro_task
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectProTaskList" parameterType="ProTask" resultMap="ProTaskResult">
|
<select id="selectProTaskList" parameterType="ProTask" resultMap="ProTaskResult">
|
||||||
|
Loading…
Reference in New Issue
Block a user