|
|
@@ -1,9 +1,10 @@
|
|
|
package org.springblade.factory.api.controller;
|
|
|
|
|
|
|
|
|
-import com.alibaba.excel.util.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -12,8 +13,6 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
-import org.redisson.api.RLock;
|
|
|
-import org.redisson.api.RedissonClient;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
@@ -23,9 +22,7 @@ import org.springblade.factory.entity.*;
|
|
|
import org.springblade.factory.service.*;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
-import org.springblade.u9cloud.entity.ZcrmViewCustomerSel;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -40,7 +37,6 @@ import java.security.Principal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeParseException;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -62,6 +58,10 @@ public class SalesForecastSummaryController {
|
|
|
|
|
|
private final PcBladeSalesForecastMainService salesForecastMainService;
|
|
|
|
|
|
+ private final ZcrmViewItemSelService itemSelService;
|
|
|
+
|
|
|
+ private final ZcrmViewWhqohSelService whqohSelService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IUserClient userClient;
|
|
|
|
|
|
@@ -388,8 +388,9 @@ public class SalesForecastSummaryController {
|
|
|
return R.fail("年份和月份参数无效");
|
|
|
}
|
|
|
|
|
|
- Long customerId = AuthUtil.getUserId();
|
|
|
- List<PcBladeSalesForecastSummary> list = forecastService.getForecastByUserAndMonth(customerId, year, month);
|
|
|
+ Long userId = AuthUtil.getUserId();
|
|
|
+ R<User> user = userClient.userInfoById(userId);
|
|
|
+ List<PcBladeSalesForecastSummary> list = forecastService.getForecastByUserAndMonth(user.getData().getCustomerId(), year, month);
|
|
|
return R.data(list);
|
|
|
}
|
|
|
|
|
|
@@ -767,6 +768,27 @@ public class SalesForecastSummaryController {
|
|
|
|
|
|
private final PjpfBrandDescService brandService;
|
|
|
|
|
|
+// /**
|
|
|
+// * 品牌列表
|
|
|
+// */
|
|
|
+// @GetMapping("/brand-desc")
|
|
|
+// @ApiOperation(value = "品牌列表", notes = "传入cname,status,type等查询条件")
|
|
|
+// @ApiOperationSupport(order = 1)
|
|
|
+// public R<IPage<PjpfBrandDesc>> brandDesc(
|
|
|
+// @ApiIgnore @RequestParam Map<String, Object> brandParams,
|
|
|
+// Query query,
|
|
|
+// BladeUser bladeUser) {
|
|
|
+// // 构建查询条件
|
|
|
+// QueryWrapper<PjpfBrandDesc> queryWrapper = Condition.getQueryWrapper(brandParams, PjpfBrandDesc.class);
|
|
|
+// // 执行分页查询
|
|
|
+// IPage<PjpfBrandDesc> pages = brandService.page(Condition.getPage(query), queryWrapper);
|
|
|
+// // 转换VO并返回
|
|
|
+// return R.data(pages);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 品牌列表
|
|
|
*/
|
|
|
@@ -777,14 +799,45 @@ public class SalesForecastSummaryController {
|
|
|
@ApiIgnore @RequestParam Map<String, Object> brandParams,
|
|
|
Query query,
|
|
|
BladeUser bladeUser) {
|
|
|
- // 构建查询条件
|
|
|
- QueryWrapper<PjpfBrandDesc> queryWrapper = Condition.getQueryWrapper(brandParams, PjpfBrandDesc.class);
|
|
|
- // 执行分页查询
|
|
|
- IPage<PjpfBrandDesc> pages = brandService.page(Condition.getPage(query), queryWrapper);
|
|
|
+
|
|
|
+ Page<ViewItemSel> page = new Page<>();
|
|
|
+ LambdaQueryWrapper<ViewItemSel> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ IPage<ViewItemSel> itemPage = itemSelService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ // 2. 手动映射为PjpfBrandDesc分页数据
|
|
|
+ IPage<PjpfBrandDesc> brandPage = new Page<>(itemPage.getCurrent(), itemPage.getSize(), itemPage.getTotal());
|
|
|
+ List<PjpfBrandDesc> brandList = itemPage.getRecords().stream().map(item -> {
|
|
|
+ PjpfBrandDesc brand = new PjpfBrandDesc();
|
|
|
+ // 字段映射(根据业务逻辑调整)
|
|
|
+ brand.setId(item.getItemId()); // 料品ID -> 品牌主键
|
|
|
+ brand.setTenantId(String.valueOf(item.getOrgId())); // 组织ID -> 租户ID
|
|
|
+ brand.setCname(item.getItemName()); // 料品名称 -> 品牌名称
|
|
|
+ brand.setSalesCompanyId(item.getOrgId()); // 组织ID -> 所属公司ID
|
|
|
+ brand.setSalesCompanyName(item.getOrgName()); // 组织名称 -> 所属公司名称
|
|
|
+ brand.setType(item.getMainItemCategoryCode()); // 主分类编码 -> 类型
|
|
|
+ brand.setWhetherIntegral("");
|
|
|
+ return brand;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ brandPage.setRecords(brandList);
|
|
|
// 转换VO并返回
|
|
|
- return R.data(pages);
|
|
|
+ return R.data(brandPage);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 单条查询
|
|
|
+// */
|
|
|
+// @GetMapping("/brand-desc/{id}")
|
|
|
+// @ApiOperation(value = "单条查询", notes = "传入品牌ID")
|
|
|
+// @ApiImplicitParam(name = "id", value = "品牌ID", required = true, paramType = "path")
|
|
|
+// @ApiOperationSupport(order = 2)
|
|
|
+// public R<PjpfBrandDesc> getBrandDesc(@PathVariable("id") Long id) {
|
|
|
+// PjpfBrandDesc brand = brandService.getById(id);
|
|
|
+// return R.data(brand);
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* 单条查询
|
|
|
*/
|
|
|
@@ -793,15 +846,54 @@ public class SalesForecastSummaryController {
|
|
|
@ApiImplicitParam(name = "id", value = "品牌ID", required = true, paramType = "path")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
public R<PjpfBrandDesc> getBrandDesc(@PathVariable("id") Long id) {
|
|
|
- PjpfBrandDesc brand = brandService.getById(id);
|
|
|
+
|
|
|
+ QueryWrapper<ViewItemSel> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("Item_ID", id);
|
|
|
+ ViewItemSel viewItemSel = itemSelService.getOne(queryWrapper);
|
|
|
+ if (viewItemSel == null) {
|
|
|
+ R.fail("料品数据不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ PjpfBrandDesc brand = new PjpfBrandDesc();
|
|
|
+ // 字段映射(根据业务逻辑调整)
|
|
|
+ brand.setId(viewItemSel.getItemId()); // 料品ID -> 品牌主键
|
|
|
+ brand.setTenantId(String.valueOf(viewItemSel.getOrgId())); // 组织ID -> 租户ID
|
|
|
+ brand.setCname(viewItemSel.getItemName()); // 料品名称 -> 品牌名称
|
|
|
+ brand.setSalesCompanyId(viewItemSel.getOrgId()); // 组织ID -> 所属公司ID
|
|
|
+ brand.setSalesCompanyName(viewItemSel.getOrgName()); // 组织名称 -> 所属公司名称
|
|
|
+ brand.setType(viewItemSel.getMainItemCategoryCode()); // 主分类编码 -> 类型
|
|
|
+ brand.setWhetherIntegral("");
|
|
|
+
|
|
|
return R.data(brand);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/* ========== 库存表 ========== */
|
|
|
private final PjpfStockDescService stockService;
|
|
|
|
|
|
+// /**
|
|
|
+// * 库存列表
|
|
|
+// */
|
|
|
+// @GetMapping("brand-stock")
|
|
|
+// @ApiOperation(value = "库存列表", notes = "传入cname,goodsId,brandId等查询条件")
|
|
|
+// @ApiOperationSupport(order = 1)
|
|
|
+// public R<IPage<PjpfStockDesc>> brandStock(
|
|
|
+// @ApiIgnore @RequestParam Map<String, Object> stockParams,
|
|
|
+// Query query,
|
|
|
+// BladeUser bladeUser) {
|
|
|
+// // 构建查询条件
|
|
|
+// QueryWrapper<PjpfStockDesc> queryWrapper = Condition.getQueryWrapper(stockParams, PjpfStockDesc.class);
|
|
|
+// // 执行分页查询
|
|
|
+// IPage<PjpfStockDesc> pages = stockService.page(Condition.getPage(query), queryWrapper);
|
|
|
+// // 转换VO并返回
|
|
|
+// return R.data(pages);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 库存列表
|
|
|
*/
|
|
|
@@ -812,28 +904,99 @@ public class SalesForecastSummaryController {
|
|
|
@ApiIgnore @RequestParam Map<String, Object> stockParams,
|
|
|
Query query,
|
|
|
BladeUser bladeUser) {
|
|
|
- // 构建查询条件
|
|
|
- QueryWrapper<PjpfStockDesc> queryWrapper = Condition.getQueryWrapper(stockParams, PjpfStockDesc.class);
|
|
|
- // 执行分页查询
|
|
|
- IPage<PjpfStockDesc> pages = stockService.page(Condition.getPage(query), queryWrapper);
|
|
|
+
|
|
|
+ QueryWrapper<ViewWhqohSel> queryWrapper = new QueryWrapper<>();
|
|
|
+ Page<ViewWhqohSel> page = new Page<>();
|
|
|
+
|
|
|
+ // 3. 查询库存视图数据
|
|
|
+ IPage<ViewWhqohSel> whqohPage = whqohSelService.page(page, queryWrapper);
|
|
|
+
|
|
|
+ // 4. 手动映射为PjpfStockDesc分页数据
|
|
|
+ IPage<PjpfStockDesc> stockPage = new Page<>(
|
|
|
+ whqohPage.getCurrent(),
|
|
|
+ whqohPage.getSize(),
|
|
|
+ whqohPage.getTotal()
|
|
|
+ );
|
|
|
+
|
|
|
+ List<PjpfStockDesc> stockList = whqohPage.getRecords().stream().map(whqoh -> {
|
|
|
+ PjpfStockDesc stock = new PjpfStockDesc();
|
|
|
+ // 字段映射(根据业务逻辑调整)
|
|
|
+ stock.setId(whqoh.getItemId()); // 商品ID作为主键
|
|
|
+ stock.setTenantId(whqoh.getOrgId().toString()); // 组织ID作为租户ID
|
|
|
+ stock.setStorageId(whqoh.getWarehouseId()); // 仓库ID
|
|
|
+ stock.setStorageName(whqoh.getWarehouseName()); // 仓库名称
|
|
|
+ stock.setGoodsId(whqoh.getItemId()); // 商品ID
|
|
|
+ stock.setCode(whqoh.getItemCode()); // 物料编号(商品编码)
|
|
|
+ stock.setCname(whqoh.getItemName()); // 商品名称
|
|
|
+ stock.setTypeNo(whqoh.getItemPecs()); // 规格型号(映射自Item_PECS)
|
|
|
+ stock.setProductDescription(whqoh.getItemDescription()); // 商品描述
|
|
|
+ stock.setSalesCompanyId(whqoh.getOrgId()); // 所属公司ID(组织ID)
|
|
|
+ stock.setSalesCompanyName(whqoh.getOrgName()); // 所属公司名称(组织名称)
|
|
|
+ stock.setBalanceQuantity(whqoh.getStoreQty()); // 结余数量(总)
|
|
|
+ stock.setStoreInventory(whqoh.getStoreQty()); // 商城库存(假设与总库存一致)
|
|
|
+ // 其他需要的字段继续映射...
|
|
|
+ return stock;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ stockPage.setRecords(stockList);
|
|
|
+
|
|
|
// 转换VO并返回
|
|
|
- return R.data(pages);
|
|
|
+ return R.data(stockPage);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 单条查询
|
|
|
+// */
|
|
|
+// @GetMapping("/brand-stock/{id}")
|
|
|
+// @ApiOperation(value = "单条查询", notes = "传入库存ID")
|
|
|
+// @ApiImplicitParam(name = "id", value = "库存ID", required = true, paramType = "path")
|
|
|
+// @ApiOperationSupport(order = 2)
|
|
|
+// public R<PjpfStockDesc> getBrandStock(@PathVariable("id") Long id) {
|
|
|
+// PjpfStockDesc stock = stockService.getById(id);
|
|
|
+// return R.data(stock);
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* 单条查询
|
|
|
*/
|
|
|
@GetMapping("/brand-stock/{id}")
|
|
|
- @ApiOperation(value = "单条查询", notes = "传入库存ID")
|
|
|
- @ApiImplicitParam(name = "id", value = "库存ID", required = true, paramType = "path")
|
|
|
+ @ApiOperation(value = "单条查询", notes = "传入库存对应的商品ID")
|
|
|
+ @ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
public R<PjpfStockDesc> getBrandStock(@PathVariable("id") Long id) {
|
|
|
- PjpfStockDesc stock = stockService.getById(id);
|
|
|
- return R.data(stock);
|
|
|
- }
|
|
|
+ // 1. 根据商品ID查询原始库存视图数据
|
|
|
+ ViewWhqohSel whqoh = whqohSelService.getOne(
|
|
|
+ new LambdaQueryWrapper<ViewWhqohSel>()
|
|
|
+ .eq(ViewWhqohSel::getItemId, id)
|
|
|
+ );
|
|
|
|
|
|
+ if (whqoh == null) {
|
|
|
+ return R.fail("未找到对应的库存信息");
|
|
|
+ }
|
|
|
|
|
|
+ // 2. 手动映射为PjpfStockDesc对象
|
|
|
+ PjpfStockDesc stock = new PjpfStockDesc();
|
|
|
+ stock.setId(whqoh.getItemId()); // 商品ID作为主键
|
|
|
+ stock.setTenantId(whqoh.getOrgId().toString()); // 组织ID作为租户ID
|
|
|
+ stock.setStorageId(whqoh.getWarehouseId()); // 仓库ID
|
|
|
+ stock.setStorageName(whqoh.getWarehouseName()); // 仓库名称
|
|
|
+ stock.setGoodsId(whqoh.getItemId()); // 商品ID
|
|
|
+ stock.setCode(whqoh.getItemCode()); // 物料编号(商品编码)
|
|
|
+ stock.setCname(whqoh.getItemName()); // 商品名称
|
|
|
+ stock.setTypeNo(whqoh.getItemPecs()); // 规格型号
|
|
|
+ stock.setProductDescription(whqoh.getItemDescription()); // 商品描述
|
|
|
+ stock.setSalesCompanyId(whqoh.getOrgId()); // 所属公司ID
|
|
|
+ stock.setSalesCompanyName(whqoh.getOrgName()); // 所属公司名称
|
|
|
+ stock.setBalanceQuantity(whqoh.getStoreQty()); // 结余数量
|
|
|
+ stock.setStoreInventory(whqoh.getStoreQty()); // 商城库存
|
|
|
+
|
|
|
+ // 其他需要的字段继续映射...
|
|
|
|
|
|
+ return R.data(stock);
|
|
|
+ }
|
|
|
|
|
|
/* ========== 工厂端审核 ========== */
|
|
|
|