main #1
| @ -147,54 +147,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | |||||||
|     @Override |     @Override | ||||||
|     public ScrProductionDriParam driQuery(ScrProductionParam scrProductionParam) { |     public ScrProductionDriParam driQuery(ScrProductionParam scrProductionParam) { | ||||||
|         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); |         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); | ||||||
|         if (ObjectUtil.isNotNull(scrProductionParam)) { |         buildDateQueryConditions(queryWrapper, scrProductionParam); | ||||||
|             // 按指定日期查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getProductionDay())) { |  | ||||||
|                 LocalDate targetDate = LocalDate.parse(scrProductionParam.getProductionDay()); |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getProductionDay, targetDate); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按月份查询(如果有年份和月份参数) |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getYear()) && ObjectUtil.isNotEmpty(scrProductionParam.getMonth())) { |  | ||||||
|                 Integer year = scrProductionParam.getYear(); |  | ||||||
|                 Integer month = scrProductionParam.getMonth(); |  | ||||||
| 
 |  | ||||||
|                 LocalDate startDate = LocalDate.of(year, month, 1); |  | ||||||
|                 LocalDate endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); |  | ||||||
| 
 |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, startDate) |  | ||||||
|                         .le(ScrProduction::getProductionDay, endDate); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按年份查询(只有年份参数,没有月份参数) |  | ||||||
|             else if (ObjectUtil.isNotEmpty(scrProductionParam.getYear())) { |  | ||||||
|                 Integer year = scrProductionParam.getYear(); |  | ||||||
| 
 |  | ||||||
|                 LocalDate startDate = LocalDate.of(year, 1, 1); |  | ||||||
|                 LocalDate endDate = LocalDate.of(year, 12, 31); |  | ||||||
| 
 |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, startDate) |  | ||||||
|                         .le(ScrProduction::getProductionDay, endDate); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按日期范围查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getStartDate()) && ObjectUtil.isNotEmpty(scrProductionParam.getEndDate())) { |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, scrProductionParam.getStartDate()) |  | ||||||
|                         .le(ScrProduction::getProductionDay, scrProductionParam.getEndDate()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 其他可能的过滤条件 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getFurnaceNumber())) { |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getFurnaceNumber, scrProductionParam.getFurnaceNumber()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getProduct())) { |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getProduct, scrProductionParam.getProduct()); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         // 查询符合条件的所有产量记录 |         // 查询符合条件的所有产量记录 | ||||||
|         List<ScrProduction> productions = this.list(queryWrapper); |         List<ScrProduction> productions = this.list(queryWrapper); | ||||||
| @ -210,7 +163,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | |||||||
|                 .reduce(BigDecimal.ZERO, BigDecimal::add); |                 .reduce(BigDecimal.ZERO, BigDecimal::add); | ||||||
| 
 | 
 | ||||||
|         // 计算平均合格率 |         // 计算平均合格率 | ||||||
|         BigDecimal avgPassRate =null; |         BigDecimal avgPassRate = BigDecimal.valueOf(0); | ||||||
|         if (!productions.isEmpty()) { |         if (!productions.isEmpty()) { | ||||||
|             List<BigDecimal> validPassRates = productions.stream() |             List<BigDecimal> validPassRates = productions.stream() | ||||||
|                     .map(ScrProduction::getPassRate) |                     .map(ScrProduction::getPassRate) | ||||||
| @ -237,48 +190,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | |||||||
|     public List<ScrProduction> driQhQuery(ScrProductionParam scrProductionParam) { |     public List<ScrProduction> driQhQuery(ScrProductionParam scrProductionParam) { | ||||||
|         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); |         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); | ||||||
| 
 | 
 | ||||||
|         if (ObjectUtil.isNotNull(scrProductionParam)) { |         buildDateQueryConditions(queryWrapper, scrProductionParam); | ||||||
|             // 按指定日期查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getProductionDay())) { |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getProductionDay, scrProductionParam.getProductionDay()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按年月查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getYear()) && ObjectUtil.isNotEmpty(scrProductionParam.getMonth())) { |  | ||||||
|                 Integer year = scrProductionParam.getYear(); |  | ||||||
|                 Integer month = scrProductionParam.getMonth(); |  | ||||||
| 
 |  | ||||||
|                 LocalDate startDate = LocalDate.of(year, month, 1); |  | ||||||
|                 LocalDate endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); |  | ||||||
| 
 |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, startDate) |  | ||||||
|                         .le(ScrProduction::getProductionDay, endDate); |  | ||||||
|             } |  | ||||||
|             // 按年度查询 |  | ||||||
|             else if (ObjectUtil.isNotEmpty(scrProductionParam.getYear())) { |  | ||||||
|                 Integer year = scrProductionParam.getYear(); |  | ||||||
| 
 |  | ||||||
|                 LocalDate startDate = LocalDate.of(year, 1, 1); |  | ||||||
|                 LocalDate endDate = LocalDate.of(year, 12, 31); |  | ||||||
| 
 |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, startDate) |  | ||||||
|                         .le(ScrProduction::getProductionDay, endDate); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按日期范围查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getStartDate()) && ObjectUtil.isNotEmpty(scrProductionParam.getEndDate())) { |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, scrProductionParam.getStartDate()) |  | ||||||
|                         .le(ScrProduction::getProductionDay, scrProductionParam.getEndDate()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按产品查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getProduct())) { |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getProduct, scrProductionParam.getProduct()); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         // 查询原始数据 |         // 查询原始数据 | ||||||
|         List<ScrProduction> productions = this.list(queryWrapper); |         List<ScrProduction> productions = this.list(queryWrapper); | ||||||
| @ -312,48 +224,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | |||||||
|     public List<ScrProductionMaterParam> driMaterQuery(ScrProductionParam scrProductionParam) { |     public List<ScrProductionMaterParam> driMaterQuery(ScrProductionParam scrProductionParam) { | ||||||
|         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); |         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); | ||||||
| 
 | 
 | ||||||
