From 38036d31f01eb2ee03147a1021d84afa3fcb19bd Mon Sep 17 00:00:00 2001 From: wangqi Date: Tue, 12 Nov 2024 20:38:30 +0800 Subject: [PATCH] feature: update http sync jst job --- .../mybatis/DataSourceConstants.java | 2 +- .../sync/framework/model/AbstractJob.java | 105 ++++++++++++++++++ .../module/http/sync/framework/model/Job.java | 24 ++++ .../carp-module-http-job/pom.xml | 5 + ...gnConfig.java => HttpSyncFeignConfig.java} | 2 +- .../job/config/HttpSyncOpenAPIConfig.java | 34 ++++++ .../job/controller/job/CarpJstController.java | 48 ++++++++ .../module/http/sync/job/enums/JobGroup.java | 36 ++++++ .../module/http/sync/job/enums/JobType.java | 36 ++++++ .../http/sync/job/enums/JstApiEnum.java | 68 ++++++++++++ .../module/http/sync/job/enums/JstJob.java | 40 +++++++ .../http/sync/job/jst/AbstractJstJob.java | 71 ++++++++++++ .../module/http/sync/job/jst/JstJobParam.java | 28 +++++ .../http/sync/job/jst/order/JstOrderJob.java | 47 ++++++++ .../job/repository/entity/jst/JstOrder.java | 3 + .../{ => task}/jst/AbstractJstRootTask.java | 2 +- .../{ => task}/jst/AbstractJstSubTask.java | 2 +- .../jst/order/JstOrderRootTask.java | 4 +- .../{ => task}/jst/order/JstOrderSubTask.java | 56 +++++++++- .../{ => task}/jst/util/JstResultWrapper.java | 2 +- .../sync/job/{ => task}/jst/util/JstUtil.java | 2 +- .../repository/mapper/jst/JstOrderMapper.xml | 3 +- .../jst/response/order/OrdersOutSimpleDO.java | 1 + carp-server/pom.xml | 4 +- .../src/main/resources/application-dev.yml | 34 +++++- .../docker/mysql/init.d/data-service-jst.sql | 13 ++- 26 files changed, 646 insertions(+), 26 deletions(-) create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/AbstractJob.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/Job.java rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/{DefaultFeignConfig.java => HttpSyncFeignConfig.java} (98%) create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncOpenAPIConfig.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/controller/job/CarpJstController.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobGroup.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobType.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstApiEnum.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstJob.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstJob.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/JstJobParam.java create mode 100644 carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderJob.java rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/{ => task}/jst/AbstractJstRootTask.java (95%) rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/{ => task}/jst/AbstractJstSubTask.java (95%) rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/{ => task}/jst/order/JstOrderRootTask.java (90%) rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/{ => task}/jst/order/JstOrderSubTask.java (64%) rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/{ => task}/jst/util/JstResultWrapper.java (96%) rename carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/{ => task}/jst/util/JstUtil.java (96%) diff --git a/carp-framework/carp-framework-mybatis/src/main/java/cn/sliew/carp/framework/mybatis/DataSourceConstants.java b/carp-framework/carp-framework-mybatis/src/main/java/cn/sliew/carp/framework/mybatis/DataSourceConstants.java index b0692847..98243cf6 100644 --- a/carp-framework/carp-framework-mybatis/src/main/java/cn/sliew/carp/framework/mybatis/DataSourceConstants.java +++ b/carp-framework/carp-framework-mybatis/src/main/java/cn/sliew/carp/framework/mybatis/DataSourceConstants.java @@ -23,7 +23,7 @@ public enum DataSourceConstants { public static final String MAPPER_FRAMEWORK_DAG_PACKAGE = "cn.sliew.carp.framework.dag.repository.mapper"; public static final String MAPPER_MODULE_DATASOURCE_PACKAGE = "cn.sliew.carp.module.datasource.repository.mapper"; - public static final String MAPPER_MODULE_HTTP_SYNC_PACKAGE = "cn.sliew.carp.module.http.sync.repository.mapper"; + public static final String MAPPER_MODULE_HTTP_SYNC_PACKAGE = "cn.sliew.carp.module.http.sync.framework.repository.mapper"; public static final String MAPPER_MODULE_KUBERNETES_PACKAGE = "cn.sliew.carp.module.kubernetes.repository.mapper"; public static final String MAPPER_MODULE_PLUGIN_PACKAGE = "cn.sliew.carp.module.plugin.repository.mapper"; public static final String MAPPER_MODULE_SCHEDULER_PACKAGE = "cn.sliew.carp.module.scheduler.repository.mapper"; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/AbstractJob.java b/carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/AbstractJob.java new file mode 100644 index 00000000..a7ffccb2 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/AbstractJob.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.framework.model; + +import cn.sliew.carp.module.http.sync.framework.model.internal.ProcessResult; +import cn.sliew.carp.module.http.sync.framework.model.internal.SimpleJobContext; +import cn.sliew.milky.common.exception.Rethrower; +import cn.sliew.milky.common.util.JacksonUtil; +import lombok.extern.slf4j.Slf4j; +import org.apache.pekko.Done; +import org.apache.pekko.NotUsed; +import org.apache.pekko.actor.typed.ActorSystem; +import org.apache.pekko.actor.typed.SpawnProtocol; +import org.apache.pekko.japi.Pair; +import org.apache.pekko.stream.*; +import org.apache.pekko.stream.javadsl.*; + +import java.util.concurrent.CompletionStage; +import java.util.concurrent.TimeUnit; + +@Slf4j +public abstract class AbstractJob implements Job { + + protected ActorSystem actorSystem; + + public AbstractJob(ActorSystem actorSystem) { + this.actorSystem = actorSystem; + } + + @Override + public void process(String param) { + doExecute(param); + } + + protected void doExecute(Object param) { + SimpleJobContext context = buildJobContext(); + JobProcessor processor = buildJobProcessor(context); + RootTask rootTask = buildRootTask(param); + + Source source = Source.single(rootTask) + .mapConcat(root -> processor.map(root)) + .viaMat(KillSwitches.single(), Keep.right()); + + Flow process = Flow.create() + .map(subTask -> processor.process(subTask)).mapAsync(1, future -> future); + + Flow subTasks = + Flow.fromGraph( + GraphDSL.create( + b -> { + int concurrency = context.getSubTaskParallelism(); + UniformFanOutShape partition = + b.add(Partition.create(concurrency, subTask -> Math.toIntExact(subTask.getIdentifier()) % concurrency)); + UniformFanInShape merge = + b.add(MergeSequence.create(concurrency, result -> result.getSubTask().getIdentifier())); + + for (int i = 0; i < concurrency; i++) { + b.from(partition.out(i)) + .via(b.add(process.async())) + .viaFanIn(merge); + } + + return FlowShape.of(partition.in(), merge.out()); + })); + + Pair> pair = source.via(subTasks) + .log(getJobName()) + .toMat(Sink.foreach(result -> processor.reduce(result)), Keep.both()) + .run(actorSystem); + UniqueKillSwitch killSwitch = pair.first(); + try { + pair.second().toCompletableFuture().get(1, TimeUnit.HOURS); + } catch (Exception e) { + log.error("job 执行异常, job: {}, param: {}", getJobName(), JacksonUtil.toJsonString(param)); + killSwitch.abort(e); + Rethrower.throwAs(e); + } + } + + public abstract String getJobName(); + + protected abstract SimpleJobContext buildJobContext(); + + protected JobProcessor buildJobProcessor(SimpleJobContext context) { + return new DefaultJobProcessor(context); + } + + protected abstract RootTask buildRootTask(Object param); +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/Job.java b/carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/Job.java new file mode 100644 index 00000000..98038a45 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-framework/src/main/java/cn/sliew/carp/module/http/sync/framework/model/Job.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.framework.model; + +public interface Job { + + void process(String param); +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/pom.xml b/carp-modules/carp-module-http-sync/carp-module-http-job/pom.xml index 8cf4e78a..d12d5b2d 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/pom.xml +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/pom.xml @@ -34,6 +34,11 @@ carp-framework-exception + + ${project.parent.groupId} + carp-framework-web + + ${project.parent.groupId} carp-module-http-framework diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/DefaultFeignConfig.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncFeignConfig.java similarity index 98% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/DefaultFeignConfig.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncFeignConfig.java index ccd5187d..8e1cafed 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/DefaultFeignConfig.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncFeignConfig.java @@ -46,7 +46,7 @@ @EnableFeignClients(basePackages = { "cn.sliew.carp.module.http.sync" }) -public class DefaultFeignConfig { +public class HttpSyncFeignConfig { @Autowired private MappingJackson2HttpMessageConverter jacksonConverter; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncOpenAPIConfig.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncOpenAPIConfig.java new file mode 100644 index 00000000..2283275f --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/config/HttpSyncOpenAPIConfig.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.config; + +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class HttpSyncOpenAPIConfig { + + @Bean + public GroupedOpenApi carpHttpSyncModuleOpenApi() { + return GroupedOpenApi.builder().group("Http同步模块") + .pathsToMatch("/api/carp/http-sync/**") + .packagesToScan("cn.sliew.carp.module.http.sync").build(); + } +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/controller/job/CarpJstController.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/controller/job/CarpJstController.java new file mode 100644 index 00000000..ca969cf1 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/controller/job/CarpJstController.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.controller.job; + +import cn.sliew.carp.framework.common.security.annotations.AnonymousAccess; +import cn.sliew.carp.framework.web.response.ApiResponseWrapper; +import cn.sliew.carp.module.http.sync.job.jst.order.JstOrderJob; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@AnonymousAccess +@RestController +@ApiResponseWrapper +@RequestMapping("/api/carp/http-sync/job/jst") +@Tag(name = "Http同步管理-聚水潭") +public class CarpJstController { + + @Autowired + private JstOrderJob jstOrderJob; + + @GetMapping("jstOrderJob") + @Operation(summary = "订单", description = "订单") + public void jstOrderJob(@RequestParam("param") String param) { + jstOrderJob.process(param); + } + +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobGroup.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobGroup.java new file mode 100644 index 00000000..aad50814 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobGroup.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.enums; + +import lombok.Getter; + +@Getter +public enum JobGroup { + + JST("jst", "聚水潭"), + ; + + private String group; + private String desc; + + JobGroup(String group, String desc) { + this.group = group; + this.desc = desc; + } +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobType.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobType.java new file mode 100644 index 00000000..22980948 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JobType.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.enums; + +import lombok.Getter; + +@Getter +public enum JobType { + + NORMAL("normal", "普通任务"), + ; + + private String type; + private String desc; + + JobType(String type, String desc) { + this.type = type; + this.desc = desc; + } +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstApiEnum.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstApiEnum.java new file mode 100644 index 00000000..b95ebad2 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstApiEnum.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.enums; + +import lombok.Getter; + +@Getter +public enum JstApiEnum { + + SHOPS_QUERY("shops.query", "店铺查询"), + WMS_PARTNER_QUERY("wms.partner.query", "仓库查询"), + CATEGORY_QUERY("category.query", "商品类目查询"), + LOGISTIC_QUERY("logistic.query", "发货信息查询"), + COMBINE_SKU_QUERY("combine.sku.query", "组合商品查询"), + INVENTORY_COUNT_QUERY("inventory.count.query", "库存盘点查询"), + INVENTORY_QUERY("inventory.query", "库存查询"), + PACK_QUERY("pack.query", "箱及仓位库存查询-按照修改时间查询"), + MALL_ITEM_QUERY("mall.item.query", "普通商品查询(按款查询)"), + PURCHASEIN_QUERY("purchasein.query", "采购入库查询"), + PURCHASEOUT_QUERY("purchaseout.query", "采购退货查询"), + PURCHASE_QUERY("purchase.query", "采购单查询"), + SKUMAP_QUERY("skumap.query", "商品映射查询"), + SKU_QUERY("sku.query", "普通商品资料查询(按sku查询)"), + SUPPLIER_QUERY("supplier.query", "供应商查询"), + AFTERSALE_RECEIVED_QUERY("aftersale.received.query", "实际收货查询"), + ALLOCATE_QUERY("allocate.query", "调拨单查询"), + ORDER_ACTION_QUERY("order.action.query", "订单操作日志查询"), + OTHER_INOUT_QUERY("other.inout.query", "其它出入库查询"), + JUSHUITAN_INOUT_WATER_QUERY("jushuitan.inout.water.query", "进出仓流水"), + JUSHUITAN_TRACKINFO_QUERY("jushuitan.trackinfo.query", "通过唯一码查询物流日志"), + + ORDERS_SINGLE_QUERY("orders.single.query", "订单查询"), + REFUND_SINGLE_QUERY("refund.single.query", "退货退款查询"), + ORDERS_OUT_SIMPLE_QUERY("orders.out.simple.query", "销售出库查询"), + + ORDERS_HISTORY_QUERY("orders.history.query", "历史订单查询"), + REFUND_HISTORY_QUERY("refund.history.query", "历史退货退款查询"), + JUSHUITAN_SALEOUT_HISTORY_QUERY("jushuitan.saleout.history.query", "历史销售出库单查询"), + + JUSHUITAN_ORDER_LIST_QUERY("jushuitan.order.list.query", "聚水潭奇门云订单"), + JUSHUITAN_REFUND_LIST_QUERY("jushuitan.refund.list.query", "聚水潭奇门云售后"), + JUSHUITAN_SALEOUT_LIST_QUERY("jushuitan.saleout.list.query", "聚水潭奇门云销售出库"), + ; + + private String api; + private String desc; + + JstApiEnum(String api, String desc) { + this.api = api; + this.desc = desc; + } +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstJob.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstJob.java new file mode 100644 index 00000000..eb505007 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/enums/JstJob.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.enums; + +import lombok.Getter; + +@Getter +public enum JstJob { + + NORMAL_ORDERS_SINGLE_QUERY(JobGroup.JST, JobType.NORMAL, JstApiEnum.ORDERS_SINGLE_QUERY, "订单查询"), + ; + + private JobGroup group; + private JobType type; + private JstApiEnum api; + private String desc; + + JstJob(JobGroup group, JobType type, JstApiEnum api, String desc) { + this.group = group; + this.type = type; + this.api = api; + this.desc = desc; + } +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstJob.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstJob.java new file mode 100644 index 00000000..be9ce10b --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstJob.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.jst; + +import cn.sliew.carp.module.http.sync.framework.model.AbstractJob; +import cn.sliew.carp.module.http.sync.framework.model.RootTask; +import cn.sliew.carp.module.http.sync.framework.model.internal.SimpleJobContext; +import cn.sliew.carp.module.http.sync.job.enums.JstJob; +import cn.sliew.carp.module.http.sync.job.repository.entity.jst.JstAuth; +import cn.sliew.carp.module.http.sync.job.repository.mapper.jst.JstAuthMapper; +import cn.sliew.carp.module.http.sync.job.task.jst.AbstractJstRootTask; +import cn.sliew.milky.common.util.JacksonUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.apache.pekko.actor.typed.ActorSystem; +import org.apache.pekko.actor.typed.SpawnProtocol; + +import static cn.sliew.milky.common.check.Ensures.checkState; + +public abstract class AbstractJstJob extends AbstractJob { + + private final JstAuthMapper jstAuthMapper; + + public AbstractJstJob(ActorSystem actorSystem, JstAuthMapper jstAuthMapper) { + super(actorSystem); + this.jstAuthMapper = jstAuthMapper; + } + + @Override + public String getJobName() { + return String.format("%s.%s.%s", getJstJob().getGroup().getGroup(), getJstJob().getApi().getApi(), getJstJob().getType().getType()); + } + + @Override + protected SimpleJobContext buildJobContext() { + return new SimpleJobContext(); + } + + @Override + protected RootTask buildRootTask(Object param) { + JstJobParam jstJobParam = JacksonUtil.parseJsonString((String) param, JstJobParam.class); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(JstAuth.class) + .eq(JstAuth::getAppKey, jstJobParam.getAppKey()) + .eq(JstAuth::getCompany, jstJobParam.getCompany()); + + JstAuth jstAuth = jstAuthMapper.selectOne(queryWrapper); + checkState(jstAuth != null); + + return buildJstRootTask(jstAuth); + } + + protected abstract JstJob getJstJob(); + + protected abstract AbstractJstRootTask buildJstRootTask(JstAuth jstAuth); +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/JstJobParam.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/JstJobParam.java new file mode 100644 index 00000000..90cb66fb --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/JstJobParam.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.jst; + +import lombok.Data; + +@Data +public class JstJobParam { + + private String appKey; + private String company; +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderJob.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderJob.java new file mode 100644 index 00000000..ce217ec1 --- /dev/null +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderJob.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.http.sync.job.jst.order; + +import cn.sliew.carp.module.http.sync.job.enums.JstJob; +import cn.sliew.carp.module.http.sync.job.jst.AbstractJstJob; +import cn.sliew.carp.module.http.sync.job.repository.entity.jst.JstAuth; +import cn.sliew.carp.module.http.sync.job.repository.mapper.jst.JstAuthMapper; +import cn.sliew.carp.module.http.sync.job.task.jst.AbstractJstRootTask; +import cn.sliew.carp.module.http.sync.job.task.jst.order.JstOrderRootTask; +import org.apache.pekko.actor.typed.ActorSystem; +import org.apache.pekko.actor.typed.SpawnProtocol; +import org.springframework.stereotype.Component; + +@Component +public class JstOrderJob extends AbstractJstJob { + + public JstOrderJob(ActorSystem actorSystem, JstAuthMapper jstAuthMapper) { + super(actorSystem, jstAuthMapper); + } + + @Override + protected JstJob getJstJob() { + return JstJob.NORMAL_ORDERS_SINGLE_QUERY; + } + + @Override + protected AbstractJstRootTask buildJstRootTask(JstAuth jstAuth) { + return new JstOrderRootTask(System.currentTimeMillis(), jstAuth); + } +} diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/repository/entity/jst/JstOrder.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/repository/entity/jst/JstOrder.java index a00b5cf2..e68fe783 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/repository/entity/jst/JstOrder.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/repository/entity/jst/JstOrder.java @@ -34,6 +34,9 @@ public class JstOrder extends BaseSyncMeta { @TableField("app_key") private String appKey; + @TableField("company") + private String company; + @TableField("is_cod") private String isCod; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstRootTask.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/AbstractJstRootTask.java similarity index 95% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstRootTask.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/AbstractJstRootTask.java index f249968e..72ec715a 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstRootTask.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/AbstractJstRootTask.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package cn.sliew.carp.module.http.sync.job.jst; +package cn.sliew.carp.module.http.sync.job.task.jst; import cn.sliew.carp.module.http.sync.framework.model.AbstractRootTask; import cn.sliew.carp.module.http.sync.job.repository.entity.jst.JstAuth; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstSubTask.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/AbstractJstSubTask.java similarity index 95% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstSubTask.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/AbstractJstSubTask.java index 51f375c9..baec8cde 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/AbstractJstSubTask.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/AbstractJstSubTask.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package cn.sliew.carp.module.http.sync.job.jst; +package cn.sliew.carp.module.http.sync.job.task.jst; import cn.sliew.carp.module.http.sync.framework.model.AbstractSubTask; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderRootTask.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/order/JstOrderRootTask.java similarity index 90% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderRootTask.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/order/JstOrderRootTask.java index bbfaf5f5..a96ace1a 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderRootTask.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/order/JstOrderRootTask.java @@ -16,9 +16,9 @@ * limitations under the License. */ -package cn.sliew.carp.module.http.sync.job.jst.order; +package cn.sliew.carp.module.http.sync.job.task.jst.order; -import cn.sliew.carp.module.http.sync.job.jst.AbstractJstRootTask; +import cn.sliew.carp.module.http.sync.job.task.jst.AbstractJstRootTask; import cn.sliew.carp.module.http.sync.job.repository.entity.jst.JstAuth; public class JstOrderRootTask extends AbstractJstRootTask { diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderSubTask.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/order/JstOrderSubTask.java similarity index 64% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderSubTask.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/order/JstOrderSubTask.java index b0a8a96e..ea82bef9 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/order/JstOrderSubTask.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/order/JstOrderSubTask.java @@ -16,23 +16,29 @@ * limitations under the License. */ -package cn.sliew.carp.module.http.sync.job.jst.order; +package cn.sliew.carp.module.http.sync.job.task.jst.order; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; import cn.sliew.carp.framework.exception.SliewException; import cn.sliew.carp.module.http.sync.framework.model.FetchResult; import cn.sliew.carp.module.http.sync.framework.model.internal.SimpleJobContext; -import cn.sliew.carp.module.http.sync.job.jst.AbstractJstSubTask; -import cn.sliew.carp.module.http.sync.job.jst.util.JstResultWrapper; -import cn.sliew.carp.module.http.sync.job.jst.util.JstUtil; import cn.sliew.carp.module.http.sync.job.remote.JstRemoteService; +import cn.sliew.carp.module.http.sync.job.repository.entity.jst.JstOrder; import cn.sliew.carp.module.http.sync.job.repository.mapper.jst.JstOrderMapper; +import cn.sliew.carp.module.http.sync.job.task.jst.AbstractJstSubTask; +import cn.sliew.carp.module.http.sync.job.task.jst.util.JstResultWrapper; +import cn.sliew.carp.module.http.sync.job.task.jst.util.JstUtil; import cn.sliew.carp.module.http.sync.remote.jst.request.order.OrdersSingleQuery; import cn.sliew.carp.module.http.sync.remote.jst.response.JstNewResult; import cn.sliew.carp.module.http.sync.remote.jst.response.order.JstOrdersResult; import cn.sliew.carp.module.http.sync.remote.jst.response.order.OrdersSingleDO; import cn.sliew.milky.common.util.JacksonUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.pekko.japi.Pair; import org.apache.pekko.stream.javadsl.Source; @@ -97,6 +103,48 @@ protected JstOrdersResult requestRemote(SimpleJobContext context, OrdersSingleQu @Override protected void persistData(SimpleJobContext context, OrdersSingleQuery request, JstOrdersResult response) { + if (CollectionUtils.isEmpty(response.getDatas())) { + return; + } + response.getDatas().forEach(data -> upsert(request, data)); + } + + private void upsert(OrdersSingleQuery request, OrdersSingleDO data) { + JstOrder record = convert(request, data); + + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(JstOrder.class) + .eq(JstOrder::getAppKey, record.getAppKey()) + .eq(JstOrder::getCompany, record.getCompany()) + .eq(JstOrder::getOId, record.getOId()) + .select(JstOrder::getId); + + JstOrder jstOrder = jstOrderMapper.selectOne(queryWrapper); + if (jstOrder != null) { + record.setId(jstOrder.getId()); + record.setEditor("sync-task"); + jstOrderMapper.updateById(record); + } else { + record.setCreator("sync-task"); + record.setEditor("sync-task"); + jstOrderMapper.insert(record); + } + } + private JstOrder convert(OrdersSingleQuery request, OrdersSingleDO data) { + JstOrder record = BeanUtil.copyProperties(data, JstOrder.class); + if (CollectionUtils.isEmpty(data.getItems()) == false) { + record.setItems(JacksonUtil.toJsonString(data.getItems())); + } + if (org.springframework.util.CollectionUtils.isEmpty(data.getPays()) == false) { + record.setPays(JacksonUtil.toJsonString(data.getPays())); + } + if (org.springframework.util.CollectionUtils.isEmpty(data.getRawSoIds()) == false) { + record.setRawSoIds(JacksonUtil.toJsonString(data.getRawSoIds())); + } + record.setSyncStartTime(DateUtil.parse(request.getModifiedBegin(), DatePattern.NORM_DATETIME_PATTERN).toJdkDate()); + record.setSyncEndTime(DateUtil.parse(request.getModifiedEnd(), DatePattern.NORM_DATETIME_PATTERN).toJdkDate()); + record.setSyncPageIndex(request.getPageIndex()); + record.setSyncPageSize(request.getPageSize()); + return record; } } diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/util/JstResultWrapper.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/util/JstResultWrapper.java similarity index 96% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/util/JstResultWrapper.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/util/JstResultWrapper.java index 6d2822e5..d67fb65d 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/util/JstResultWrapper.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/util/JstResultWrapper.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package cn.sliew.carp.module.http.sync.job.jst.util; +package cn.sliew.carp.module.http.sync.job.task.jst.util; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/util/JstUtil.java b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/util/JstUtil.java similarity index 96% rename from carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/util/JstUtil.java rename to carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/util/JstUtil.java index e49cf8c3..34ea1624 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/jst/util/JstUtil.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/java/cn/sliew/carp/module/http/sync/job/task/jst/util/JstUtil.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package cn.sliew.carp.module.http.sync.job.jst.util; +package cn.sliew.carp.module.http.sync.job.task.jst.util; import cn.hutool.core.bean.BeanUtil; import cn.sliew.carp.module.http.sync.remote.jst.response.JstResult; diff --git a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/resources/cn/sliew/carp/module/http/sync/job/repository/mapper/jst/JstOrderMapper.xml b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/resources/cn/sliew/carp/module/http/sync/job/repository/mapper/jst/JstOrderMapper.xml index 23ffbd57..e7149171 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/resources/cn/sliew/carp/module/http/sync/job/repository/mapper/jst/JstOrderMapper.xml +++ b/carp-modules/carp-module-http-sync/carp-module-http-job/src/main/resources/cn/sliew/carp/module/http/sync/job/repository/mapper/jst/JstOrderMapper.xml @@ -27,6 +27,7 @@ + @@ -130,7 +131,7 @@ create_time, editor, update_time, - app_key, is_cod, l_id, send_date, pay_date, freight, receiver_address, receiver_district, wms_co_id, logistics_company, as_id, free_amount, shop_name, question_type, outer_pay_id, so_id, `type`, order_from, `status`, pay_amount, shop_buyer_id, open_id, shop_status, receiver_mobile, receiver_phone, order_date, question_desc, receiver_city, receiver_state, receiver_name, o_id, shop_id, co_id, remark, drp_co_id_from, modified, labels, paid_amount, currency, buyer_message, lc_id, invoice_title, invoice_type, buyer_tax_no, creator_name, plan_delivery_date, node, receiver_town, drp_co_id_to, shop_site, un_lid, end_time, receiver_country, receiver_zip, seller_flag, receiver_email, referrer_id, referrer_name, created, pays, items, skus, f_weight, weight, ts, buyer_id, buyer_paid_amount, seller_income_amount, chosen_channel, link_o_id, merge_so_id, shipment, sign_time, cb_finances, f_freight, batch_id, produced_date, tem_ext_data, discount_rate, tag, amount, is_split, is_merge, glasses, outer_as_id, outer_so_id, __raw_so_ids__, ext_datas, raw_so_id, drp_from, drp_to, sync_start_time, sync_end_time, sync_page_index, sync_page_size + app_key, company, is_cod, l_id, send_date, pay_date, freight, receiver_address, receiver_district, wms_co_id, logistics_company, as_id, free_amount, shop_name, question_type, outer_pay_id, so_id, `type`, order_from, `status`, pay_amount, shop_buyer_id, open_id, shop_status, receiver_mobile, receiver_phone, order_date, question_desc, receiver_city, receiver_state, receiver_name, o_id, shop_id, co_id, remark, drp_co_id_from, modified, labels, paid_amount, currency, buyer_message, lc_id, invoice_title, invoice_type, buyer_tax_no, creator_name, plan_delivery_date, node, receiver_town, drp_co_id_to, shop_site, un_lid, end_time, receiver_country, receiver_zip, seller_flag, receiver_email, referrer_id, referrer_name, created, pays, items, skus, f_weight, weight, ts, buyer_id, buyer_paid_amount, seller_income_amount, chosen_channel, link_o_id, merge_so_id, shipment, sign_time, cb_finances, f_freight, batch_id, produced_date, tem_ext_data, discount_rate, tag, amount, is_split, is_merge, glasses, outer_as_id, outer_so_id, __raw_so_ids__, ext_datas, raw_so_id, drp_from, drp_to, sync_start_time, sync_end_time, sync_page_index, sync_page_size diff --git a/carp-modules/carp-module-http-sync/carp-module-http-remote/carp-module-http-remote-jst/src/main/java/cn/sliew/carp/module/http/sync/remote/jst/response/order/OrdersOutSimpleDO.java b/carp-modules/carp-module-http-sync/carp-module-http-remote/carp-module-http-remote-jst/src/main/java/cn/sliew/carp/module/http/sync/remote/jst/response/order/OrdersOutSimpleDO.java index d101ef8d..99b3c602 100644 --- a/carp-modules/carp-module-http-sync/carp-module-http-remote/carp-module-http-remote-jst/src/main/java/cn/sliew/carp/module/http/sync/remote/jst/response/order/OrdersOutSimpleDO.java +++ b/carp-modules/carp-module-http-sync/carp-module-http-remote/carp-module-http-remote-jst/src/main/java/cn/sliew/carp/module/http/sync/remote/jst/response/order/OrdersOutSimpleDO.java @@ -24,6 +24,7 @@ import lombok.Setter; import java.math.BigDecimal; +import java.util.List; import java.util.Map; @Getter diff --git a/carp-server/pom.xml b/carp-server/pom.xml index 2e8b3bbd..47acff79 100644 --- a/carp-server/pom.xml +++ b/carp-server/pom.xml @@ -42,11 +42,11 @@ ${project.parent.groupId} - carp-module-application-vela + carp-module-datasource ${project.parent.groupId} - carp-module-datasource + carp-module-http-job ${project.parent.groupId} diff --git a/carp-server/src/main/resources/application-dev.yml b/carp-server/src/main/resources/application-dev.yml index 4b54044f..b80a4331 100644 --- a/carp-server/src/main/resources/application-dev.yml +++ b/carp-server/src/main/resources/application-dev.yml @@ -16,11 +16,35 @@ # spring: - datasource.carp: - driver-class-name: com.mysql.cj.jdbc.Driver - jdbc-url: jdbc:mysql://${MYSQL_HOST:127.0.0.1}:${MYSQL_PORT:3306}/carp?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useAffectedRows=true - username: ${MYSQL_USERNAME:root} - password: ${MYSQL_PASSWORD:123456} + datasource: + carp: + minimum-idle: 1 + maximum-pool-size: 5 + auto-commit: true + idle-timeout: 600000 + pool-name: carp + max-lifetime: 900000 + connection-timeout: 10000 + connection-test-query: SELECT 1 + validation-timeout: 1000 + driver-class-name: com.mysql.cj.jdbc.Driver + jdbc-url: jdbc:mysql://${MYSQL_HOST:127.0.0.1}:${MYSQL_PORT:3306}/carp?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useAffectedRows=true + username: ${MYSQL_USERNAME:root} + password: ${MYSQL_PASSWORD:123456} + dataservice: + minimum-idle: 1 + maximum-pool-size: 5 + auto-commit: true + idle-timeout: 600000 + pool-name: carp + max-lifetime: 900000 + connection-timeout: 10000 + connection-test-query: SELECT 1 + validation-timeout: 1000 + driver-class-name: com.mysql.cj.jdbc.Driver + jdbc-url: jdbc:mysql://${MYSQL_HOST:127.0.0.1}:${MYSQL_PORT:3306}/data_service?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useAffectedRows=true + username: ${MYSQL_USERNAME:root} + password: ${MYSQL_PASSWORD:123456} quartz: properties: org.quartz: diff --git a/tools/docker/mysql/init.d/data-service-jst.sql b/tools/docker/mysql/init.d/data-service-jst.sql index daea3e0b..820e16b8 100644 --- a/tools/docker/mysql/init.d/data-service-jst.sql +++ b/tools/docker/mysql/init.d/data-service-jst.sql @@ -18,14 +18,15 @@ create table `jst_auth` `editor` varchar(32) comment '修改人', `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', primary key (`id`), - unique key `uniq_app` (`app_key`) + unique key `uniq_app` (`app_key`, `company`) ) engine = innodb comment='聚水潭 授权信息'; drop table if exists jst_order; create table `jst_order` ( - `id` bigint not null auto_increment comment '自增主键', - `app_key` varchar(64) not null comment '聚水潭应用 key', + `id` bigint not null auto_increment comment '自增主键', + `app_key` varchar(64) not null comment '聚水潭应用 key', + `company` varchar(255) not null comment '公司名称', `is_cod` varchar(8) comment '是否货到付款', `l_id` varchar(256) comment '快递单号', `send_date` datetime comment '发货日期', @@ -121,9 +122,9 @@ create table `jst_order` `sync_page_index` int(11) comment '同步元信息-页数', `sync_page_size` int(11) comment '同步元信息-条数', `creator` varchar(32) comment '创建人', - `create_time` datetime not null default current_timestamp comment '创建时间', + `create_time` datetime not null default current_timestamp comment '创建时间', `editor` varchar(32) comment '修改人', - `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', + `update_time` datetime not null default current_timestamp on update current_timestamp comment '更新时间', primary key (`id`), - unique key `uniq_o_id` (`app_key`,`o_id`) + unique key `uniq_o_id` (`app_key`,`company`,`o_id`) ) engine = innodb comment='聚水潭 订单查询(非淘系订单查询)'; \ No newline at end of file