手机推送修改

master
Yangwl 2 months ago
parent 439ad9bc23
commit 9aca5a3e48

@ -3,7 +3,10 @@ package com.op.mes.controller;
import com.op.mes.domain.EnergyExpend;
import com.op.mes.domain.H5;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.domain.vo.MesDailyReportVo;
import com.op.mes.service.H5ApiService;
import com.op.mes.service.IMesReportWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -14,6 +17,8 @@ import javax.validation.constraints.Max;
import java.util.List;
import java.util.Map;
import static com.op.common.core.utils.PageUtils.startPage;
/**
* H5
*
@ -26,12 +31,13 @@ public class H5ApiController {
@Autowired
private H5ApiService h5ApiService;
@Autowired
private IMesReportWorkService mesReportWorkService;
@GetMapping("/dailyProductDetil")
public List<H5> list(H5 h5)
public List<MesDailyReportVo> list(MesDailyReportVo mesDailyReportVo)
{
String workTime=h5.getFeedbackTime();
List<H5> list = h5ApiService.dailyProductDetil(workTime);
startPage();
List<MesDailyReportVo> list = mesReportWorkService.getDailyReportNew(mesDailyReportVo);
return list;
}
//能源数据

@ -1,6 +1,10 @@
package com.op.mes.domain;
public class H5 {
import com.op.common.core.web.domain.BaseEntity;
import java.util.List;
public class H5 extends BaseEntity {
private String workOrderCode;
private String lineName;
private String productName;
@ -20,6 +24,16 @@ public class H5 {
private String reason;
private String shift;
private List<H5> children;
public List<H5> getChildren() {
return children;
}
public void setChildren(List<H5> children) {
this.children = children;
}
public String getShift() {
return shift;
}

@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map;
public interface H5ApiService {
List<H5> dailyProductDetil(String workTime);
// List<H5> dailyProductDetil(String workTime);
List EnergyExpend();
}

@ -4,11 +4,15 @@ package com.op.mes.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.mes.domain.EnergyExpend;
import com.op.mes.domain.H5;
import com.op.mes.domain.MesDailyReport;
import com.op.mes.mapper.H5ApiMapper;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.mes.service.H5ApiService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
@ -23,142 +27,155 @@ import java.util.stream.Collectors;
public class H5ApiServiceImpl implements H5ApiService {
@Autowired
private H5ApiMapper h5ApiMapper;
@Autowired
private MesReportWorkMapper mesReportWorkMapper;
// @Override
// @DS("#header.poolName")
// public List<MesDailyReport> dailyProductDetil(String workTime) {
//
//
@Override
@DS("#header.poolName")
public List<H5> dailyProductDetil(String workTime) {
//查询当天的生产情况
H5 h5=new H5();
h5.setFeedbackTime(workTime);
//报工信息
List<H5> h5List=h5ApiMapper.selectMesLineProdceList(h5);
//报工信息处理
//母单报工数据
List<H5> filteredList = h5List.stream()
.filter(h5s -> "0".equals(h5s.getParentOrder()))
.collect(Collectors.toList());
//子单报工数据
List<H5> filteredLists = h5List.stream()
.filter(h5s -> !"0".equals(h5s.getParentOrder()))
.collect(Collectors.toList());
// 按照 workOrderCode 分组,并计算各个字段的统计值
List<H5> resultList = filteredList.stream()
.collect(Collectors.groupingBy(
H5::getWorkOrderCode, // 按 workOrderCode 分组
Collectors.collectingAndThen(
Collectors.toList(),
list -> {
double averageStandardStaffing = list.stream()
.collect(Collectors.averagingDouble(H5::getStandardStaffing));
double averageActualEmployment = list.stream()
.collect(Collectors.averagingDouble(H5::getActualEmployment));
double totalProductionDuration = list.stream()
.collect(Collectors.summingDouble(H5::getProductionDuration));
double totalPlanProduction = list.stream()
.collect(Collectors.summingDouble(H5::getPlanProduction));
double totalProduction = list.stream()
.collect(Collectors.summingDouble(H5::getProduction));
H5 resultH5 = new H5();
resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
resultH5.setLineName(list.get(0).getLineName());
resultH5.setProductName(list.get(0).getProductName());
resultH5.setCategory(list.get(0).getCategory());
resultH5.setSpecifications(list.get(0).getSpecifications());
resultH5.setStandardEfficiency(list.get(0).getStandardEfficiency());
resultH5.setActualEmployment(averageActualEmployment);
resultH5.setStandardStaffing((int) Math.round(averageStandardStaffing)); // 计算的平均值
resultH5.setProductionDuration(totalProductionDuration); // 总和
resultH5.setPlanProduction((int) Math.round(totalPlanProduction)); // 总和
resultH5.setProduction((int) Math.round(totalProduction)); // 总和
resultH5.setReason(list.get(0).getReason());
resultH5.setShift(list.get(0).getShift());
return resultH5;
}
)
))
.values()
.stream()
.collect(Collectors.toList());
List<H5> resultLists = filteredLists.stream()
.collect(Collectors.groupingBy(
H5::getWorkOrderCode, // 按 workOrderCode 分组
Collectors.collectingAndThen(
Collectors.toList(),
list -> {
double averageActualEmployment =Math.round(list.stream()
.collect(Collectors.averagingDouble(H5::getActualEmployment)));
H5 resultH5 = new H5();
resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
resultH5.setActualEmployment(averageActualEmployment);
resultH5.setParentOrder(list.get(0).getParentOrder());
return resultH5;
}
)
))
.values()
.stream()
.collect(Collectors.toList());
// 将 resultLists 转换为 Map以便快速查找
Map<String, H5> parentOrderToH5Map = resultLists.stream()
.collect(Collectors.toMap(
H5::getParentOrder,
h5s -> h5s
));
// 更新 resultList 中的 actualEmployment
// 更新 resultList 中的 actualEmployment
resultList.forEach(h51 -> {
H5 matchingH52 = parentOrderToH5Map.get(h51.getWorkOrderCode());
if (matchingH52 != null) {
h51.setActualEmployment(matchingH52.getActualEmployment());
}
});
// 更新 actualEfficiency 为百分比形式,保留一位小数
resultList.forEach(h5a -> {
double production = h5a.getProduction();
double productionDuration = h5a.getProductionDuration();
double actualEmployment = h5a.getActualEmployment();
double standardEfficiency=h5a.getStandardEfficiency();
// 避免除以零的情况
if (productionDuration != 0 && actualEmployment != 0) {
double actualEfficiency = production / productionDuration / actualEmployment;
actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
h5a.setActualEfficiency(actualEfficiency);
String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency/standardEfficiency)*100); // 格式化为百分比形式
h5a.setEfficiencyAcRate(efficiencyAcRate); // 设置百分比形式
} else {
h5a.setEfficiencyAcRate("0.0%"); // 或者设为其他默认值
}
});
resultList.stream()
.forEach(h5a -> {
double production = h5a.getProduction();
double productionDuration = h5a.getProductionDuration();
double actualEmployment = h5a.getActualEmployment();
double standardEfficiency = h5a.getStandardEfficiency();
// Avoid division by zero
if (productionDuration != 0 && actualEmployment != 0) {
double actualEfficiency = production / productionDuration / actualEmployment;
actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
h5a.setActualEfficiency(actualEfficiency);
// Format efficiency as a percentage
String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency / standardEfficiency) * 100);
h5a.setEfficiencyAcRate(efficiencyAcRate);
} else {
h5a.setEfficiencyAcRate("0.0%");
}
});
// H5 h5=new H5();
// h5.setFeedbackTime(workTime);
return resultList;
}
// //报工信息
// List<H5> h5List=h5ApiMapper.selectMesLineProdceList(h5);
//// List<H5> resultList = new ArrayList<>();
//// if (h5List != null && h5List.size() >0){
//// resultList = filterParentWithChildren(h5List);
//// }
//
//
// //报工信息处理
// //母单报工数据
// List<H5> filteredList = h5List.stream()
// .filter(h5s -> "0".equals(h5s.getParentOrder()))
// .collect(Collectors.toList());
// //子单报工数据
// List<H5> filteredLists = h5List.stream()
// .filter(h5s -> !"0".equals(h5s.getParentOrder()))
// .collect(Collectors.toList());
// // 按照 workOrderCode 分组,并计算各个字段的统计值
// List<H5> resultList = filteredList.stream()
// .collect(Collectors.groupingBy(
// H5::getWorkOrderCode, // 按 workOrderCode 分组
// Collectors.collectingAndThen(
// Collectors.toList(),
// list -> {
// double averageStandardStaffing = list.stream()
// .collect(Collectors.averagingDouble(H5::getStandardStaffing));
// double averageActualEmployment = list.stream()
// .collect(Collectors.averagingDouble(H5::getActualEmployment));
// double totalProductionDuration = list.stream()
// .collect(Collectors.summingDouble(H5::getProductionDuration));
// double totalPlanProduction = list.stream()
// .collect(Collectors.summingDouble(H5::getPlanProduction));
// double totalProduction = list.stream()
// .collect(Collectors.summingDouble(H5::getProduction));
//
// H5 resultH5 = new H5();
// resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
// resultH5.setLineName(list.get(0).getLineName());
// resultH5.setProductName(list.get(0).getProductName());
// resultH5.setCategory(list.get(0).getCategory());
// resultH5.setSpecifications(list.get(0).getSpecifications());
// resultH5.setStandardEfficiency(list.get(0).getStandardEfficiency());
// resultH5.setActualEmployment(averageActualEmployment);
// resultH5.setStandardStaffing((int) Math.round(averageStandardStaffing)); // 计算的平均值
// resultH5.setProductionDuration(totalProductionDuration); // 总和
// resultH5.setPlanProduction((int) Math.round(totalPlanProduction)); // 总和
// resultH5.setProduction((int) Math.round(totalProduction)); // 总和
// resultH5.setReason(list.get(0).getReason());
// resultH5.setShift(list.get(0).getShift());
// return resultH5;
// }
// )
// ))
// .values()
// .stream()
// .collect(Collectors.toList());
//
// List<H5> resultLists = filteredLists.stream()
// .collect(Collectors.groupingBy(
// H5::getWorkOrderCode, // 按 workOrderCode 分组
// Collectors.collectingAndThen(
// Collectors.toList(),
// list -> {
// double averageActualEmployment =Math.round(list.stream()
// .collect(Collectors.averagingDouble(H5::getActualEmployment)));
// H5 resultH5 = new H5();
// resultH5.setWorkOrderCode(list.get(0).getWorkOrderCode()); // 设置 workOrderCode
// resultH5.setActualEmployment(averageActualEmployment);
// resultH5.setParentOrder(list.get(0).getParentOrder());
// return resultH5;
// }
// )
// ))
// .values()
// .stream()
// .collect(Collectors.toList());
//
// // 将 resultLists 转换为 Map以便快速查找
// Map<String, H5> parentOrderToH5Map = resultLists.stream()
// .collect(Collectors.toMap(
// H5::getParentOrder,
// h5s -> h5s
// ));
//
// // 更新 resultList 中的 actualEmployment
// resultList.forEach(h51 -> {
// H5 matchingH52 = parentOrderToH5Map.get(h51.getWorkOrderCode());
// if (matchingH52 != null) {
// h51.setActualEmployment(matchingH52.getActualEmployment());
// }
// });
// // 更新 actualEfficiency 为百分比形式,保留一位小数
// resultList.forEach(h5a -> {
// double production = h5a.getProduction();
// double productionDuration = h5a.getProductionDuration();
// double actualEmployment = h5a.getActualEmployment();
// double standardEfficiency=h5a.getStandardEfficiency();
// // 避免除以零的情况
// if (productionDuration != 0 && actualEmployment != 0) {
// double actualEfficiency = production / productionDuration / actualEmployment;
// actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
// h5a.setActualEfficiency(actualEfficiency);
// String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency/standardEfficiency)*100); // 格式化为百分比形式
// h5a.setEfficiencyAcRate(efficiencyAcRate); // 设置百分比形式
// } else {
// h5a.setEfficiencyAcRate("0.0%"); // 或者设为其他默认值
// }
// });
//
// resultList.stream()
// .forEach(h5a -> {
// double production = h5a.getProduction();
// double productionDuration = h5a.getProductionDuration();
// double actualEmployment = h5a.getActualEmployment();
// double standardEfficiency = h5a.getStandardEfficiency();
//
// // Avoid division by zero
// if (productionDuration != 0 && actualEmployment != 0) {
// double actualEfficiency = production / productionDuration / actualEmployment;
// actualEfficiency = Math.round(actualEfficiency * 10.0) / 10.0;
// h5a.setActualEfficiency(actualEfficiency);
//
// // Format efficiency as a percentage
// String efficiencyAcRate = String.format("%.1f%%", (actualEfficiency / standardEfficiency) * 100);
// h5a.setEfficiencyAcRate(efficiencyAcRate);
// } else {
// h5a.setEfficiencyAcRate("0.0%");
// }
// });
//
//
// return resultList;
// }
@Override
@DS("#header.poolName")

Loading…
Cancel
Save