| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.ProductDto; |
| | | import com.ruoyi.basic.dto.ProductModelAnticlockwiseDto; |
| | | import com.ruoyi.basic.dto.ProductModelDto; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductModelService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | } |
| | | } |
| | | |
| | | public Boolean checkProductModelExist(Long productId, String model) { |
| | | return true; |
| | | //反向新增成品产品,只有销售关联新增的时候调用 |
| | | @Override |
| | | public Long productModelAnticlockwise(ProductModelAnticlockwiseDto productModelDto) { |
| | | ProductModel oldProductModel = new ProductModel(); |
| | | if (ObjectUtils.isNotEmpty(productModelDto.getId())) { |
| | | oldProductModel = productModelMapper.selectById(productModelDto.getId()); |
| | | }else { |
| | | oldProductModel = productModelMapper.selectOldProductModel(productModelDto.getModel(), productModelDto.getProductName()); |
| | | } |
| | | //存在就更新 |
| | | if (oldProductModel != null) { |
| | | oldProductModel.setModel(productModelDto.getModel()); |
| | | oldProductModel.setUnit(productModelDto.getUnit()); |
| | | oldProductModel.setSubUnit(productModelDto.getSubUnit()); |
| | | oldProductModel.setDeptId(SecurityUtils.getDeptId()[0]); |
| | | productModelMapper.updateById(oldProductModel); |
| | | Product product = productMapper.selectById(oldProductModel.getProductId()); |
| | | product.setProductName(productModelDto.getProductName()); |
| | | productMapper.updateById(product); |
| | | return oldProductModel.getId(); |
| | | }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()); |
| | | product.setParentId(productParent.getId()); |
| | | product.setDeptId(SecurityUtils.getDeptId()[0]); |
| | | productMapper.insert( product); |
| | | //新增产品规格 |
| | | ProductModel productModel = new ProductModel(); |
| | | productModel.setProductId(product.getId()); |
| | | productModel.setModel(productModelDto.getModel()); |
| | | productModel.setUnit(productModelDto.getUnit()); |
| | | productModel.setSubUnit(productModelDto.getSubUnit()); |
| | | productModel.setDeptId(SecurityUtils.getDeptId()[0]); |
| | | productModelMapper.insert(productModel); |
| | | return productModel.getId(); |
| | | |
| | | } |
| | | } |
| | | } |