删除回滚完善,销售损耗添加字段type、prodId、地块选择数据返回增加库存量和面积
| | |
| | | //库存充足,减去相应库存 |
| | | farmProductStockService.stockReduce(inventory.getSaleNum(),inventory.getProid()); |
| | | } |
| | | inventory.setProdId(inventory.getProid()); |
| | | return R.status(inventoryService.saveOrUpdate(inventory)); |
| | | } |
| | | |
| | |
| | | inventory.setLandId(processInvVO.getLandId()); |
| | | processInvService.updateById(processInv); |
| | | } |
| | | inventory.setProdId(inventory.getProid()); |
| | | return R.status(inventoryService.saveOrUpdate(inventory)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | Inventory inventory = inventoryService.getById(Long.parseLong(ids)); |
| | | FarmProductStock farmProductStock = farmProductStockService.selectBy2Id(inventory.getStrainId(), inventory.getLandId()); |
| | | if (inventory.getType() == 0){ |
| | | FarmProductStock farmProductStock = farmProductStockService.getById(inventory.getProdId()); |
| | | Double weight = Double.parseDouble(farmProductStock.getWeight())+inventory.getSaleNum(); |
| | | farmProductStock.setWeight(weight.toString()); |
| | | farmProductStockService.updateById(farmProductStock); |
| | | }else { |
| | | ProcessInv inv = processInvService.findById(inventory.getProdId()); |
| | | Double weight = inv.getProductInventoryNum()+inventory.getSaleNum(); |
| | | inv.setProductInventoryNum(weight); |
| | | processInvService.updateById(inv); |
| | | } |
| | | return R.status(inventoryService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | |
| | | * 地块id |
| | | */ |
| | | private String landId; |
| | | |
| | | /** |
| | | * 品种类型(0农产品、1加工产品) |
| | | */ |
| | | private Integer type; |
| | | /** |
| | | * 各自库存的主键 |
| | | */ |
| | | private String prodId; |
| | | } |
| | |
| | | */ |
| | | @GetMapping("/selcetByStrainId") |
| | | public R selcetByStrainId(String strainId,String farmId) { |
| | | List<Land> list = landService.selectByStrainId(strainId,farmId); |
| | | List<LandVO> list = landService.selectByStrainId(strainId,farmId); |
| | | return R.data(list); |
| | | } |
| | | |
| | |
| | | * @param strainId 品种id |
| | | * @return |
| | | */ |
| | | List<Land> selectByStrainId(@Param("strainId") String strainId,@Param("farmId") String farmId); |
| | | List<LandVO> selectByStrainId(@Param("strainId") String strainId,@Param("farmId") String farmId); |
| | | |
| | | List<Land> getByStrainIdFarmId(@Param("land")LandVO land); |
| | | |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="selectByStrainId" resultType="org.springblade.modules.lang.entity.Land"> |
| | | SELECT land.id,land.land_name,land.url,land.farm_id |
| | | <select id="selectByStrainId" resultType="org.springblade.modules.lang.vo.LandVO"> |
| | | SELECT DISTINCT land.id,land.land_name,land.url,land.farm_id,fps.weight, |
| | | ( CASE WHEN land_unit = 2 THEN FORMAT(land.land_area * 0.0015,3) WHEN land_unit = 1 THEN land.land_area * 0.1 ELSE land.land_area END ) land_area |
| | | FROM sys_land land |
| | | LEFT JOIN sys_farm_product_stock fps ON fps.land_id = land.id |
| | | WHERE fps.strain_id = #{strainId} |
| | | LEFT JOIN sys_farm_plant sfp ON sfp.land_id = land.id |
| | | WHERE 1=1 |
| | | <if test="strainId !=null and strainId != ''"> |
| | | AND fps.strain_id = #{strainId} |
| | | </if> |
| | | <if test="farmId !=null and farmId != '' "> |
| | | AND land.farm_id = #{farmId} |
| | | </if> |
| | |
| | | Land getLandInfo(LandVO land); |
| | | /** |
| | | * 更新地块信息 |
| | | * @param farm |
| | | * @return |
| | | */ |
| | | boolean updateLandById(Land land); |
| | | boolean updateLandAr(Land land); |
| | |
| | | * @param farmId 农场id |
| | | * @return |
| | | */ |
| | | List<Land> selectByStrainId(String strainId,String farmId); |
| | | List<LandVO> selectByStrainId(String strainId,String farmId); |
| | | /** |
| | | * 根据品种id查询地块(种养品种) |
| | | * @param land |
| | |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Consumer; |
| | | |
| | | /** |
| | | * 地块表 服务实现类 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Land> selectByStrainId(String strainId,String farmId) { |
| | | public List<LandVO> selectByStrainId(String strainId,String farmId) { |
| | | return baseMapper.selectByStrainId(strainId,farmId); |
| | | } |
| | | |
| | |
| | | String sfpStatus; |
| | | String sfpId; |
| | | String detail; |
| | | String weight; |
| | | } |
| | |
| | | Boolean del(Long id); |
| | | |
| | | ProcessInvVO getLand(@Param("processInv") ProcessInv processInv); |
| | | |
| | | ProcessInv findById(@Param("prodId") String prodId); |
| | | } |
| | |
| | | AND inv.id = #{processInv.id} |
| | | </if> |
| | | </select> |
| | | <select id="findById" resultType="org.springblade.modules.processInv.entity.ProcessInv"> |
| | | SELECT id,strain_id,product_id,product_inventory_num,create_time,update_user,update_time,status,is_deleted |
| | | FROM sys_process_inv |
| | | WHERE is_deleted = 0 AND id = #{prodId} |
| | | </select> |
| | | </mapper> |
| | |
| | | Boolean del(Long id); |
| | | |
| | | ProcessInvVO getLand(ProcessInv processInv); |
| | | |
| | | ProcessInv findById(String prodId); |
| | | } |
| | |
| | | public ProcessInvVO getLand(ProcessInv processInv) { |
| | | return baseMapper.getLand(processInv); |
| | | } |
| | | |
| | | @Override |
| | | public ProcessInv findById(String prodId) { |
| | | return baseMapper.findById(prodId); |
| | | } |
| | | } |
| | |
| | | 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.InventoryLoss.entity.Inventory; |
| | | import org.springblade.modules.farmplant.entity.FarmProductStock; |
| | | import org.springblade.modules.farmplant.service.FarmProductStockService; |
| | | import org.springblade.modules.process.service.IProcessService; |
| | |
| | | //库存充足,减去相应库存 |
| | | farmProductStockService.stockReduce(sale.getSaleNum(),sale.getProid()); |
| | | } |
| | | sale.setProdId(sale.getProid()); |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | |
| | | sale.setLandId(processInvVO.getLandId()); |
| | | processInvService.updateById(processInv); |
| | | } |
| | | sale.setProdId(sale.getProid()); |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | Sale sale = saleService.getById(Long.parseLong(ids)); |
| | | FarmProductStock farmProductStock = farmProductStockService.selectBy2Id(sale.getStrainId(), sale.getLandId()); |
| | | if (sale.getType() == 0){ |
| | | FarmProductStock farmProductStock = farmProductStockService.getById(sale.getProdId()); |
| | | Double weight = Double.parseDouble(farmProductStock.getWeight())+sale.getSaleNum(); |
| | | farmProductStock.setWeight(weight.toString()); |
| | | farmProductStockService.updateById(farmProductStock); |
| | | }else { |
| | | ProcessInv inv = processInvService.findById(sale.getProdId()); |
| | | Double weight = inv.getProductInventoryNum()+sale.getSaleNum(); |
| | | inv.setProductInventoryNum(weight); |
| | | processInvService.updateById(inv); |
| | | } |
| | | return R.status(saleService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | |
| | | * 地块id |
| | | */ |
| | | private String landId; |
| | | |
| | | /** |
| | | * 品种类型(0农产品、1加工产品) |
| | | */ |
| | | private Integer type; |
| | | /** |
| | | * 各自库存的主键 |
| | | */ |
| | | private String prodId; |
| | | } |