| | |
| | | |
| | | import com.example.erp.entity.pp.FlowCard; |
| | | import com.example.erp.mapper.pp.ReportMapper; |
| | | import com.example.erp.mapper.sd.OrderProcessDetailMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.sql.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | | @DS("pp") |
| | | public class ReportService { |
| | | @Autowired |
| | | ReportMapper reportMapper; |
| | | private final ReportMapper reportMapper; |
| | | |
| | | private final OrderProcessDetailMapper orderProcessDetailMapper; |
| | | |
| | | public Map<String, Object> processCardProgressSv(String orderId, FlowCard flowCard) { |
| | | public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper) { |
| | | this.reportMapper = reportMapper; |
| | | this.orderProcessDetailMapper = orderProcessDetailMapper; |
| | | } |
| | | |
| | | //流程卡进度方法 |
| | | public Map<String, Object> processCardProgressSv(String orderId, List<Integer> columns) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", reportMapper.processCardProgressMp(orderId, flowCard)); |
| | | //获取表格内容数据 |
| | | 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}, |
| | | 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; |
| | | } |
| | | } |