From b51f37241e4b369718d5e27a3686ca7edadaf69b Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期四, 06 三月 2025 16:37:52 +0800 Subject: [PATCH] 新增工时查询接口, 修改配置文件 --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java | 103 +-------------------------------------------------- 1 files changed, 3 insertions(+), 100 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java index ae86eed..186e0a1 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderServiceImpl.java @@ -442,6 +442,9 @@ if (StringUtils.isBlank(product.getAsk()) || StringUtils.isBlank(product.getTell())) { throw new ErrorException("鏈夋楠岄」鐨勮姹傚�兼垨瑕佹眰鎻忚堪涓虹┖, 璇峰厛鍘绘爣鍑嗗簱閰嶇疆瑕佹眰鍊兼垨瑕佹眰鎻忚堪"); } + if (StringUtils.isBlank(product.getSonLaboratory())) { + throw new ErrorException("鏈夋楠岄」鐨勭殑瀛愬疄楠屽涓虹粦瀹�, 璇峰厛缁戝畾瀛愬疄楠屽"); + } insProductMapper.insert(product); } } @@ -557,112 +560,12 @@ return productDto2IPage; } - @Override - public IPage<CostStatisticsDto> costStatistics(IPage<CostStatisticsDto> page, CostStatisticsDto costStatisticsDto) { - String dates = costStatisticsDto.getDates(); - String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); - costStatisticsDto.setDates(null); - - //todo:浠呯湅鑷繁 - - IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); - List<CostStatisticsDto> collect = dtoIPage.getRecords().stream().map(dto -> { - Set<String> uniqueTags = new HashSet<>(); - if (dto.getInspectionItem().contains(",")) { - for (String s : dto.getInspectionItem().split(",")) { - uniqueTags.add(s.split("@")[0]); - } - } else { - uniqueTags.add(dto.getInspectionItem().split("@")[0]); - } - dto.setInspectionItem(uniqueTags.toString()); - return dto; - }).collect(Collectors.toList()); - dtoIPage.setRecords(collect); - return dtoIPage; - } - - @Override - public Map<String, Object> costStatistics2(CostStatisticsDto costStatisticsDto) { - Map<String, Object> map = new HashMap<>(); - String dates = costStatisticsDto.getDates(); - String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); - costStatisticsDto.setDates(null); - List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); - double totalPrice = costStatisticsDtos.stream() - .filter(dto -> dto.getPrice() != null) // 杩囨护鎺変环鏍间负 null 鐨勫璞� - .mapToDouble(value -> value.getPrice().doubleValue() * value.getNum()) - .sum(); - map.put("total", totalPrice); - return map; - } - - @Override - public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) { - List<SampleDefectsFatherVo> sampleDefectsFatherVos = insOrderMapper.selectSampleDefects(page, inspectionItems, orderNumber); - Map<String, Object> map = new HashMap<>(); - map.put("records", sampleDefectsFatherVos); - Long aLong = insOrderMapper.getCount(inspectionItems, orderNumber); - map.put("total", aLong); - return map; - } @Override public int updateStatus(Integer id) { return insOrderMapper.updateStatus(id); } - - @Override - public void export(CostStatisticsDto costStatisticsDto, HttpServletResponse response) throws IOException { - //鏌ヨ瀵煎嚭鐨勮垂鐢ㄧ粺璁℃暟鎹� - String dates = costStatisticsDto.getDates(); - String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); - costStatisticsDto.setDates(null); - List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); - costStatisticsDtos = costStatisticsDtos.stream().map(dto -> { - Set<String> uniqueTags = new HashSet<>(); - if (dto.getInspectionItem().contains(",")) { - for (String s : dto.getInspectionItem().split(",")) { - uniqueTags.add(s.split("@")[0]); - } - } else { - uniqueTags.add(dto.getInspectionItem().split("@")[0]); - } - dto.setInspectionItem(uniqueTags.toString()); - return dto; - }).collect(Collectors.toList()); - - response.setContentType("application/vnd.ms-excel"); - response.setCharacterEncoding("UTF-8"); - // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴 - String fileName = URLEncoder.encode("鏍峰搧璐圭敤缁熻瀵煎嚭", "UTF-8"); - response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); - Map<String, List<CostStatisticsDto>> groupByCompany = - costStatisticsDtos.stream().filter(e -> StrUtil.isNotEmpty(e.getCompany())) - .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); - try { - // 鏂板缓ExcelWriter - // 鏂板缓ExcelWriter - ExcelWriter excelWriter = - EasyExcel.write(response.getOutputStream()) - .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) - .build(); - for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { - String sheetName = companyDataEntry.getKey(); - List<CostStatisticsDto> dataList = companyDataEntry.getValue(); - WriteSheet mainSheet = EasyExcel.writerSheet(sheetName) - .head(CostStatisticsDto.class) - .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) - .build(); - excelWriter.write(dataList, mainSheet); - } - // 鍏抽棴娴� - excelWriter.finish(); - } catch (IOException e) { - throw new RuntimeException("瀵煎嚭澶辫触"); - } - } /** * 鑾峰彇ifs搴撳瓨淇℃伅 -- Gitblit v1.9.3