Browse Source

替换成U9的数据

bai 2 months ago
parent
commit
6834d1a725

+ 4 - 0
blade-ops/blade-xxljob-admin/src/main/java/com/xxl/job/admin/JobAdminApplication.java

@@ -3,11 +3,15 @@ package com.xxl.job.admin;
 import org.springblade.common.constant.LauncherConstant;
 import org.springblade.core.launch.BladeApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 /**
  * @author xuxueli 2018-10-28 00:38:13
  */
 @SpringBootApplication
+@EnableFeignClients(basePackages = "com.xxl.job.admin.controller.u9cloud.feign") // 扫描Feign客户端所在包
+@EnableScheduling // 若使用Spring定时任务,保留此注解
 public class JobAdminApplication {
 
 	public static void main(String[] args) {

+ 11 - 11
blade-ops/blade-xxljob-admin/src/main/java/com/xxl/job/admin/controller/u9cloud/feign/U9CloudFeignClient.java

@@ -3,7 +3,7 @@ package com.xxl.job.admin.controller.u9cloud.feign;
 import com.xxl.job.admin.controller.u9cloud.config.FeignConfig;
 import org.springblade.core.tool.api.R;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.GetMapping;
 
 // 基础Feign客户端
 @FeignClient(
@@ -14,42 +14,42 @@ import org.springframework.web.bind.annotation.PostMapping;
 public interface U9CloudFeignClient {
 
 	// 客户数据同步
-	@PostMapping("/api/viewCustomerSel/executionSynchronization")
+	@GetMapping("/api/viewCustomerSel/executionSynchronization")
 	R<Boolean> syncCustomerData();
 
 	// 部门数据同步
-	@PostMapping("/api/viewDepartmentSel/executionSynchronization")
+	@GetMapping("/api/viewDepartmentSel/executionSynchronization")
 	R<Boolean> syncDepartmentData();
 
 	// 料品数据同步
-	@PostMapping("/api/viewItemSel/executionSynchronization")
+	@GetMapping("/api/viewItemSel/executionSynchronization")
 	R<Boolean> syncItemData();
 
 	// 业务员数据同步
-	@PostMapping("/api/viewOperatorsSel/executionSynchronization")
+	@GetMapping("/api/viewOperatorsSel/executionSynchronization")
 	R<Boolean> syncOperatorsData();
 
 	// 标准出货数据同步
-	@PostMapping("/api/viewShipSel/executionSynchronization")
+	@GetMapping("/api/viewShipSel/executionSynchronization")
 	R<Boolean> syncShipData();
 
 	// 供应商数据同步
-	@PostMapping("/api/viewSupplierSel/executionSynchronization")
+	@GetMapping("/api/viewSupplierSel/executionSynchronization")
 	R<Boolean> syncSupplierData();
 
 	// 库存数据同步
-	@PostMapping("/api/viewWhqohSel/executionSynchronization")
+	@GetMapping("/api/viewWhqohSel/executionSynchronization")
 	R<Boolean> syncWhqohData();
 
 	// 应收单数据同步
-	@PostMapping("/api/viewARBillHeadSel/executionSynchronization")
+	@GetMapping("/api/viewARBillHeadSel/executionSynchronization")
 	R<Boolean> syncARBillData();
 
 	// 收款单数据同步
-	@PostMapping("/viewRecBillHeadSel/executionSynchronization")
+	@GetMapping("/viewRecBillHeadSel/executionSynchronization")
 	R<Boolean> syncRecBillData();
 
 	// 销售价目表数据同步
-	@PostMapping("/api/viewSalepriceSel/executionSynchronization")
+	@GetMapping("/api/viewSalepriceSel/executionSynchronization")
 	R<Boolean> syncSalepriceData();
 }

+ 0 - 204
blade-ops/blade-xxljob-admin/src/main/java/com/xxl/job/admin/controller/u9cloud/feign/U9CloudSyncController.java

@@ -1,204 +0,0 @@
-package com.xxl.job.admin.controller.u9cloud.feign;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springblade.core.tool.api.R;
-import org.springblade.u9cloud.service.*;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@Slf4j
-@RestController
-@AllArgsConstructor
-@RequestMapping("/api")
-@Api(value = "U9数据同步", tags = "U9数据同步接口")
-public class U9CloudSyncController {
-//
-//	private final ZcrmViewCustomerSelService zcrmViewCustomerSelService;
-//	private final ZcrmViewDepartmentSelService zcrmViewDepartmentSelService;
-//	private final ZcrmViewItemSelService zcrmViewItemSelService;
-//	private final ZcrmViewOperatorsSelService zcrmViewOperatorsSelService;
-//	private final ZcrmViewShipSelService zcrmViewShipSelService;
-//	private final ZcrmViewSupplierSelService zcrmViewSupplierSelService;
-//	private final ZcrmViewWhqohSelService zcrmViewWhqohSelService;
-//	private final ZcrmViewSalePriceSelService zcrmViewSalePriceSelService;
-//	private final ZcrmViewRecBillHeadSelService zcrmViewRecBillHeadSelService;
-//	private final ZcrmViewARBillHeadSelService zcrmViewARBillHeadSelService;
-//
-//	@PostMapping("/viewCustomerSel/executionSynchronization")
-//	@ApiOperation("同步客户数据")
-//	public R<Boolean> syncCustomerData() {
-//		try {
-//			log.info("开始同步U9客户数据");
-//			boolean success = zcrmViewCustomerSelService.insertBatchCustomers();
-//			log.info("U9客户数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步客户数据失败", e);
-//			return R.fail("同步客户数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewDepartmentSel/executionSynchronization")
-//	@ApiOperation("同步部门数据")
-//	public R<Boolean> syncDepartmentData() {
-//		try {
-//			log.info("开始同步U9部门数据");
-//			boolean success = zcrmViewDepartmentSelService.insertBatchDepartments();
-//			log.info("U9部门数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步部门数据失败", e);
-//			return R.fail("同步部门数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewItemSel/executionSynchronization")
-//	@ApiOperation("同步物料数据")
-//	public R<Boolean> syncItemData() {
-//		try {
-//			log.info("开始同步U9物料数据");
-//			boolean success = zcrmViewItemSelService.insertBatchItems();
-//			log.info("U9物料数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步物料数据失败", e);
-//			return R.fail("同步物料数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewOperatorsSel/executionSynchronization")
-//	@ApiOperation("同步操作员数据")
-//	public R<Boolean> syncOperatorsData() {
-//		try {
-//			log.info("开始同步U9操作员数据");
-//			boolean success = zcrmViewOperatorsSelService.insertBatchOperators();
-//			log.info("U9操作员数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步操作员数据失败", e);
-//			return R.fail("同步操作员数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewShipSel/executionSynchronization")
-//	@ApiOperation("同步物流数据")
-//	public R<Boolean> syncShipData() {
-//		try {
-//			log.info("开始同步U9物流数据");
-//			boolean success = zcrmViewShipSelService.insertBatchShips();
-//			log.info("U9物流数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步物流数据失败", e);
-//			return R.fail("同步物流数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewSupplierSel/executionSynchronization")
-//	@ApiOperation("同步供应商数据")
-//	public R<Boolean> syncSupplierData() {
-//		try {
-//			log.info("开始同步U9供应商数据");
-//			boolean success = zcrmViewSupplierSelService.insertBatchSuppliers();
-//			log.info("U9供应商数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步供应商数据失败", e);
-//			return R.fail("同步供应商数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewWhqohSel/executionSynchronization")
-//	@ApiOperation("同步库存数据")
-//	public R<Boolean> syncWhqohData() {
-//		try {
-//			log.info("开始同步U9库存数据");
-//			boolean success = zcrmViewWhqohSelService.insertBatchWhqohs();
-//			log.info("U9库存数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步库存数据失败", e);
-//			return R.fail("同步库存数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewARBillHeadSel/executionSynchronization")
-//	@ApiOperation("同步应收单数据")
-//	public R<Boolean> syncARBillData() {
-//		try {
-//			log.info("开始同步U9应收单数据");
-//			boolean success = zcrmViewARBillHeadSelService.insertBatchCustomers();
-//			log.info("U9应收单数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步应收单数据失败", e);
-//			return R.fail("同步应收单数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewRecBillHeadSel/executionSynchronization")
-//	@ApiOperation("同步收款单数据")
-//	public R<Boolean> syncRecBillData() {
-//		try {
-//			log.info("开始同步U9收款单数据");
-//			boolean success = zcrmViewRecBillHeadSelService.insertBatchOperators();
-//			log.info("U9收款单数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步收款单数据失败", e);
-//			return R.fail("同步收款单数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/viewSalepriceSel/executionSynchronization")
-//	@ApiOperation("同步销售价目表数据")
-//	public R<Boolean> syncSalepriceData() {
-//		try {
-//			log.info("开始同步U9销售价目表数据");
-//			boolean success = zcrmViewSalePriceSelService.insertBatchOperators();
-//			log.info("U9销售价目表数据同步{}", success ? "成功" : "失败");
-//			return R.data(success, success ? "同步成功" : "同步失败");
-//		} catch (Exception e) {
-//			log.error("同步销售价目表数据失败", e);
-//			return R.fail("同步销售价目表数据失败:" + e.getMessage());
-//		}
-//	}
-//
-//	@PostMapping("/syncAllData")
-//	@ApiOperation("同步所有U9数据")
-//	public R<Boolean> syncAllData() {
-//		try {
-//			log.info("开始同步所有U9数据");
-//
-//			// 按依赖顺序执行同步
-//			boolean deptSuccess = zcrmViewDepartmentSelService.insertBatchDepartments();
-//			if (!deptSuccess) {
-//				return R.fail("部门数据同步失败,终止后续同步");
-//			}
-//
-//			boolean customerSuccess = zcrmViewCustomerSelService.insertBatchCustomers();
-//			boolean itemSuccess = zcrmViewItemSelService.insertBatchItems();
-//			boolean operatorSuccess = zcrmViewOperatorsSelService.insertBatchOperators();
-//			boolean supplierSuccess = zcrmViewSupplierSelService.insertBatchSuppliers();
-//			boolean shipSuccess = zcrmViewShipSelService.insertBatchShips();
-//			boolean whqohSuccess = zcrmViewWhqohSelService.insertBatchWhqohs();
-//			boolean arBillSuccess = zcrmViewARBillHeadSelService.insertBatchCustomers();
-//			boolean recBillSuccess = zcrmViewRecBillHeadSelService.insertBatchOperators();
-//			boolean salepriceSuccess = zcrmViewSalePriceSelService.insertBatchOperators();
-//
-//			boolean allSuccess = customerSuccess && itemSuccess && operatorSuccess &&
-//				supplierSuccess && shipSuccess && whqohSuccess &&
-//				arBillSuccess && recBillSuccess && salepriceSuccess;
-//
-//			log.info("所有U9数据同步{}", allSuccess ? "成功" : "部分失败");
-//			return R.data(allSuccess, allSuccess ? "所有数据同步成功" : "部分数据同步失败");
-//		} catch (Exception e) {
-//			log.error("同步所有U9数据失败", e);
-//			return R.fail("同步所有U9数据失败:" + e.getMessage());
-//		}
-//	}
-}

+ 1 - 0
blade-ops/blade-xxljob-admin/src/main/java/com/xxl/job/admin/controller/u9cloud/feign/U9CloudTaskJob.java

@@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springblade.core.tool.api.R;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 

+ 14 - 0
blade-service-api/blade-factory-api/src/main/java/org/springblade/factory/entity/ViewCustomerSel.java

@@ -226,5 +226,19 @@ public class ViewCustomerSel extends BaseEntity {
 	@JsonProperty("ARConfirmTerm_NAME")
 	@TableField("ARConfirmTerm_NAME")
 	private String arConfirmTermName;
+
+
+	@JsonProperty("PubDescSeg4_Code")
+	@TableField("PubDescSeg4_Code")
+	private String pubDescSeg4Code;
+
+	@JsonProperty("PubDescSeg4_Name")
+	@TableField("PubDescSeg4_Name")
+	private String pubDescSeg4Name;
+
+
+
+
+
 }
 

+ 27 - 0
blade-service-api/blade-factory-api/src/main/java/org/springblade/factory/entity/ViewItemSel.java

@@ -136,5 +136,32 @@ public class ViewItemSel extends BaseEntity {
 	@JsonProperty("Item_Price")
 	@TableField("Item_Price")
 	private BigDecimal itemPrice;
+
+
+	// 在 ViewItemSel 实体类中修改这两个字段:
+	@JsonProperty("PubDescSeg4_Code")
+	@TableField(value = "PubDescSeg4_Code") // 添加 exist = false
+	private String pubDescSeg4Code;
+
+	@JsonProperty("PubDescSeg4_Name")
+	@TableField(value = "PubDescSeg4_Name") // 添加 exist = false
+	private String pubDescSeg4Name;
+
+	// 在ViewItemSel中找到以下字段,添加@TableField(exist = false)
+	@JsonProperty("volume")
+	@TableField(value = "volume") // 标记为非数据库字段
+	private String volume;
+
+	@JsonProperty("pattern")
+	@TableField(value = "pattern") // 标记为非数据库字段
+	private String pattern;
+
+	@JsonProperty("layer")
+	@TableField(value = "layer") // 标记为非数据库字段
+	private String layer;
+
+	@JsonProperty("speed")
+	@TableField(value = "speed") // 标记为非数据库字段
+	private String speed;
 }
 

+ 99 - 78
blade-service-api/blade-factory-api/src/main/java/org/springblade/factory/entity/ViewShipSel.java

@@ -15,108 +15,129 @@ public class ViewShipSel extends BaseEntity {
 
 	private static final long serialVersionUID = 1L;
 
-	@JsonProperty("Org_ID")
-	@TableField("Org_ID")
-	private Long orgId;
 
-	@JsonProperty("Org_Code")
-	@TableField("Org_Code")
-	private String orgCode;
+	@Data
+	@TableName("zcrm_view_ship_sel")
+	public class ZcrmViewShipSel extends BaseEntity {
 
-	@JsonProperty("Org_Name")
-	@TableField("Org_Name")
-	private String orgName;
+		private static final long serialVersionUID = 1L;
 
-	@JsonProperty("DocType_ID")
-	@TableField("DocType_ID")
-	private Long docTypeId;
+		@JsonProperty("Org_ID")
+		@TableField("Org_ID")
+		private Long orgId;
 
-	@JsonProperty("DocType_Code")
-	@TableField("DocType_Code")
-	private String docTypeCode;
+		@JsonProperty("Org_Code")
+		@TableField("Org_Code")
+		private String orgCode;
 
-	@JsonProperty("DocType_Name")
-	@TableField("DocType_Name")
-	private String docTypeName;
+		@JsonProperty("Org_Name")
+		@TableField("Org_Name")
+		private String orgName;
 
-	@JsonProperty("DocNo")
-	@TableField("DocNo")
-	private String docNo;
+		@JsonProperty("DocType_ID")
+		@TableField("DocType_ID")
+		private Long docTypeId;
 
-	@JsonProperty("BusinessDate")
-	@TableField("BusinessDate")
-	private LocalDateTime businessDate;
+		@JsonProperty("DocType_Code")
+		@TableField("DocType_Code")
+		private String docTypeCode;
 
-	@JsonProperty("Status")
-	@TableField("Status")
-	private Integer status;
+		@JsonProperty("DocType_Name")
+		@TableField("DocType_Name")
+		private String docTypeName;
 
-	@JsonProperty("Customer_ID")
-	@TableField("Customer_ID")
-	private Long customerId;
+		@JsonProperty("DocNo")
+		@TableField("DocNo")
+		private String docNo;
 
-	@JsonProperty("Customer_Code")
-	@TableField("Customer_Code")
-	private String customerCode;
+		@JsonProperty("BusinessDate")
+		@TableField("BusinessDate")
+		private LocalDateTime businessDate;
 
-	@JsonProperty("Customer_Name")
-	@TableField("Customer_Name")
-	private String customerName;
+		@JsonProperty("Status")
+		@TableField("Status")
+		private Integer status;
 
-	@JsonProperty("Item_ID")
-	@TableField("Item_ID")
-	private Long itemId;
+		@JsonProperty("Customer_ID")
+		@TableField("Customer_ID")
+		private Long customerId;
 
-	@JsonProperty("Item_Code")
-	@TableField("Item_Code")
-	private String itemCode;
+		@JsonProperty("Customer_Code")
+		@TableField("Customer_Code")
+		private String customerCode;
 
-	@JsonProperty("Item_Name")
-	@TableField("Item_Name")
-	private String itemName;
+		@JsonProperty("Customer_Name")
+		@TableField("Customer_Name")
+		private String customerName;
 
-	@JsonProperty("SPECS")
-	@TableField("SPECS")
-	private String specs;
+		@JsonProperty("Item_ID")
+		@TableField("Item_ID")
+		private Long itemId;
 
-	@JsonProperty("Qty")
-	@TableField("Qty")
-	private BigDecimal qty;
+		@JsonProperty("Item_Code")
+		@TableField("Item_Code")
+		private String itemCode;
 
-	@JsonProperty("OrderPrice")
-	@TableField("OrderPrice")
-	private BigDecimal orderPrice;
+		@JsonProperty("Item_Name")
+		@TableField("Item_Name")
+		private String itemName;
 
-	@JsonProperty("FinallyPrice")
-	@TableField("FinallyPrice")
-	private BigDecimal finallyPrice;
+		@JsonProperty("SPECS")
+		@TableField("SPECS")
+		private String specs;
 
-	@JsonProperty("TotalMoneyTC")
-	@TableField("TotalMoneyTC")
-	private BigDecimal totalMoneyTc;
+		@JsonProperty("Qty")
+		@TableField("Qty")
+		private BigDecimal qty;
 
-	@JsonProperty("TotalNetMoneyTC")
-	@TableField("TotalNetMoneyTC")
-	private BigDecimal totalNetMoneyTc;
+		@JsonProperty("OrderPrice")
+		@TableField("OrderPrice")
+		private BigDecimal orderPrice;
 
-	@JsonProperty("TotalTaxTC")
-	@TableField("TotalTaxTC")
-	private BigDecimal totalTaxTc;
+		@JsonProperty("FinallyPrice")
+		@TableField("FinallyPrice")
+		private BigDecimal finallyPrice;
 
-	@JsonProperty("WH_ID")
-	@TableField("WH_ID")
-	private Long whId;
+		@JsonProperty("TotalMoneyTC")
+		@TableField("TotalMoneyTC")
+		private BigDecimal totalMoneyTc;
 
-	@JsonProperty("WH_Code")
-	@TableField("WH_Code")
-	private String whCode;
+		@JsonProperty("TotalNetMoneyTC")
+		@TableField("TotalNetMoneyTC")
+		private BigDecimal totalNetMoneyTc;
 
-	@JsonProperty("WH_Name")
-	@TableField("WH_Name")
-	private String whName;
+		@JsonProperty("TotalTaxTC")
+		@TableField("TotalTaxTC")
+		private BigDecimal totalTaxTc;
 
-	@JsonProperty("LineStatus")
-	@TableField("LineStatus")
-	private Integer lineStatus;
+		@JsonProperty("WH_ID")
+		@TableField("WH_ID")
+		private Long whId;
+
+		@JsonProperty("WH_Code")
+		@TableField("WH_Code")
+		private String whCode;
+
+		@JsonProperty("WH_Name")
+		@TableField("WH_Name")
+		private String whName;
+
+		@JsonProperty("LineStatus")
+		@TableField("LineStatus")
+		private Integer lineStatus;
+
+		@JsonProperty("SoDocNo")
+		@TableField("SoDocNo")
+		private String soDocNo;
+
+		@JsonProperty("SoDocLineNo")
+		@TableField("SoDocLineNo")
+		private Integer soDocLineNo;
+
+		@JsonProperty("ShipAddress")
+		@TableField("ShipAddress")
+		private String shipAddress;
+
+	}
 }
 

+ 0 - 2
blade-service-api/blade-u9cloud-api/src/main/java/org/springblade/u9cloud/entity/ZcrmViewShipSel.java

@@ -131,6 +131,4 @@ public class ZcrmViewShipSel extends BaseEntity {
 	@TableField("ShipAddress")
 	private String shipAddress;
 
-
-
 }

+ 185 - 16
blade-service/blade-factory/src/main/java/org/springblade/factory/api/controller/SalesForecastSummaryController.java

@@ -1,8 +1,10 @@
 package org.springblade.factory.api.controller;
 
 
+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;
@@ -35,6 +37,7 @@ import java.security.Principal;
 import java.time.LocalDate;
 import java.time.format.DateTimeParseException;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 销售预测接口 控制器
@@ -55,6 +58,10 @@ public class SalesForecastSummaryController {
 
 	private final PcBladeSalesForecastMainService salesForecastMainService;
 
+	private final ZcrmViewItemSelService itemSelService;
+
+	private final ZcrmViewWhqohSelService whqohSelService;
+
 	@Autowired
 	private IUserClient userClient;
 
@@ -760,6 +767,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);
+//	}
+
+
+
+
 	/**
 	 * 品牌列表
 	 */
@@ -770,14 +798,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);
+//	}
+
 	/**
 	 * 单条查询
 	 */
@@ -786,15 +845,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);
+//	}
+
+
+
 	/**
 	 * 库存列表
 	 */
@@ -805,28 +903,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);
+	}
 
 	/* ========== 工厂端审核 ========== */
 

