From 583b80a582f9280a262ee72506d31d1bfa46f734 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 10 十二月 2025 11:29:57 +0800
Subject: [PATCH] 补交
---
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java | 220 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 169 insertions(+), 51 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 9049abc..b68291d 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;
@@ -26,9 +28,14 @@
import java.sql.Date;
import java.sql.SQLOutput;
import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
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;
@@ -55,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) {
@@ -83,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())
@@ -99,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);
}
}
@@ -332,29 +372,47 @@
// return map;
// }
- private static String to080000(String s) {
- if (s == null || s.isEmpty()) return null;
- String v = s.trim();
- // 鍙繚鐣欐棩鏈熼儴鍒嗭紙鍓�10浣� yyyy-MM-dd锛�
- String datePart = v.length() >= 10 ? v.substring(0, 10) : v;
- return datePart + " 08:00:00";
+
+ private static final DateTimeFormatter DATE_TIME_FMT =
+ DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+ private String toReportTime(String dateStr, String reportTime) {
+ if (dateStr == null || dateStr.isEmpty()) {
+ return null;
+ }
+
+ // 鍙繚鐣� yyyy-MM-dd锛岄槻姝㈠墠绔紶瀹屾暣鏃堕棿瀵艰嚧 parse 寮傚父
+ String onlyDate = dateStr.length() > 10 ? dateStr.substring(0, 10) : dateStr;
+
+
+ String[] parts = reportTime.split(":");
+ int hour = Integer.parseInt(parts[0]);
+ int minute = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
+ int second = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;
+
+ LocalDate date = LocalDate.parse(onlyDate);
+ LocalTime time = LocalTime.of(hour, minute, second);
+
+ return LocalDateTime.of(date, time).format(DATE_TIME_FMT);
}
//璺ㄥ伐搴忔鐮�
public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize,
List<String> selectDate,
+ String reportTime,
CrossProcessBreakingDTO crossProcessBreakingDTO) {
Integer offset = (pageNum - 1) * pageSize;
- // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 15 澶�
- String startDate = to080000(LocalDate.now().minusDays(15).toString());
- String endDate = to080000(LocalDate.now().toString());
+ // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 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 = to080000(selectDate.get(0));
+ startDate = toReportTime(selectDate.get(0), reportTime);
}
if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
- endDate = to080000(selectDate.get(1));
+ endDate = toReportTime(selectDate.get(1), reportTime);
}
}
@@ -363,7 +421,6 @@
// 浣跨敤寮傛绾跨▼姹�
String finalEndDate = endDate;
String finalStartDate = startDate;
- System.out.println(finalEndDate+"==="+finalStartDate);
CompletableFuture<List<CrossProcessBreakingDTO>> dataFuture = asyncExecutor.runAsync(() ->
reportMapper.getProcessBreaking(offset, pageSize, finalStartDate, finalEndDate, crossProcessBreakingDTO));
@@ -392,19 +449,21 @@
//闈炶法宸ュ簭娆$牬
public Map<String, Object> notCrossProcessBreakingSv(Integer pageNum, Integer pageSize,
List<String> selectDate,
+ String reportTime,
CrossProcessBreakingDTO crossProcessBreakingDTO) {
Integer offset = (pageNum - 1) * pageSize;
- // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 15 澶�
- String startDate = to080000(LocalDate.now().minusDays(15).toString());
- String endDate = to080000(LocalDate.now().toString());
+ // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 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 = to080000(selectDate.get(0));
+ startDate = toReportTime(selectDate.get(0), reportTime);
}
if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
- endDate = to080000(selectDate.get(1));
+ endDate = toReportTime(selectDate.get(1), reportTime);
}
}
@@ -601,25 +660,31 @@
public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize,
List<String> selectDate,
+ String reportTime,
DamageReportDTO damageReportDTO) {
- Integer offset = (pageNum - 1) * pageSize;
- // 榛樿鏃堕棿鑼冨洿锛氳繃鍘� 15 澶�
- String startDate = to080000(LocalDate.now().minusDays(15).toString());
- String endDate = to080000(LocalDate.now().toString());
+ 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 = to080000(selectDate.get(0));
+ startDate = toReportTime(selectDate.get(0), reportTime);
}
if (selectDate.get(1) != null && !selectDate.get(1).isEmpty()) {
- endDate = to080000(selectDate.get(1));
+ endDate = toReportTime(selectDate.get(1), reportTime);
}
}
- Map<String, Object> result = new HashMap<>();
- String finalEndDate = endDate;
- String finalStartDate = startDate;
- // 寮傛浠诲姟瀹氫箟
+ Map<String, Object> result = new HashMap<>();
+ String finalStartDate = startDate;
+ String finalEndDate = endDate;
+
+ // 寮傛浠诲姟瀹氫箟
CompletableFuture<List<DamageReportDTO>> dataFuture = asyncExecutor.runAsync(() ->
reportMapper.selectDamageReportMp(offset, pageSize, finalStartDate, finalEndDate, damageReportDTO));
@@ -629,7 +694,7 @@
CompletableFuture<Map<String, Float>> footSumFuture = asyncExecutor.runAsync(() ->
reportMapper.damageReportFootSum(finalStartDate, finalEndDate, damageReportDTO));
- //绛夊緟鍏ㄩ儴浠诲姟瀹屾垚
+ // 绛夊緟鍏ㄩ儴浠诲姟瀹屾垚
CompletableFuture.allOf(dataFuture, totalFuture, footSumFuture).join();
try {
@@ -638,8 +703,10 @@
result.put("footSum", footSumFuture.get());
} catch (Exception e) {
e.printStackTrace();
- throw new RuntimeException("骞惰鏌ヨ寮傚父锛�" + e.getMessage(), e);
+ throw new RuntimeException("娆$牬鎬昏〃骞惰鏌ヨ寮傚父锛�" + e.getMessage(), e);
}
+
+ // 鍥炰紶鍓嶇鐨勬椂闂达紙鐜板湪鏄甫鏃跺垎绉掔殑锛�
List<String> list = new ArrayList<>();
list.add(startDate);
list.add(endDate);
@@ -647,6 +714,7 @@
return result;
}
+
public Map<String, Object> splittingDetailsOutsideSv(String orderId, Report report) {
Map<String, Object> map = new HashMap<>();
@@ -661,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;
}
@@ -925,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) {
@@ -942,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) {
@@ -972,14 +1073,14 @@
}
String inputVal= (String) dates.get("inputVal");
String project= (String) dates.get("project");
- String terminationVals= (String) dates.get("terminationVals");
- if ("null".equals(inputVal)) {
+ String terminationVals= dates.get("terminationVals").toString();;
+ if (inputVal==null) {
inputVal = "";
}
- if ("null".equals(project)) {
+ if (project==null) {
project = "";
}
- if ("null".equals(terminationVals)) {
+ if (terminationVals==null) {
terminationVals = "";
}
List<WorkInProgressDTO> dataList1 =reportMapper.exportWorkInProgressMp(process,inputVal,project,terminationVals);
@@ -1243,14 +1344,14 @@
}
String inputVal= (String) dates.get("inputVal");
String project= (String) dates.get("project");
- String terminationVals= (String) dates.get("terminationVals");
- if ("null".equals(inputVal)) {
+ String terminationVals= dates.get("terminationVals").toString();;
+ if (inputVal==null) {
inputVal = "";
}
- if ("null".equals(project)) {
+ if (project==null) {
project = "";
}
- if ("null".equals(terminationVals)) {
+ if (terminationVals==null) {
terminationVals = "";
}
@@ -1612,10 +1713,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;
}
--
Gitblit v1.8.0