|         if (ObjectUtil.isNotNull(scrProductionParam)) { |         buildDateQueryConditions(queryWrapper, scrProductionParam); | ||||||
|             // 按指定日期查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getProductionDay())) { |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getProductionDay, scrProductionParam.getProductionDay()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按年月查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getYear()) && ObjectUtil.isNotEmpty(scrProductionParam.getMonth())) { |  | ||||||
|                 Integer year = scrProductionParam.getYear(); |  | ||||||
|                 Integer month = scrProductionParam.getMonth(); |  | ||||||
| 
 |  | ||||||
|                 LocalDate startDate = LocalDate.of(year, month, 1); |  | ||||||
|                 LocalDate endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); |  | ||||||
| 
 |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, startDate) |  | ||||||
|                         .le(ScrProduction::getProductionDay, endDate); |  | ||||||
|             } |  | ||||||
|             // 按年度查询 |  | ||||||
|             else if (ObjectUtil.isNotEmpty(scrProductionParam.getYear())) { |  | ||||||
|                 Integer year = scrProductionParam.getYear(); |  | ||||||
| 
 |  | ||||||
|                 LocalDate startDate = LocalDate.of(year, 1, 1); |  | ||||||
|                 LocalDate endDate = LocalDate.of(year, 12, 31); |  | ||||||
| 
 |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, startDate) |  | ||||||
|                         .le(ScrProduction::getProductionDay, endDate); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按日期范围查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getStartDate()) && ObjectUtil.isNotEmpty(scrProductionParam.getEndDate())) { |  | ||||||
|                 queryWrapper.lambda() |  | ||||||
|                         .ge(ScrProduction::getProductionDay, scrProductionParam.getStartDate()) |  | ||||||
|                         .le(ScrProduction::getProductionDay, scrProductionParam.getEndDate()); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             // 按炉号查询 |  | ||||||
|             if (ObjectUtil.isNotEmpty(scrProductionParam.getFurnaceNumber())) { |  | ||||||
|                 queryWrapper.lambda().eq(ScrProduction::getFurnaceNumber, scrProductionParam.getFurnaceNumber()); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         // 添加产品过滤条件:只查询硅锰、铬铁、硅铁 |         // 添加产品过滤条件:只查询硅锰、铬铁、硅铁 | ||||||
|         queryWrapper.lambda().in(ScrProduction::getProduct, "硅锰", "铬铁", "硅铁"); |         queryWrapper.lambda().in(ScrProduction::getProduct, "硅锰", "铬铁", "硅铁"); | ||||||
| @ -483,5 +354,43 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | |||||||
|                 }) |                 }) | ||||||
|                 .collect(Collectors.toList()); |                 .collect(Collectors.toList()); | ||||||
|     } |     } | ||||||
|  | /** | ||||||
|  |  * 构建产量查询的通用日期条件 | ||||||
|  |  * | ||||||
|  |  * @param queryWrapper 查询构造器 | ||||||
|  |  * @param scrProductionParam 查询参数 | ||||||
|  |  */ | ||||||
|  | private void buildDateQueryConditions(QueryWrapper<ScrProduction> queryWrapper, ScrProductionParam scrProductionParam) { | ||||||
|  |     if (ObjectUtil.isNotEmpty(scrProductionParam.getProductionDay())) { | ||||||
|  |         queryWrapper.lambda().eq(ScrProduction::getProductionDay, scrProductionParam.getProductionDay()); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (ObjectUtil.isNotEmpty(scrProductionParam.getYear()) && ObjectUtil.isNotEmpty(scrProductionParam.getMonth())) { | ||||||
|  |         Integer year = scrProductionParam.getYear(); | ||||||
|  |         Integer month = scrProductionParam.getMonth(); | ||||||
|  | 
 | ||||||
|  |         LocalDate startDate = LocalDate.of(year, month, 1); | ||||||
|  |         LocalDate endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); | ||||||
|  | 
 | ||||||
|  |         queryWrapper.lambda() | ||||||
|  |                 .ge(ScrProduction::getProductionDay, startDate) | ||||||
|  |                 .le(ScrProduction::getProductionDay, endDate); | ||||||
|  |     } else if (ObjectUtil.isNotEmpty(scrProductionParam.getYear())) { | ||||||
|  |         Integer year = scrProductionParam.getYear(); | ||||||
|  | 
 | ||||||
|  |         LocalDate startDate = LocalDate.of(year, 1, 1); | ||||||
|  |         LocalDate endDate = LocalDate.of(year, 12, 31); | ||||||
|  | 
 | ||||||
|  |         queryWrapper.lambda() | ||||||
|  |                 .ge(ScrProduction::getProductionDay, startDate) | ||||||
|  |                 .le(ScrProduction::getProductionDay, endDate); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (ObjectUtil.isNotEmpty(scrProductionParam.getStartDate()) && ObjectUtil.isNotEmpty(scrProductionParam.getEndDate())) { | ||||||
|  |         queryWrapper.lambda() | ||||||
|  |                 .ge(ScrProduction::getProductionDay, scrProductionParam.getStartDate()) | ||||||
|  |                 .le(ScrProduction::getProductionDay, scrProductionParam.getEndDate()); | ||||||
|  |     } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user