From cc9dcfec975f6a10121be67eac6d029d159b9460 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期二, 20 十月 2026 14:19:42 +0800
Subject: [PATCH] feat:长期协议,不定期新增单位,标的物 历史导入标的物,根据接口查询 石煤机乙方总公司选总公司 和 分公司 银行流水加 时间拉取 流水数据 产品加拉取按钮 盖章件关闭控制
---
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 202 insertions(+), 0 deletions(-)
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
index 55db786..19e3f92 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
@@ -1,16 +1,218 @@
package com.by4cloud.platformx.business.service.impl;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+
+import cn.hutool.core.util.ObjUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.by4cloud.platformx.business.dto.BusinessCustomerAddDTO;
import com.by4cloud.platformx.business.entity.BusinessCustomer;
+import com.by4cloud.platformx.business.mapper.BipBanklViewMapper;
+import com.by4cloud.platformx.business.mapper.BipViewMapper;
import com.by4cloud.platformx.business.mapper.BusinessCustomerMapper;
import com.by4cloud.platformx.business.service.BusinessCustomerService;
+import com.by4cloud.platformx.business.vo.*;
+import com.by4cloud.platformx.common.core.util.R;
+import com.by4cloud.platformx.common.excel.vo.ErrorMessage;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.validation.BindingResult;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* 瀹㈠晢淇℃伅
*
* @author platformx
* @date 2026-05-07 10:13:22
*/
+@Slf4j
+@RequiredArgsConstructor
@Service
public class BusinessCustomerServiceImpl extends ServiceImpl<BusinessCustomerMapper, BusinessCustomer> implements BusinessCustomerService {
+
+ private final BipViewMapper bipViewMapper;
+ private final BipBanklViewMapper bipBanklViewMapper;
+
+ @Override
+ public R syncMainBusCus(String compId) {
+ List<BusinessCustomer> bcList = baseMapper.selectList(Wrappers.<BusinessCustomer>lambdaQuery()
+ .eq(StrUtil.isNotEmpty(compId),BusinessCustomer::getCompId,compId)
+ .and(wrapper -> wrapper.isNull(BusinessCustomer::getCreditCode)
+ .or().isNull(BusinessCustomer::getLegalPerson)
+ .or().isNull(BusinessCustomer::getBankName)
+ .or().isNull(BusinessCustomer::getBankAccount)
+ .or().isNull(BusinessCustomer::getRegisterName)
+ .or().isNull(BusinessCustomer::getBipCode))
+ );
+ if (CollUtil.isNotEmpty(bcList)){
+ for (BusinessCustomer bc:bcList
+ ) {
+ log.info("寮�濮嬪悓姝}淇℃伅",bc.getCompanyName());
+ CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(bc.getCompanyName());
+ if (ObjUtil.isNull(custInfo)){
+ continue;
+ }
+ if (ObjUtil.isNotNull(custInfo)){
+ bc.setCreditCode(custInfo.getCertificateId());
+ bc.setRegisterName(custInfo.getCustName());
+ bc.setLegalPerson(custInfo.getLegalPerson());
+ bc.setAddress(custInfo.getRegistrationAddress());
+ bc.setBipCode(custInfo.getCustCode());
+ baseMapper.updateById(bc);
+ log.info("{}鍚屾鍚嶇О銆佹硶浜恒�佸湴鍧�銆佷俊鐢ㄧ爜銆乥ipcode淇℃伅鎴愬姛",bc.getCompanyName());
+ }
+ List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(bc.getCompanyName());
+ if (CollUtil.isEmpty(bankVoList)){
+ continue;
+ }
+ if (CollUtil.isNotEmpty(bankVoList)){
+ if (StrUtil.isEmpty(bc.getBankAccount())){
+ bc.setBankAccount(bankVoList.get(0).getBankAccount());
+ baseMapper.updateById(bc);
+ log.info("{}鍚屾閾惰鍗″彿淇℃伅鎴愬姛",bc.getCompanyName());
+ }
+ List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName());
+ if (CollUtil.isNotEmpty(bankNameVoList)){
+ bc.setBankName(bankNameVoList.get(0).getBankNameName());
+ baseMapper.updateById(bc);
+ log.info("{}鍚屾閾惰鍚嶇О淇℃伅鎴愬姛",bc.getCompanyName());
+ }
+ }
+
+ }
+ }
+ return R.ok();
+ }
+
+ @Override
+ public BusinessCustomerMainVo queryMainBC(String companyName) {
+ BusinessCustomerMainVo bc = new BusinessCustomerMainVo();
+ bc.setCompanyName(companyName);
+ log.info("涓绘暟鎹煡璇}淇℃伅",companyName);
+ CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(companyName);
+ if (ObjUtil.isNotNull(custInfo)){
+ bc.setCreditCode(custInfo.getCertificateId());
+ bc.setRegisterName(custInfo.getCustName());
+ bc.setLegalPerson(custInfo.getLegalPerson());
+ bc.setAddress(custInfo.getRegistrationAddress());
+ log.info("{}涓绘暟鎹煡璇㈠悕绉般�佹硶浜恒�佸湴鍧�銆佷俊鐢ㄧ爜淇℃伅鎴愬姛",companyName);
+ }
+ List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(bc.getCompanyName());
+ if (CollUtil.isNotEmpty(bankVoList)){
+ if (StrUtil.isEmpty(bc.getBankAccount())){
+ bc.setBankAccount(bankVoList.get(0).getBankAccount());
+ log.info("{}涓绘暟鎹煡璇㈤摱琛屽崱鍙蜂俊鎭垚鍔�",companyName);
+ }
+ List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName());
+ if (CollUtil.isNotEmpty(bankNameVoList)){
+ bc.setBankName(bankNameVoList.get(0).getBankNameName());
+ log.info("{}涓绘暟鎹煡璇㈤摱琛屽悕绉颁俊鎭垚鍔�",companyName);
+ }
+ }
+ return bc;
+ }
+
+ @Override
+ public R saveCustomerSgb(BusinessCustomerAddDTO addDTO) {
+ if (StrUtil.isBlank(addDTO.getCompanyName())||StrUtil.isBlank(addDTO.getCreditCode())){
+ return R.failed("瀹㈠晢鍚嶇О鎴栫ぞ浼氫俊鐢ㄤ唬鐮佷笉鑳戒负绌�");
+ }
+ BusinessCustomer bc = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery().eq(BusinessCustomer::getCompanyName,addDTO.getCompanyName())
+ .eq(BusinessCustomer::getCreditCode,addDTO.getCreditCode()).last("limit 1"));
+ if (ObjUtil.isNotNull(bc)){
+ return R.failed("瀹㈠晢宸插瓨鍦�");
+ }
+ BusinessCustomer customer = new BusinessCustomer();
+ customer.setErpCompanyCode(addDTO.getErpCompanyCode());
+ log.info("涓绘暟鎹煡璇}淇℃伅",addDTO.getCompanyName());
+ CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(addDTO.getCompanyName());
+ if (ObjUtil.isNotNull(custInfo)){
+ if (!addDTO.getCreditCode().equals(custInfo.getCertificateId())){
+ return R.failed("涓绘暟鎹ぞ浼氫俊鐢ㄤ唬鐮佷笌鏂板鐨勪笉涓�鑷�");
+ }
+ customer.setCompanyName(addDTO.getCompanyName());
+ customer.setCreditCode(custInfo.getCertificateId());
+ customer.setRegisterName(custInfo.getCustName());
+ customer.setLegalPerson(custInfo.getLegalPerson());
+ customer.setAddress(custInfo.getRegistrationAddress());
+ customer.setProvince(customer.getCreditCode().substring(2,4));
+ if (StrUtil.isNotEmpty(addDTO.getSalesModel())&& addDTO.getSalesModel().matches("[0-9]+")){
+ customer.setSalesModel(Long.valueOf(addDTO.getSalesModel()));
+ }
+ if (StrUtil.isNotEmpty(addDTO.getExportServiceAttr())&& addDTO.getExportServiceAttr().matches("[0-9]+")){
+ customer.setExportServiceAttr(Long.valueOf(addDTO.getExportServiceAttr()));
+ }
+ if (StrUtil.isNotEmpty(addDTO.getClassId())&& addDTO.getClassId().matches("[0-9]+")){
+ customer.setClassId(Long.valueOf(addDTO.getClassId()));
+ }
+ customer.setInvoiceType("01");
+ log.info("{}涓绘暟鎹煡璇㈠悕绉般�佹硶浜恒�佸湴鍧�銆佷俊鐢ㄧ爜淇℃伅鎴愬姛",addDTO.getCompanyName());
+ List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(addDTO.getCompanyName());
+ if (CollUtil.isNotEmpty(bankVoList)){
+ customer.setBankAccount(bankVoList.get(0).getBankAccount());
+ log.info("{}涓绘暟鎹煡璇㈤摱琛屽崱鍙蜂俊鎭垚鍔�",addDTO.getCompanyName());
+ List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName());
+ if (CollUtil.isNotEmpty(bankNameVoList)){
+ customer.setBankName(bankNameVoList.get(0).getBankNameName());
+ log.info("{}涓绘暟鎹煡璇㈤摱琛屽悕绉颁俊鎭垚鍔�",addDTO.getCompanyName());
+ }
+ }
+ customer.setRegisterName(custInfo.getCustName());
+ baseMapper.insert(customer);
+ return R.ok();
+ }
+ return R.failed("涓绘暟鎹鍟嗕俊鎭笉瀛樺湪");
+ }
+
+ @Override
+ public R importBusinessCustomer(List<BusinessCustomerImportVo> excelVOList, BindingResult bindingResult) {
+ List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
+ if (CollUtil.isNotEmpty(excelVOList)) {
+ Long line = 0L;
+ for (BusinessCustomerImportVo excelVO : excelVOList
+ ) {
+ Set<String> errorMsg = new HashSet<>();
+ if (StrUtil.isBlank(excelVO.getCreditCode())||StrUtil.isBlank(excelVO.getErpCompanyCode())){
+ errorMsg.add(excelVO.getCompanyName()+"绀句細淇$敤浠g爜鎴朎RP瀹㈡埛缂栫爜涓嶈兘涓虹┖");
+ errorMessageList.add(new ErrorMessage(line++, errorMsg));
+ continue;
+ }
+ BusinessCustomer customer = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery()
+ .eq(BusinessCustomer::getCreditCode, excelVO.getCreditCode())
+ .last("limit 1"));
+ if (ObjUtil.isNull(customer)) {
+ customer = BeanUtil.copyProperties(excelVO, BusinessCustomer.class);
+ CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(excelVO.getCompanyName());
+ if (ObjUtil.isNotNull(custInfo)) {
+ customer.setCreditCode(custInfo.getCertificateId());
+ customer.setRegisterName(custInfo.getCustName());
+ customer.setLegalPerson(custInfo.getLegalPerson());
+ customer.setAddress(custInfo.getRegistrationAddress());
+ customer.setProvince(customer.getCreditCode().substring(2, 4));
+ customer.setInvoiceType("01");
+ log.info("{}涓绘暟鎹煡璇㈠悕绉般�佹硶浜恒�佸湴鍧�銆佷俊鐢ㄧ爜淇℃伅鎴愬姛", excelVO.getCompanyName());
+ List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(excelVO.getCompanyName());
+ if (CollUtil.isNotEmpty(bankVoList)) {
+ customer.setBankAccount(bankVoList.get(0).getBankAccount());
+ log.info("{}涓绘暟鎹煡璇㈤摱琛屽崱鍙蜂俊鎭垚鍔�", excelVO.getCompanyName());
+ List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName());
+ if (CollUtil.isNotEmpty(bankNameVoList)) {
+ customer.setBankName(bankNameVoList.get(0).getBankNameName());
+ log.info("{}涓绘暟鎹煡璇㈤摱琛屽悕绉颁俊鎭垚鍔�", excelVO.getCompanyName());
+ }
+ }
+ customer.setRegisterName(custInfo.getCustName());
+ baseMapper.insert(customer);
+ }
+ }
+ }
+ }
+ return R.ok();
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1