Commit 94a20d0add5efd0e52b662e11c7af04b50ca1af8

Authored by zhangmeiyang
1 parent 14200344

金蝶多对一费用项优化,应收单单据创建优化

Showing 18 changed files with 415 additions and 144 deletions
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractBasicHandler.java
@@ -11,6 +11,7 @@ import com.diligrp.etrade.thirdparty.mapper.TransMapper; @@ -11,6 +11,7 @@ import com.diligrp.etrade.thirdparty.mapper.TransMapper;
11 import com.diligrp.etrade.thirdparty.type.BasicEnum; 11 import com.diligrp.etrade.thirdparty.type.BasicEnum;
12 import com.kingdee.bos.webapi.entity.IdentifyInfo; 12 import com.kingdee.bos.webapi.entity.IdentifyInfo;
13 import jakarta.annotation.Resource; 13 import jakarta.annotation.Resource;
  14 +import org.springframework.transaction.annotation.Transactional;
14 import org.springframework.util.ObjectUtils; 15 import org.springframework.util.ObjectUtils;
15 16
16 import java.util.Arrays; 17 import java.util.Arrays;
@@ -53,6 +54,16 @@ public abstract class AbstractBasicHandler<T extends BaseSourceCo> implements Ty @@ -53,6 +54,16 @@ public abstract class AbstractBasicHandler<T extends BaseSourceCo> implements Ty
53 recordMapper.recordTheMappingData(mapping); 54 recordMapper.recordTheMappingData(mapping);
54 } 55 }
55 56
  57 + @Transactional
  58 + protected void deleteMapping(Long marketId, String systemCode, Long systemDataId){
  59 + var mapping = new MappingDto();
  60 + mapping.setMarketId(marketId);
  61 + mapping.setBusiness(getType().code);
  62 + mapping.setSystemCode(systemCode);
  63 + mapping.setSystemDataId(systemDataId);
  64 + recordMapper.deleteTheMappingData(mapping);
  65 + }
  66 +
