Commit 82900ba020412c9a516efd644e774d704f21b321
1 parent
ade50705
金蝶对接pt4
Showing
11 changed files
with
166 additions
and
41 deletions
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/component/TransferComponent.java
... | ... | @@ -13,7 +13,6 @@ import org.springframework.util.ObjectUtils; |
13 | 13 | |
14 | 14 | import java.time.LocalDateTime; |
15 | 15 | import java.time.format.DateTimeFormatter; |
16 | -import java.util.Objects; | |
17 | 16 | |
18 | 17 | /** |
19 | 18 | * Transfer Component (传输组件) |
... | ... | @@ -38,7 +37,7 @@ public class TransferComponent { |
38 | 37 | * @param systemCode 系统代码 |
39 | 38 | */ |
40 | 39 | public void transBaseCo(BaseBillCo co, Long marketId, String systemCode) { |
41 | - co.setF_PZCW_Text(Objects.requireNonNull(OperateType.getOperateType(Integer.parseInt(co.getF_PZCW_Text()))).getName()); | |
40 | + co.setF_PZCW_Text(OperateType.getOperateType(Integer.parseInt(co.getF_PZCW_Text())).getName()); | |
42 | 41 | co.setFDATE(LocalDateTime.now().format(DateTimeFormatter.ofPattern(Constants.DATE_TIME_FORMAT))); |
43 | 42 | co.setFCURRENCYID(new FCURRENCYID()); |
44 | 43 | co.setFMAINBOOKSTDCURRID(new FMAINBOOKSTDCURRID()); | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/demarcate/AbstractBillHandler.java
... | ... | @@ -4,13 +4,11 @@ import com.diligrp.etrade.core.util.JsonUtils; |
4 | 4 | import com.diligrp.etrade.thirdparty.component.TransferComponent; |
5 | 5 | import com.diligrp.etrade.thirdparty.domain.co.business.BaseBillCo; |
6 | 6 | import com.diligrp.etrade.thirdparty.domain.dto.BusinessDetailDto; |
7 | +import com.diligrp.etrade.thirdparty.domain.dto.BusinessDto; | |
7 | 8 | import com.diligrp.etrade.thirdparty.domain.dto.ClientDto; |
8 | 9 | import com.diligrp.etrade.thirdparty.domain.model.FEntityDetail; |
9 | 10 | import com.diligrp.etrade.thirdparty.mapper.TransMapper; |
10 | -import com.diligrp.etrade.thirdparty.type.BasicEnum; | |
11 | -import com.diligrp.etrade.thirdparty.type.BusinessEnum; | |
12 | -import com.diligrp.etrade.thirdparty.type.DynamicType; | |
13 | -import com.diligrp.etrade.thirdparty.type.SelectType; | |
11 | +import com.diligrp.etrade.thirdparty.type.*; | |
14 | 12 | import com.diligrp.etrade.thirdparty.utils.PurchaseOrderApiUtils; |
15 | 13 | import com.kingdee.bos.webapi.entity.IdentifyInfo; |
16 | 14 | import jakarta.annotation.Resource; |
... | ... | @@ -20,6 +18,7 @@ import java.util.ArrayList; |
20 | 18 | import java.util.HashMap; |
21 | 19 | import java.util.List; |
22 | 20 | import java.util.Map; |
21 | +import java.util.stream.Collectors; | |
23 | 22 | |
24 | 23 | /** |
25 | 24 | * 抽象业务处理程序 |
... | ... | @@ -83,6 +82,38 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM |
83 | 82 | t.getFSettleTypeID().setFNumber(data.getItemValue()); |
84 | 83 | } |
85 | 84 | |
85 | + /** | |
86 | + * Transfer Dynamic Charge 项目 | |
87 | + * | |
88 | + * @param data 数据 | |
89 | + * @param entity 实体 | |
90 | + */ | |
91 | + protected static <T extends BaseBillCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) { | |
92 | + Map<String, String> relationMap = new HashMap<>(); | |
93 | + Map<String, String> codeMap = new HashMap<>(); | |
94 | + for (BusinessDetailDto dto : data) { | |
95 | + if (!ObjectUtils.isEmpty(dto.getItemRelationId())) { | |
96 | + relationMap.put(String.valueOf(dto.getItemRelationId()), dto.getItemValue()); | |
97 | + } | |
98 | + if (!ObjectUtils.isEmpty(dto.getItemCode())) { | |
99 | + codeMap.put(dto.getItemCode(), dto.getItemValue()); | |
100 | + } | |
101 | + } | |
102 | + List<FEntityDetail> fEntityDetail = entity.getFEntityDetail().stream().filter(f -> ObjectUtils.isEmpty(f.getFCOSTID())).toList(); | |
103 | + fEntityDetail.forEach(e -> { | |
104 | + var costId = e.getFASSETID().getFNUMBER(); | |
105 | + if (relationMap.containsKey(costId)) { | |
106 | + e.getFCOSTID().setFNUMBER(relationMap.get(costId)); | |
107 | + } else if (codeMap.containsKey(costId)) { | |
108 | + e.getFCOSTID().setFNUMBER(relationMap.get(costId)); | |
109 | + } | |
110 | + }); | |
111 | + } | |
112 | + | |
113 | + protected <T extends BaseBillCo> List<T> validDataSync(List<T> ts, Long marketId, String systemCode) { | |
114 | + return ts.stream().filter(t -> !isSync(marketId, systemCode, DynamicType.fromCode(t.getSystemDynamicCode()))).collect(Collectors.toList()); | |
115 | + } | |
116 | + | |
86 | 117 | |
87 | 118 | /** |
88 | 119 | * 固定转换 |
... | ... | @@ -106,34 +137,22 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM |
106 | 137 | } |
107 | 138 | |
108 | 139 | /** |
109 | - * Transfer Dynamic Charge 项目 | |
110 | 140 | * |
111 | - * @param data 数据 | |
112 | - * @param entity 实体 | |
141 | + * 是否同步 | |
142 | + * | |
143 | + * @param marketId 市场 ID | |
144 | + * @param systemCode 系统代码 | |
145 | + * @return boolean | |
113 | 146 | */ |
114 | - protected static <T extends BaseBillCo> void transferDynamicChargeItem(T entity, List<BusinessDetailDto> data) { | |
115 | - Map<String,String> relationMap = new HashMap<>(); | |
116 | - Map<String,String> codeMap = new HashMap<>(); | |
117 | - for (BusinessDetailDto dto : data) { | |
118 | - if (!ObjectUtils.isEmpty(dto.getItemRelationId())){ | |
119 | - relationMap.put(String.valueOf(dto.getItemRelationId()), dto.getItemValue()); | |
120 | - } | |
121 | - if (!ObjectUtils.isEmpty(dto.getItemCode())){ | |
122 | - codeMap.put(dto.getItemCode(), dto.getItemValue()); | |
123 | - } | |
147 | + protected boolean isSync(Long marketId, String systemCode, DynamicType dynamicType) { | |
148 | + BusinessDto businessConfig = transMapper.getBusinessConfig(systemCode, marketId, dynamicType.code); | |
149 | + if (ObjectUtils.isEmpty(businessConfig)) { | |
150 | + return false; | |
124 | 151 | } |
125 | - List<FEntityDetail> fEntityDetail = entity.getFEntityDetail().stream().filter(f -> ObjectUtils.isEmpty(f.getFCOSTID())).toList(); | |
126 | - fEntityDetail.forEach(e->{ | |
127 | - var costId = e.getFASSETID().getFNUMBER(); | |
128 | - if (relationMap.containsKey(costId)){ | |
129 | - e.getFCOSTID().setFNUMBER(relationMap.get(costId)); | |
130 | - }else if (codeMap.containsKey(costId)){ | |
131 | - e.getFCOSTID().setFNUMBER(relationMap.get(costId)); | |
132 | - } | |
133 | - }); | |
152 | + return ObjectUtils.nullSafeEquals(businessConfig.getSyncType(), SyncType.SYNC.code); | |
134 | 153 | } |
135 | 154 | |
136 | - protected void transferDataList(List<T> ts, Long marketId, String systemCode){ | |
155 | + protected void transferDataList(List<T> ts, Long marketId, String systemCode) { | |
137 | 156 | ts.forEach(e -> { |
138 | 157 | DynamicType dynamicType = DynamicType.fromCode(e.getSystemDynamicCode()); |
139 | 158 | transfer(e, marketId, systemCode); |
... | ... | @@ -157,7 +176,7 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM |
157 | 176 | BasicEnum.FINANCIAL_CHANNEL_TYPE_TO_LOWER.code, |
158 | 177 | BasicEnum.FINANCIAL_BUSINESS_TYPE_TO_LOWER.code |
159 | 178 | }; |
160 | - var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(),queryArrays ); | |
179 | + var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(), queryArrays); | |
161 | 180 | Map<String, BusinessDetailDto> map = new HashMap<>(); |
162 | 181 | dynamicParam.forEach(e -> map.computeIfAbsent(e.getCode(), k -> e)); |
163 | 182 | return map; |
... | ... | @@ -173,7 +192,7 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM |
173 | 192 | */ |
174 | 193 | protected Map<String, List<BusinessDetailDto>> getFilteredDynamicDataMulti(DynamicType dynamicType, Long marketId, String systemCode) { |
175 | 194 | var queryArrays = new String[]{BasicEnum.CHARGE_ITEM_TO_LOWER.code}; |
176 | - var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(),queryArrays); | |
195 | + var dynamicParam = transMapper.getFixedWithQueryArrays(systemCode, dynamicType.code, marketId, SelectType.FIXED.getCode(), queryArrays); | |
177 | 196 | Map<String, List<BusinessDetailDto>> map = new HashMap<>(); |
178 | 197 | dynamicParam.forEach(e -> map.computeIfAbsent(e.getCode(), k -> new ArrayList<>()).add(e)); |
179 | 198 | return map; |
... | ... | @@ -187,7 +206,7 @@ public abstract class AbstractBillHandler<T extends BaseBillCo> implements TypeM |
187 | 206 | * @param ts 茨 |
188 | 207 | * @throws Exception 例外 |
189 | 208 | */ |
190 | - protected void sendPurchaseOrder(List<T> ts,Long marketId, String systemCode) throws Exception { | |
209 | + protected void sendPurchaseOrder(List<T> ts, Long marketId, String systemCode) throws Exception { | |
191 | 210 | var identifyInfo = new IdentifyInfo(); |
192 | 211 | ClientDto clientParam = transMapper.getClientParam(systemCode, marketId); |
193 | 212 | identifyInfo.setAppId(clientParam.getApplyId()); | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/domain/dto/BusinessDto.java
0 → 100644
1 | +package com.diligrp.etrade.thirdparty.domain.dto; | |
2 | + | |
3 | +/** | |
4 | + * @Author: zhangmeiyang | |
5 | + * @CreateTime: 2024-10-31 10:32 | |
6 | + * @Version: todo | |
7 | + */ | |
8 | +public class BusinessDto { | |
9 | + private Long id; | |
10 | + private Long marketId; | |
11 | + private String systemCode; | |
12 | + private String code; | |
13 | + private String name; | |
14 | + private String syncType; | |
15 | + | |
16 | + public Long getId() { | |
17 | + return id; | |
18 | + } | |
19 | + | |
20 | + public void setId(Long id) { | |
21 | + this.id = id; | |
22 | + } | |
23 | + | |
24 | + public Long getMarketId() { | |
25 | + return marketId; | |
26 | + } | |
27 | + | |
28 | + public void setMarketId(Long marketId) { | |
29 | + this.marketId = marketId; | |
30 | + } | |
31 | + | |
32 | + public String getSystemCode() { | |
33 | + return systemCode; | |
34 | + } | |
35 | + | |
36 | + public void setSystemCode(String systemCode) { | |
37 | + this.systemCode = systemCode; | |
38 | + } | |
39 | + | |
40 | + public String getCode() { | |
41 | + return code; | |
42 | + } | |
43 | + | |
44 | + public void setCode(String code) { | |
45 | + this.code = code; | |
46 | + } | |
47 | + | |
48 | + public String getName() { | |
49 | + return name; | |
50 | + } | |
51 | + | |
52 | + public void setName(String name) { | |
53 | + this.name = name; | |
54 | + } | |
55 | + | |
56 | + public String getSyncType() { | |
57 | + return syncType; | |
58 | + } | |
59 | + | |
60 | + public void setSyncType(String syncType) { | |
61 | + this.syncType = syncType; | |
62 | + } | |
63 | +} | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/EntranceFeeBillHandler.java
... | ... | @@ -18,9 +18,10 @@ import java.util.List; |
18 | 18 | public class EntranceFeeBillHandler extends AbstractBillHandler<EntranceFeeBillCo> { |
19 | 19 | @Override |
20 | 20 | public void handle(String json, Long marketId, String systemCode) throws Exception{ |
21 | - List<EntranceFeeBillCo> entranceFeeBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {}); | |
22 | - transferDataList(entranceFeeBillCos, marketId, systemCode); | |
23 | - sendPurchaseOrder(entranceFeeBillCos, marketId, systemCode); | |
21 | + List<EntranceFeeBillCo> origin = JsonUtils.fromJsonString(json, new TypeReference<>() {}); | |
22 | + List<EntranceFeeBillCo> ts = validDataSync(origin, marketId, systemCode); | |
23 | + transferDataList(ts, marketId, systemCode); | |
24 | + sendPurchaseOrder(ts, marketId, systemCode); | |
24 | 25 | } |
25 | 26 | |
26 | 27 | @Override | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/SettleBillHandler.java
... | ... | @@ -21,7 +21,7 @@ public class SettleBillHandler extends AbstractBillHandler<SettleBillCo> { |
21 | 21 | public void handle(String json, Long marketId, String systemCode) throws Exception { |
22 | 22 | List<SettleBillCo> settleBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {}); |
23 | 23 | transferDataList(settleBillCos, marketId, systemCode); |
24 | - super.sendPurchaseOrder(settleBillCos,marketId, systemCode); | |
24 | + sendPurchaseOrder(settleBillCos,marketId, systemCode); | |
25 | 25 | } |
26 | 26 | |
27 | 27 | @Override | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/handler/business/WeighingBillHandler.java
... | ... | @@ -18,9 +18,10 @@ import java.util.List; |
18 | 18 | public class WeighingBillHandler extends AbstractBillHandler<WeighingBillCo> { |
19 | 19 | @Override |
20 | 20 | public void handle(String json, Long marketId, String systemCode) throws Exception { |
21 | - List<WeighingBillCo> weighingBillCos = JsonUtils.fromJsonString(json, new TypeReference<>() {}); | |
22 | - transferDataList(weighingBillCos, marketId, systemCode); | |
23 | - sendPurchaseOrder(weighingBillCos, marketId, systemCode); | |
21 | + List<WeighingBillCo> origin = JsonUtils.fromJsonString(json, new TypeReference<>() {}); | |
22 | + List<WeighingBillCo> ts = validDataSync(origin, marketId, systemCode); | |
23 | + transferDataList(ts, marketId, systemCode); | |
24 | + sendPurchaseOrder(ts, marketId, systemCode); | |
24 | 25 | } |
25 | 26 | |
26 | 27 | @Override | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/mapper/TransMapper.java
... | ... | @@ -58,6 +58,16 @@ public interface TransMapper extends MybatisMapperSupport { |
58 | 58 | @DataSource(DataSourceConstants.DS_KEY_SLAVE) |
59 | 59 | BaseConfigDto getBaseConfig(@Param("systemCode") String systemCode, @Param("marketId") Long marketId); |
60 | 60 | |
61 | + /** | |
62 | + * 获取基本配置 | |
63 | + * | |
64 | + * @param systemCode 系统代码 | |
65 | + * @param marketId 市场 ID | |
66 | + * @return {@link BaseConfigDto} | |
67 | + */ | |
68 | + @DataSource(DataSourceConstants.DS_KEY_SLAVE) | |
69 | + BusinessDto getBusinessConfig(@Param("systemCode") String systemCode, @Param("marketId") Long marketId,@Param("dynamicType")String dynamicType); | |
70 | + | |
61 | 71 | |
62 | 72 | /** |
63 | 73 | * 获取客户 | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/type/OperateType.java
1 | 1 | package com.diligrp.etrade.thirdparty.type; |
2 | 2 | |
3 | +import com.diligrp.etrade.thirdparty.error.ThirdPartyException; | |
4 | + | |
3 | 5 | import java.util.ArrayList; |
4 | 6 | import java.util.Arrays; |
5 | 7 | import java.util.List; |
... | ... | @@ -154,7 +156,7 @@ public enum OperateType { |
154 | 156 | return type; |
155 | 157 | } |
156 | 158 | } |
157 | - return null; | |
159 | + throw new ThirdPartyException("错误的操作类型"); | |
158 | 160 | } |
159 | 161 | |
160 | 162 | public static String getName(int code) { | ... | ... |
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/type/SyncType.java
0 → 100644
etrade-thirdparty/src/main/java/com/diligrp/etrade/thirdparty/utils/BillTypeApiUtils.java
... | ... | @@ -37,7 +37,7 @@ public class BillTypeApiUtils extends BaseApiUtils { |
37 | 37 | }); |
38 | 38 | var message = new GeneralSendMessage(); |
39 | 39 | message.setModel(map); |
40 | - message.setAutoSubmitAndAudit(true); | |
40 | +// message.setAutoSubmitAndAudit(true); | |
41 | 41 | return save(JsonUtils.toJsonString(message)); |
42 | 42 | } |
43 | 43 | ... | ... |
etrade-thirdparty/src/main/resources/com/diligrp/etrade/thirdparty/mapper/TransMapper.xml
... | ... | @@ -115,4 +115,20 @@ |
115 | 115 | AND system_code = #{systemCode} |
116 | 116 | AND dict_code = #{billTypeId} |
117 | 117 | </select> |
118 | + <select id="getBusinessConfig" resultType="com.diligrp.etrade.thirdparty.domain.dto.BusinessDto"> | |
119 | + SELECT | |
120 | + id AS id | |
121 | + , market_id AS marketId | |
122 | + , `code` AS code | |
123 | + , system_code AS systemCode | |
124 | + , `name` AS name | |
125 | + , sync_type AS syncType | |
126 | + FROM | |
127 | + `dili-basic-data`.financial_business | |
128 | + WHERE | |
129 | + 1 = 1 | |
130 | + AND market_id = #{marketId} | |
131 | + AND system_code = #{systemCode} | |
132 | + AND `code` = #{dynamicType} | |
133 | + </select> | |
118 | 134 | </mapper> | ... | ... |