无关风月
2025-01-10 70061624664c6ef437c0250e8ae2c9cffd1134e0
manage/src/main/java/com/jilongda/manage/controller/TInventoryController.java
@@ -17,8 +17,10 @@
import com.jilongda.manage.vo.TInventoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -76,7 +78,7 @@
            tInventoryFrameDetail.setInventoryId(tInventory.getId());
        }
        inventoryFrameDetailService.saveBatch(query.getList());
        return ApiResult.success();
        return ApiResult.success(tInventory.getId());
    }
    @ApiOperation(value = "镜片添加盘点")
    @PostMapping(value = "/addLensInventory")
@@ -88,16 +90,18 @@
            tInventoryFrameDetail.setInventoryId(tInventory.getId());
        }
        inventoryLensDetailService.saveBatch(query.getList());
        return ApiResult.success();
        return ApiResult.success(tInventory.getId());
    }
    @ApiOperation(value = "镜架-根据品牌id查询对应库存")
    @PostMapping(value = "/getCountByBrandId")
    public ApiResult getCountByBrandId(Integer id) {
    public ApiResult getCountByBrandId(Integer id,Integer storeId) {
        List<Integer> collect = modelService.lambdaQuery().eq(TModel::getBrandId, id)
                .list().stream().map(TModel::getId).distinct().collect(Collectors.toList());
        if (collect.isEmpty())collect.add(-1);
        List<TFrameGoods> list = frameGoodsService.lambdaQuery().in(TFrameGoods::getModelId, collect).list();
        List<TFrameGoods> list = frameGoodsService.lambdaQuery().in(TFrameGoods::getModelId, collect)
                .eq(TFrameGoods::getStoreId,storeId)
                .list();
        if (list.isEmpty())return ApiResult.success("0");
        int i = 0;
        for (TFrameGoods tFrameGoods : list) {
@@ -106,12 +110,13 @@
        return ApiResult.success(i);
    }
    @ApiOperation(value = "镜架-根据材质id查询对应库存")
    @PostMapping(value = "/getCountByMaterialId")
    public ApiResult getCountByMaterialId(Integer id) {
    @GetMapping(value = "/getCountByMaterialId")
    public ApiResult getCountByMaterialId(Integer id,Integer storeId) {
        List<Integer> collect = modelService.lambdaQuery().eq(TModel::getMaterialId, id)
                .list().stream().map(TModel::getId).distinct().collect(Collectors.toList());
        if (collect.isEmpty())collect.add(-1);
        List<TFrameGoods> list = frameGoodsService.lambdaQuery().in(TFrameGoods::getModelId, collect).list();
        List<TFrameGoods> list = frameGoodsService.lambdaQuery().in(TFrameGoods::getModelId, collect).
        eq(TFrameGoods::getStoreId,storeId).list();
        if (list.isEmpty())return ApiResult.success("0");
        int i = 0;
        for (TFrameGoods tFrameGoods : list) {
@@ -123,32 +128,36 @@
    @PostMapping(value = "/getCurrentByParamFrame")
    public ApiResult<Integer> getCurrentByParamFrame(@RequestBody GetCurrentByParam getCurrentByParam) {
        // 根据型号名称 查询型号列表ids
        List<Integer> collect = modelService.lambdaQuery().eq(TModel::getName, getCurrentByParam.getModel())
                .eq(TModel::getColor,getCurrentByParam.getColor())
                .eq(TModel::getMaterialId,getCurrentByParam.getMaterialId())
                .eq(TModel::getBrandId,getCurrentByParam.getBrandId())
        List<Integer> collect = modelService.lambdaQuery().eq(StringUtils.hasLength(getCurrentByParam.getModel()),TModel::getName, getCurrentByParam.getModel())
                .eq(StringUtils.hasLength(getCurrentByParam.getColor()),TModel::getColor,getCurrentByParam.getColor())
                .eq(getCurrentByParam.getMaterialId()!=null,TModel::getMaterialId,getCurrentByParam.getMaterialId())
                .eq(getCurrentByParam.getBrandId()!=null,TModel::getBrandId,getCurrentByParam.getBrandId())
                .list().stream().map(TModel::getId).collect(Collectors.toList());
        TFrameGoods one = frameGoodsService.lambdaQuery().in(TFrameGoods::getModelId, collect)
                .eq(TFrameGoods::getColor, getCurrentByParam.getColor()).one();
        if (one!=null){
            return ApiResult.success(one.getTotal());
        }
        return ApiResult.success(0);
        if (collect.isEmpty())collect.add(-1);
        List<TFrameGoods> one = frameGoodsService.lambdaQuery().in(TFrameGoods::getModelId, collect)
                .eq(TFrameGoods::getStoreId,getCurrentByParam.getStoreId())
                .eq(TFrameGoods::getColor, getCurrentByParam.getColor()).list();
        if (one.isEmpty())return ApiResult.success(0);
        Integer temp = one.stream()
                .mapToInt(TFrameGoods::getTotal)
                .sum();
        return ApiResult.success(temp);
    }
    @ApiOperation(value = "镜片-根据品牌id、型号名称、色号名称、材质id查询当前库存")
    @PostMapping(value = "/getCurrentByParamLens")
    public ApiResult<Integer> getCurrentByParamLens(@RequestBody GetCurrentByParamLens dto) {
        TLensGoods one = lensGoodsService.lambdaQuery().in(TLensGoods::getSeriesId, dto.getSeriesId())
        List<TLensGoods> one = lensGoodsService.lambdaQuery().in(TLensGoods::getSeriesId, dto.getSeriesId())
                .eq(dto.getLensType()!=null,TLensGoods::getLensType, dto.getLensType())
                .eq(dto.getRefractiveIndex()!=null,TLensGoods::getRefractiveIndex, dto.getRefractiveIndex())
                .eq(dto.getBallMirror()!=null,TLensGoods::getBallMirror, dto.getBallMirror())
                .eq(dto.getColumnMirror()!=null,TLensGoods::getColumnMirror, dto.getColumnMirror())
                .one();
        if (one!=null){
            return ApiResult.success(one.getTotal());
        }
        return ApiResult.success(0);
                .eq(StringUtils.hasLength(dto.getRefractiveIndex()),TLensGoods::getRefractiveIndex, dto.getRefractiveIndex())
                .eq(StringUtils.hasLength(dto.getBallMirror()),TLensGoods::getBallMirror, dto.getBallMirror())
                .eq(StringUtils.hasLength(dto.getColumnMirror()),TLensGoods::getColumnMirror, dto.getColumnMirror())
                .eq(dto.getStoreId()!=null,TLensGoods::getStoreId, dto.getStoreId())
                .list();
        if (one.isEmpty())return ApiResult.success(0);
        Integer temp = one.stream()
                .mapToInt(TLensGoods::getTotal)
                .sum();
        return ApiResult.success(temp);
    }
    @ApiOperation(value = "查看详情")
    @GetMapping(value = "/getDetailById")
@@ -156,6 +165,7 @@
        TInventoryInfoVO tInventoryInfoVO = new TInventoryInfoVO();
        TInventory byId = inventoryService.getById(id);
        BeanUtils.copyProperties(byId, tInventoryInfoVO);
        switch (byId.getType()){
            case 1:
                List<TInventoryFrameDetail> list = inventoryFrameDetailService.lambdaQuery().eq(TInventoryFrameDetail::getInventoryId, id).list();