56 /** 67 /**
57 * 获取身份信息 68 * 获取身份信息
58 * 69 *
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractBillHandler.java
1 package com.diligrp.etrade.thirdparty.demarcate; 1 package com.diligrp.etrade.thirdparty.demarcate;
2 2
3 -import com.diligrp.etrade.core.util.JsonUtils;  
4 import com.diligrp.etrade.thirdparty.component.TransferComponent; 3 import com.diligrp.etrade.thirdparty.component.TransferComponent;
5 import com.diligrp.etrade.thirdparty.domain.co.business.BaseBillCo; 4 import com.diligrp.etrade.thirdparty.domain.co.business.BaseBillCo;
6 import com.diligrp.etrade.thirdparty.domain.dto.BusinessDetailDto; 5 import com.diligrp.etrade.thirdparty.domain.dto.BusinessDetailDto;
7 import com.diligrp.etrade.thirdparty.domain.dto.BusinessDto; 6 import com.diligrp.etrade.thirdparty.domain.dto.BusinessDto;
8 import com.diligrp.etrade.thirdparty.domain.dto.ClientDto; 7 import com.diligrp.etrade.thirdparty.domain.dto.ClientDto;
9 -import com.diligrp.etrade.thirdparty.domain.model.FEntityDetail;  
10 import com.diligrp.etrade.thirdparty.error.ThirdPartyException; 8 import com.diligrp.etrade.thirdparty.error.ThirdPartyException;
11 import com.diligrp.etrade.thirdparty.mapper.TransMapper; 9 import com.diligrp.etrade.thirdparty.mapper.TransMapper;
12 import com.diligrp.etrade.thirdparty.type.*; 10 import com.diligrp.etrade.thirdparty.type.*;
13 -import com.diligrp.etrade.thirdparty.utils.PurchaseOrderApiUtils;  
14 import com.kingdee.bos.webapi.entity.IdentifyInfo; 11 import com.kingdee.bos.webapi.entity.IdentifyInfo;
15 import jakarta.annotation.Resource; 12 import jakarta.annotation.Resource;
16 import org.springframework.util.ObjectUtils; 13 import org.springframework.util.ObjectUtils;
17 14
18 -import java.math.BigDecimal;  
19 import java.util.ArrayList; 15 import java.util.ArrayList;
20 import java.util.HashMap; 16 import java.util.HashMap;
21 import java.util.List; 17 import java.util.List;
@@ -53,6 +49,55 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM @@ -53,6 +49,55 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM
53 } 49 }
54 50
55 /** 51 /**
  52 + * 处理
  53 + *
  54 + * @param json JSON 格式
  55 + * @param marketId 市场 ID
  56 + * @param systemCode 系统代码
  57 + * @throws Exception 例外
  58 + */
  59 + public abstract void handle(String json, Long marketId, String systemCode) throws Exception;
  60 +
  61 + /**
  62 + * 获取动态数据
  63 + *
  64 + * @param marketId 市场 ID
  65 + * @param systemCode 系统代码
  66 + * @param dynamicType 动态型
  67 + * @return {@link Map}<{@link String}, {@link BusinessDetailDto}>
  68 + */
  69 + protected Map<String, BusinessDetailDto> getFilteredDynamicDataSingle(DynamicType dynamicType, Long marketId, String systemCode) {
  70 + var queryArrays = new String[]{
  71 + BasicEnum.DEPARTMENT_TO_LOWER.code,
  72 + BasicEnum.CUSTOMER_TO_LOWER.code,
  73 + BasicEnum.FINANCIAL_CHANNEL_TYPE_TO_LOWER.code,
  74 + BasicEnum.FINANCIAL_BUSINESS_TYPE_TO_LOWER.code
  75 + };
  76 + var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(), queryArrays);
  77 + Map<String, BusinessDetailDto> map = new HashMap<>();
  78 + if (!ObjectUtils.isEmpty(dynamicParam)) {
  79 + dynamicParam.forEach(e -> map.computeIfAbsent(e.getCode(), k -> e));
  80 + }
  81 + return map;
  82 + }
  83 +
  84 + /**
  85 + * 传输数据列表
  86 + *
  87 + * @param ts 茨
  88 + * @param marketId 市场 ID
  89 + * @param systemCode 系统代码
  90 + */
  91 + protected void transferDataListWithOutFeeItem(List<T> ts, Long marketId, String systemCode) {
  92 + ts.forEach(e -> {
  93 + DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());
  94 + transfer(e, marketId, systemCode);
  95 + getFilteredDynamicDataSingle(dynamicType, marketId, systemCode).forEach((k, v) -> TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v));
  96 + getFilteredDynamicDataMulti(dynamicType, marketId, systemCode).forEach((k, v) -> TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v));
  97 + });
  98 + }
  99 +
  100 + /**
56 * 转换动态配置部门 101 * 转换动态配置部门
57 * 102 *
58 * @param t t 103 * @param t t
@@ -180,22 +225,6 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM @@ -180,22 +225,6 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM
180 /** 225 /**
181 * 传输数据列表 226 * 传输数据列表
182 * 227 *
183 - * @param ts 茨  
184 - * @param marketId 市场 ID  
185 - * @param systemCode 系统代码  
186 - */  
187 - protected void transferDataListWithOutFeeItem(List<T> ts, Long marketId, String systemCode) {  
188 - ts.forEach(e -> {  
189 - DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode());  
190 - transfer(e, marketId, systemCode);  
191 - getFilteredDynamicDataSingle(dynamicType, marketId, systemCode).forEach((k, v) -> TRANSFER_FUNCTION_SINGLE_MAP.get(k).transferDynamic(e, v));  
192 - getFilteredDynamicDataMulti(dynamicType, marketId, systemCode).forEach((k, v) -> TRANSFER_FUNCTION_MULTI_MAP.get(k).transferDynamic(e, v));  
193 - });  
194 - }  
195 -  
196 - /**  
197 - * 传输数据列表  
198 - *  
199 * 228 *
200 * @param ts 茨 229 * @param ts 茨
201 * @param marketId 市场 ID 230 * @param marketId 市场 ID
@@ -219,29 +248,6 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM @@ -219,29 +248,6 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM
219 * @param dynamicType 动态型 248 * @param dynamicType 动态型
220 * @return {@link Map}<{@link String}, {@link BusinessDetailDto}> 249 * @return {@link Map}<{@link String}, {@link BusinessDetailDto}>
221 */ 250 */
222 - protected Map<String, BusinessDetailDto> getFilteredDynamicDataSingle(DynamicType dynamicType, Long marketId, String systemCode) {  
223 - var queryArrays = new String[]{  
224 - BasicEnum.DEPARTMENT_TO_LOWER.code,  
225 - BasicEnum.CUSTOMER_TO_LOWER.code,  
226 - BasicEnum.FINANCIAL_CHANNEL_TYPE_TO_LOWER.code,  
227 - BasicEnum.FINANCIAL_BUSINESS_TYPE_TO_LOWER.code  
228 - };  
229 - var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(), queryArrays);  
230 - Map<String, BusinessDetailDto> map = new HashMap<>();  
231 - if (!ObjectUtils.isEmpty(dynamicParam)) {  
232 - dynamicParam.forEach(e -> map.computeIfAbsent(e.getCode(), k -> e));  
233 - }  
234 - return map;  
235 - }  
236 -  
237 - /**  
238 - * 获取动态数据  
239 - *  
240 - * @param marketId 市场 ID  
241 - * @param systemCode 系统代码  
242 - * @param dynamicType 动态型  
243 - * @return {@link Map}<{@link String}, {@link BusinessDetailDto}>  
244 - */  
245 protected Map<String, List<BusinessDetailDto>> getFilteredDynamicDataMulti(DynamicType dynamicType, Long marketId, String systemCode) { 251 protected Map<String, List<BusinessDetailDto>> getFilteredDynamicDataMulti(DynamicType dynamicType, Long marketId, String systemCode) {
246 var queryArrays = new String[]{BasicEnum.CHARGE_ITEM_TO_LOWER.code}; 252 var queryArrays = new String[]{BasicEnum.CHARGE_ITEM_TO_LOWER.code};
247 var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(), queryArrays); 253 var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(), queryArrays);
@@ -262,51 +268,22 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM @@ -262,51 +268,22 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM
262 */ 268 */
263 protected void sendPurchaseOrder(List<T> ts, Long marketId, String systemCode) throws Exception { 269 protected void sendPurchaseOrder(List<T> ts, Long marketId, String systemCode) throws Exception {
264 var identifyInfo = getIdentifyInfo(marketId, systemCode); 270 var identifyInfo = getIdentifyInfo(marketId, systemCode);
265 - var util = new PurchaseOrderApiUtils(identifyInfo);  
266 for (T e : ts) { 271 for (T e : ts) {
267 var billId = e.getFBillTypeID().getFNUMBER(); 272 var billId = e.getFBillTypeID().getFNUMBER();
268 //获取单据类型 273 //获取单据类型
269 String documentType = getDocumentType(marketId, systemCode, billId); 274 String documentType = getDocumentType(marketId, systemCode, billId);
  275 + if (ObjectUtils.isEmpty(documentType)) {
  276 + throw new ThirdPartyException("未配置业务映射");
  277 + }
270 var fixedBusinessType = e.getFixedBusinessType(); 278 var fixedBusinessType = e.getFixedBusinessType();
271 //业务类型固定的情况下 279 //业务类型固定的情况下
272 if (!ObjectUtils.isEmpty(fixedBusinessType)){ 280 if (!ObjectUtils.isEmpty(fixedBusinessType)){
273 e.getFBillTypeID().setFNUMBER(fixedBusinessType); 281 e.getFBillTypeID().setFNUMBER(fixedBusinessType);
274 } 282 }
275 - if (ObjectUtils.isEmpty(documentType)) {  
276 - throw new ThirdPartyException("未配置业务映射");  
277 - }  
278 - if (util.getPurchaseOrder(e.getFBillTypeID().getFNUMBER(), e.getF_ZDB_Text1(), getAllAmountFor(e), e.getF_ZDB_Text667())) {  
279 - util.createOnePurchaseOrder(JsonUtils.toJsonString(e), documentType);  
280 - } 283 + BillType.getBillType(documentType).handle(e,identifyInfo);
281 } 284 }
282 } 285 }
283 286
284 - private IdentifyInfo getIdentifyInfo(Long marketId, String systemCode) {  
285 - var identifyInfo = new IdentifyInfo();  
286 - ClientDto clientParam = transMapper.getClientParam(systemCode, marketId);  
287 - identifyInfo.setAppId(clientParam.getApplyId());  
288 - identifyInfo.setUserName(clientParam.getUsername());  
289 - identifyInfo.setServerUrl(clientParam.getServiceAddress());  
290 - identifyInfo.setAppSecret(clientParam.getSecurityKey());  
291 - identifyInfo.setdCID(clientParam.getDataCentreId());  
292 - return identifyInfo;  
293 - }  
294 -  
295 - /**  
296 - * 获取 所有金额  
297 - *  
298 - * @param e e  
299 - * @return {@link String}  
300 - */  
301 - private String getAllAmountFor(T e) {  
302 - var allAmountFor = BigDecimal.ZERO;  
303 - for (FEntityDetail f : e.getFEntityDetail()) {  
304 - BigDecimal single = f.getFPrice().multiply(f.getFPriceQty());  
305 - allAmountFor = allAmountFor.add(single);  
306 - }  
307 - return allAmountFor.toString();  
308 - }  
309 -  
310 /** 287 /**
311 * 获取文档类型 288 * 获取文档类型
312 * 289 *
@@ -315,29 +292,53 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM @@ -315,29 +292,53 @@ public abstract class AbstractBillHandler&lt;T extends BaseBillCo&gt; implements TypeM
315 * @param billTypeId 账单类型 ID 292 * @param billTypeId 账单类型 ID
316 * @return {@link String} 293 * @return {@link String}
317 */ 294 */
318 - protected String getDocumentType(Long marketId, String systemCode, String billTypeId) { 295 + private String getDocumentType(Long marketId, String systemCode, String billTypeId) {
319 var res = transMapper.getMappingDict(BasicEnum.FINANCIAL_BUSINESS_TYPE_TO_LOWER.code, systemCode, marketId, billTypeId); 296 var res = transMapper.getMappingDict(BasicEnum.FINANCIAL_BUSINESS_TYPE_TO_LOWER.code, systemCode, marketId, billTypeId);
320 return ObjectUtils.isEmpty(res) ? null : res.getMapType(); 297 return ObjectUtils.isEmpty(res) ? null : res.getMapType();
321 } 298 }
322 299
323 - 300 + /**
  301 + * 传递函数 Single
  302 + *
  303 + * @author zhangmeiyang
  304 + * @date 2024/11/20
  305 + */
