智慧农业后台管理
删除回滚完善,销售损耗添加字段type、prodId、地块选择数据返回增加库存量和面积
14 files modified
78 ■■■■ changed files
src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/InventoryLoss/entity/Inventory.java 9 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/lang/controller/LandController.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/lang/mapper/LandMapper.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml 11 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/lang/service/ILandService.java 4 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/lang/service/impl/LandServiceImpl.java 3 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/lang/vo/LandVO.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/processInv/service/IProcessInvService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/processInv/service/impl/ProcessInvServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sale/controller/SaleController.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/sale/entity/Sale.java 9 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java
@@ -126,6 +126,7 @@
            //库存充足,减去相应库存
            farmProductStockService.stockReduce(inventory.getSaleNum(),inventory.getProid());
        }
        inventory.setProdId(inventory.getProid());
        return R.status(inventoryService.saveOrUpdate(inventory));
    }
@@ -159,6 +160,7 @@
            inventory.setLandId(processInvVO.getLandId());
            processInvService.updateById(processInv);
        }
        inventory.setProdId(inventory.getProid());
        return R.status(inventoryService.saveOrUpdate(inventory));
    }
@@ -170,10 +172,17 @@
    @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)));
    }
src/main/java/org/springblade/modules/InventoryLoss/entity/Inventory.java
@@ -76,5 +76,12 @@
     * 地块id
     */
    private String landId;
    /**
     * 品种类型(0农产品、1加工产品)
     */
    private Integer type;
    /**
     * 各自库存的主键
     */
    private String prodId;
}
src/main/java/org/springblade/modules/lang/controller/LandController.java
@@ -113,7 +113,7 @@
     */
    @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);
    }
src/main/java/org/springblade/modules/lang/mapper/LandMapper.java
@@ -94,7 +94,7 @@
     * @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);
src/main/java/org/springblade/modules/lang/mapper/LandMapper.xml
@@ -228,11 +228,16 @@
        </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>
src/main/java/org/springblade/modules/lang/service/ILandService.java
@@ -57,8 +57,6 @@
    Land getLandInfo(LandVO land);
    /**
     * 更新地块信息
     * @param farm
     * @return
     */
    boolean updateLandById(Land land);
    boolean updateLandAr(Land land);
@@ -99,7 +97,7 @@
     * @param farmId 农场id
     * @return
     */
    List<Land> selectByStrainId(String strainId,String farmId);
    List<LandVO> selectByStrainId(String strainId,String farmId);
    /**
     * 根据品种id查询地块(种养品种)
     * @param land
src/main/java/org/springblade/modules/lang/service/impl/LandServiceImpl.java
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
/**
 * 地块表 服务实现类
@@ -120,7 +121,7 @@
    }
    @Override
    public List<Land> selectByStrainId(String strainId,String farmId) {
    public List<LandVO> selectByStrainId(String strainId,String farmId) {
        return baseMapper.selectByStrainId(strainId,farmId);
    }
src/main/java/org/springblade/modules/lang/vo/LandVO.java
@@ -42,4 +42,5 @@
    String sfpStatus;
    String sfpId;
    String detail;
    String weight;
}
src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.java
@@ -53,4 +53,6 @@
    Boolean del(Long id);
    ProcessInvVO getLand(@Param("processInv") ProcessInv processInv);
    ProcessInv findById(@Param("prodId") String prodId);
}
src/main/java/org/springblade/modules/processInv/mapper/ProcessInvMapper.xml
@@ -84,4 +84,9 @@
            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>
src/main/java/org/springblade/modules/processInv/service/IProcessInvService.java
@@ -60,4 +60,6 @@
    Boolean del(Long id);
    ProcessInvVO getLand(ProcessInv processInv);
    ProcessInv findById(String prodId);
}
src/main/java/org/springblade/modules/processInv/service/impl/ProcessInvServiceImpl.java
@@ -81,4 +81,9 @@
    public ProcessInvVO getLand(ProcessInv processInv) {
        return baseMapper.getLand(processInv);
    }
    @Override
    public ProcessInv findById(String prodId) {
        return baseMapper.findById(prodId);
    }
}
src/main/java/org/springblade/modules/sale/controller/SaleController.java
@@ -29,6 +29,7 @@
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;
@@ -129,6 +130,7 @@
            //库存充足,减去相应库存
            farmProductStockService.stockReduce(sale.getSaleNum(),sale.getProid());
        }
        sale.setProdId(sale.getProid());
        return R.status(saleService.saveOrUpdate(sale));
    }
@@ -164,6 +166,7 @@
            sale.setLandId(processInvVO.getLandId());
            processInvService.updateById(processInv);
        }
        sale.setProdId(sale.getProid());
        return R.status(saleService.saveOrUpdate(sale));
    }
@@ -175,10 +178,17 @@
    @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)));
    }
src/main/java/org/springblade/modules/sale/entity/Sale.java
@@ -88,5 +88,12 @@
     * 地块id
     */
    private String landId;
    /**
     * 品种类型(0农产品、1加工产品)
     */
    private Integer type;
    /**
     * 各自库存的主键
     */
    private String prodId;
}