src/main/java/com/ruoyi/basic/mapper/CustomerPrivatePoolMapper.java
@@ -26,4 +26,5 @@ List<CustomerPrivatePoolDto> selectInfos(); List<CustomerPrivatePoolDto> selectByCusterNames(@Param("collect") List<String> collect); } src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
@@ -184,6 +184,13 @@ }else { //æ¾å°ç¶èç¹ Product productParent = productMapper.selectOne(new QueryWrapper<Product>().lambda().eq(Product::getProductName, "æå").last("limit 1")); if (ObjectUtils.isEmpty(productParent)) { Product product = new Product(); product.setProductName("æå"); product.setDeptId(SecurityUtils.getDeptId()[0]); productMapper.insert(product); productParent.setId(product.getId()); } //æ°å¢äº§å大类 Product product = new Product(); product.setProductName(productModelDto.getProductName()); src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -2,7 +2,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -16,7 +15,6 @@ import com.ruoyi.basic.pojo.ProductModel; import com.ruoyi.common.enums.AuditEnum; import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; @@ -35,18 +33,18 @@ import com.ruoyi.quality.service.IQualityInspectService; import lombok.AllArgsConstructor; import org.springframework.aop.framework.AopContext; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.ruoyi.production.mapper.ProductionProductMainMapper; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @Service @@ -183,7 +181,7 @@ productionProductInput.setQuantity(productStructureDto.getUnitQuantity().multiply(dto.getQuantity())); productionProductInput.setProductMainId(productionProductMain.getId()); productionProductInputMapper.insert(productionProductInput); stockUtils.substractStock(productStructureDto.getProductModelId(), productionProductInput.getQuantity(), StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), productionProductMain.getId()); // stockUtils.substractStock(productStructureDto.getProductModelId(), productionProductInput.getQuantity(), StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode(), productionProductMain.getId()); } /*æ°å¢æ¥å·¥äº§åºè¡¨*/ @@ -465,7 +463,7 @@ //å é¤ä¸éè¦è´¨æ£çåæ ¼å ¥åº stockUtils.deleteStockInRecord(productionProductMain.getId(), StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode()); //å é¤æå ¥å¯¹åºçåºåºè®°å½ stockUtils.deleteStockOutRecord(productionProductMain.getId(), StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode()); // stockUtils.deleteStockOutRecord(productionProductMain.getId(), StockOutQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_OUT.getCode()); // å é¤ä¸»è¡¨ productionProductMainMapper.deleteById(productionProductMain.getId()); return true; src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -185,7 +185,14 @@ salesLedgerService.exportProcessContract(id); } /** @GetMapping("/importSalsesLedger") @ApiOperation("é³å å¯¼å ¥éå®å°è´¦æ°") public AjaxResult importSalsesLedger( MultipartFile file) { return salesLedgerService.importSalsesLedger(file); } /**w * æ°å¢ä¿®æ¹éå®å°è´¦ */ @Log(title = "éå®å°è´¦", businessType = BusinessType.INSERT) src/main/java/com/ruoyi/sales/dto/SalesLedgerSimpleImportDto.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,37 @@ package com.ruoyi.sales.dto; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.framework.aspectj.lang.annotation.Excel; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.util.Date; @Data public class SalesLedgerSimpleImportDto { @Excel(name = "è®¢è´§æ¥æ") @DateTimeFormat(pattern = "yy.MM.dd") @JsonFormat(pattern = "yy.MM.dd", timezone = "GMT+8") private Date orderDate; @Excel(name = "客æ·åç§°") private String customerName; @Excel(name = "产ååç§°") private String productName; @Excel(name = "æ°é") private BigDecimal quantity; @Excel(name = "åä»·") private BigDecimal unitPrice; @Excel(name = "éé¢") private BigDecimal amount; @Excel(name = "订åç¼å·") private String orderNo; } src/main/java/com/ruoyi/sales/service/ISalesLedgerService.java
@@ -3,7 +3,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.aftersalesservice.pojo.AfterSalesService; import com.ruoyi.common.enums.SaleEnum; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.sales.dto.LossProductModelDto; @@ -58,4 +57,6 @@ * @param id */ void exportProcessContract(@NotNull Long id); AjaxResult importSalsesLedger(MultipartFile file); } src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -531,6 +531,141 @@ exportProcessContractToWord(exportProcessContract); } @Override @Transactional(rollbackFor = Exception.class) public AjaxResult importSalsesLedger(MultipartFile file) { LoginUser loginUser = SecurityUtils.getLoginUser(); int successCount = 0; Date lastDate = null; BigDecimal lastUnitPrice = null; int skipCount = 0; List<String> errorMessages = new ArrayList<>(); CustomerPrivatePoolDto lastCustomer = null; try { InputStream inputStream = file.getInputStream(); ExcelUtil<SalesLedgerSimpleImportDto> excelUtil = new ExcelUtil<>(SalesLedgerSimpleImportDto.class); List<SalesLedgerSimpleImportDto> importDataList = excelUtil.importExcel(inputStream); if (CollectionUtils.isEmpty(importDataList)) { return AjaxResult.error("å¯¼å ¥æ°æ®ä¸ºç©ºï¼"); } List<String> customerNames = importDataList.stream() .map(SalesLedgerSimpleImportDto::getCustomerName) .filter(StrUtil::isNotBlank) .distinct() .collect(Collectors.toList()); List<CustomerPrivatePoolDto> customers = customerPrivatePoolMapper.selectByCusterNames(customerNames); for (int i = 0; i < importDataList.size(); i++) { SalesLedgerSimpleImportDto importDto = importDataList.get(i); int rowNum = i + 2; if (StrUtil.isBlank(importDto.getOrderNo())) { errorMessages.add(String.format("第%dè¡ï¼è®¢åç¼å·ä¸ºç©º", rowNum)); skipCount++; continue; } if (importDto.getQuantity() == null ) { errorMessages.add(String.format("第%dè¡ï¼æ°éä¸è½ä¸ºç©º", rowNum)); skipCount++; continue; } long count = salesLedgerMapper.selectCount(new LambdaQueryWrapper<SalesLedger>() .eq(SalesLedger::getSalesContractNo, importDto.getOrderNo())); if (count > 0) { errorMessages.add(String.format("第%dè¡ï¼è®¢åç¼å·[%s]å·²åå¨", rowNum, importDto.getOrderNo())); skipCount++; continue; } CustomerPrivatePoolDto matchedCustomer = customers.stream() .filter(c -> c.getCustomerName().equals(importDto.getCustomerName())) .findFirst() .orElse(lastCustomer); if (matchedCustomer == null) { errorMessages.add(String.format("第%dè¡ï¼å®¢æ·[%s]ä¸åå¨ä¸æ åå²å®¢æ·", rowNum, importDto.getCustomerName())); skipCount++; continue; } lastCustomer = matchedCustomer; try { SalesLedger salesLedger = new SalesLedger(); salesLedger.setSalesContractNo(importDto.getOrderNo()); salesLedger.setCustomerName(matchedCustomer.getCustomerName()); salesLedger.setCustomerId(matchedCustomer.getCustomerId()); salesLedger.setCustomerContractNo(matchedCustomer.getTaxpayerIdentificationNumber()); Date date = importDto.getOrderDate(); if (ObjectUtils.isEmpty(date)){ date = lastDate; } lastDate = date; salesLedger.setEntryDate(date); salesLedger.setContractAmount(importDto.getAmount()); salesLedger.setEntryPerson(loginUser.getUserId().toString()); salesLedger.setTenantId(matchedCustomer.getTenantId()); salesLedgerMapper.insert(salesLedger); SalesLedgerProduct product = new SalesLedgerProduct(); product.setSalesLedgerId(salesLedger.getId()); product.setType(1); product.setQuantity(importDto.getQuantity()); BigDecimal unitPrice = importDto.getUnitPrice(); if (ObjectUtils.isEmpty(unitPrice)) { unitPrice = lastUnitPrice; } lastUnitPrice = unitPrice; product.setTaxInclusiveUnitPrice(unitPrice); product.setTaxInclusiveTotalPrice(unitPrice.multiply(importDto.getQuantity())); product.setTaxExclusiveTotalPrice(unitPrice.multiply(importDto.getQuantity())); product.setNoInvoiceNum(importDto.getQuantity()); product.setNoInvoiceAmount(importDto.getAmount()); product.setPendingInvoiceTotal(importDto.getAmount()); product.setUnit("/"); product.setProductCategory(importDto.getProductName()); product.setSpecificationModel(importDto.getProductName()); product.setRegister(loginUser.getNickName()); product.setRegisterDate(LocalDateTime.now()); product.setApproveStatus(0); if (ObjectUtils.isEmpty(product.getProductModelId())) { ProductModelAnticlockwiseDto productModelAnticlockwiseDto = new ProductModelAnticlockwiseDto(); productModelAnticlockwiseDto.setModel(product.getSpecificationModel()); productModelAnticlockwiseDto.setProductName(product.getProductCategory()); productModelAnticlockwiseDto.setUnit("/"); productModelAnticlockwiseDto.setSubUnit("/"); Long productModelId = productModelService.productModelAnticlockwise(productModelAnticlockwiseDto); product.setProductModelId(productModelId); } salesLedgerProductMapper.insert(product); salesLedgerProductServiceImpl.addProductionData(product); successCount++; } catch (Exception e) { log.error("第{}è¡è®¢å[{}]å¯¼å ¥å¤±è´¥ï¼{}", rowNum, importDto.getOrderNo(), e.getMessage(), e); errorMessages.add(String.format("第%dè¡è®¢å[%s]ï¼å¯¼å ¥å¤±è´¥-%s", rowNum, importDto.getOrderNo(), e.getMessage())); skipCount++; } } String message = String.format("å¯¼å ¥å®æï¼æå%dæ¡ï¼è·³è¿%dæ¡", successCount, skipCount); if (!errorMessages.isEmpty()) { message += "ãé误详æ ï¼" + String.join("ï¼", errorMessages); } return AjaxResult.success(message); } catch (Exception e) { log.error("å¯¼å ¥éå®å°è´¦å¤±è´¥", e); throw new RuntimeException("å¯¼å ¥å¤±è´¥ï¼" + e.getMessage(), e); } } @SneakyThrows private void exportProcessContractToWord(@NotNull ExportProcessContractVo exportProcessContract) { @@ -611,11 +746,12 @@ List<Long> productIds = products.stream() .map(SalesLedgerProduct::getId) .collect(Collectors.toList()); //å é¤çäº§æ°æ® salesLedgerProductServiceImpl.deleteProductionData(productIds); // æ¹éå é¤äº§åå表 if (!productIds.isEmpty()) { //å é¤çäº§æ°æ® salesLedgerProductServiceImpl.deleteProductionData(productIds); salesLedgerProductMapper.deleteBatchIds(productIds); } src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -6,12 +6,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.framework.web.domain.R; import com.ruoyi.sales.dto.SimpleProductDto; import com.ruoyi.sales.mapper.SalesLedgerProductMapper; import com.ruoyi.sales.pojo.SalesLedgerProduct; import com.ruoyi.stock.dto.StockInRecordDto; import com.ruoyi.stock.dto.StockInventoryDto; import com.ruoyi.stock.dto.StockOutRecordDto; src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
@@ -99,7 +99,7 @@ coalesce(c.tenant_id, cp.tenant_id) as tenant_id, coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account, coalesce(c.bank_account, cp.bank_account) as bank_account, coalesce(c.bank_code, cp.bank_code) as bank_code coalesce(c.bank_code, cp.bank_code) as bank_code, coalesce(c.corporation, cp.corporation) as corporation, coalesce(c.fax, cp.fax) as fax, coalesce(c.agent, cp.agent) as agent, @@ -108,5 +108,38 @@ left join customer c on c.id = cpp.customer_id and cpp.type = 1 left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0 </select> <select id="selectByCusterNames" resultType="com.ruoyi.basic.dto.CustomerPrivatePoolDto"> select cpp.id, cpp.bound_id, cpp.type, coalesce(c.id, cp.id) as customer_id, coalesce(c.customer_name, cp.customer_name) as customer_name, coalesce(c.customer_type, cp.customer_type) as customer_type, coalesce(c.taxpayer_identification_number, cp.taxpayer_identification_number) as taxpayer_identification_number, coalesce(c.company_address, cp.company_address) as company_address, coalesce(c.company_phone, cp.company_phone) as company_phone, coalesce(c.contact_person, cp.contact_person) as contact_person, coalesce(c.contact_phone, cp.contact_phone) as contact_phone, coalesce(c.maintainer, cp.maintainer) as maintainer, coalesce(c.maintenance_time, cp.maintenance_time) as maintenance_time, coalesce(c.tenant_id, cp.tenant_id) as tenant_id, coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account, coalesce(c.bank_account, cp.bank_account) as bank_account, coalesce(c.bank_code, cp.bank_code) as bank_code, coalesce(c.corporation, cp.corporation) as corporation, coalesce(c.fax, cp.fax) as fax, coalesce(c.agent, cp.agent) as agent, coalesce(c.bank_name, cp.bank_name) as bank_name from customer_private_pool cpp left join customer c on c.id = cpp.customer_id and cpp.type = 1 left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0 where c.customer_name in <foreach item="item" collection="collect" separator="," open="(" close=")"> #{item} </foreach> or cp.customer_name in <foreach item="item" collection="collect" separator="," open="(" close=")"> #{item} </foreach> </select> </mapper> src/main/resources/mapper/basic/ProductModelMapper.xml
@@ -126,7 +126,8 @@ INNER JOIN tree t ON t2.id = t.id; </select> <select id="selectOldProductModel" resultType="com.ruoyi.basic.pojo.ProductModel"> select * from product_model left join select product_model.*,product.product_name from product_model left join product on product_model.product_id = product.id where product_model.model = #{model} and product.product_name = #{productName} src/main/resources/static/ÏúÊŲ̂Õ˵¼ÈëÄ£°å.xlsxBinary files differ