+ 152 - 68
blade-service/blade-factory/src/main/java/org/springblade/factory/api/controller/SalesOrderController.java

@@ -26,6 +26,7 @@ import org.springblade.system.user.feign.IUserClient;
 import org.springblade.u9cloud.entity.ZcrmU9cWebapiSo;
 import org.springblade.u9cloud.entity.ZcrmU9cWebapiSoApprove;
 import org.springblade.u9cloud.entity.ZcrmU9cWebapiSoSubmit;
+import org.springblade.u9cloud.entity.ZcrmViewCustomerSel;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -71,6 +72,10 @@ public class SalesOrderController {
 	private final PjpfStockDescService stockService;
 
 	private final PjpfBrandDescService brandService;
+	@Autowired
+	private ZcrmViewItemSelService zcrmViewItemSelService;
+	@Autowired
+	private ZcrmViewWhqohSelService zcrmViewWhqohSelService;
 
 
 	/**
@@ -748,82 +753,165 @@ public class SalesOrderController {
 
 
 	// TODO 修改这个接口---考虑关联关系和映射方式
-	// 用户关联品牌和商品业务接口
+//	// 用户关联品牌和商品业务接口
+//	@GetMapping("/getUserLinkGoods")
+//	@ApiOperation(value = "用户关联品牌和商品业务接口", notes = "获取当前用户关联的品牌和商品信息")
+//	public R<?> getUserLinkGoods() {
+//		// 获取当前登录用户ID
+//		Long userId = AuthUtil.getUserId();
+//		System.err.println();
+//		if (userId == null) {
+//			return R.fail("未获取到登录用户信息,请先登录");
+//		}
+//
+//		//修改---重要修复   userID需要修改成CUSTOMER_ID传参
+//		R<User> user = userClient.userInfoById(userId);
+//		Long customer_id = new Long("0");
+//		if (user.getData() == null && user.getData().getCustomerId() == null) {
+//			return R.fail("用户不存在");
+//		} else {
+//			customer_id = user.getData().getCustomerId();
+//		}
+//
+//		// 构建查询条件
+//		QueryWrapper<PcBladeUserLinkGoods> queryWrapper = new QueryWrapper<>();
+//		queryWrapper.eq("CUSTOMER_ID", customer_id)
+//			.eq("is_deleted", 0);  // 先只过滤已删除状态
+//
+//		// 增加调试信息:显示当前用户ID和查询条件
+//		Map<String, Object> debugInfo = new HashMap<>();
+//		debugInfo.put("currentUserId", userId);
+//		debugInfo.put("queryCondition", queryWrapper.getEntity());
+//
+//		// 查询所有状态的关联记录(用于调试)
+//		List<PcBladeUserLinkGoods> allStatusList = pcBladeUserLinkGoodsService.list(queryWrapper);
+//		debugInfo.put("totalRecords", allStatusList.size());
+//		debugInfo.put("statusDistribution", allStatusList.stream()
+//			.collect(Collectors.groupingBy(PcBladeUserLinkGoods::getStatus, Collectors.counting())));
+//
+//		// 应用状态过滤
+//		queryWrapper.eq("status", 1);  // 只查询状态为1的记录
+//		List<PcBladeUserLinkGoods> userLinkGoodsList = pcBladeUserLinkGoodsService.list(queryWrapper);
+//
+//		if (CollectionUtils.isEmpty(userLinkGoodsList)) {
+//			// 返回调试信息帮助排查问题
+//			Map<String, Object> result = new HashMap<>();
+//			result.put("debug", debugInfo);
+//			return R.data(result, "未查询到关联的品牌和商品数据");
+//		}
+//
+//		// 收集需要查询的ID,使用Set去重
+//		Set<Long> stockIds = new HashSet<>();
+//		Set<Long> brandIds = new HashSet<>();
+//
+//		for (PcBladeUserLinkGoods linkGoods : userLinkGoodsList) {
+//			System.err.println(linkGoods);
+//			if (linkGoods.getStockDescId() != null) {
+//				stockIds.add(linkGoods.getStockDescId());
+//			}
+//			if (linkGoods.getBrandId() != null) {
+//				brandIds.add(linkGoods.getBrandId());
+//			}
+//		}
+//
+//		// 批量查询库存信息
+//		List<PjpfStockDesc> stockList = stockIds.isEmpty() ?
+//			Collections.emptyList() :
+//			stockService.listByIds(stockIds);
+//
+//		// 批量查询品牌信息
+//		List<PjpfBrandDesc> brandList = brandIds.isEmpty() ?
+//			Collections.emptyList() :
+//			brandService.listByIds(brandIds);
+//
+//		// 组装返回结果
+//		Map<String, Object> resultMap = new HashMap<>();
+//		resultMap.put("pjpfStockDescList", stockList);
+//		resultMap.put("pjpfBrandDescList", brandList);
+////		resultMap.put("debug", debugInfo);  // 包含调试信息
+//
+//		return R.data(resultMap, "获取成功");
+//	}
+
+
+
+	/**
+	 * 用户关联品牌和商品业务接口
+	 */
 	@GetMapping("/getUserLinkGoods")
 	@ApiOperation(value = "用户关联品牌和商品业务接口", notes = "获取当前用户关联的品牌和商品信息")
 	public R<?> getUserLinkGoods() {
 		// 获取当前登录用户ID
-		Long userId = AuthUtil.getUserId();
-		System.err.println();
-		if (userId == null) {
+		String userAccount = AuthUtil.getUserAccount();
+		if (userAccount == null) {
 			return R.fail("未获取到登录用户信息,请先登录");
 		}
 
-		//修改---重要修复   userID需要修改成CUSTOMER_ID传参
-		R<User> user = userClient.userInfoById(userId);
-		Long customer_id = new Long("0");
-		if (user.getData() == null && user.getData().getCustomerId() == null) {
-			return R.fail("用户不存在");
-		} else {
-			customer_id = user.getData().getCustomerId();
-		}
-
-		// 构建查询条件
-		QueryWrapper<PcBladeUserLinkGoods> queryWrapper = new QueryWrapper<>();
-		queryWrapper.eq("CUSTOMER_ID", customer_id)
-			.eq("is_deleted", 0);  // 先只过滤已删除状态
-
-		// 增加调试信息:显示当前用户ID和查询条件
-		Map<String, Object> debugInfo = new HashMap<>();
-		debugInfo.put("currentUserId", userId);
-		debugInfo.put("queryCondition", queryWrapper.getEntity());
-
-		// 查询所有状态的关联记录(用于调试)
-		List<PcBladeUserLinkGoods> allStatusList = pcBladeUserLinkGoodsService.list(queryWrapper);
-		debugInfo.put("totalRecords", allStatusList.size());
-		debugInfo.put("statusDistribution", allStatusList.stream()
-			.collect(Collectors.groupingBy(PcBladeUserLinkGoods::getStatus, Collectors.counting())));
-
-		// 应用状态过滤
-		queryWrapper.eq("status", 1);  // 只查询状态为1的记录
-		List<PcBladeUserLinkGoods> userLinkGoodsList = pcBladeUserLinkGoodsService.list(queryWrapper);
-
-		if (CollectionUtils.isEmpty(userLinkGoodsList)) {
-			// 返回调试信息帮助排查问题
-			Map<String, Object> result = new HashMap<>();
-			result.put("debug", debugInfo);
-			return R.data(result, "未查询到关联的品牌和商品数据");
-		}
-
-		// 收集需要查询的ID,使用Set去重
-		Set<Long> stockIds = new HashSet<>();
-		Set<Long> brandIds = new HashSet<>();
-
-		for (PcBladeUserLinkGoods linkGoods : userLinkGoodsList) {
-			System.err.println(linkGoods);
-			if (linkGoods.getStockDescId() != null) {
-				stockIds.add(linkGoods.getStockDescId());
-			}
-			if (linkGoods.getBrandId() != null) {
-				brandIds.add(linkGoods.getBrandId());
-			}
-		}
-
-		// 批量查询库存信息
-		List<PjpfStockDesc> stockList = stockIds.isEmpty() ?
-			Collections.emptyList() :
-			stockService.listByIds(stockIds);
-
-		// 批量查询品牌信息
-		List<PjpfBrandDesc> brandList = brandIds.isEmpty() ?
-			Collections.emptyList() :
-			brandService.listByIds(brandIds);
+		QueryWrapper<ViewCustomerSel> queryWrapper = new QueryWrapper<>();
+		queryWrapper.eq("Customer_CODE", userAccount);
+		ViewCustomerSel viewCustomerSel = zcrmViewCustomerSelService.getOne(queryWrapper);
+		if (viewCustomerSel == null) {
+			return R.fail("未查询到用户关联信息");
+		}
+		System.err.println(viewCustomerSel);
+		String pubDescSeg4Name = viewCustomerSel.getPubDescSeg4Name();
+		System.err.println(pubDescSeg4Name);
+		// 按逗号分割成数组(处理null或空字符串)
+		String[] codeArray = pubDescSeg4Name != null && !pubDescSeg4Name.isEmpty()
+			? pubDescSeg4Name.split(",")
+			: new String[0];
+
+		// 查询料品档案并映射为品牌列表
+		QueryWrapper<ViewItemSel> itemQuery = new QueryWrapper<>();
+		itemQuery.in(codeArray.length > 0, "Item_Name", codeArray);
+		List<ViewItemSel> viewItemSelList = zcrmViewItemSelService.list(itemQuery);
+		System.err.println("料品档案查询结果数量:" + viewItemSelList.size());
+		if (viewItemSelList.isEmpty()) {
+			System.err.println("料品档案无匹配数据,查询条件:" + Arrays.toString(codeArray));
+		}
+		List<PjpfBrandDesc> brandList = viewItemSelList.stream().map(item -> {
+			PjpfBrandDesc brand = new PjpfBrandDesc();
+			brand.setId(item.getItemId());
+			brand.setTenantId(String.valueOf(item.getOrgId()));
+			brand.setCname(item.getItemName());
+			brand.setSalesCompanyId(item.getOrgId());
+			brand.setSalesCompanyName(item.getOrgName());
+			brand.setType(item.getMainItemCategoryCode());
+			// 可根据实际业务补充其他字段(如启用状态默认0启用)
+			brand.setEnableOrNot(0);
+			return brand;
+		}).collect(Collectors.toList());
+
+		// 查询库存视图并映射为库存列表
+		QueryWrapper<ViewWhqohSel> stockQuery = new QueryWrapper<>();
+		stockQuery.in(codeArray.length > 0, "Item_Name", codeArray);
+		List<ViewWhqohSel> viewWhqohSelList = zcrmViewWhqohSelService.list(stockQuery);
+		System.err.println("库存视图查询结果数量:" + viewWhqohSelList.size());
+		if (viewWhqohSelList.isEmpty()) {
+			System.err.println("库存视图无匹配数据,查询条件:" + Arrays.toString(codeArray));
+		}
+		List<PjpfStockDesc> stockList = viewWhqohSelList.stream().map(whqoh -> {
+			PjpfStockDesc stock = new PjpfStockDesc();
+			stock.setId(whqoh.getItemId());
+			stock.setTenantId(String.valueOf(whqoh.getOrgId()));
+			stock.setStorageId(whqoh.getWarehouseId());
+			stock.setStorageName(whqoh.getWarehouseName());
+			stock.setGoodsId(whqoh.getItemId());
+			stock.setCode(whqoh.getItemCode());
+			stock.setCname(whqoh.getItemName());
+			stock.setTypeNo(whqoh.getItemPecs());
+			stock.setProductDescription(whqoh.getItemDescription());
+			stock.setSalesCompanyId(whqoh.getOrgId());
+			stock.setSalesCompanyName(whqoh.getOrgName());
+			stock.setBalanceQuantity(whqoh.getStoreQty());
+			stock.setStoreInventory(whqoh.getStoreQty());
+			return stock;
+		}).collect(Collectors.toList());
 
 		// 组装返回结果
 		Map<String, Object> resultMap = new HashMap<>();
 		resultMap.put("pjpfStockDescList", stockList);
 		resultMap.put("pjpfBrandDescList", brandList);
-//		resultMap.put("debug", debugInfo);  // 包含调试信息
 
 		return R.data(resultMap, "获取成功");
 	}
@@ -831,8 +919,4 @@ public class SalesOrderController {
 
 
 
-
-
-
-
 }