| | |
| | | package com.ruoyi.web.controller.task; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.utils.util.AIUtil; |
| | | import com.ruoyi.system.vo.TCrmClinicVO; |
| | | import com.ruoyi.web.controller.yuncang.api.trade.LogisticsSyncAck; |
| | | import com.ruoyi.web.controller.yuncang.api.trade.LogisticsSyncQuery; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | * @author xiaochen |
| | | * @date 2023/7/11 8:39 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class TaskUtil { |
| | | |
| | |
| | | private TCrmSupplierVerifyService crmSupplierVerifyService; |
| | | @Autowired |
| | | private TSysOtherConfigService sysOtherConfigService; |
| | | @Autowired |
| | | private TSysCloudConfigService sysCloudConfigService; |
| | | |
| | | // @Scheduled(fixedRate = 86460000) |
| | | // @Scheduled(cron = "10 0 0 * * ?") |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 每小时更新订单云物流状态 |
| | | */ |
| | | @Scheduled(cron = "0 0 * * * ?") |
| | | public void hourUpdateOrderCloudLogisticsStatus() { |
| | | try { |
| | | TSysCloudConfig sysCloudConfig = sysCloudConfigService.getOne(Wrappers.lambdaQuery(TSysCloudConfig.class) |
| | | .eq(TSysCloudConfig::getCloudWarehouse, 1) |
| | | .last("LIMIT 1")); |
| | | |
| | | JSONObject jsonObject = LogisticsSyncQuery.logisticsSyncQuery(sysCloudConfig.getSid(), sysCloudConfig.getAppKey(), |
| | | sysCloudConfig.getAppSecret(), sysCloudConfig.getUrl(), ""); |
| | | if(Objects.nonNull(jsonObject)){ |
| | | JSONArray trades = jsonObject.getJSONArray("trades"); |
| | | Map<String, String> map = new HashMap<>(); |
| | | List<String> tidList = new ArrayList<>(); |
| | | List<Map<String, Object>> logistics_list = new ArrayList<>(); |
| | | for (int i = 0; i < trades.size(); i++) { |
| | | JSONObject trade_order = JSONObject.parseObject(JSONObject.toJSONString(trades.get(i))); |
| | | String rec_id = trade_order.getString("rec_id"); // 主键,用于logistics_sync_ack回写状态 |
| | | String tid = trade_order.getString("tid"); // 原始单号 |
| | | String logistics_no = trade_order.getString("logistics_no"); // 物流单号 |
| | | String logistics_name = trade_order.getString("logistics_name"); // 物流名称 |
| | | map.put(tid, logistics_no); |
| | | tidList.add(tid); |
| | | Map<String, Object> logistics_1 = new HashMap<>(); |
| | | logistics_1.put("rec_id", rec_id); |
| | | logistics_1.put("status", 0); |
| | | logistics_1.put("message", "同步成功"); |
| | | logistics_list.add(logistics_1); |
| | | } |
| | | |
| | | List<TErpProcurement> procurements = erpProcurementService.list(Wrappers.lambdaQuery(TErpProcurement.class) |
| | | .in(TErpProcurement::getProcurementCode, tidList)); |
| | | if(!CollectionUtils.isEmpty(procurements)){ |
| | | for (TErpProcurement procurement : procurements) { |
| | | procurement.setLogisticsNo(map.get(procurement.getProcurementCode())); |
| | | procurement.setStatus(4); |
| | | } |
| | | erpProcurementService.updateBatchById(procurements); |
| | | } |
| | | // 物流同步回写 |
| | | JSONObject logisticsSyncAck = LogisticsSyncAck.logisticsSyncAck(sysCloudConfig.getSid(), sysCloudConfig.getAppKey(), |
| | | sysCloudConfig.getAppSecret(), sysCloudConfig.getUrl(), logistics_list); |
| | | log.info("物流同步成功"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 供应商周期核查 |