| | |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.common.utils.excel.ExcelUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.other.mapper.TempFileMapper; |
| | |
| | | if (!bindList.isEmpty()) { |
| | | List<Integer> processIds = bindList.stream().map(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId).collect(Collectors.toList()); |
| | | Map<Integer, Integer> processQuantityMap = bindList.stream().collect(Collectors.toMap(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId, SalesLedgerProductProcessBind::getQuantity, (a, b) -> a)); |
| | | Map<Integer, BigDecimal> processAmountMap = bindList.stream().collect(Collectors.toMap(SalesLedgerProductProcessBind::getSalesLedgerProductProcessId, SalesLedgerProductProcessBind::getAmount, (a, b) -> a)); |
| | | List<SalesLedgerProductProcess> processList = salesLedgerProductProcessService.listByIds(processIds); |
| | | processList.forEach(p -> p.setQuantity(processQuantityMap.get(p.getId()))); |
| | | processList.forEach(p -> { |
| | | p.setQuantity(processQuantityMap.get(p.getId())); |
| | | if (processAmountMap.get(p.getId()) != null) p.setUnitPrice(processAmountMap.get(p.getId())); |
| | | }); |
| | | product.setSalesProductProcessList(processList); |
| | | } |
| | | ProductModel productModel = productModelMap.get(product.getProductModelId()); |
| | |
| | | SalesLedgerProductProcess p = new SalesLedgerProductProcess(); |
| | | p.setId(process.getId()); |
| | | p.setQuantity(processQty.intValue()); |
| | | p.setUnitPrice(process.getUnitPrice()); |
| | | processList.add(p); |
| | | extraProcessAmountPerPiece = extraProcessAmountPerPiece.add(defaultDecimal(process.getUnitPrice()).multiply(processQty)); |
| | | } |
| | |
| | | record.setSalesLedgerProcessRouteId(route.getId()); |
| | | Integer isCompleted = inputRecord != null && inputRecord.getIsCompleted() != null ? inputRecord.getIsCompleted() : 0; |
| | | record.setIsCompleted(isCompleted); |
| | | record.setCompletedTime(Objects.equals(isCompleted, 1) ? LocalDateTime.now() : null); |
| | | if (Objects.equals(isCompleted, 1)) { |
| | | record.setCompletedTime(inputRecord != null && inputRecord.getCompletedTime() != null ? inputRecord.getCompletedTime() : LocalDateTime.now()); |
| | | } else { |
| | | record.setCompletedTime(null); |
| | | } |
| | | routeRecordList.add(record); |
| | | } |
| | | salesLedgerProcessRouteRecordService.saveBatch(routeRecordList); |
| | |
| | | SalesLedgerProductProcess bind = new SalesLedgerProductProcess(); |
| | | bind.setId(process.getId()); |
| | | bind.setQuantity(entry.getValue()); |
| | | bind.setUnitPrice(process.getUnitPrice()); |
| | | result.add(bind); |
| | | } |
| | | return result; |
| | |
| | | // 5. 取消审批流程 |
| | | cancelApproveProcesses(id, originalLedger.getSalesContractNo()); |
| | | |
| | | // 6. 重新生成:创建新台账副本 |
| | | // 6. 重新生成:此处不直接在后端入库,而是返回原单据ID给前端 |
| | | // 前端拿到ID后会获取原单据详情并跳转到新增页面(带入预填数据),由用户在页面上编辑后统一新增,以避免数据重复生成 |
| | | if (dto.getCounterReviewType() == 2) { |
| | | SalesLedger newLedger = new SalesLedger(); |
| | | BeanUtils.copyProperties(originalLedger, newLedger); |
| | | newLedger.setId(null); |
| | | newLedger.setSalesContractNo(generateSalesContractNo()); |
| | | newLedger.setDeliveryStatus(1); |
| | | newLedger.setStockStatus(0); |
| | | newLedger.setReviewStatus(0); |
| | | newLedger.setCounterReviewTime(null); |
| | | newLedger.setCounterReviewPerson(null); |
| | | newLedger.setCounterReviewPersonId(null); |
| | | newLedger.setCounterReviewType(null); |
| | | newLedger.setCounterReviewDesc(null); |
| | | salesLedgerMapper.insert(newLedger); |
| | | |
| | | // 复制产品到新台账 |
| | | List<SalesLedgerProduct> originalProducts = salesLedgerProductMapper.selectList( |
| | | Wrappers.<SalesLedgerProduct>lambdaQuery() |
| | | .eq(SalesLedgerProduct::getSalesLedgerId, id) |
| | | ); |
| | | for (SalesLedgerProduct originalProduct : originalProducts) { |
| | | SalesLedgerProduct newProduct = new SalesLedgerProduct(); |
| | | BeanUtils.copyProperties(originalProduct, newProduct); |
| | | newProduct.setId(null); |
| | | newProduct.setSalesLedgerId(newLedger.getId()); |
| | | newProduct.setStockedQuantity(BigDecimal.ZERO); |
| | | newProduct.setShippedQuantity(BigDecimal.ZERO); |
| | | newProduct.setUnqualifiedStockedQuantity(BigDecimal.ZERO); |
| | | newProduct.setUnqualifiedShippedQuantity(BigDecimal.ZERO); |
| | | newProduct.setReturnQuality(BigDecimal.ZERO); |
| | | newProduct.setAvailableQuality(newProduct.getQuantity().subtract(newProduct.getReturnQuality())); |
| | | newProduct.setProductStockStatus(0); |
| | | newProduct.fillRemainingQuantity(); |
| | | salesLedgerProductMapper.insert(newProduct); |
| | | } |
| | | newLedgerIds.add(newLedger.getId()); |
| | | newLedgerIds.add(id); |
| | | } |
| | | } |
| | | return newLedgerIds; |
| | |
| | | sheetMap.put("工艺路线", sheetData); |
| | | } |
| | | |
| | | com.ruoyi.common.utils.excel.ExcelUtils.exportManySheet(response, "销售台账工艺路线导出", sheetMap); |
| | | ExcelUtils.exportManySheet(response, "销售台账工艺路线导出", sheetMap); |
| | | } catch (Exception e) { |
| | | log.error("导出售后台账工艺路线失败", e); |
| | | throw new ServiceException("导出售后台账工艺路线失败:" + e.getMessage()); |
| | |
| | | |
| | | private List<Object> buildProcessRouteRow(SalesLedger salesLedger, SalesLedgerProduct product, SalesLedgerProcessRouteRecord route) { |
| | | List<Object> row = new ArrayList<>(); |
| | | row.add(salesLedger.getEntryDate() == null ? "" : DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, salesLedger.getEntryDate())); |
| | | row.add(route.getCompletedTime() == null ? "" : route.getCompletedTime().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | row.add(salesLedger.getSalesContractNo()); |
| | | row.add(salesLedger.getCustomerName()); |
| | | row.add(product == null ? "" : product.getSpecificationModel()); |
| | |
| | | } |
| | | |
| | | } |
| | | |