| | |
| | | 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.basic.pojo.Product; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.service.ProductOrderService; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanDto; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanImportDto; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanSummaryDto; |
| | | import com.ruoyi.productionPlan.mapper.ProductionPlanMapper; |
| | | import com.ruoyi.productionPlan.pojo.ProductionPlan; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.time.Instant; |
| | |
| | | public List<ProductionPlanSummaryDto> summaryByProductType(ProductionPlanSummaryDto query) { |
| | | return baseMapper.selectSummaryByProductType(query); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importProdData(MultipartFile file) { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new ServiceException("导入数据不能为空"); |
| | | } |
| | | ExcelUtil<ProductionPlanImportDto> excelUtil = new ExcelUtil<>(ProductionPlanImportDto.class); |
| | | List<ProductionPlanImportDto> list; |
| | | try { |
| | | list = excelUtil.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | log.error("生产需求Excel导入失败", e); |
| | | throw new ServiceException("Excel解析失败"); |
| | | } |
| | | |
| | | if (list == null || list.isEmpty()) { |
| | | throw new ServiceException("Excel没有数据"); |
| | | } |
| | | List<ProductionPlan> entityList = new ArrayList<>(list.size()); |
| | | ProductionPlan entity; |
| | | for (ProductionPlanImportDto dto : list) { |
| | | entity = new ProductionPlan(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | entity.setDataSourceType(2); |
| | | entity.setDataSyncType(1); |
| | | |
| | | entityList.add(entity); |
| | | } |
| | | this.saveBatch(entityList); |
| | | } |
| | | |
| | | @Override |
| | | public void exportProdData(HttpServletResponse response, List<Long> ids) { |
| | | List<ProductionPlan> list; |
| | | if (ids != null && !ids.isEmpty()) { |
| | | list = baseMapper.selectBatchIds(ids); |
| | | } else { |
| | | list = baseMapper.selectList(null); |
| | | } |
| | | |
| | | List<ProductionPlanImportDto> exportList = new ArrayList<>(); |
| | | for (ProductionPlan entity : list) { |
| | | ProductionPlanImportDto dto = new ProductionPlanImportDto(); |
| | | BeanUtils.copyProperties(entity, dto); |
| | | exportList.add(dto); |
| | | } |
| | | ExcelUtil<ProductionPlanImportDto> util = new ExcelUtil<>(ProductionPlanImportDto.class); |
| | | util.exportExcel(response, exportList, "销售生产需求数据"); |
| | | } |
| | | } |