From 9171db8f5ddd91b4619bf6a928dcbe98b82f33a0 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期三, 09 九月 2026 15:34:14 +0800
Subject: [PATCH] feat:工业泵收款推送 bip收款单与收款确认分离 开票前校验产品是否维护税收分类信息
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 103 insertions(+), 8 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
index 7e8d4a8..db2005c 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ProductServiceImpl.java
@@ -1,17 +1,23 @@
package com.by4cloud.platformx.business.service.impl;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeUtil;
-import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.by4cloud.platformx.admin.api.entity.SysDept;
import com.by4cloud.platformx.business.dto.ProductAddDTO;
import com.by4cloud.platformx.business.dto.ProductQueryDTO;
+import com.by4cloud.platformx.business.dto.SyncProductDTO;
+import com.by4cloud.platformx.business.entity.BusinessCustomer;
import com.by4cloud.platformx.business.entity.Product;
import com.by4cloud.platformx.business.entity.TaxCode;
import com.by4cloud.platformx.business.mapper.ProductMapper;
@@ -22,16 +28,20 @@
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.common.data.datascope.DataScope;
import com.by4cloud.platformx.common.excel.vo.ErrorMessage;
+import com.by4cloud.platformx.common.security.util.SecurityUtils;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;
-
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+
+;
/**
* 浜у搧淇℃伅
@@ -39,11 +49,15 @@
* @author platformx
* @date 2026-05-07 10:17:52
*/
+@Slf4j
@Service
@RequiredArgsConstructor
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
private final TaxCodeMapper taxCodeMapper;
+
+ @Value("${erp.smj}")
+ private String smjErp;
@Override
public List<Tree<Long>> treeList() {
@@ -112,6 +126,15 @@
// .eq(StrUtil.isNotEmpty(queryDTO.getParentId()),Product::getParentId,queryDTO.getParentId())
// .in(StrUtil.isNotEmpty(queryDTO.getContractCategory())&&StrUtil.equals(queryDTO.getContractCategory(), "water_house"),
// Product::getErpCode,erpCodes);
+ if (StrUtil.equals(SecurityUtils.getUser().getCompId()+"","2089995177814495234")||
+ StrUtil.equals(SecurityUtils.getUser().getCompId()+"","2089996921978040321")||
+ StrUtil.equals(SecurityUtils.getUser().getCompId()+"","2089997578009128962")){
+ List<ProductSelectVo> selectVos = baseMapper.getProductSMJListByParentId(queryDTO, Arrays.asList(erpCodes));
+ if (selectVos.size()>2000){
+ return R.ok(selectVos.subList(0,1999));
+ }
+ return R.ok(selectVos);
+ }
List<ProductSelectVo> selectVos = baseMapper.getProductListByParentId(queryDTO, Arrays.asList(erpCodes),DataScope.of("comp_id"));
if (selectVos.size()>2000){
return R.ok(selectVos.subList(0,1999));
@@ -121,14 +144,14 @@
@Override
public R saveErpProduct(List<ProductAddDTO> addDTOS) {
- if (ArrayUtil.isNotEmpty(addDTOS.toArray())){
+ if (CollUtil.isNotEmpty(addDTOS)){
for (ProductAddDTO addDTO:addDTOS
) {
List<Product> classPro = baseMapper.selectListByScope(Wrappers.<Product>lambdaQuery()
.eq(StrUtil.isNotEmpty(addDTO.getErpTypeCode()),Product::getErpCode,addDTO.getErpTypeCode())
.eq(StrUtil.isNotEmpty(addDTO.getErpTypeName()),Product::getProductName,addDTO.getErpTypeName())
, DataScope.of("comp_id"));
- if (ArrayUtil.isEmpty(classPro.toArray())){
+ if (CollUtil.isEmpty(classPro)){
Product product = new Product();
product.setProductName(addDTO.getErpTypeName());
product.setProductType(addDTO.getSpecification());
@@ -163,7 +186,7 @@
@Override
public R importProduct(List<ProductExcelVO> excelVOList, BindingResult bindingResult) {
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
- if (ArrayUtil.isNotEmpty(excelVOList.toArray())) {
+ if (CollUtil.isNotEmpty(excelVOList)) {
List<List<ProductExcelVO>> groups = splitList(excelVOList, 5000);
groups.stream().forEach(group->{
for (ProductExcelVO addDTO:group
@@ -174,7 +197,7 @@
errorMsg.add("浜у搧鍒嗙被淇℃伅娌℃湁");
}
List<Product> one = this.listByScope(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, addDTO.getErpCode()));
- if (ArrayUtil.isNotEmpty(one.toArray())){
+ if (CollUtil.isNotEmpty(one)){
errorMsg.add("浜у搧erp缂栫爜宸插瓨鍦�");
}
if (CollUtil.isEmpty(errorMsg)){
@@ -182,7 +205,7 @@
.eq(StrUtil.isNotEmpty(addDTO.getErpTypeCode()),Product::getErpCode,addDTO.getErpTypeCode())
.eq(StrUtil.isNotEmpty(addDTO.getErpTypeName()),Product::getProductName,addDTO.getErpTypeName())
, DataScope.of("comp_id"));
- if (ArrayUtil.isEmpty(classPro.toArray())){
+ if (CollUtil.isEmpty(classPro)){
Product product = new Product();
product.setProductName(addDTO.getErpTypeName());
product.setProductType(addDTO.getSpecification());
@@ -233,4 +256,76 @@
Math.min((i + 1) * batchSize, totalSize)))
.collect(Collectors.toList());
}
+
+ @Override
+ public R syncSMJByDate(SyncProductDTO dto) {
+ String startDate = "";
+ if (StrUtil.isBlank(dto.getStartDate())){
+ startDate = DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1));
+ }else {
+ startDate = dto.getStartDate();
+ }
+ JSONObject loginJson = new JSONObject();
+ loginJson.put("username", "admin");
+ loginJson.put("password", "Zimafold@2026");
+ log.info("鐭崇叅鏈轰骇鍝佽幏鍙杢oken鍏ュ弬锛歿}", loginJson.toJSONString());
+ String loginResp = HttpUtil.post(smjErp + "/api/account/v1/login", loginJson.toJSONString());
+ log.info("鐭崇叅鏈轰骇鍝佽幏鍙杢oken鍥炲弬锛歿}", loginResp);
+ JSONObject respJson = JSONObject.parseObject(loginResp);
+ if (respJson.getInteger("code") == 0) {
+ JSONObject dataJson = JSONObject.parseObject(respJson.getString("data"));
+ HttpResponse response = HttpRequest.get(smjErp + "/api/item/v1/byDateCre?startDate=" + startDate)
+ .header("token", dataJson.getString("token")) // 娣诲姞璁よ瘉澶�
+ .execute(); // 鎵ц璇锋眰.post(ymjErp,request.toJSONString());
+ log.info("鐭崇叅鏈轰骇鍝佽幏鍙栧洖鍙傦細{}", response.body());
+ JSONObject proResult = JSONObject.parseObject(response.body());
+ JSONArray items = proResult.getJSONArray("data");
+ if (CollUtil.isNotEmpty(items)){
+ log.info("鐭崇叅鏈轰骇鍝佽幏鍙栨暟閲忥細{}", items.size());
+ items.stream().forEach(item->{
+ JSONObject product = (JSONObject) item;
+ Product productClass = baseMapper.selectOne(Wrappers.<Product>lambdaQuery()
+ .eq(Product::getProductName,product.getString("itemClassName"))
+ .and(wrapper -> wrapper.eq(Product::getCompId,"2089995177814495234")
+ .or().eq(Product::getCompId,"2089996921978040321")
+ .or().eq(Product::getCompId,"2089997578009128962")
+ )
+ .last("limit 1")
+ );
+ if(ObjUtil.isNull(productClass)){
+ log.info("浜у搧鍒嗙被锛歿}涓嶅瓨鍦�",product.getString("itemClassName"));
+ productClass = new Product();
+ productClass.setProductName(product.getString("itemClassName"));
+ productClass.setErpCode(product.getString("itemClassName"));
+ productClass.setParentId(0L);
+ productClass.setCompId(2089995177814495234L);
+ baseMapper.insert(productClass);
+ log.info("浜у搧鍒嗙被锛歿}鏂板鎴愬姛",product.getString("itemClassName"));
+ }
+ Product productNew = baseMapper.selectOne(Wrappers.<Product>lambdaQuery()
+ .eq(Product::getErpCode,product.getString("itemNo"))
+ .and(wrapper -> wrapper.eq(Product::getCompId,"2089995177814495234")
+ .or().eq(Product::getCompId,"2089996921978040321")
+ .or().eq(Product::getCompId,"2089997578009128962")
+ )
+ .last("limit 1")
+ );
+ if(ObjUtil.isNull(productNew)){
+ log.info("浜у搧锛歿}涓嶅瓨鍦�",product.getString("itemNo"));
+ productNew = new Product();
+ productNew.setProductName(product.getString("note"));
+ productNew.setErpCode(product.getString("itemNo"));
+ productNew.setProductType(product.getString("grade"));
+ productNew.setCompId(2089995177814495234L);
+ productNew.setParentId(productClass.getId());
+ baseMapper.insert(productNew);
+ log.info("浜у搧锛歿}鏂板鎴愬姛",product.getString("itemNo"));
+ return;
+ }
+ log.info("浜у搧锛歿}瀛樺湪",product.getString("itemNo"));
+ });
+ }
+ }
+ return R.ok();
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1