From 9ccc8bd3a53160a40cf60f14e5867f6ce9f6c58f Mon Sep 17 00:00:00 2001
From: guoyujie <guoyujie@ng.com>
Date: 星期五, 26 十二月 2025 16:49:15 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override
---
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 216 insertions(+), 23 deletions(-)
diff --git a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
index 85c1798..ad0c82b 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
@@ -15,9 +15,11 @@
import com.example.erp.entity.pp.Report;
import com.example.erp.mapper.pp.*;
import com.example.erp.mapper.sd.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
@@ -32,6 +34,8 @@
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Function;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static cn.hutool.core.convert.Convert.toDouble;
@@ -58,6 +62,33 @@
@Resource
private AsyncQueryExecutor asyncExecutor;
+
+ //鏍规嵁鍦ㄥ埗鍝佸悕绉拌幏鍙栧帤搴�
+ private List<BigDecimal> parseGlassThicknessList(String glassName) {
+ List<BigDecimal> list = new ArrayList<>();
+ if (glassName == null || glassName.isEmpty()) {
+ return list;
+ }
+
+ // 鍖归厤鎵�鏈� "鏁板瓧 + mm"锛屾敮鎸佸皬鏁帮紝渚嬪 3.2mm銆�5mm銆�8mm
+ Pattern pattern = Pattern.compile("(\\d+(?:\\.\\d+)?)mm");
+ Matcher matcher = pattern.matcher(glassName);
+
+ while (matcher.find()) {
+ String numStr = matcher.group(1); // 鎹曡幏 5銆�8銆�3.2
+ try {
+ list.add(new BigDecimal(numStr));
+ } catch (Exception ignore) {
+ }
+ }
+ return list;
+ }
+
+ //鐜荤拑鍘氬害姹傚拰
+ private BigDecimal calcGlassThicknessSum(String glassName) {
+ return parseGlassThicknessList(glassName).stream()
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
+ }
//涓婂伐搴忔姤宸ョ彮缁�
private void mergeTeamsGroupsName( List<WorkInProgressDTO> dataList1,List<WorkInProgressDTO> dataList2) {
@@ -86,9 +117,11 @@
if(productDetail!=null){
dto1.setGlassName(productDetail.getDetail());
}
+ BigDecimal thicknessSum = calcGlassThicknessSum(productDetail.getDetail());
+ dto1.setThickness(thicknessSum);
//basicData.getNickname().equals("stepC")
- }else if(basicData.getNickname().equals("stepC")){
+ }else if(basicData.getNickname().equals("stepC")){//澶瑰眰
OrderGlassDetail orderGlassDetailGroup = orderGlassDetailMapper
.selectOne(new QueryWrapper<OrderGlassDetail>()
.eq("order_id", dto1.getOrderId())
@@ -102,9 +135,13 @@
orderGlassDetailMapper.getMaxTechnologyNumberByGroup(dto1.getOrderId(),dto1.getOrderNumber(), String.valueOf(orderGlassDetailGroup.getGroup()))
);
dto1.setGlassName(glassName);
-
- }else{
- dto1.setGlassName(dto1.getProductName());
+ BigDecimal thicknessSum = calcGlassThicknessSum(glassName);
+ dto1.setThickness(thicknessSum);
+ }else{//涓┖
+ String glassName = productDetailMapper.getGlassName(orderDetail.getProductId());
+ dto1.setGlassName(glassName);
+ BigDecimal thicknessSum = calcGlassThicknessSum(glassName);
+ dto1.setThickness(thicknessSum);
}
}
@@ -176,7 +213,7 @@
//鍒ゆ柇澶硅兌鍜屽す鑳跺悗宸ュ簭
//Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")
if(Objects.equals(basicData.getNickname(), "stepA") || Objects.equals(basicData.getNickname(), "stepC")){
- clos.put(uniqueList.get(i).get("process"), 14+i);
+ clos.put(uniqueList.get(i).get("process"), 15+i);
}
//鍒ゆ柇涓┖鍜屼腑绌哄悗宸ュ簭
//Objects.equals(basicData.getNickname(), "stepB") || Objects.equals(basicData.getNickname(), "stepD")
@@ -666,7 +703,7 @@
result.put("footSum", footSumFuture.get());
} catch (Exception e) {
e.printStackTrace();
- throw new RuntimeException("骞惰鏌ヨ寮傚父锛�" + e.getMessage(), e);
+ throw new RuntimeException("娆$牬鎬昏〃骞惰鏌ヨ寮傚父锛�" + e.getMessage(), e);
}
// 鍥炰紶鍓嶇鐨勬椂闂达紙鐜板湪鏄甫鏃跺垎绉掔殑锛�
@@ -692,10 +729,27 @@
return map;
}
- public Map<String, Object> yieldSv(String selectTime1, String selectTime2, String selectProcesses, Report report) {
+ public Map<String, Object> yieldSv(List<String> selectDate, String selectProcesses,String reportTime, Report report) {
Map<String, Object> map = new HashMap<>();
- map.put("data", reportMapper.yieldMp(selectTime1, selectTime2, selectProcesses, report));
+ // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 7 澶╋紙鏃ユ湡 + reportTime锛�
+ String startDate = toReportTime(LocalDate.now().minusDays(7).toString(), reportTime);
+ String endDate = toReportTime(LocalDate.now().toString(), reportTime);
+
+ // 濡傛灉鍓嶇浼犱簡鏃堕棿锛屽氨鐢ㄥ墠绔棩鏈� + reportTime
+ if (selectDate != null && selectDate.size() == 2) {
+ if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
+ startDate = toReportTime(selectDate.get(0), reportTime);
+ }
+ if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
+ endDate = toReportTime(selectDate.get(1), reportTime);
+ }
+ }
+ map.put("data", reportMapper.yieldMp(startDate, endDate, selectProcesses, report));
map.put("process", productionSchedulingMapper.selectProcess());
+ List<String> list = new ArrayList<>();
+ list.add(startDate);
+ list.add(endDate);
+ map.put("selectDate",list);
return map;
}
@@ -956,12 +1010,22 @@
return map;
}
- public List exportCrossProcessBreakingSv(List<LocalDate> dates) {
+ public List exportCrossProcessBreakingSv(List<String> dates) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ List<LocalDateTime> dateTimeList = dates.stream()
+ .map(s -> LocalDateTime.parse(s, formatter))
+ .collect(Collectors.toList());
return reportMapper.exportCrossProcessBreakingMp(dates);
}
- public List exportNotCrossProcessBreakingSv(List<LocalDate> dates) {
- return reportMapper.exportNotCrossProcessBreakingMp(dates);
+ public List exportNotCrossProcessBreakingSv(List<String> dates) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ List<LocalDateTime> dateTimeList = dates.stream()
+ .map(s -> LocalDateTime.parse(s, formatter))
+ .collect(Collectors.toList());
+ return reportMapper.exportNotCrossProcessBreakingMp(dateTimeList);
}
// public List exportTeamOutputSv(Map<String, Object> dates) {
@@ -973,9 +1037,15 @@
// String laminating = reportMapper.getLaminating(process);
// return reportMapper.exportTeamOutputMp(date,process,laminating);
// }
- public List exportDamageReportSv(Map<String, Object> dates) {
- List<LocalDate> date= (List<LocalDate>) dates.get("date");
- return reportMapper.exportDamageReportMp(date);
+ public List exportDamageReportSv(List<String> dates) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ List<LocalDateTime> dateTimeList = dates.stream()
+ .map(s -> LocalDateTime.parse(s, formatter))
+ .collect(Collectors.toList());
+
+ // 杩欓噷鐢� LocalDateTime 鍘昏皟鐢� mapper
+ return reportMapper.exportDamageReportMp(dateTimeList);
}
public List exportOrderPlanDecompositionSv(List<LocalDate> dates) {
@@ -1054,30 +1124,44 @@
// }
public Map<String, Object> teamOutputSv(Integer pageNum, Integer pageSize,
- String selectTime1, String selectTime2,
+ List<String> selectDate,
+ String reportTime,
String selectProcesses, TeamOutputDTO teamOutputDTO) {
if ("all".equals(selectProcesses)) {
selectProcesses = "";
}
+// 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 15 澶╋紙鏃ユ湡 + reportTime锛�
+ String startDate = toReportTime(LocalDate.now().minusDays(15).toString(), reportTime);
+ String endDate = toReportTime(LocalDate.now().toString(), reportTime);
+ // 濡傛灉鍓嶇浼犱簡鏃堕棿锛屽氨鐢ㄥ墠绔棩鏈� + reportTime
+ if (selectDate != null && selectDate.size() == 2) {
+ if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
+ startDate = toReportTime(selectDate.get(0), reportTime);
+ }
+ if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
+ endDate = toReportTime(selectDate.get(1), reportTime);
+ }
+ }
Integer offset = (pageNum - 1) * pageSize;
Map<String, Object> result = new HashMap<>();
String laminating = reportMapper.getLaminating(selectProcesses);
-
+ String finalStartDate = startDate;
+ String finalEndDate = endDate;
String finalSelectProcesses = selectProcesses;
CompletableFuture<List<TeamOutputDTO>> dataFuture = asyncExecutor.runAsync(() ->
- reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO));
+ reportMapper.teamOutputMp(offset, pageSize, finalStartDate, finalEndDate, finalSelectProcesses, laminating, teamOutputDTO));
CompletableFuture<List<Map<String, String>>> processFuture = asyncExecutor.runAsync(() ->
productionSchedulingMapper.selectProcess());
CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() ->
- reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO));
+ reportMapper.teamOutputPageTotal(offset, pageSize, finalStartDate, finalEndDate, finalSelectProcesses, laminating, teamOutputDTO));
CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() ->
- reportMapper.teamOutputFootSum(selectTime1, selectTime2, finalSelectProcesses, laminating, teamOutputDTO));
+ reportMapper.teamOutputFootSum(finalStartDate, finalEndDate, finalSelectProcesses, laminating, teamOutputDTO));
// 绛夊緟鎵�鏈変换鍔″畬鎴�
CompletableFuture.allOf(dataFuture, processFuture, totalFuture, footSumFuture).join();
@@ -1091,7 +1175,10 @@
e.printStackTrace();
throw new RuntimeException("骞惰鏌ヨ寮傚父锛�" + e.getMessage(), e);
}
-
+ List<String> list = new ArrayList<>();
+ list.add(startDate);
+ list.add(endDate);
+ result.put("selectDate", list);
return result;
}
@@ -1118,6 +1205,34 @@
}
String laminating = reportMapper.getLaminating(process);
List<TeamOutputDTO> list = reportMapper.exportTeamOutputMp(date, process, laminating);
+
+ // 娓呮礂姣忎釜 TeamOutputDTO 瀹炰緥鐨� String 瀛楁锛堝幓闄ゅ墠鍚庣┖鏍硷級
+ for (TeamOutputDTO dto : list) {
+ for (Field field : dto.getClass().getDeclaredFields()) {
+ field.setAccessible(true);
+ try {
+ Object value = field.get(dto);
+ if (value instanceof String) {
+ String trimmed = ((String) value).trim();
+ field.set(dto, trimmed);
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return list;
+ }
+
+ public List exportTeamOutputSummarySv(Map<String, Object> dates) {
+ List<LocalDate> date= (List<LocalDate>) dates.get("date");
+ String process= (String) dates.get("processes");
+ if (process.equals("all")){
+ process="";
+ }
+ String laminating = reportMapper.getLaminating(process);
+ List<TeamOutputDTO> list = reportMapper.exportTeamOutputSummaryMp(date, process, laminating);
// 娓呮礂姣忎釜 TeamOutputDTO 瀹炰緥鐨� String 瀛楁锛堝幓闄ゅ墠鍚庣┖鏍硷級
for (TeamOutputDTO dto : list) {
@@ -1258,7 +1373,7 @@
}
totalSumMap.put("stockNum", totalStockNum);
- totalSumMap.put("stockArea", totalStockArea);
+ totalSumMap.put("stockArea", Double.valueOf(String.format("%.2f", totalStockArea)));
map.put("data", resultList);
map.put("total", totalSumMap);
@@ -1643,10 +1758,27 @@
return map;
}
- public Map<String, Object> yieldProcessSv(String selectTime1, String selectTime2, Report report) {
+ public Map<String, Object> yieldProcessSv(List<String> selectDate,String reportTime, Report report) {
Map<String, Object> map = new HashMap<>();
- map.put("data", reportMapper.yieldProcessMp(selectTime1, selectTime2, report));
+ // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 7 澶╋紙鏃ユ湡 + reportTime锛�
+ String startDate = toReportTime(LocalDate.now().minusDays(7).toString(), reportTime);
+ String endDate = toReportTime(LocalDate.now().toString(), reportTime);
+
+ // 濡傛灉鍓嶇浼犱簡鏃堕棿锛屽氨鐢ㄥ墠绔棩鏈� + reportTime
+ if (selectDate != null && selectDate.size() == 2) {
+ if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
+ startDate = toReportTime(selectDate.get(0), reportTime);
+ }
+ if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
+ endDate = toReportTime(selectDate.get(1), reportTime);
+ }
+ }
+ map.put("data", reportMapper.yieldProcessMp(startDate, endDate, report));
map.put("process", productionSchedulingMapper.selectProcess());
+ List<String> list = new ArrayList<>();
+ list.add(startDate);
+ list.add(endDate);
+ map.put("selectDate",list);
return map;
}
@@ -1665,4 +1797,65 @@
return map;
}
+
+ public Map<String, Object> TeamOutputSummarySv(Integer pageNum, Integer pageSize, List<String> selectDate,
+ String reportTime, String selectProcesses, TeamOutputDTO teamOutputDTO) {
+ if ("all".equals(selectProcesses)) {
+ selectProcesses = "";
+ }
+
+ Integer offset = (pageNum - 1) * pageSize;
+
+ // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 15 澶╋紙鏃ユ湡 + reportTime锛�
+ String startDate = toReportTime(LocalDate.now().minusDays(15).toString(), reportTime);
+ String endDate = toReportTime(LocalDate.now().toString(), reportTime);
+
+ // 濡傛灉鍓嶇浼犱簡鏃堕棿锛屽氨鐢ㄥ墠绔棩鏈� + reportTime
+ if (selectDate != null && selectDate.size() == 2) {
+ if (selectDate.get(0) != null && !selectDate.get(0).isEmpty()) {
+ startDate = toReportTime(selectDate.get(0), reportTime);
+ }
+ if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
+ endDate = toReportTime(selectDate.get(1), reportTime);
+ }
+ }
+ Map<String, Object> result = new HashMap<>();
+
+ String laminating = reportMapper.getLaminating(selectProcesses);
+
+ String finalSelectProcesses = selectProcesses;
+ String finalStartDate = startDate;
+ String finalEndDate = endDate;
+ CompletableFuture<List<TeamOutputDTO>> dataFuture = asyncExecutor.runAsync(() ->
+ reportMapper.TeamOutputSummaryMp(offset, pageSize, finalStartDate, finalEndDate, finalSelectProcesses, laminating, teamOutputDTO));
+
+ CompletableFuture<List<Map<String, String>>> processFuture = asyncExecutor.runAsync(() ->
+ productionSchedulingMapper.selectProcess());
+
+ CompletableFuture<Map<String, Integer>> totalFuture = asyncExecutor.runAsync(() ->
+ reportMapper.teamOutputSummaryPageTotal(offset, pageSize, finalStartDate, finalEndDate, finalSelectProcesses, laminating, teamOutputDTO));
+
+
+
+ CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() ->
+ reportMapper.teamOutputFootSum(finalStartDate, finalEndDate, finalSelectProcesses, laminating, teamOutputDTO));
+
+ // 绛夊緟鎵�鏈変换鍔″畬鎴�
+ CompletableFuture.allOf(dataFuture, processFuture, totalFuture, footSumFuture).join();
+
+ try {
+ result.put("data", dataFuture.get());
+ result.put("process", processFuture.get());
+ result.put("total", totalFuture.get());
+ result.put("footSum", footSumFuture.get());
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("骞惰鏌ヨ寮傚父锛�" + e.getMessage(), e);
+ }
+ List<String> list = new ArrayList<>();
+ list.add(startDate);
+ list.add(endDate);
+ result.put("selectDate", list);
+ return result;
+ }
}
--
Gitblit v1.8.0