企业微信推送修改

master
Yangwl 10 months ago
parent dc57edbaa1
commit d944723919

@ -7,13 +7,13 @@ public class H5 {
private String category;
private String specifications;
private int StandardStaffing;
private int actualEmployment;
private String productionDuration;
private Double actualEmployment;
private Double productionDuration;
private int planProduction;
private int production;
private String hourlyProduction;
private String standardEfficiency;
private String actualEfficiency;
private double standardEfficiency;
private double actualEfficiency;
private String efficiencyAcRate;
private String feedbackTime;
private String parentOrder;
@ -91,19 +91,19 @@ public class H5 {
StandardStaffing = standardStaffing;
}
public int getActualEmployment() {
public Double getActualEmployment() {
return actualEmployment;
}
public void setActualEmployment(int actualEmployment) {
public void setActualEmployment(Double actualEmployment) {
this.actualEmployment = actualEmployment;
}
public String getProductionDuration() {
public Double getProductionDuration() {
return productionDuration;
}
public void setProductionDuration(String productionDuration) {
public void setProductionDuration(Double productionDuration) {
this.productionDuration = productionDuration;
}
@ -123,19 +123,19 @@ public class H5 {
this.hourlyProduction = hourlyProduction;
}
public String getStandardEfficiency() {
public double getStandardEfficiency() {
return standardEfficiency;
}
public void setStandardEfficiency(String standardEfficiency) {
public void setStandardEfficiency(double standardEfficiency) {
this.standardEfficiency = standardEfficiency;
}
public String getActualEfficiency() {
public double getActualEfficiency() {
return actualEfficiency;
}
public void setActualEfficiency(String actualEfficiency) {
public void setActualEfficiency(double actualEfficiency) {
this.actualEfficiency = actualEfficiency;
}

@ -24,8 +24,109 @@ public class H5ApiServiceImpl implements H5ApiService {
//查询当天的生产情况
H5 h5=new H5();
h5.setFeedbackTime(workTime);
//母单报工信息
//报工信息
List<H5> h5List=h5ApiMapper.selectMesLineProdceList(h5);
return 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)); // 总和
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 = 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%"); // 或者设为其他默认值
}
});
return resultList;
}
}

@ -25,9 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -100,7 +99,6 @@ public class MesReportWorksServiceImpl implements IMesReportWorksService {
SysNoticeGroup noticeQo = new SysNoticeGroup();
//取模板
noticeQo.setNoticeId(23L);
List<SysNoticeGroup> notices = mesReportWorkMapper.getNoticesGroup(noticeQo);
if(!CollectionUtils.isEmpty(notices)) {
List<WechartDTO> wecharts = new ArrayList<>();
@ -108,12 +106,20 @@ public class MesReportWorksServiceImpl implements IMesReportWorksService {
WechartDTO wechart0 = new WechartDTO();
wechart0.setUserId(noticedto.getWxId());
String contentInfo = noticedto.getNoticeContent();
contentInfo = contentInfo.replace("${ymd}", DateUtils.getDate())
// 定义格式化日期的格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
// 获取当前日期
Calendar calendar = Calendar.getInstance();
// 将日期设置为前一天
calendar.add(Calendar.DATE, -1);
Date yesterday = calendar.getTime();
// 格式化前一天的日期
String currentDate = dateFormat.format(yesterday);
contentInfo = contentInfo.replace("${ymd}", currentDate)
.replace("${factory}", prowork.getFactoryCode())
.replace("${carName}", prowork.getWorkorderName());
Matcher m = p2.matcher(contentInfo);
contentInfo = m.replaceAll("");
wechart0.setText(contentInfo);
wecharts.add(wechart0);
}

@ -20,86 +20,30 @@
<result property="efficiencyAcRate" column="efficiencyAcRate"/>
</resultMap>
<select id="selectMesLineProdceList" parameterType="H5" resultMap="H5Result">
SELECT
mrw.workorder_code,
mrw.machine_name,
mrw.product_code,
mrw.product_name,
bpa.category,
bp.umrez,
SUM ( mrw.quantity ) AS plan_production,
SUM ( mrw.quantity_feedback ) AS quantity_feedback,
MAX(A.quantity_s) AS quantity_s,
MAX(A.quantity_s_total) AS quantity_s_total,
bpa.man_standar,
MAX(A.use_man) AS use_man,
FORMAT(ROUND((MAX(A.work_time)), 1), '0.#') AS work_time,
mrw.parent_order ,
bpa.iei,
FORMAT(ROUND((bpa.iei / bp.umrez / bpa.man_standar), 1), '0.#') AS standardEfficiency,
FORMAT(ROUND(
CASE
WHEN MAX(A.use_man) = 0 OR SUM(A.work_time) = 0 THEN NULL
ELSE (SUM(mrw.quantity_feedback)) / MAX(A.use_man) / (MAX(A.work_time))
END,
1
), '0.#') AS actualEfficiency,
FORMAT(
CASE
WHEN (bpa.iei / bp.umrez / bpa.man_standar) = 0
THEN NULL
ELSE (CAST(
ROUND(
CASE
WHEN MAX(A.use_man) = 0 OR SUM(A.work_time) = 0 THEN NULL
ELSE (SUM(mrw.quantity_feedback)) / MAX(A.use_man) / (MAX(A.work_time))
END,
1
) AS DECIMAL(10,1))
/ CAST(
ROUND((bpa.iei / bp.umrez / bpa.man_standar), 1) AS DECIMAL(10,1)
) * 100
)
END,
'0.#'
) + '%' AS efficiencyAcRate
FROM
[dbo].[mes_report_work] mrw
LEFT JOIN base_product_attached bpa ON bpa.product_code = RIGHT ( mrw.product_code, 11 )
LEFT JOIN base_product bp ON bp.product_code = mrw.product_code
LEFT JOIN (
SELECT
mrws.workorder_code,
mrws.parent_order,
MAX(mrws.use_man) AS use_man,
MAX(pow.quantity_split) AS quantity_s,
SUM(mrws.quantity_feedback) AS quantity_s_total,
SUM (mrws.work_time ) AS work_time
FROM
[dbo].[mes_report_work] mrws
LEFT JOIN pro_order_workorder pow ON mrws.workorder_code=pow.workorder_code
WHERE
CAST (mrws.feedback_time AS DATE ) = #{feedbackTime}
AND mrws.parent_order != '0'
GROUP BY
mrws.workorder_code,
mrws.parent_order
) A ON A.parent_order= mrw.workorder_code
WHERE
CAST ( mrw.feedback_time AS DATE ) = #{feedbackTime}
AND mrw.parent_order = '0'
GROUP BY
mrw.workorder_code,
mrw.machine_name,
mrw.product_code,
mrw.product_name,
bpa.category,
bp.umrez,
bpa.man_standar,
mrw.use_man,
mrw.parent_order,
bpa.iei
ORDER BY mrw.machine_name ASC
SELECT
mrws.workorder_code,
mrws.machine_name,
mrws.product_name,
bpa.category,
bp.umrez,
mrws.quantity as plan_production,
mrws.quantity_feedback ,
mlp.use_man as man_standar,
mrws.use_man,
mrws.work_time,
CAST(ROUND(mlp.efficiency / mlp.attr1 / mlp.use_man, 1) AS FLOAT) AS standardEfficiency,
CAST(ROUND(mrws.quantity_feedback / mrws.work_time / mrws.use_man, 1) AS FLOAT) AS actualEfficiency,
mrws.parent_order
FROM
[dbo].[mes_report_work] mrws
LEFT JOIN pro_order_workorder pow ON mrws.workorder_code = pow.workorder_code
LEFT JOIN base_product_attached bpa ON bpa.product_code = RIGHT ( mrws.product_code, 11 )
LEFT JOIN base_product bp ON bp.product_code = mrws.product_code
LEFT JOIN mes_line_product mlp ON mlp.product_code=mrws.product_code AND mlp.line_code=mrws.machine_code
WHERE
CAST(mrws.feedback_time AS DATE) = #{feedbackTime}
AND mrws.del_flag = '0'
ORDER BY mrws.machine_name ASC
</select>

Loading…
Cancel
Save