| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | @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) { |
| | |
| | | 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()) |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | result.put("footSum", footSumFuture.get()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("并行查询异常:" + e.getMessage(), e); |
| | | throw new RuntimeException("次破总表并行查询异常:" + e.getMessage(), e); |
| | | } |
| | | |
| | | // 回传前端的时间(现在是带时分秒的) |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | // 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) { |
| | |
| | | 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; |
| | | } |
| | | |