|
|
@@ -10,6 +10,7 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.redis.utils.CacheUtils;
|
|
|
@@ -19,10 +20,13 @@ import org.dromara.system.domain.TblCarInfo;
|
|
|
import org.dromara.system.domain.bo.SysDictDataBo;
|
|
|
import org.dromara.system.domain.bo.TblCarInfoBo;
|
|
|
import org.dromara.system.domain.bo.TblCarScheduleBo;
|
|
|
+import org.dromara.system.domain.bo.TblExpressStaticsBo;
|
|
|
import org.dromara.system.domain.vo.SysDictDataVo;
|
|
|
import org.dromara.system.domain.vo.TblCarInfoVo;
|
|
|
import org.dromara.system.domain.vo.TblCarScheduleVo;
|
|
|
+import org.dromara.system.domain.vo.TblExpressStaticsVo;
|
|
|
import org.dromara.system.service.ISysDictDataService;
|
|
|
+import org.dromara.system.service.ITblExpressStaticsService;
|
|
|
import org.dromara.system.service.impl.TblCarInfoServiceImpl;
|
|
|
import org.dromara.system.service.impl.TblCarScheduleServiceImpl;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -35,10 +39,8 @@ import javax.crypto.Cipher;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.security.Key;
|
|
|
import java.text.DateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Component
|
|
|
public class CabinetUtil {
|
|
|
@@ -46,6 +48,9 @@ public class CabinetUtil {
|
|
|
@Autowired
|
|
|
ISysDictDataService sysDictDataService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ITblExpressStaticsService tblExpressStaticsService;
|
|
|
+
|
|
|
private final static String appid = "bw_open_express_A8C848769E5C04E0";
|
|
|
private final static String appkey = "5AFC6E07CFCF4A359B775D1416A9799A";
|
|
|
|
|
|
@@ -191,8 +196,6 @@ public class CabinetUtil {
|
|
|
}catch (Exception e){
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if(cabinetList!=null && cabinetList.size()>0){
|
|
|
cabinetList.forEach(item->{
|
|
|
try {
|
|
|
@@ -274,6 +277,30 @@ public class CabinetUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Scheduled(fixedRate = 60*60*1000)
|
|
|
+ public R<TblExpressStaticsBo> getData() {
|
|
|
+ try{
|
|
|
+ String month = getLastMonth();
|
|
|
+ TblExpressStaticsBo bo = new TblExpressStaticsBo();
|
|
|
+ bo.setMonth(month);
|
|
|
+ bo.setUserId(1L);
|
|
|
+ bo.setData(getExpressDeliveryStatistics("19559316717",month));
|
|
|
+ TblExpressStaticsBo query = new TblExpressStaticsBo();
|
|
|
+ query.setMonth(month);
|
|
|
+ query.setUserId(1L);
|
|
|
+ List<TblExpressStaticsVo> list = tblExpressStaticsService.queryList(query);
|
|
|
+ if(list.size() > 0){
|
|
|
+ bo.setId(list.get(0).getId());
|
|
|
+ tblExpressStaticsService.updateByBo(bo);
|
|
|
+ }else{
|
|
|
+ tblExpressStaticsService.insertByBo(bo);
|
|
|
+ }
|
|
|
+ return R.ok(bo);
|
|
|
+ }catch (Exception e){
|
|
|
+ return R.fail(e.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取柜子信息
|
|
|
public static String getCabinetInfo(String cabinetCode) throws Exception {
|
|
|
int times = (int) (DateUtil.date().getTime()/1000);
|
|
|
@@ -315,13 +342,33 @@ public class CabinetUtil {
|
|
|
int times = (int) (DateUtil.date().getTime()/1000);
|
|
|
String str_sign = appid + "=" + times + "=" + appid;
|
|
|
str_sign = encrypt(str_sign);
|
|
|
- String result3= HttpRequest.post(hosts + "/api/v2/search/express_delivery_statistics/").body(JSON.toJSONString(Map.of("哈哈哈哈",courierMobile,"market_id","3219","search_month",month)))
|
|
|
+ log.info(JSON.toJSONString(Map.of("timestamp",times+"","Content-Type","application/json","appid",appid,"sign",str_sign)));
|
|
|
+ log.info(JSON.toJSONString(Map.of("courier_mobile",courierMobile,"market_id",3219,"search_month",month)));
|
|
|
+ String result3= HttpRequest.post(hosts + "/kd/api/v2/search/express_delivery_statistics/").body(JSON.toJSONString(Map.of("courier_mobile",courierMobile,"market_id",3219,"search_month",month)))
|
|
|
.addHeaders(Map.of("timestamp",times+"","Content-Type","application/json","appid",appid,"sign",str_sign))
|
|
|
.execute().body();
|
|
|
return result3;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static String getLastMonth() {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
|
|
|
+ Date date = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ // 设置为当前时间
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH,-1);
|
|
|
+ // 设置为上一个月
|
|
|
+ //calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
|
|
|
+ date = calendar.getTime();
|
|
|
+ return format.format(date);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String args[]) throws Exception {
|
|
|
+ log.info(getExpressDeliveryStatistics("19559316717","2025-01"));
|
|
|
+ }
|
|
|
+
|
|
|
// 获取柜子盒子
|
|
|
public static String getCabinetBoxs(String cabinetCode) throws Exception {
|
|
|
int times = (int) (DateUtil.date().getTime()/1000);
|