|
@@ -2,14 +2,17 @@ package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.date.StopWatch;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.rongwei.bscommon.sys.dao.ApsProcessOperationProcessEquDao;
|
|
|
+import com.rongwei.bscommon.sys.dao.ApsReportRecordsDao;
|
|
|
import com.rongwei.bscommon.sys.service.ApsProcessOperationBackupService;
|
|
|
import com.rongwei.bscommon.sys.service.ApsProcessOperationService;
|
|
|
import com.rongwei.bscommon.sys.service.GanttService;
|
|
|
import com.rongwei.bsentity.domain.ApsProcessOperationBackupDo;
|
|
|
import com.rongwei.bsentity.domain.ApsProcessOperationDo;
|
|
|
import com.rongwei.bsentity.vo.GanttVos;
|
|
|
+import com.rongwei.bsentity.vo.ProcessOutputAndInputNumber;
|
|
|
import com.rongwei.bsentity.vo.ScheduleGanttVo;
|
|
|
import com.rongwei.commonservice.service.RedisService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
@@ -41,25 +44,26 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class GanttServiceImpl implements GanttService {
|
|
|
public static final String GANTT_ITEM_NAME = "%s %d卷 %s %s %tF";
|
|
|
- public static final String GANTT_ITEM_NAME_PREFIX = "%s %s";
|
|
|
- public static final String GANTT_DESC_PREFIX = " 计划时间:%s-%s </br>" +
|
|
|
- "实际时间:%s-%s </br>" +
|
|
|
- "加工设备:%s/%s </br>";
|
|
|
- public static final String GANTT_DESC =
|
|
|
- "输入物料:%s %d卷</br>" +
|
|
|
- "工序:%s </br>" +
|
|
|
- "作业状态:%s </br>" +
|
|
|
- "完成情况:已开工 %d/已报工 %d/已检验 %d/未完工 %d </br>" +
|
|
|
- "客户订单号:%s </br>" +
|
|
|
- "客户名称:%s </br>" +
|
|
|
- "交货期:%tF </br>" +
|
|
|
- "订单产品:%s </br>";
|
|
|
+// public static final String GANTT_ITEM_NAME_PREFIX = "%s %s";
|
|
|
+// public static final String GANTT_DESC_PREFIX = " 计划时间:%s-%s </br>" +
|
|
|
+// "实际时间:%s-%s </br>" +
|
|
|
+// "加工设备:%s/%s </br>";
|
|
|
+// public static final String GANTT_DESC =
|
|
|
+// "输入物料:%s %d卷</br>" +
|
|
|
+// "工序:%s </br>" +
|
|
|
+// "作业状态:%s </br>" +
|
|
|
+// "完成情况:已开工 %d/已报工 %d/已检验 %d/未完工 %d </br>" +
|
|
|
+// "客户订单号:%s </br>" +
|
|
|
+// "客户名称:%s </br>" +
|
|
|
+// "交货期:%tF </br>" +
|
|
|
+// "订单产品:%s </br>";
|
|
|
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
public static final String DEFAULT_TYPE = "project";
|
|
|
public static final String DEFAULT_RENDER = "split";
|
|
|
public static final String COMBINED_PROCESSING = "合并加工";
|
|
|
public static final String SCHEDULING_STR = "%s-正在排程";
|
|
|
public static final String SCHEDULING_TO_BE_PUBLISHED_STR = "%s-排程结束待发布";
|
|
|
+ public static final String DEFAULT_SPLIT="-;-";
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
@Autowired
|
|
|
private ApsProcessOperationProcessEquDao apsProcessOperationProcessEquDao;
|
|
@@ -71,7 +75,8 @@ public class GanttServiceImpl implements GanttService {
|
|
|
private RedisService redisService;
|
|
|
@Autowired
|
|
|
private ApsProcessOperationBackupService apsProcessOperationBackupService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ApsReportRecordsDao apsReportRecordsDao;
|
|
|
/**
|
|
|
* 根据条件获取gantt
|
|
|
*
|
|
@@ -94,11 +99,19 @@ public class GanttServiceImpl implements GanttService {
|
|
|
startDate = searchDateList.get(0);
|
|
|
endDate = searchDateList.get(1);
|
|
|
}
|
|
|
+ StopWatch stopWatch = new StopWatch();
|
|
|
+ stopWatch.start();
|
|
|
List<GanttVos> apsProcessOperationProcessEquDos = apsProcessOperationProcessEquDao.getGanttDataList(
|
|
|
startDate, endDate, factoryId, workShopIdList, orderNoList,
|
|
|
null, productionLineId, equId, null, productionLineName, equName);
|
|
|
+ stopWatch.stop();
|
|
|
+ log.error("甘特图查询用时:{}",stopWatch.getTotalTimeSeconds());
|
|
|
+ StopWatch stopWatch1 = new StopWatch();
|
|
|
+ stopWatch1.start();
|
|
|
List<ScheduleGanttVo> scheduleGanttVos = assembleGanttData(apsProcessOperationProcessEquDos);
|
|
|
- log.info("甘特图查询结束时间:" + DateUtil.now());
|
|
|
+ stopWatch1.stop();
|
|
|
+ log.error("甘特图组装数据用时:{}",stopWatch1.getTotalTimeSeconds());
|
|
|
+
|
|
|
return R.ok(scheduleGanttVos);
|
|
|
// dataMap.forEach((k, v) -> {
|
|
|
// ScheduleGanttVo vo = new ScheduleGanttVo();
|
|
@@ -284,11 +297,16 @@ public class GanttServiceImpl implements GanttService {
|
|
|
*/
|
|
|
public List<ScheduleGanttVo> assembleGanttData(List<GanttVos> apsProcessOperationProcessEquDos) {
|
|
|
// 需要返回给前端的数据
|
|
|
- List<ScheduleGanttVo> resultVo;
|
|
|
+ List<ScheduleGanttVo> resultVo=new ArrayList<>();
|
|
|
if (apsProcessOperationProcessEquDos.isEmpty()) {
|
|
|
- return new ArrayList<>();
|
|
|
+ return resultVo;
|
|
|
}
|
|
|
- resultVo = new ArrayList<>();
|
|
|
+ // 获取工序对应的 输入输出批次号
|
|
|
+ List<String> processId = apsProcessOperationProcessEquDos.stream().map(GanttVos::getProcessid).distinct().collect(Collectors.toList());
|
|
|
+ // 工序作业对应的输入和输出批次号
|
|
|
+ Map<String, String> processAndNumberMap = apsReportRecordsDao.selectInputAndOutputNumByProcessId(processId).stream().collect(Collectors.toMap(ProcessOutputAndInputNumber::getProcessId, ProcessOutputAndInputNumber::getNumber));
|
|
|
+
|
|
|
+
|
|
|
// 对数据按照加工车间分组
|
|
|
LinkedHashMap<String, List<GanttVos>> dataMap = apsProcessOperationProcessEquDos.stream()
|
|
|
.collect(Collectors.groupingBy(GanttVos::getProcessworkshopid,
|
|
@@ -302,6 +320,7 @@ public class GanttServiceImpl implements GanttService {
|
|
|
// 具体工序作业的对象
|
|
|
ScheduleGanttVo dateVo;
|
|
|
int workShopIndex = 1;
|
|
|
+ String inputNumber;
|
|
|
for (Map.Entry<String, List<GanttVos>> workShopEntry : dataMap.entrySet()) {
|
|
|
workShopVo = new ScheduleGanttVo();
|
|
|
workShopVo.setId(workShopIndex++);
|
|
@@ -324,8 +343,9 @@ public class GanttServiceImpl implements GanttService {
|
|
|
deviceVo.setDevicetype(deviceEntry.getValue().get(0).getDevicetype());
|
|
|
deviceVo.setRender(DEFAULT_RENDER);
|
|
|
deviceVo.setStart_date(deviceEntry.getValue().get(0).getPlanstartdate());
|
|
|
+ deviceVo.setProductlineid(deviceEntry.getValue().get(0).getProductlineid());
|
|
|
+ deviceVo.setProductlinename(deviceEntry.getValue().get(0).getProductlinename());
|
|
|
resultVo.add(deviceVo);
|
|
|
-
|
|
|
// 对数据按照 计划开始时间+计划结束时间 分组
|
|
|
LinkedHashMap<String, List<GanttVos>> planDataMap = deviceEntry.getValue().stream().collect(Collectors.groupingBy(info -> {
|
|
|
if (COMBINED_PROCESSING.equals(info.getProcessway())) {
|
|
@@ -334,9 +354,15 @@ public class GanttServiceImpl implements GanttService {
|
|
|
return info.getUuid();
|
|
|
},
|
|
|
LinkedHashMap::new, Collectors.toList()));
|
|
|
-
|
|
|
for (Map.Entry<String, List<GanttVos>> planDateEntry : planDataMap.entrySet()) {
|
|
|
List<GanttVos> ganttVos = planDateEntry.getValue();
|
|
|
+ ganttVos.forEach(data->{
|
|
|
+ String number = processAndNumberMap.getOrDefault(data.getProcessid(), "");
|
|
|
+ if(StringUtils.isNotBlank(number) && number.split(DEFAULT_SPLIT).length==2){
|
|
|
+ data.setInputnumber(number.split(DEFAULT_SPLIT)[0]);
|
|
|
+ data.setOutputnumber(number.split(DEFAULT_SPLIT)[1]);
|
|
|
+ }
|
|
|
+ });
|
|
|
List<String> itemNames = new ArrayList<>();
|
|
|
// 按照工序作业明细ID 进行分组 并且获取 图列的 名称和描述
|
|
|
LinkedHashMap<String, List<GanttVos>> collect = ganttVos.stream().collect(Collectors.groupingBy(GanttVos::getId, LinkedHashMap::new, Collectors.toList()));
|
|
@@ -349,49 +375,45 @@ public class GanttServiceImpl implements GanttService {
|
|
|
}).collect(Collectors.joining("</br>"));
|
|
|
itemNames.add(itemName);
|
|
|
|
|
|
- String itemPrefix = String.format(GANTT_DESC_PREFIX,
|
|
|
- dateFormat(ganttVos.get(0).getPlanstartdate()),
|
|
|
- dateFormat(ganttVos.get(0).getPlanenddate()),
|
|
|
- dateFormat(ganttVos.get(0).getActualstartdate()),
|
|
|
- dateFormat(ganttVos.get(0).getActualfinishdate()),
|
|
|
- ganttVos.get(0).getProcessworkshop(), ganttVos.get(0).getProcessdevice());
|
|
|
- String itemDesc = ganttVos.stream().map(info -> {
|
|
|
- return String.format(GANTT_DESC, info.getInmatercondition(), info.getPlanprocessrall(),
|
|
|
- info.getProcessname(), info.getWorkstatus(),
|
|
|
- info.getStartingroll(), info.getReportroll(),
|
|
|
- info.getCheckoutroll(), info.getUnfinishroll(),
|
|
|
- info.getCustomorderno(), info.getCustomerabbreviation(),
|
|
|
- info.getDeliverydate(), info.getOutputorderproduct());
|
|
|
- }).collect(Collectors.joining("</br>"));
|
|
|
+// String itemPrefix = String.format(GANTT_DESC_PREFIX,
|
|
|
+// dateFormat(ganttVos.get(0).getPlanstartdate()),
|
|
|
+// dateFormat(ganttVos.get(0).getPlanenddate()),
|
|
|
+// dateFormat(ganttVos.get(0).getActualstartdate()),
|
|
|
+// dateFormat(ganttVos.get(0).getActualfinishdate()),
|
|
|
+// ganttVos.get(0).getProcessworkshop(), ganttVos.get(0).getProcessdevice());
|
|
|
+// String itemDesc = ganttVos.stream().map(info -> {
|
|
|
+// return String.format(GANTT_DESC, info.getInmatercondition(), info.getPlanprocessrall(),
|
|
|
+// info.getProcessname(), info.getWorkstatus(),
|
|
|
+// info.getStartingroll(), info.getReportroll(),
|
|
|
+// info.getCheckoutroll(), info.getUnfinishroll(),
|
|
|
+// info.getCustomorderno(), info.getCustomerabbreviation(),
|
|
|
+// info.getDeliverydate(), info.getOutputorderproduct());
|
|
|
+// }).collect(Collectors.joining("</br>"));
|
|
|
dateVo = new ScheduleGanttVo();
|
|
|
dateVo.setId(workShopIndex++);
|
|
|
dateVo.setParent(deviceVo.getId());
|
|
|
dateVo.setText(StringUtils.join(itemNames, "</br>"));
|
|
|
- dateVo.setTooltip(itemPrefix + itemDesc);
|
|
|
+// dateVo.setTooltip(itemPrefix + itemDesc);
|
|
|
dateVo.setOpen(false);
|
|
|
dateVo.setStart_date(planDateEntry.getValue().get(0).getPlanstartdate());
|
|
|
dateVo.setEnd_date(planDateEntry.getValue().get(0).getPlanenddate());
|
|
|
dateVo.setName(StringUtils.join(itemNames, "</br>"));
|
|
|
- dateVo.setDesc(itemPrefix + itemDesc);
|
|
|
+// dateVo.setDesc(itemPrefix + itemDesc);
|
|
|
dateVo.setProcessdetailids(ganttVos.stream().map(GanttVos::getId).distinct().collect(Collectors.joining(",")));
|
|
|
dateVo.setProcessids(ganttVos.stream().map(GanttVos::getProcessid).distinct().collect(Collectors.joining(",")));
|
|
|
dateVo.setGanttVos(ganttVos);
|
|
|
dateVo.setWorkstatus(ganttVos.stream().map(GanttVos::getWorkstatus).distinct().collect(Collectors.joining(",")));
|
|
|
dateVo.setLockmark(ganttVos.stream().map(GanttVos::getLockmark).distinct().collect(Collectors.joining(",")));
|
|
|
- dateVo.setConflict(ganttVos.get(0).getConflict());
|
|
|
+// dateVo.setConflict(ganttVos.get(0).getConflict());
|
|
|
dateVo.setProductionorderid(ganttVos.stream().map(GanttVos::getProductionorderid).collect(Collectors.joining(",")));
|
|
|
// 冲突描述
|
|
|
List<GanttVos> conflictdes = ganttVos.stream().filter(v -> StringUtils.isNotBlank(v.getConflictdes())).collect(Collectors.toList());
|
|
|
- if (conflictdes != null && conflictdes.size() > 0) {
|
|
|
+ if (!conflictdes.isEmpty()) {
|
|
|
String desc = conflictdes.stream().map(GanttVos::getConflictdes).collect(Collectors.joining(";"));
|
|
|
dateVo.setConflictdes(desc);
|
|
|
dateVo.setSoftconflictdes(conflictdes.stream().map(GanttVos::getSoftconflictdes).collect(Collectors.joining(";")));
|
|
|
// 有冲突描述时
|
|
|
- if (StringUtils.isBlank(dateVo.getConflictdes()) && StringUtils.isBlank(dateVo.getSoftconflictdes())) {
|
|
|
- dateVo.setConflict(true);
|
|
|
- } else {
|
|
|
- dateVo.setConflict(false);
|
|
|
- }
|
|
|
+ dateVo.setConflict(StringUtils.isBlank(dateVo.getConflictdes()) && StringUtils.isBlank(dateVo.getSoftconflictdes()));
|
|
|
}
|
|
|
|
|
|
resultVo.add(dateVo);
|