| 对比新文件 |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.production.bean.dto.ProductionAccountDto; |
| | | import com.ruoyi.production.bean.dto.ProductionProductMainDto; |
| | | import com.ruoyi.production.bean.vo.ProductionAccountVo; |
| | | import com.ruoyi.production.mapper.ProductionAccountMapper; |
| | | import com.ruoyi.production.mapper.ProductionProductMainMapper; |
| | | import com.ruoyi.production.pojo.ProductionAccount; |
| | | import com.ruoyi.production.service.ProductionAccountService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ProductionAccountServiceImpl extends ServiceImpl<ProductionAccountMapper, ProductionAccount> implements ProductionAccountService { |
| | | |
| | | |
| | | private final ProductionProductMainMapper productionProductMainMapper; |
| | | |
| | | @Override |
| | | public IPage<ProductionAccountVo> listPage(Page<ProductionAccountDto> page, ProductionAccountDto dto) { |
| | | ProductionAccountDto queryDto = normalizeDateQuery(dto); |
| | | return baseMapper.listPage(page, queryDto); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ProductionProductMainDto> listProductionDetails(ProductionAccountDto dto, Page page) { |
| | | return productionProductMainMapper.listProductionDetails(normalizeDateQuery(dto), page); |
| | | } |
| | | |
| | | private ProductionAccountDto normalizeDateQuery(ProductionAccountDto dto) { |
| | | if (dto == null) { |
| | | return new ProductionAccountDto(); |
| | | } |
| | | LocalDate[] dateRange = dto.getDateRange(); |
| | | if ((dto.getEntryDateStart() == null || dto.getEntryDateEnd() == null) |
| | | && dateRange != null |
| | | && dateRange.length > 0) { |
| | | if (dto.getEntryDateStart() == null) { |
| | | dto.setEntryDateStart(dateRange[0]); |
| | | } |
| | | if (dto.getEntryDateEnd() == null) { |
| | | dto.setEntryDateEnd(dateRange.length > 1 ? dateRange[1] : dateRange[0]); |
| | | } |
| | | } |
| | | |
| | | String dateType = dto.getDateType(); |
| | | if ("day".equalsIgnoreCase(dateType)) { |
| | | if (dto.getEntryDate() == null && dateRange != null && dateRange.length > 0) { |
| | | dto.setEntryDate(dateRange[0]); |
| | | } |
| | | if (dto.getEntryDate() == null) { |
| | | dto.setEntryDate(dto.getEntryDateStart()); |
| | | } |
| | | dto.setEntryDateStart(null); |
| | | dto.setEntryDateEnd(null); |
| | | } else if ("month".equalsIgnoreCase(dateType)) { |
| | | if ((dto.getEntryDateStart() == null || dto.getEntryDateEnd() == null) && dto.getEntryDate() != null) { |
| | | LocalDate monthDate = dto.getEntryDate(); |
| | | dto.setEntryDateStart(monthDate.withDayOfMonth(1)); |
| | | dto.setEntryDateEnd(monthDate.withDayOfMonth(monthDate.lengthOfMonth())); |
| | | } |
| | | dto.setEntryDate(null); |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | | } |