| | |
| | | package com.ruoyi.sales.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.metadata.fill.FillConfig; |
| | | import com.alibaba.excel.write.metadata.fill.FillWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.ruoyi.account.pojo.AccountIncome; |
| | | import com.ruoyi.account.service.AccountIncomeService; |
| | | import com.ruoyi.basic.mapper.CustomerMapper; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.device.execl.DeviceMaintenanceExeclDto; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | |
| | | import com.ruoyi.sales.pojo.*; |
| | | import com.ruoyi.sales.service.ISalesLedgerProductService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.vo.ShippingNoteVo; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | /** |
| | | * 销售台账Service业务层处理 |
| | |
| | | |
| | | int tableStart = 10; |
| | | Row headerRow = sheet.createRow(tableStart); |
| | | headerRow.setHeightInPoints((short)18); |
| | | headerRow.setHeightInPoints((short) 18); |
| | | |
| | | String[] headers = {"序号", "物料编号", "品名/规格", "单位", "数量", "订单号", "共四联"}; |
| | | for (int i = 0; i < headers.length; i++) { |
| | |
| | | for (int i = 0; i < productList.size(); i++) { |
| | | SalesLedgerProduct p = productList.get(i); |
| | | Row dataRow = sheet.createRow(currentRow++); |
| | | dataRow.setHeightInPoints((short)18); |
| | | dataRow.setHeightInPoints((short) 18); |
| | | |
| | | String materialCode = ""; |
| | | if (p.getProductModelId() != null) { |
| | |
| | | for (int i = 0; i < needEmpty; i++) { |
| | | int seq = productList.size() + i; |
| | | Row dataRow = sheet.createRow(currentRow++); |
| | | dataRow.setHeightInPoints((short)18); |
| | | dataRow.setHeightInPoints((short) 18); |
| | | |
| | | for (int c = 0; c <= 5; c++) dataRow.createCell(c).setCellStyle(dataCenterStyle); |
| | | |
| | |
| | | |
| | | // 合计 |
| | | Row totalRow = sheet.createRow(currentRow); |
| | | totalRow.setHeightInPoints((short)18); |
| | | totalRow.setHeightInPoints((short) 18); |
| | | |
| | | // 合计放在第二列,不合并单元格 |
| | | totalRow.createCell(1).setCellValue("合计"); |
| | | totalRow.createCell(4).setCellValue(totalQuantity.doubleValue()); |
| | | |
| | | |
| | | // 设置样式 |
| | | for (int c = 0; c <= 5; c++) { |
| | | Cell cell = totalRow.getCell(c) != null ? totalRow.getCell(c) : totalRow.createCell(c); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<SalesLedger> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) { |
| | | public IPage<SalesLedgerDto> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) { |
| | | return salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto); |
| | | } |
| | | |
| | |
| | | // 4. 处理子表数据 |
| | | List<SalesLedgerProduct> productList = salesLedgerDto.getProductData(); |
| | | if (productList != null && !productList.isEmpty()) { |
| | | handleSalesLedgerProducts(salesLedger.getId(), productList, salesLedgerDto.getType(), salesLedgerDto.isProduce()); |
| | | handleSalesLedgerProducts(salesLedger.getId(), productList, salesLedgerDto.getType(), Boolean.TRUE.equals(salesLedgerDto.getProduce())); |
| | | updateMainContractAmount( |
| | | salesLedger.getId(), |
| | | productList, |
| | |
| | | salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice()); |
| | | salesLedgerProductMapper.insert(salesLedgerProduct); |
| | | |
| | | } |
| | | } |
| | | if (isProduce) { |
| | | for (SalesLedgerProduct salesLedgerProduct : products) { |
| | | // 添加生产数据 |
| | | if (isProduce) { |
| | | salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | } |
| | | salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct); |
| | | } |
| | | } |
| | | } |
| | |
| | | private SalesLedger convertToEntity(SalesLedgerDto dto) { |
| | | SalesLedger entity = new SalesLedger(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setProduce(dto.getProduce()); |
| | | return entity; |
| | | } |
| | | |
| | |
| | | throw new RuntimeException("动态更新主表金额失败", e); |
| | | } |
| | | } |
| | | } |
| | | } |