1、接口对接,增加库存判断,省市县对接,动态调整库存
| | |
| | | List<FarmProductStockVO> statisticsProduct(@Param("farmProductStock") FarmProductStockVO farmProductStock); |
| | | List<FarmProductStockVO> statisticsProductx(@Param("page") IPage page, @Param("farmProductStock") FarmProductStockVO farmProductStock); |
| | | Map<String, String> selctProductCount(String year); |
| | | boolean stockCompare(double sale,String id); |
| | | boolean stockReduce(double sale,String id); |
| | | } |
| | |
| | | and sfps.tenant_id = #{farmProductStock.tenantId} |
| | | </if> |
| | | </select> |
| | | |
| | | <!--销售对比库存是否充足--> |
| | | <select id="stockCompare" resultType="boolean"> |
| | | SELECT |
| | | CASE |
| | | WHEN |
| | | weight > #{sale} THEN |
| | | TRUE ELSE FALSE |
| | | END result |
| | | FROM |
| | | sys_farm_product_stock |
| | | WHERE |
| | | strain_id = #{id} |
| | | </select> |
| | | <!--减去对应库存--> |
| | | <update id="stockReduce"> |
| | | UPDATE sys_farm_product_stock SET weight = weight - #{sale} |
| | | WHERE |
| | | strain_id = #{id} |
| | | </update> |
| | | </mapper> |
| | |
| | | FarmProductStockVO statisticsProduct(FarmProductStockVO farmProductStock); |
| | | IPage<FarmProductStockVO> statisticsProductx(IPage<FarmProductStockVO> page, FarmProductStockVO farmProductStock); |
| | | Map<String, String> selctProductCount(String year); |
| | | //查看库存是否充足 |
| | | boolean stockCompare(double sale,String id); |
| | | //减去相应库存 |
| | | boolean stockReduce(double sale,String id); |
| | | } |
| | |
| | | public Map<String, String> selctProductCount(String year) { |
| | | return baseMapper.selctProductCount(year); |
| | | } |
| | | |
| | | @Override |
| | | public boolean stockCompare(double sale,String id) { |
| | | return baseMapper.stockCompare(sale,id); |
| | | } |
| | | @Override |
| | | public boolean stockReduce(double sale,String id) { |
| | | return baseMapper.stockReduce(sale,id); |
| | | } |
| | | } |
| | |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.farmplant.service.FarmProductStockService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | public class SaleController extends BladeController { |
| | | |
| | | private final ISaleService saleService; |
| | | private final FarmProductStockService farmProductStockService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submit(@Valid @RequestBody Sale sale) { |
| | | boolean res = farmProductStockService.stockCompare(sale.getSaleNum(),sale.getStrainId()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | farmProductStockService.stockReduce(sale.getSaleNum(),sale.getStrainId()); |
| | | } |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.springblade.modules.sale.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 销售记录表实体类 |
| | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 品种id |
| | | */ |
| | | private Integer strainId; |
| | | private String strainId; |
| | | /** |
| | | * 销售时间 |
| | | */ |
| | | private LocalDateTime saleTime; |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date saleTime; |
| | | /** |
| | | * 销售数量 |
| | | */ |
| | | private Integer saleNum; |
| | | private Double saleNum; |
| | | /** |
| | | * 销售去向 |
| | | * 销售去向(省) |
| | | */ |
| | | private Integer saleDestination; |
| | | /** |
| | |
| | | * 销售价格 |
| | | */ |
| | | private Double salePrice; |
| | | |
| | | /** |
| | | * 销售去向(市) |
| | | */ |
| | | private Integer city; |
| | | /** |
| | | * 销售去向(县) |
| | | */ |
| | | private Integer county; |
| | | /** |
| | | * 品牌 |
| | | */ |
| | | private String saleBrand; |
| | | |
| | | } |
| | |
| | | YEAR ( sale_time ) = YEAR ( date_sub( now( ) |
| | | , INTERVAL 1 YEAR ) ); |
| | | </select> |
| | | |
| | | </mapper> |