| doc/河南鹤壁天沐钢化玻璃厂.sql | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/basic/controller/ProductController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/basic/pojo/ProductModel.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/basic/service/IProductModelService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/resources/mapper/basic/ProductModelMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
doc/ºÓÄϺױÚÌìãå¸Ö»¯²£Á§³§.sql
@@ -91,3 +91,10 @@ ALTER TABLE `product-inventory-management-hbtmblc`.`sales_ledger` MODIFY COLUMN `delivery_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'åè´§ç¶æï¼1-æªåè´§ï¼2-审æ¹ä¸ï¼3-审æ¹ä¸éè¿ï¼4-审æ¹éè¿ï¼5-å·²åè´§' AFTER `delivery_date`; ALTER TABLE `product-inventory-management-hbtmblc`.`sales_ledger_product` MODIFY COLUMN `quantity` decimal(18, 2) NULL COMMENT 'æ°é' AFTER `unit`, MODIFY COLUMN `tax_rate` decimal(5, 0) NULL COMMENT 'ç¨ç' AFTER `min_stock`, MODIFY COLUMN `tax_inclusive_unit_price` decimal(18, 2) NULL COMMENT 'å«ç¨åä»·' AFTER `tax_rate`, MODIFY COLUMN `tax_inclusive_total_price` decimal(18, 2) NULL COMMENT 'å«ç¨æ»ä»·' AFTER `tax_inclusive_unit_price`, MODIFY COLUMN `tax_exclusive_total_price` decimal(18, 2) NULL COMMENT 'ä¸å«ç¨æ»ä»·' AFTER `tax_inclusive_total_price`; src/main/java/com/ruoyi/basic/controller/ProductController.java
@@ -7,6 +7,7 @@ import com.ruoyi.basic.dto.ProductModelDto; import com.ruoyi.basic.dto.ProductModelExportDto; import com.ruoyi.basic.dto.ProductTreeDto; import com.ruoyi.basic.pojo.Product; import com.ruoyi.basic.pojo.ProductModel; import com.ruoyi.basic.service.IProductModelService; import com.ruoyi.basic.service.IProductService; @@ -38,6 +39,7 @@ private IProductModelService productModelService; @Autowired private ISalesLedgerProductService salesLedgerProductService; /** * æ¥è¯¢äº§å */ @@ -85,7 +87,7 @@ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(SalesLedgerProduct::getProductId, ids); List<SalesLedgerProduct> salesLedgerProductList = salesLedgerProductService.list(queryWrapper); if (salesLedgerProductList.size() > 0) { if (!salesLedgerProductList.isEmpty()) { return AjaxResult.error("该产ååå¨éå®/éè´è®°å½ï¼ä¸è½å é¤"); } return toAjax(productService.delProductByIds(ids)); @@ -143,4 +145,14 @@ ExcelUtil<ProductModelExportDto> excelUtil = new ExcelUtil<>(ProductModelExportDto.class); excelUtil.importTemplateExcel(response, "产åè§æ ¼å¯¼å ¥æ¨¡æ¿"); } /** * è·å产å大类 */ @GetMapping("/getParentNames") @ApiOperation("è·å产å大类") public AjaxResult getParentNames() { List<Product> list = productModelService.getParentNames(); return AjaxResult.success(list); } } src/main/java/com/ruoyi/basic/pojo/ProductModel.java
@@ -69,4 +69,10 @@ @TableField(exist = false) private LocalDateTime createTime; @TableField(exist = false) private Long parentId; @TableField(exist = false) private String parentName; } src/main/java/com/ruoyi/basic/service/IProductModelService.java
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.basic.dto.ProductDto; import com.ruoyi.basic.dto.ProductModelDto; import com.ruoyi.basic.pojo.Product; import com.ruoyi.basic.pojo.ProductModel; import com.ruoyi.framework.web.domain.AjaxResult; import org.springframework.web.multipart.MultipartFile; @@ -35,4 +36,7 @@ IPage<ProductModel> modelListPage(Page page , ProductDto productDto); AjaxResult importProductModel(MultipartFile file, Integer productId); List<Product> getParentNames(); } src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
@@ -151,4 +151,11 @@ throw new ServiceException("å¯¼å ¥å¤±è´¥"); } } @Override public List<Product> getParentNames() { LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.isNull(Product::getParentId).select(Product::getId, Product::getProductName); return productMapper.selectList(queryWrapper); } } src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java
@@ -89,27 +89,48 @@ @Override public int addOrEditProduct(ProductDto productDto) { checkDuplicateName(productDto); if (productDto.getId() == null) { // æ°å¢äº§åé»è¾ if (productDto.getParentId() == null) { // è¥æªæå®ç¶èç¹ï¼é»è®¤ä¸ºæ ¹èç¹ï¼parentId 设为 nullï¼ productDto.setParentId(null); } else { // æ£æ¥ç¶èç¹æ¯å¦åå¨ï¼å¯éï¼æ ¹æ®ä¸å¡éæ±ï¼ if (productDto.getParentId() != null) { Product parent = productMapper.selectById(productDto.getParentId()); if (parent == null) { throw new IllegalArgumentException("ç¶èç¹ä¸åå¨ï¼æ æ³æ·»å å产å"); throw new IllegalArgumentException("ç¶èç¹ä¸åå¨"); } } return productMapper.insert(productDto); Product product = new Product(); BeanUtils.copyProperties(productDto, product); return productMapper.insert(product); } else { // ç¼è¾äº§åé»è¾ // æ£æ¥äº§åæ¯å¦åå¨ï¼å¯éï¼æ ¹æ®ä¸å¡éæ±ï¼ Product existingProduct = productMapper.selectById(productDto.getId()); if (existingProduct == null) { throw new IllegalArgumentException("è¦ç¼è¾ç产åä¸åå¨"); throw new IllegalArgumentException("产åä¸åå¨"); } return productMapper.updateById(productDto); Product product = new Product(); BeanUtils.copyProperties(productDto, product); return productMapper.updateById(product); } } /** * æ ¡éªå级ç®å½ä¸æ¯å¦åå¨éå¤åç§° */ private void checkDuplicateName(ProductDto productDto) { LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>(); if (productDto.getParentId() == null) { queryWrapper.isNull(Product::getParentId); } else { queryWrapper.eq(Product::getParentId, productDto.getParentId()); } queryWrapper.eq(Product::getProductName, productDto.getProductName()); if (productDto.getId() != null) { queryWrapper.ne(Product::getId, productDto.getId()); } if (productMapper.selectCount(queryWrapper) > 0) { throw new IllegalArgumentException("å¨è¯¥å±çº§ä¸å·²åå¨å为 [" + productDto.getProductName() + "] ç产å"); } } src/main/resources/mapper/basic/ProductModelMapper.xml
@@ -15,20 +15,51 @@ <result column="product_name" property="productName" /> <result column="product_id" property="productId" /> </resultMap> <select id="listPageProductModel" resultType="com.ruoyi.basic.pojo.ProductModel"> select pm.*,p.product_name from product_model pm left join product p on pm.product_id = p.id WITH RECURSIVE product_tree AS ( SELECT id, product_name, id AS top_id, product_name AS top_name FROM product WHERE parent_id IS NULL OR parent_id = 0 UNION ALL SELECT p.id, p.product_name, t.top_id, t.top_name FROM product p INNER JOIN product_tree t ON p.parent_id = t.id ) SELECT pm.*, pt.product_name AS productName, pt.top_name AS parentName FROM product_model pm LEFT JOIN product_tree pt ON pm.product_id = pt.id <where> <if test="c.parentId != null"> AND pt.top_id = #{c.parentId} </if> <if test="c.model != null and c.model != ''"> and pm.model like concat('%',#{c.model},'%') AND pm.model LIKE CONCAT('%', #{c.model}, '%') </if> <if test="c.productName != null and c.productName != ''"> and p.product_name like concat('%',#{c.productName},'%') AND pt.product_name LIKE CONCAT('%', #{c.productName}, '%') </if> <if test="c.parentName != null and c.parentName != ''"> AND pt.top_name LIKE CONCAT('%', #{c.parentName}, '%') </if> </where> order by pm.id ORDER BY pm.id DESC </select> <select id="selectLatestRecord" resultType="com.ruoyi.basic.pojo.ProductModel"> SELECT * FROM product_model ORDER BY create_time DESC, id DESC