| | |
| | | import org.springblade.modules.InventoryLoss.entity.Inventory; |
| | | import org.springblade.modules.InventoryLoss.service.InventoryService; |
| | | import org.springblade.modules.InventoryLoss.vo.InventoryVO; |
| | | import org.springblade.modules.process.service.IProcessService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | |
| | | |
| | | private final InventoryService inventoryService; |
| | | private final FarmProductStockService farmProductStockService; |
| | | private final IProcessService processService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | return R.status(inventoryService.saveOrUpdate(inventory)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 库存损耗记录表 |
| | | */ |
| | | @PostMapping("/submitProcess") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submitProcess(@Valid @RequestBody InventoryVO inventory) { |
| | | boolean res = processService.stockCompare(inventory.getSaleNum(),inventory.getProid()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | processService.stockReduce(inventory.getSaleNum(),inventory.getProid()); |
| | | } |
| | | return R.status(inventoryService.saveOrUpdate(inventory)); |
| | | } |
| | | |
| | | /** |
| | | * 删除 库存损耗记录表 |
| | |
| | | */ |
| | | List<ProcessVO> selectProcessPage(IPage page, @Param("process") ProcessVO process); |
| | | |
| | | boolean stockCompare(@Param("saleNum") Double saleNum, @Param("proid") String proid); |
| | | |
| | | Boolean stockReduce(@Param("saleNum") Double saleNum, @Param("proid") String proid); |
| | | } |
| | |
| | | |
| | | |
| | | <select id="selectProcessPage" resultMap="processResultMap"> |
| | | SELECT p.strain_id, |
| | | SELECT p.strain_id,p.id, |
| | | p.land_id,sale_time,sale_num,strain_name,process_id, |
| | | SUM(p.process_num) as process_num, |
| | | m.machining_type AS processName, |
| | |
| | | <if test="process.strainId !=null and process.strainId !=''"> |
| | | and p.strain_id = #{process.strainId} |
| | | </if> |
| | | GROUP BY p.strain_id,m.machining_type,m.machining_tp,p.land_id,sale_time,sale_num,process_id |
| | | GROUP BY p.strain_id,m.machining_type,m.machining_tp,p.land_id,sale_time,sale_num,process_id,p.id |
| | | </select> |
| | | |
| | | <select id="stockCompare" resultType="boolean"> |
| | | SELECT |
| | | CASE |
| | | WHEN |
| | | process_num > #{saleNum} THEN |
| | | TRUE ELSE FALSE |
| | | END result |
| | | FROM |
| | | sys_process |
| | | WHERE |
| | | id = #{proid} |
| | | </select> |
| | | |
| | | <update id="stockReduce"> |
| | | UPDATE sys_process SET process_num = process_num - #{saleNum} |
| | | WHERE |
| | | id = #{proid} |
| | | </update> |
| | | </mapper> |
| | |
| | | */ |
| | | IPage<ProcessVO> selectProcessPage(IPage<ProcessVO> page, ProcessVO process); |
| | | |
| | | /** |
| | | * 库存对比 |
| | | * @param saleNum 销售数量 |
| | | * @param proid 加工表主键 |
| | | * @return |
| | | */ |
| | | boolean stockCompare(Double saleNum, String proid); |
| | | |
| | | /** |
| | | * 对应库存减少 |
| | | * @param saleNum 销售数量 |
| | | * @param proid 加工表主键 |
| | | * @return |
| | | */ |
| | | Boolean stockReduce(Double saleNum, String proid); |
| | | } |
| | |
| | | return page.setRecords(baseMapper.selectProcessPage(page, process)); |
| | | } |
| | | |
| | | @Override |
| | | public boolean stockCompare(Double saleNum, String proid) { |
| | | return baseMapper.stockCompare(saleNum,proid); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean stockReduce(Double saleNum, String proid) { |
| | | return baseMapper.stockReduce(saleNum,proid); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.farmplant.service.FarmProductStockService; |
| | | import org.springblade.modules.process.service.IProcessService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | |
| | | private final ISaleService saleService; |
| | | private final FarmProductStockService farmProductStockService; |
| | | private final IProcessService processService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 销售记录表(加工产品) |
| | | */ |
| | | @PostMapping("/submitProcess") |
| | | @ApiOperationSupport(order = 8) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submitProcess(@Valid @RequestBody SaleVO sale) { |
| | | //对比加工表库存量 |
| | | boolean res = processService.stockCompare(sale.getSaleNum(),sale.getProid()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | processService.stockReduce(sale.getSaleNum(),sale.getProid()); |
| | | } |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | | /** |
| | | * 删除 销售记录表 |