大屏
This commit is contained in:
		
							parent
							
								
									c8820a1bb7
								
							
						
					
					
						commit
						39207b06bd
					
				| @ -147,54 +147,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | ||||
|     @Override | ||||
|     public ScrProductionDriParam driQuery(ScrProductionParam scrProductionParam) { | ||||
|         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); | ||||
|         if (ObjectUtil.isNotNull(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()); | ||||
|             } | ||||
|         } | ||||
|         buildDateQueryConditions(queryWrapper, scrProductionParam); | ||||
| 
 | ||||
|         // 查询符合条件的所有产量记录 | ||||
|         List<ScrProduction> productions = this.list(queryWrapper); | ||||
| @ -210,7 +163,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | ||||
|                 .reduce(BigDecimal.ZERO, BigDecimal::add); | ||||
| 
 | ||||
|         // 计算平均合格率 | ||||
|         BigDecimal avgPassRate =null; | ||||
|         BigDecimal avgPassRate = BigDecimal.valueOf(0); | ||||
|         if (!productions.isEmpty()) { | ||||
|             List<BigDecimal> validPassRates = productions.stream() | ||||
|                     .map(ScrProduction::getPassRate) | ||||
| @ -237,48 +190,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | ||||
|     public List<ScrProduction> driQhQuery(ScrProductionParam scrProductionParam) { | ||||
|         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); | ||||
| 
 | ||||
|         if (ObjectUtil.isNotNull(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()); | ||||
|             } | ||||
|         } | ||||
|         buildDateQueryConditions(queryWrapper, scrProductionParam); | ||||
| 
 | ||||
|         // 查询原始数据 | ||||
|         List<ScrProduction> productions = this.list(queryWrapper); | ||||
| @ -312,48 +224,7 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | ||||
|     public List<ScrProductionMaterParam> driMaterQuery(ScrProductionParam scrProductionParam) { | ||||
|         QueryWrapper<ScrProduction> queryWrapper = new QueryWrapper<>(); | ||||
| 
 | ||||
|         if (ObjectUtil.isNotNull(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()); | ||||
|             } | ||||
|         } | ||||
|         buildDateQueryConditions(queryWrapper, scrProductionParam); | ||||
| 
 | ||||
|         // 添加产品过滤条件:只查询硅锰、铬铁、硅铁 | ||||
|         queryWrapper.lambda().in(ScrProduction::getProduct, "硅锰", "铬铁", "硅铁"); | ||||
| @ -483,5 +354,43 @@ public class ScrProductionServiceImpl extends ServiceImpl<ScrProductionMapper, S | ||||
|                 }) | ||||
|                 .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