|
package com.example.erp.service.pp;
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
import com.example.erp.dto.pp.*;
|
import com.example.erp.entity.pp.DamageDetails;
|
import com.example.erp.entity.pp.Report;
|
import com.example.erp.mapper.pp.ProductionSchedulingMapper;
|
import com.example.erp.mapper.pp.ReportMapper;
|
import com.example.erp.mapper.sd.OrderProcessDetailMapper;
|
import org.springframework.stereotype.Service;
|
|
import java.sql.Date;
|
import java.time.LocalDate;
|
import java.util.*;
|
|
@Service
|
@DS("pp")
|
public class ReportService {
|
private final ReportMapper reportMapper;
|
|
private final OrderProcessDetailMapper orderProcessDetailMapper;
|
private final ProductionSchedulingMapper productionSchedulingMapper;
|
|
|
public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper, ProductionSchedulingMapper productionSchedulingMapper) {
|
this.reportMapper = reportMapper;
|
this.orderProcessDetailMapper = orderProcessDetailMapper;
|
this.productionSchedulingMapper = productionSchedulingMapper;
|
}
|
|
//流程卡进度方法
|
public Map<String, Object> processCardProgressSv(String orderId, List<Integer> columns) {
|
Map<String, Object> map = new HashMap<>();
|
//获取表格内容数据
|
map.put("data", reportMapper.processCardProgressMp(orderId));
|
|
//获取表头工序筛选数据
|
List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId);
|
List<Map<String, String>> processList = processFilterList;
|
|
List<String> filterList = new ArrayList<>();
|
//循环遍历数组,判断此序号当前的工序
|
for (int i = 1; i < processFilterList.size(); i++) {
|
filterList.add(processFilterList.get(i).get("process"));
|
List<Map<String, String>> lastProcessList =
|
orderProcessDetailMapper.filterLastProcess(
|
orderId,
|
String.valueOf(processFilterList.get(i).get("order_number")),
|
String.valueOf(processFilterList.get(i).get("technology_number")),
|
String.valueOf(processFilterList.get(i).get("id"))
|
);
|
if (!lastProcessList.isEmpty()) {
|
int finalI = i;
|
lastProcessList.forEach(lastProcess -> {
|
if (filterList.contains(lastProcess.get("process"))) {
|
processList.add(lastProcess);
|
}
|
});
|
}
|
|
}
|
// 使用HashSet来记录已经遇到的value值
|
Set<String> seenValues = new HashSet<>();
|
// 创建一个新的List来存储结果
|
List<Map<String, String>> uniqueList = new ArrayList<>();
|
|
// 反向遍历原始List
|
for (int i = processList.size() - 1; i >= 0; i--) {
|
Map<String, String> maps = processList.get(i);
|
String value = maps.values().iterator().next(); // 假设每个Map只有一个value
|
|
// 如果value还没有被看到过,就添加到结果List和HashSet中
|
if (!seenValues.contains(value)) {
|
uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序
|
seenValues.add(value);
|
}
|
}
|
map.put("title", uniqueList);
|
|
|
List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId);
|
List<Map<String, Integer>> rowCount = new ArrayList<>();
|
columns.forEach(col -> {
|
getRowCount.forEach(row -> {
|
Map<String, Integer> getRow = new HashMap<>();
|
// { row: 0, col: 1, rowspan: 3, colspan: 0},
|
Object rowNumObj = row.get("RowNum");
|
if (rowNumObj instanceof Double) {
|
getRow.put("row", ((Double) rowNumObj).intValue());
|
} else if (rowNumObj instanceof Integer) {
|
getRow.put("row", (Integer) rowNumObj);
|
}
|
getRow.put("col", col);
|
getRow.put("rowspan", row.get("rowCount"));
|
getRow.put("colspan", 0);
|
rowCount.add(getRow);
|
});
|
});
|
|
|
map.put("mergeCells", rowCount);
|
|
return map;
|
}
|
|
public Map<String, Object> crossProcessBreakingSv(Integer pageNum, Integer pageSize, List<String> selectDate, CrossProcessBreakingDTO crossProcessBreakingDTO) {
|
Integer offset = (pageNum - 1) * pageSize;
|
String endDate = LocalDate.now().toString();
|
String startDate = LocalDate.now().minusDays(15).toString();
|
if (selectDate != null && selectDate.size() == 2) {
|
if (!selectDate.get(0).isEmpty()) {
|
startDate = selectDate.get(0);
|
}
|
if (!selectDate.get(1).isEmpty()) {
|
endDate = selectDate.get(1);
|
}
|
}
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.getProcessBreaking(offset, pageSize, startDate, endDate, crossProcessBreakingDTO));
|
map.put("total", reportMapper.getProcessBreakingTotal(offset, pageSize, startDate, endDate, crossProcessBreakingDTO));
|
List<String> list = new ArrayList<>();
|
list.add(startDate);
|
list.add(endDate);
|
map.put("selectDate", list);
|
return map;
|
}
|
|
public Map<String, Object> workInProgressSv(Integer pageNum, Integer pageSize, String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) {
|
Integer offset = (pageNum - 1) * pageSize;
|
if ("null".equals(orderId)) {
|
orderId = "";
|
}
|
if ("null".equals(inputProject)) {
|
inputProject = "";
|
}
|
if ("null".equals(optionVal)) {
|
optionVal = ("");
|
}
|
|
Map<String, Object> map = new HashMap<>();
|
if (optionVal.equals("1")){
|
/* 根据销售单号汇总*/
|
map.put("data", reportMapper.workInProgressOrderMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
|
// map.put("total", reportMapper.workInProgressOrderTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
|
map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
|
}else if(optionVal.equals("2")){
|
/* 根流程卡号汇总*/
|
map.put("data", reportMapper.workInProgressProcessMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
|
// map.put("total", reportMapper.workInProgressProcessTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
|
map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
|
|
} else if (optionVal.equals("3")) {
|
|
} else {
|
//没有选择分组
|
map.put("data", reportMapper.workInProgressMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
|
//map.put("total", reportMapper.workInProgressTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
|
map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
|
|
}
|
map.put("process", productionSchedulingMapper.selectProcess());
|
return map;
|
}
|
|
public Map<String, Object> selectProcessToBeCompletedSv(Date selectTime1, Date selectTime2, String orderId, String inputProject, String selectProcesses, Report report) {
|
if ("null".equals(orderId)) {
|
orderId = "";
|
}
|
if ("null".equals(inputProject)) {
|
inputProject = "";
|
}
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.processToBeCompletedMp(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report));
|
map.put("process", productionSchedulingMapper.selectProcess());
|
map.put("footSum" ,reportMapper.processToBeCompletedFootSum(selectTime1, selectTime2, orderId, inputProject, selectProcesses, report));
|
|
return map;
|
}
|
|
public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, DamageReportDTO damageReportDTO) {
|
Integer offset = (pageNum - 1) * pageSize;
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
|
map.put("total", reportMapper.getDamageReportPageTotal(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
|
map.put("footSum" ,reportMapper.damageReportFootSum(selectTime1, selectTime2, damageReportDTO));
|
return map;
|
}
|
|
public Map<String, Object> splittingDetailsOutsideSv(String orderId, Report report) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.splittingDetailsOutsideMp(orderId, report));
|
return map;
|
}
|
|
public Map<String, Object> qualityReportSv(Date selectTime1, Date selectTime2, Report report) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.qualityReportMp(selectTime1, selectTime2, report));
|
return map;
|
}
|
|
public Map<String, Object> yieldSv(Date selectTime1, Date selectTime2, String selectProcesses, Report report) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.yieldMp(selectTime1, selectTime2, selectProcesses, report));
|
map.put("process", productionSchedulingMapper.selectProcess());
|
return map;
|
}
|
|
public Map<String, Object> productionScheduleSv(String orderId, List<Integer> columns) {
|
Map<String, Object> map = new HashMap<>();
|
//获取表格内容数据
|
map.put("data", reportMapper.productionScheduleMp(orderId));
|
|
//获取表头工序筛选数据
|
List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcess(orderId);
|
List<Map<String, String>> processList = processFilterList;
|
|
List<String> filterList = new ArrayList<>();
|
//循环遍历数组,判断此序号当前的工序
|
for (int i = 1; i < processFilterList.size(); i++) {
|
filterList.add(processFilterList.get(i).get("process"));
|
List<Map<String, String>> lastProcessList =
|
orderProcessDetailMapper.filterLastProcess(
|
orderId,
|
String.valueOf(processFilterList.get(i).get("order_number")),
|
String.valueOf(processFilterList.get(i).get("technology_number")),
|
String.valueOf(processFilterList.get(i).get("id"))
|
);
|
if (!lastProcessList.isEmpty()) {
|
int finalI = i;
|
lastProcessList.forEach(lastProcess -> {
|
if (filterList.contains(lastProcess.get("process"))) {
|
processList.add(lastProcess);
|
}
|
});
|
}
|
|
}
|
// 使用HashSet来记录已经遇到的value值
|
Set<String> seenValues = new HashSet<>();
|
// 创建一个新的List来存储结果
|
List<Map<String, String>> uniqueList = new ArrayList<>();
|
|
// 反向遍历原始List
|
for (int i = processList.size() - 1; i >= 0; i--) {
|
Map<String, String> maps = processList.get(i);
|
String value = maps.values().iterator().next(); // 假设每个Map只有一个value
|
|
// 如果value还没有被看到过,就添加到结果List和HashSet中
|
if (!seenValues.contains(value)) {
|
uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序
|
seenValues.add(value);
|
}
|
}
|
map.put("title", uniqueList);
|
|
|
List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRow(orderId);
|
List<Map<String, Integer>> rowCount = new ArrayList<>();
|
columns.forEach(col -> {
|
getRowCount.forEach(row -> {
|
Map<String, Integer> getRow = new HashMap<>();
|
// { row: 0, col: 1, rowspan: 3, colspan: 0},
|
getRow.put("row", row.get("RowNum"));
|
getRow.put("col", col);
|
getRow.put("rowspan", row.get("rowCount"));
|
getRow.put("colspan", 0);
|
rowCount.add(getRow);
|
});
|
});
|
|
|
map.put("mergeCells", rowCount);
|
|
return map;
|
}
|
|
public Map<String, Object> taskCompletionStatusSv(Date selectTime1, Date selectTime2, List<Integer> columns) {
|
Map<String, Object> map = new HashMap<>();
|
//获取表格内容数据
|
map.put("data", reportMapper.taskCompletionStatusMp(selectTime1, selectTime2));
|
|
//获取表头工序筛选数据
|
List<Map<String, String>> processFilterList = orderProcessDetailMapper.filterOrderProcessCollect(selectTime1, selectTime2);
|
List<Map<String, String>> processList = processFilterList;
|
|
List<String> filterList = new ArrayList<>();
|
//循环遍历数组,判断此序号当前的工序
|
for (int i = 1; i < processFilterList.size(); i++) {
|
filterList.add(processFilterList.get(i).get("process"));
|
List<Map<String, String>> lastProcessList =
|
orderProcessDetailMapper.filterLastProcess(
|
String.valueOf(processFilterList.get(i).get("order_id")),
|
String.valueOf(processFilterList.get(i).get("order_number")),
|
String.valueOf(processFilterList.get(i).get("technology_number")),
|
String.valueOf(processFilterList.get(i).get("id"))
|
);
|
if (!lastProcessList.isEmpty()) {
|
int finalI = i;
|
lastProcessList.forEach(lastProcess -> {
|
if (filterList.contains(lastProcess.get("process"))) {
|
processList.add(lastProcess);
|
}
|
});
|
}
|
|
}
|
// 使用HashSet来记录已经遇到的value值
|
Set<String> seenValues = new HashSet<>();
|
// 创建一个新的List来存储结果
|
List<Map<String, String>> uniqueList = new ArrayList<>();
|
|
// 反向遍历原始List
|
for (int i = processList.size() - 1; i >= 0; i--) {
|
Map<String, String> maps = processList.get(i);
|
String value = maps.values().iterator().next(); // 假设每个Map只有一个value
|
|
// 如果value还没有被看到过,就添加到结果List和HashSet中
|
if (!seenValues.contains(value)) {
|
uniqueList.add(0, maps); // 添加到结果List的开头,以保持原顺序
|
seenValues.add(value);
|
}
|
}
|
map.put("title", uniqueList);
|
|
|
List<Map<String, Integer>> getRowCount = orderProcessDetailMapper.getGlassLRowCollect(selectTime1, selectTime2);
|
List<Map<String, Integer>> rowCount = new ArrayList<>();
|
columns.forEach(col -> {
|
getRowCount.forEach(row -> {
|
Map<String, Integer> getRow = new HashMap<>();
|
// { row: 0, col: 1, rowspan: 3, colspan: 0},
|
getRow.put("row", row.get("RowNum"));
|
getRow.put("col", col);
|
getRow.put("rowspan", row.get("rowCount"));
|
getRow.put("colspan", 0);
|
rowCount.add(getRow);
|
});
|
});
|
|
|
map.put("mergeCells", rowCount);
|
|
return map;
|
}
|
|
public Map<String, Object> orderPlanDecompositionSv(Date selectTime1, Date selectTime2, Report report) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.orderPlanDecompositionMp(selectTime1, selectTime2, report));
|
return map;
|
}
|
|
public Map<String, Object> orderReportingWorks(Date selectTime1, Date selectTime2, Report report) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.orderReportingWorks(selectTime1, selectTime2, report));
|
return map;
|
}
|
|
public Map<String, Object> rawMaterialRequisitionSv(Date selectTime1, Date selectTime2, Report report) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.rawMaterialRequisitionMp(selectTime1, selectTime2, report));
|
return map;
|
}
|
|
public List exportCrossProcessBreakingSv(List<LocalDate> dates) {
|
return reportMapper.exportCrossProcessBreakingMp(dates);
|
}
|
|
public List exportDamageReportSv(List<LocalDate> dates) {
|
if (dates != null && dates.size() > 1) {
|
dates.set(1, dates.get(1).plusDays(1)); // 将第二个日期加一天
|
}
|
System.out.println(dates);
|
return reportMapper.exportDamageReportMp(dates);
|
}
|
|
public List exportOrderPlanDecompositionSv(List<LocalDate> dates) {
|
return reportMapper.exportOrderPlanDecompositionMp(dates);
|
}
|
|
public List exportProcessToBeCompletedSv(Map<String, Object> dates) {
|
List<LocalDate> date= (List<LocalDate>) dates.get("date");
|
String process= (String) dates.get("processes");
|
String inputVal= (String) dates.get("inputVal");
|
String project= (String) dates.get("project");
|
if ("null".equals(inputVal)) {
|
inputVal = "";
|
}
|
if ("null".equals(project)) {
|
project = "";
|
}
|
return reportMapper.exportProcessToBeCompletedMp(date,process,inputVal,project);
|
}
|
|
public List exportWorkInProgressSv(Map<String, Object> dates) {
|
String process= (String) dates.get("processes");
|
String inputVal= (String) dates.get("inputVal");
|
String project= (String) dates.get("project");
|
if ("null".equals(inputVal)) {
|
inputVal = "";
|
}
|
if ("null".equals(project)) {
|
project = "";
|
}
|
return reportMapper.exportWorkInProgressMp(process,inputVal,project);
|
}
|
|
public List exportTaskCompletionStatusSv(Map<String, Object> dates) {
|
return reportMapper.exportTaskCompletionStatusMp(dates);
|
}
|
|
public List exportRawMaterialRequisitionSv(List<LocalDate> dates) {
|
return reportMapper.exportRawMaterialRequisitionMp(dates);
|
}
|
|
public List exportQualityReportSv(List<LocalDate> dates) {
|
return reportMapper.exportQualityReportSv(dates);
|
}
|
|
public List exportYieldSv(Map<String, Object> dates) {
|
List<LocalDate> date= (List<LocalDate>) dates.get("date");
|
String process= (String) dates.get("processes");
|
return reportMapper.exportYieldMp(date,process);
|
}
|
|
public Map<String, Object> teamOutputSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, String selectProcesses, TeamOutputDTO teamOutputDTO) {
|
if (selectProcesses.equals("全部")){
|
selectProcesses="";
|
}
|
Integer offset = (pageNum - 1) * pageSize;
|
Map<String, Object> map = new HashMap<>();
|
String laminating = reportMapper.getLaminating(selectProcesses);
|
map.put("data", reportMapper.teamOutputMp(offset, pageSize, selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO));
|
map.put("process", productionSchedulingMapper.selectProcess());
|
map.put("total", reportMapper.teamOutputPageTotal(offset, pageSize, selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO));
|
map.put("footSum" ,reportMapper.teamOutputFootSum(selectTime1, selectTime2,selectProcesses,laminating, teamOutputDTO));
|
return map;
|
}
|
|
public Map<String, Object> scheduleProductionScheduleSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, String processes, ScheduleProductionScheduleDTO scheduleProductionScheduleDTO) {
|
Integer offset = (pageNum - 1) * pageSize;
|
Map<String, Object> map = new HashMap<>();
|
map.put("data", reportMapper.scheduleProductionScheduleMp(offset, pageSize, selectTime1, selectTime2,processes, scheduleProductionScheduleDTO));
|
map.put("total", reportMapper.getScheduleProductionScheduleTotal(offset, pageSize, selectTime1, selectTime2,processes, scheduleProductionScheduleDTO));
|
map.put("process", productionSchedulingMapper.selectProcess());
|
return map;
|
}
|
|
public List exportScheduleReportSv(Map<String, Object> dates) {
|
List<LocalDate> date= (List<LocalDate>) dates.get("date1");
|
String process= (String) dates.get("processes");
|
return reportMapper.exportScheduleReportMp(date,process);
|
}
|
|
public List exportTeamOutputSv(Map<String, Object> dates) {
|
List<LocalDate> date= (List<LocalDate>) dates.get("date");
|
String process= (String) dates.get("processes");
|
if (process.equals("全部")){
|
process="";
|
}
|
String laminating = reportMapper.getLaminating(process);
|
return reportMapper.exportTeamOutputMp(date,process,laminating);
|
}
|
}
|