|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.jx;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.base.IProdOrgExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.busi.jx.ISxWorkCellTaktCollectRecordService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.bean.SxWorkCellTaktCollectRecord;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pojo.model.jx.JxCellTaktReportModel;
|
|
|
|
@ -16,6 +17,7 @@ import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
@ -36,6 +38,9 @@ public class SxWorkCellTaktCollectRecordService implements ISxWorkCellTaktCollec
|
|
|
|
|
@Autowired
|
|
|
|
|
private SxWorkCellTaktCollectRecordRepository workCellTaktCollectRecordRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IProdOrgExtService prodOrgExtService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<SxWorkCellTaktCollectRecord> queryWorkCellTaktCollectRecordListByPager(SxWorkCellTaktCollectRecord workCellTaktCollectRecord, Pager pager) {
|
|
|
|
|
if (workCellTaktCollectRecord == null) {
|
|
|
|
@ -102,12 +107,14 @@ public class SxWorkCellTaktCollectRecordService implements ISxWorkCellTaktCollec
|
|
|
|
|
Map<String, List<SxWorkCellTaktCollectRecord>> recordDbMap2Cell = CollectionUtils.isEmpty(recordDbList) ? null : recordDbList.stream().filter(o -> null != o).collect(Collectors.groupingBy(SxWorkCellTaktCollectRecord::getWorkCellCode));
|
|
|
|
|
DoubleSummaryStatistics statistics;
|
|
|
|
|
if (!CollectionUtils.isEmpty(recordDbMap2Cell)) {
|
|
|
|
|
recordDbMap2Cell = recordDbMap2Cell.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, LinkedHashMap::new));
|
|
|
|
|
for (Map.Entry<String, List<SxWorkCellTaktCollectRecord>> entry : recordDbMap2Cell.entrySet()) {
|
|
|
|
|
if (null == entry) continue;
|
|
|
|
|
List<SxWorkCellTaktCollectRecord> recordDbList2Cell = entry.getValue();
|
|
|
|
|
List<MesWorkCell> workCellList = prodOrgExtService.getWorkCellListByCenter(model.getOrganizeCode(), model.getWorkCenterCode());
|
|
|
|
|
workCellList = workCellList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getSeq()))).sorted(Comparator.comparing(MesWorkCell::getSeq).thenComparing(MesWorkCell::getWorkCellCode)).collect(Collectors.toList());
|
|
|
|
|
for (MesWorkCell workCell : workCellList) {
|
|
|
|
|
List<SxWorkCellTaktCollectRecord> recordDbList2Cell = recordDbMap2Cell.get(workCell);
|
|
|
|
|
if (CollectionUtils.isEmpty(recordDbMap2Cell)) continue;
|
|
|
|
|
|
|
|
|
|
statistics = recordDbList2Cell.stream().filter(o -> null != o).mapToDouble(o -> new Double(o.getWorkTakt())).summaryStatistics();
|
|
|
|
|
JxCellTaktReportModel result = new JxCellTaktReportModel(model.getOrganizeCode(), model.getWorkCenterCode(), entry.getKey());
|
|
|
|
|
JxCellTaktReportModel result = new JxCellTaktReportModel(model.getOrganizeCode(), model.getWorkCenterCode(), workCell.getWorkCellCode());
|
|
|
|
|
result.setCreateDatetimeStart(model.getCreateDatetimeStart());
|
|
|
|
|
result.setCreateDatetimeEnd(model.getCreateDatetimeEnd());
|
|
|
|
|
result.setWorkTakt(statistics.getAverage());
|
|
|
|
@ -115,8 +122,9 @@ public class SxWorkCellTaktCollectRecordService implements ISxWorkCellTaktCollec
|
|
|
|
|
result.setWorkTaktMin(statistics.getMin());
|
|
|
|
|
resultList.add(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
statistics = CollectionUtils.isEmpty(resultList) ? null : resultList.stream().filter(o -> null != o).mapToDouble(JxCellTaktReportModel::getWorkTaktMin).summaryStatistics();
|
|
|
|
|
statistics = CollectionUtils.isEmpty(resultList) ? null : resultList.stream().filter(o -> null != o).mapToDouble(JxCellTaktReportModel::getWorkTakt).summaryStatistics();
|
|
|
|
|
pager = PagerHelper.getPager(pager, resultList.size());
|
|
|
|
|
resultList = CollectionUtils.isEmpty(resultList) ? resultList :
|
|
|
|
|
resultList.subList((pager.getCurrentPage() - 1) * pager.getPageSize(), (pager.getCurrentPage() * pager.getPageSize()) > resultList.size() ? resultList.size() : pager.getCurrentPage() * pager.getPageSize());
|
|
|
|
|