324 @FunctionalInterface 306 @FunctionalInterface
325 protected interface TransferFunctionSingle { 307 protected interface TransferFunctionSingle {
  308 + /**
  309 + * Transfer Dynamic (传输动态)
  310 + *
  311 + * @param baseBillCo Base Bill 公司
  312 + * @param data 数据
  313 + */
326 void transferDynamic(BaseBillCo baseBillCo, BusinessDetailDto data); 314 void transferDynamic(BaseBillCo baseBillCo, BusinessDetailDto data);
327 } 315 }
328 316
329 - @FunctionalInterface  
330 - protected interface TransferFunctionMulti {  
331 - void transferDynamic(BaseBillCo baseBillCo, List<BusinessDetailDto> data); 317 + private IdentifyInfo getIdentifyInfo(Long marketId, String systemCode) {
  318 + var identifyInfo = new IdentifyInfo();
  319 + ClientDto clientParam = transMapper.getClientParam(systemCode, marketId);
  320 + identifyInfo.setAppId(clientParam.getApplyId());
  321 + identifyInfo.setUserName(clientParam.getUsername());
  322 + identifyInfo.setServerUrl(clientParam.getServiceAddress());
  323 + identifyInfo.setAppSecret(clientParam.getSecurityKey());
  324 + identifyInfo.setdCID(clientParam.getDataCentreId());
  325 + return identifyInfo;
332 } 326 }
333 327
334 /** 328 /**
335 - * 处理 329 + * 传递函数 Multi
336 * 330 *
337 - * @param json JSON 格式  
338 - * @param marketId 市场 ID  
339 - * @param systemCode 系统代码  
340 - * @throws Exception 例外 331 + * @author zhangmeiyang
  332 + * @date 2024/11/20
341 */ 333 */
342 - public abstract void handle(String json, Long marketId, String systemCode) throws Exception; 334 + @FunctionalInterface
  335 + protected interface TransferFunctionMulti {
  336 + /**
  337 + * Transfer Dynamic (传输动态)
  338 + *
  339 + * @param baseBillCo Base Bill 公司
  340 + * @param data 数据
  341 + */
  342 + void transferDynamic(BaseBillCo baseBillCo, List<BusinessDetailDto> data);
  343 + }
343 } 344 }
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/exec/basic/BasicReceiver.java
@@ -66,7 +66,7 @@ public class BasicReceiver extends AbstractReceiver { @@ -66,7 +66,7 @@ public class BasicReceiver extends AbstractReceiver {
66 } catch (Exception e) { 66 } catch (Exception e) {
67 channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); 67 channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
68 if (msg.getRetryCount() > 3) { 68 if (msg.getRetryCount() > 3) {
69 - super.handleError(e.fillInStackTrace().getMessage(), msg.getData(), msg.getBasic().code, msg.getSystemCode(), msg.getMarketId()); 69 + handleError(e.fillInStackTrace().getMessage(), msg.getData(), msg.getBasic().code, msg.getSystemCode(), msg.getMarketId());
70 LOG.error("基础数据重试队列消息处理失败:", e); 70 LOG.error("基础数据重试队列消息处理失败:", e);
71 } else { 71 } else {
72 msg.setRetryCount(msg.getRetryCount() + 1); 72 msg.setRetryCount(msg.getRetryCount() + 1);
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/exec/business/BusinessReceiver.java
@@ -64,7 +64,7 @@ public class BusinessReceiver extends AbstractReceiver { @@ -64,7 +64,7 @@ public class BusinessReceiver extends AbstractReceiver {
64 } catch (Exception e) { 64 } catch (Exception e) {
65 channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); 65 channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
66 if (msg.getRetryCount() > 3) { 66 if (msg.getRetryCount() > 3) {
67 - super.handleError(e.fillInStackTrace().getMessage(), msg.getData(), msg.getBusiness().code, msg.getSystemCode(),msg.getMarketId()); 67 + handleError(e.fillInStackTrace().getMessage(), msg.getData(), msg.getBusiness().code, msg.getSystemCode(),msg.getMarketId());
68 LOG.error("业务重试队列消息处理失败:",e); 68 LOG.error("业务重试队列消息处理失败:",e);
69 }else{ 69 }else{
70 msg.setRetryCount(msg.getRetryCount() + 1); 70 msg.setRetryCount(msg.getRetryCount() + 1);
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/basic/BusinessTypeBasicHandler.java
@@ -25,18 +25,22 @@ public class BusinessTypeBasicHandler extends AbstractBasicHandler&lt;BusinessTypeC @@ -25,18 +25,22 @@ public class BusinessTypeBasicHandler extends AbstractBasicHandler&lt;BusinessTypeC
25 List<BusinessTypeCo> businessTypeCos = JsonUtils.fromJsonString(json, new TypeReference<>() {}); 25 List<BusinessTypeCo> businessTypeCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
26 var utils = new BillTypeApiUtils(getIdentifyInfo(marketId, systemCode)); 26 var utils = new BillTypeApiUtils(getIdentifyInfo(marketId, systemCode));
27 for (BusinessTypeCo e : businessTypeCos) { 27 for (BusinessTypeCo e : businessTypeCos) {
28 - super.transfer(e, marketId, systemCode);  
29 - MappingDto mappingData = super.getMappingData(marketId, systemCode, e.getSystemDataId());  
30 - e.setFBILLTYPEID(ObjectUtils.isEmpty(mappingData) ? null : mappingData.getThirdPartyDataId());  
31 - if (!ObjectUtils.isEmpty(mappingData)){  
32 - utils.updateBillType(mappingData.getThirdPartyDataId(),JsonUtils.toJsonString(e));  
33 - }else {  
34 - String billType = utils.createBillType(JsonUtils.toJsonString(e));  
35 - super.recordMapping(marketId, systemCode, e.getSystemDataId(), billType);  
36 - } 28 + transfer(e, marketId, systemCode);
  29 + MappingDto mappingData = getMappingData(marketId, systemCode, e.getSystemDataId());
  30 + saveData(marketId, systemCode, e, mappingData, utils);
37 } 31 }
38 } 32 }
39 33
  34 + private void saveData(Long marketId, String systemCode, BusinessTypeCo e, MappingDto mappingData, BillTypeApiUtils utils) throws Exception {
  35 + if (!ObjectUtils.isEmpty(mappingData)){
  36 + e.setFBILLTYPEID(mappingData.getThirdPartyDataId());
  37 + utils.updateBillType(mappingData.getThirdPartyDataId(), JsonUtils.toJsonString(e));
  38 + return;
  39 + }
  40 + String billType = utils.createBillType(JsonUtils.toJsonString(e));
  41 + recordMapping(marketId, systemCode, e.getSystemDataId(), billType);
  42 + }
  43 +
40 @Override 44 @Override
41 public BasicEnum getType() { 45 public BasicEnum getType() {
42 return BasicEnum.FINANCIAL_BUSINESS_TYPE; 46 return BasicEnum.FINANCIAL_BUSINESS_TYPE;
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/basic/ChargeItemBasicHandler.java
@@ -25,18 +25,36 @@ public class ChargeItemBasicHandler extends AbstractBasicHandler&lt;ChargeItemCo&gt; { @@ -25,18 +25,36 @@ public class ChargeItemBasicHandler extends AbstractBasicHandler&lt;ChargeItemCo&gt; {
25 List<ChargeItemCo> chargeItemCos = JsonUtils.fromJsonString(json, new TypeReference<>(){}); 25 List<ChargeItemCo> chargeItemCos = JsonUtils.fromJsonString(json, new TypeReference<>(){});
26 var utils =new FeeApiUtils(getIdentifyInfo(marketId, systemCode)); 26 var utils =new FeeApiUtils(getIdentifyInfo(marketId, systemCode));
27 for (ChargeItemCo e : chargeItemCos) { 27 for (ChargeItemCo e : chargeItemCos) {
28 - super.transfer(e, marketId, systemCode);  
29 - MappingDto mappingData = super.getMappingData(marketId, systemCode, e.getSystemDataId());  
30 - e.setFEXPID(ObjectUtils.isEmpty(mappingData) ? null : Long.valueOf(mappingData.getThirdPartyDataId())); 28 + transfer(e, marketId, systemCode);
  29 + ChargeItemCo existFee = utils.getFee(e.getFNumber(),e.getFGroup().getFNumber());
  30 + MappingDto mappingData = getMappingData(marketId, systemCode, e.getSystemDataId());
  31 + establishMappings(marketId, systemCode, e, existFee, mappingData, utils);
  32 + }
  33 + }
  34 +
  35 + private void establishMappings(Long marketId, String systemCode, ChargeItemCo e, ChargeItemCo existFee, MappingDto mappingData, FeeApiUtils utils) throws Exception {
  36 + if (ObjectUtils.isEmpty(existFee)){ //如果查询到jd上的费用项不存在 分为两种情况 1.新增映射 2.修改老的映射(但是修改了费用项编码)
31 if (!ObjectUtils.isEmpty(mappingData)){ 37 if (!ObjectUtils.isEmpty(mappingData)){
  38 + //mappingData存在表明存在旧映射关系,删除旧映射关系
  39 + deleteMapping(mappingData.getMarketId(), mappingData.getSystemCode(), mappingData.getSystemDataId());
  40 + }
  41 + String fee = utils.createFee(JsonUtils.toJsonString(e));
  42 + recordMapping(marketId, systemCode, e.getSystemDataId(), fee);
  43 + //重做映射
  44 + }else{
  45 + //查询到jd费用项存在映射 分为两种情况 1.修改映射 2.新增多重映射
  46 + if (ObjectUtils.isEmpty(mappingData)){
  47 + //新增多重映射
  48 + recordMapping(marketId, systemCode, e.getSystemDataId(), String.valueOf(existFee.getFEXPID()));
  49 + }else{
  50 + //变更映射
  51 + e.setFEXPID(Long.valueOf(mappingData.getThirdPartyDataId()));
32 utils.updateFee(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e)); 52 utils.updateFee(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e));
33 - }else {  
34 - String fee = utils.createFee(JsonUtils.toJsonString(e));  
35 - super.recordMapping(marketId, systemCode, e.getSystemDataId(), fee);  
36 } 53 }
37 } 54 }
38 } 55 }
39 56
  57 +
40 @Override 58 @Override
41 public BasicEnum getType() { 59 public BasicEnum getType() {
42 return BasicEnum.CHARGE_ITEM; 60 return BasicEnum.CHARGE_ITEM;
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/basic/ChargeItemGroupBasicHandler.java
@@ -32,7 +32,7 @@ public class ChargeItemGroupBasicHandler extends AbstractBasicHandler&lt;ChargeItem @@ -32,7 +32,7 @@ public class ChargeItemGroupBasicHandler extends AbstractBasicHandler&lt;ChargeItem
32 List<ChargeItemGroupCo> chargeItemGroupCos = JsonUtils.fromJsonString(json, new TypeReference<>() { 32 List<ChargeItemGroupCo> chargeItemGroupCos = JsonUtils.fromJsonString(json, new TypeReference<>() {
33 }); 33 });
34 for (ChargeItemGroupCo e : chargeItemGroupCos) { 34 for (ChargeItemGroupCo e : chargeItemGroupCos) {
35 - super.transfer(e, marketId, systemCode); 35 + transfer(e, marketId, systemCode);
36 Long systemParentId = e.getFParentId(); 36 Long systemParentId = e.getFParentId();
37 Long systemDataId = e.getSystemDataId(); 37 Long systemDataId = e.getSystemDataId();
38 MappingDto parentMappingData = getMappingData(marketId, systemCode, systemParentId); 38 MappingDto parentMappingData = getMappingData(marketId, systemCode, systemParentId);
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/basic/CustomerBasicHandler.java
@@ -34,31 +34,35 @@ public class CustomerBasicHandler extends AbstractBasicHandler&lt;CustomerCo&gt; { @@ -34,31 +34,35 @@ public class CustomerBasicHandler extends AbstractBasicHandler&lt;CustomerCo&gt; {
34 FGroup fGroup = new FGroup(); 34 FGroup fGroup = new FGroup();
35 transferCustomerGroup(fGroup, marketId, systemCode); 35 transferCustomerGroup(fGroup, marketId, systemCode);
36 for (CustomerCo e : customerCos) { 36 for (CustomerCo e : customerCos) {
37 - super.transfer(e, marketId, systemCode); 37 + MappingDto mappingData = getMappingData(marketId, systemCode, e.getSystemDataId());
  38 + transfer(e, marketId, systemCode);
38 e.setFGroup(fGroup); 39 e.setFGroup(fGroup);
39 - MappingDto mappingData = super.getMappingData(marketId, systemCode, e.getSystemDataId());  
40 - List<FT_BD_CUSTLOCATION> ftBdCustlocation = e.getFT_BD_CUSTLOCATION();  
41 - var list = new ArrayList<FT_BD_CUSTLOCATION>();  
42 - if (!ObjectUtils.isEmpty(ftBdCustlocation)){  
43 - for (FT_BD_CUSTLOCATION ftBdCustLocation : ftBdCustlocation) {  
44 - ftBdCustLocation.setFCompanyType(F_COMPANY_TYPE);  
45 - String contact = contactUtils.createContact(JsonUtils.toJsonString(ftBdCustLocation));  
46 - FContactId fContactId = new FContactId();  
47 - fContactId.setFNUMBER(contact);  
48 - var item = new FT_BD_CUSTLOCATION();  
49 - item.setFContactId(fContactId);  
50 - list.add(item);  
51 - }  
52 - }  
53 - e.setFT_BD_CUSTLOCATION(list);  
54 - e.setFCUSTID(ObjectUtils.isEmpty(mappingData) ? null : Long.valueOf(mappingData.getThirdPartyDataId())); 40 + e.setFT_BD_CUSTLOCATION(getFtBdCustlocations(e, contactUtils));
55 if (!ObjectUtils.isEmpty(mappingData)){ 41 if (!ObjectUtils.isEmpty(mappingData)){
  42 + e.setFCUSTID(Long.valueOf(mappingData.getThirdPartyDataId()));
56 customerUtils.updateCustomer(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e)); 43 customerUtils.updateCustomer(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e));
57 }else { 44 }else {
58 String billType = customerUtils.createCustomer(JsonUtils.toJsonString(e)); 45 String billType = customerUtils.createCustomer(JsonUtils.toJsonString(e));
59 - super.recordMapping(marketId, systemCode, e.getSystemDataId(), billType); 46 + recordMapping(marketId, systemCode, e.getSystemDataId(), billType);
  47 + }
  48 + }
  49 + }
  50 +
  51 + private List<FT_BD_CUSTLOCATION> getFtBdCustlocations(CustomerCo e, ContactApiUtils contactUtils) throws Exception {
  52 + List<FT_BD_CUSTLOCATION> ftBdCustlocation = e.getFT_BD_CUSTLOCATION();
  53 + var list = new ArrayList<FT_BD_CUSTLOCATION>();
  54 + if (!ObjectUtils.isEmpty(ftBdCustlocation)){
  55 + for (FT_BD_CUSTLOCATION ftBdCustLocation : ftBdCustlocation) {
  56 + ftBdCustLocation.setFCompanyType(F_COMPANY_TYPE);
  57 + String contact = contactUtils.createContact(JsonUtils.toJsonString(ftBdCustLocation));
  58 + FContactId fContactId = new FContactId();
  59 + fContactId.setFNUMBER(contact);
  60 + var item = new FT_BD_CUSTLOCATION();
  61 + item.setFContactId(fContactId);
  62 + list.add(item);
60 } 63 }
61 } 64 }
  65 + return list;
62 } 66 }
63 67
64 @Override 68 @Override
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/basic/DepartmentBasicHandler.java
@@ -25,19 +25,23 @@ public class DepartmentBasicHandler extends AbstractBasicHandler&lt;DepartmentCo&gt; { @@ -25,19 +25,23 @@ public class DepartmentBasicHandler extends AbstractBasicHandler&lt;DepartmentCo&gt; {
25 List<DepartmentCo> departmentCos = JsonUtils.fromJsonString(json, new TypeReference<>(){}); 25 List<DepartmentCo> departmentCos = JsonUtils.fromJsonString(json, new TypeReference<>(){});
26 var utils = new DepartmentApiUtils(getIdentifyInfo(marketId, systemCode)); 26 var utils = new DepartmentApiUtils(getIdentifyInfo(marketId, systemCode));
27 for (DepartmentCo e : departmentCos) { 27 for (DepartmentCo e : departmentCos) {
28 - super.transfer(e, marketId, systemCode);  
29 - MappingDto mappingData = super.getMappingData(marketId, systemCode, e.getSystemDataId());  
30 - e.setFDEPTID(ObjectUtils.isEmpty(mappingData) ? null : Long.valueOf(mappingData.getThirdPartyDataId()));  
31 - if (!ObjectUtils.isEmpty(mappingData)){  
32 - utils.updateDepartment(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e));  
33 - }else {  
34 - String department = utils.createDepartment(JsonUtils.toJsonString(e));  
35 - super.recordMapping(marketId, systemCode, e.getSystemDataId(), department);  
36 - } 28 + transfer(e, marketId, systemCode);
  29 + MappingDto mappingData = getMappingData(marketId, systemCode, e.getSystemDataId());
  30 + saveData(marketId, systemCode, e, mappingData, utils);
37 } 31 }
38 32
39 } 33 }
40 34
  35 + private void saveData(Long marketId, String systemCode, DepartmentCo e, MappingDto mappingData, DepartmentApiUtils utils) throws Exception {
  36 + if (!ObjectUtils.isEmpty(mappingData)){
  37 + e.setFDEPTID(Long.valueOf(mappingData.getThirdPartyDataId()));
  38 + utils.updateDepartment(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e));
  39 + }else {
  40 + String department = utils.createDepartment(JsonUtils.toJsonString(e));
  41 + recordMapping(marketId, systemCode, e.getSystemDataId(), department);
  42 + }
  43 + }
  44 +
41 @Override 45 @Override
42 public BasicEnum getType() { 46 public BasicEnum getType() {
43 return BasicEnum.DEPARTMENT; 47 return BasicEnum.DEPARTMENT;
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/basic/SettlementBasicHandler.java
@@ -25,15 +25,19 @@ public class SettlementBasicHandler extends AbstractBasicHandler&lt;SettlementCo&gt; { @@ -25,15 +25,19 @@ public class SettlementBasicHandler extends AbstractBasicHandler&lt;SettlementCo&gt; {
25 List<SettlementCo> settlementCos = JsonUtils.fromJsonString(json, new TypeReference<>() {}); 25 List<SettlementCo> settlementCos = JsonUtils.fromJsonString(json, new TypeReference<>() {});
26 var utils = new SettleTypeApiUtils(getIdentifyInfo(marketId, systemCode)); 26 var utils = new SettleTypeApiUtils(getIdentifyInfo(marketId, systemCode));
27 for (SettlementCo e : settlementCos) { 27 for (SettlementCo e : settlementCos) {
28 - super.transfer(e, marketId, systemCode);  
29 - MappingDto mappingData = super.getMappingData(marketId, systemCode, e.getSystemDataId());  
30 - e.setFID(ObjectUtils.isEmpty(mappingData) ? null : Long.valueOf(mappingData.getThirdPartyDataId()));  
31 - if (!ObjectUtils.isEmpty(mappingData)){  
32 - utils.updateSettleType(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e));  
33 - }else {  
34 - String billType = utils.createSettleType(JsonUtils.toJsonString(e));  
35 - super.recordMapping(marketId, systemCode, e.getSystemDataId(), billType);  
36 - } 28 + transfer(e, marketId, systemCode);
  29 + MappingDto mappingData = getMappingData(marketId, systemCode, e.getSystemDataId());
  30 + saveData(marketId, systemCode, e, mappingData, utils);
  31 + }
  32 + }
  33 +
  34 + private void saveData(Long marketId, String systemCode, SettlementCo e, MappingDto mappingData, SettleTypeApiUtils utils) throws Exception {
  35 + if (!ObjectUtils.isEmpty(mappingData)){
  36 + e.setFID(Long.valueOf(mappingData.getThirdPartyDataId()));
  37 + utils.updateSettleType(String.valueOf(mappingData.getThirdPartyDataId()),JsonUtils.toJsonString(e));
  38 + }else {
  39 + String billType = utils.createSettleType(JsonUtils.toJsonString(e));
  40 + recordMapping(marketId, systemCode, e.getSystemDataId(), billType);
37 } 41 }
38 } 42 }
39 43
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/mapper/RecordMapper.java
@@ -25,4 +25,11 @@ public interface RecordMapper extends MybatisMapperSupport { @@ -25,4 +25,11 @@ public interface RecordMapper extends MybatisMapperSupport {
25 */ 25 */
26 @DataSource(DataSourceConstants.DS_KEY_MASTER) 26 @DataSource(DataSourceConstants.DS_KEY_MASTER)
27 void recordTheMappingData(@Param("mapping")MappingDto mapping); 27 void recordTheMappingData(@Param("mapping")MappingDto mapping);
  28 +
  29 +
  30 + /**
  31 + * @param mapping
  32 + */
  33 + @DataSource(DataSourceConstants.DS_KEY_MASTER)
  34 + void deleteTheMappingData(@Param("mapping")MappingDto mapping);
28 } 35 }
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/type/BillType.java 0 → 100644
  1 +package com.diligrp.etrade.thirdparty.type;
  2 +
  3 +import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.domain.co.business.BaseBillCo;
  5 +import com.diligrp.etrade.thirdparty.domain.model.FEntityDetail;
  6 +import com.diligrp.etrade.thirdparty.error.ThirdPartyException;
  7 +import com.diligrp.etrade.thirdparty.utils.PurchaseOrderApiUtils;
  8 +import com.diligrp.etrade.thirdparty.utils.ReceiptsOrderApiUtils;
  9 +import com.diligrp.etrade.thirdparty.utils.ReceiptsRefundOrderApiUtils;
  10 +import com.kingdee.bos.webapi.entity.IdentifyInfo;
  11 +
  12 +import java.math.BigDecimal;
  13 +
  14 +public enum BillType {
  15 +
  16 + RECEIVABLES("AR_receivable") {
  17 + @Override
  18 + public <T extends BaseBillCo> void handle(T t, IdentifyInfo identifyInfo) throws Exception {
  19 + var util = new PurchaseOrderApiUtils(identifyInfo);
  20 + boolean purchaseOrder = util.getPurchaseOrder(t.getFBillTypeID().getFNUMBER(), t.getF_ZDB_Text1(), getAllAmountFor(t), t.getF_ZDB_Text667());
  21 + if (purchaseOrder) {
  22 + util.createOnePurchaseOrder(JsonUtils.toJsonString(t), this.value);
  23 + }
  24 + }
  25 + },
  26 + RECEIPTS("AR_RECEIVEBILL") {
  27 + @Override
  28 + public <T extends BaseBillCo> void handle(T t, IdentifyInfo identifyInfo) throws Exception {
  29 + var util = new ReceiptsOrderApiUtils(identifyInfo);
  30 + boolean purchaseOrder = util.getReceiptsOrder(t.getFBillTypeID().getFNUMBER(), t.getF_ZDB_Text1(), getAllAmountFor(t), t.getF_ZDB_Text667());
  31 + if (purchaseOrder) {
  32 + util.createOnePurchaseOrder(JsonUtils.toJsonString(t), this.value);
  33 + }
  34 + }
  35 + },
  36 + RECEIPT_AND_REFUND_FORM("AR_REFUNDBILL") {
  37 + @Override
  38 + public <T extends BaseBillCo> void handle(T t, IdentifyInfo identifyInfo) throws Exception {
  39 + var util = new ReceiptsRefundOrderApiUtils(identifyInfo);
  40 + boolean purchaseOrder = util.getReceiptsRefundOrder(t.getFBillTypeID().getFNUMBER(), t.getF_ZDB_Text1(), getAllAmountFor(t), t.getF_ZDB_Text667());
  41 + if (purchaseOrder) {
  42 + util.createOnePurchaseOrder(JsonUtils.toJsonString(t), this.value);
  43 + }
  44 + }
  45 + },
  46 + ;
  47 +
  48 + public final String value;
  49 +
  50 + BillType(String value) {
  51 + this.value = value;
  52 + }
  53 +
  54 + public static BillType getBillType(String value) {
  55 + for (BillType type : BillType.values()) {
  56 + if (type.value.equals(value)) {
  57 + return type;
  58 + }
  59 + }
  60 + throw new ThirdPartyException("未实现的业务类型");
  61 + }
  62 +
  63 + private static <T extends BaseBillCo> String getAllAmountFor(T e) {
  64 + var allAmountFor = BigDecimal.ZERO;
  65 + for (FEntityDetail f : e.getFEntityDetail()) {
  66 + BigDecimal single = f.getFPrice().multiply(f.getFPriceQty());
  67 + allAmountFor = allAmountFor.add(single);
  68 + }
  69 + return allAmountFor.toString();
  70 + }
  71 +
  72 + public abstract <T extends BaseBillCo> void handle(T t, IdentifyInfo identifyInfo) throws Exception;
  73 +}
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/DepartmentApiUtils.java
@@ -22,6 +22,17 @@ public class DepartmentApiUtils extends BaseApiUtils { @@ -22,6 +22,17 @@ public class DepartmentApiUtils extends BaseApiUtils {
22 super(identifyInfo); 22 super(identifyInfo);
23 } 23 }
24 24
  25 + /**
  26 + * {
  27 + * "FormId": "BD_Department",
  28 + * "FieldKeys": "FDEPTID",
  29 + * "FilterString": "FNumber = '001'"
  30 + * }
  31 + *
  32 + * @param json
  33 + * @return
  34 + * @throws Exception
  35 + */
25 public String createDepartment(String json) throws Exception { 36 public String createDepartment(String json) throws Exception {
26 return save(createSendMessageWithAudit(json)); 37 return save(createSendMessageWithAudit(json));
27 } 38 }
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/FeeApiUtils.java
1 package com.diligrp.etrade.thirdparty.utils; 1 package com.diligrp.etrade.thirdparty.utils;
2 2
  3 +import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.domain.co.basic.ChargeItemCo;
  5 +import com.diligrp.etrade.thirdparty.message.GeneralQueryMessage;
3 import com.kingdee.bos.webapi.entity.IdentifyInfo; 6 import com.kingdee.bos.webapi.entity.IdentifyInfo;
4 import com.kingdee.bos.webapi.entity.OperateParam; 7 import com.kingdee.bos.webapi.entity.OperateParam;
5 import com.kingdee.bos.webapi.entity.OperatorResult; 8 import com.kingdee.bos.webapi.entity.OperatorResult;
6 import org.slf4j.Logger; 9 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory; 10 import org.slf4j.LoggerFactory;
8 11
  12 +import java.util.List;
  13 +
9 /** 14 /**
10 * 费用 API 实用程序 15 * 费用 API 实用程序
11 * 16 *
@@ -22,6 +27,25 @@ public class FeeApiUtils extends BaseApiUtils { @@ -22,6 +27,25 @@ public class FeeApiUtils extends BaseApiUtils {
22 super(identifyInfo); 27 super(identifyInfo);
23 } 28 }
24 29
  30 + public ChargeItemCo getFee(String fNumber,String groupNumber) throws Exception {
  31 + var filterString = "FNumber = '%s' and FGroup.FNumber = '%s' ".formatted(fNumber,groupNumber);
  32 + var query = new GeneralQueryMessage();
  33 + query.setFormId("BD_Expense");
  34 + query.setFieldKeys("FEXPID,FNumber");
  35 + query.setFilterString(filterString);
  36 + List<List<Object>> res = api.executeBillQuery(JsonUtils.toJsonString(query));
  37 + log.info("费用项接口查回数据,json数据:{}", res);
  38 + if (res.isEmpty()){
  39 + return null;
  40 + }
  41 + var feeId = String.valueOf(res.get(0).get(0));
  42 + var FNumber = String.valueOf(res.get(0).get(1));
  43 + ChargeItemCo chargeItemCo = new ChargeItemCo();
  44 + chargeItemCo.setFEXPID(Long.valueOf(feeId));
  45 + chargeItemCo.setFNumber(FNumber);
  46 + return chargeItemCo;
  47 + }
  48 +
25 49
26 public String createFee(String json) throws Exception { 50 public String createFee(String json) throws Exception {
27 return save(createSendMessageWithAudit(json)); 51 return save(createSendMessageWithAudit(json));
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/PurchaseOrderApiUtils.java
@@ -33,7 +33,7 @@ public class PurchaseOrderApiUtils extends BaseApiUtils { @@ -33,7 +33,7 @@ public class PurchaseOrderApiUtils extends BaseApiUtils {
33 query.setFieldKeys("FID"); 33 query.setFieldKeys("FID");
34 query.setFormId("AR_receivable"); 34 query.setFormId("AR_receivable");
35 List<List<Object>> res = api.executeBillQuery(JsonUtils.toJsonString(query)); 35 List<List<Object>> res = api.executeBillQuery(JsonUtils.toJsonString(query));
36 - log.info("采购订单接口查回数据,json数据:{}", res); 36 + log.info("应收单接口查回数据,json数据:{}", res);
37 return res.isEmpty(); 37 return res.isEmpty();
38 } 38 }
39 39
@@ -43,9 +43,9 @@ public class PurchaseOrderApiUtils extends BaseApiUtils { @@ -43,9 +43,9 @@ public class PurchaseOrderApiUtils extends BaseApiUtils {
43 } 43 }
44 44
45 private void save(String json, String formId) throws Exception { 45 private void save(String json, String formId) throws Exception {
46 - log.info("采购订单接口json数据:{}", json); 46 + log.info("应收单接口json数据:{}", json);
47 String res = api.save(formId, json); 47 String res = api.save(formId, json);
48 var repoRet = getRepoRet(res); 48 var repoRet = getRepoRet(res);
49 - log.info("采购订单接口已完成,{}", repoRet); 49 + log.info("应收单接口已完成,{}", repoRet);
50 } 50 }
51 } 51 }
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/ReceiptsOrderApiUtils.java 0 → 100644
  1 +package com.diligrp.etrade.thirdparty.utils;
  2 +
  3 +import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.message.GeneralQueryMessage;
  5 +import com.kingdee.bos.webapi.entity.IdentifyInfo;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * 收款单 API 实用程序
  13 + *
  14 + * @author zhangmeiyang
  15 + * @Author: zhangmeiyang
  16 + * @CreateTime: 2024-10-15 11:09
  17 + * @Version: todo
  18 + * @date 2024/10/23
  19 + */
  20 +public class ReceiptsOrderApiUtils extends BaseApiUtils {
  21 + private static final Logger log = LoggerFactory.getLogger(ReceiptsOrderApiUtils.class);
  22 +
  23 + public ReceiptsOrderApiUtils(IdentifyInfo identifyInfo) {
  24 + super(identifyInfo);
  25 + }
  26 +
  27 + public boolean getReceiptsOrder(String FBillTypeID, String F_ZDB_text1,String allAmountFor,String F_ZDB_Text667 ) throws Exception {
  28 + String FilterString = """
  29 + FBillTypeID.FNumber = '%s' and F_ZDB_text1 ='%s' and FALLAMOUNTFOR = '%s' and F_ZDB_Text667 = '%s'
  30 + """.formatted(FBillTypeID, F_ZDB_text1,allAmountFor,F_ZDB_Text667);
  31 + var query = new GeneralQueryMessage();
  32 + query.setFilterString(FilterString);
  33 + query.setFieldKeys("FID");
  34 + query.setFormId("AR_RECEIVEBILL");
  35 + List<List<Object>> res = api.executeBillQuery(JsonUtils.toJsonString(query));
  36 + log.info("收款单接口查回数据,json数据:{}", res);
  37 + return res.isEmpty();
  38 + }
  39 +
  40 +
  41 + public void createOnePurchaseOrder(String json, String formId) throws Exception {
  42 + save(createSendMessageWithAudit(json), formId);
  43 + }
  44 +
  45 + private void save(String json, String formId) throws Exception {
  46 + log.info("收款单接口json数据:{}", json);
  47 + String res = api.save(formId, json);
  48 + var repoRet = getRepoRet(res);
  49 + log.info("收款单接口已完成,{}", repoRet);
  50 + }
  51 +}
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/ReceiptsRefundOrderApiUtils.java 0 → 100644
  1 +package com.diligrp.etrade.thirdparty.utils;
  2 +
  3 +import com.diligrp.etrade.core.util.JsonUtils;
  4 +import com.diligrp.etrade.thirdparty.message.GeneralQueryMessage;
  5 +import com.kingdee.bos.webapi.entity.IdentifyInfo;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * 收款单 API 实用程序
  13 + *
  14 + * @author zhangmeiyang
  15 + * @Author: zhangmeiyang
  16 + * @CreateTime: 2024-10-15 11:09
  17 + * @Version: todo
  18 + * @date 2024/10/23
  19 + */
  20 +public class ReceiptsRefundOrderApiUtils extends BaseApiUtils {
  21 + private static final Logger log = LoggerFactory.getLogger(ReceiptsRefundOrderApiUtils.class);
  22 +
  23 + public ReceiptsRefundOrderApiUtils(IdentifyInfo identifyInfo) {
  24 + super(identifyInfo);
  25 + }
  26 +
  27 + public boolean getReceiptsRefundOrder(String FBillTypeID, String F_ZDB_text1,String allAmountFor,String F_ZDB_Text667 ) throws Exception {
  28 + String FilterString = """
  29 + FBillTypeID.FNumber = '%s' and F_ZDB_text1 ='%s' and FALLAMOUNTFOR = '%s' and F_ZDB_Text667 = '%s'
  30 + """.formatted(FBillTypeID, F_ZDB_text1,allAmountFor,F_ZDB_Text667);
  31 + var query = new GeneralQueryMessage();
  32 + query.setFilterString(FilterString);
  33 + query.setFieldKeys("FID");
  34 + query.setFormId("AR_REFUNDBILL");
  35 + List<List<Object>> res = api.executeBillQuery(JsonUtils.toJsonString(query));
  36 + log.info("收款退款单接口查回数据,json数据:{}", res);
  37 + return res.isEmpty();
  38 + }
  39 +
  40 +
  41 + public void createOnePurchaseOrder(String json, String formId) throws Exception {
  42 + save(createSendMessageWithAudit(json), formId);
  43 + }
  44 +
  45 + private void save(String json, String formId) throws Exception {
  46 + log.info("收款收款退款单接口json数据:{}", json);
  47 + String res = api.save(formId, json);
  48 + var repoRet = getRepoRet(res);
  49 + log.info("收款收款退款单接口已完成,{}", repoRet);
  50 + }
  51 +}
etrade-thirdparty/src/main/resources/com/diligrp/etrade/thirdparty/mapper/RecordMapper.xml
@@ -31,4 +31,12 @@ @@ -31,4 +31,12 @@
31 , #{mapping.thirdPartyDataId} 31 , #{mapping.thirdPartyDataId}
32 ) 32 )
33 </insert> 33 </insert>
  34 + <delete id="deleteTheMappingData">
  35 + DELETE FROM `zr_etrade`.`tp_mapping_data`
  36 + WHERE 1=1
  37 + AND market_id = #{mapping.marketId}
  38 + AND system_code = #{mapping.systemCode}
  39 + AND business = #{mapping.business}
  40 + AND system_data_id = #{mapping.systemDataId}
  41 + </delete>
34 </mapper> 42 </mapper>