|
|
@@ -37,6 +37,7 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.security.Key;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Component
|
|
|
@@ -286,6 +287,89 @@ public class CabinetUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Scheduled(fixedRate = 2*60*60*1000)
|
|
|
+ public void getExpressHistory() throws UnsupportedEncodingException {
|
|
|
+ //获取所有快递柜的快递信息
|
|
|
+ Map<String, JSONObject> cabinetMap = new HashMap<>();
|
|
|
+ SysDictDataBo bo =new SysDictDataBo();
|
|
|
+ bo.setDictType("tbl_sites");
|
|
|
+ List<SysDictDataVo> list = SpringUtils.getBean(ISysDictDataService.class).selectDictDataList(bo);
|
|
|
+ try {
|
|
|
+ list.forEach(item->{
|
|
|
+ if(StrUtil.isNotEmpty(item.getRemark())){
|
|
|
+ JSONArray jsonArray = JSONUtil.parseArray(item.getRemark());
|
|
|
+ jsonArray.forEach(item2->{
|
|
|
+ if(((JSONObject)item2).getStr("type").equals("cabinet")){
|
|
|
+ ((JSONObject) item2).put("location",item.getDictValue());
|
|
|
+ cabinetMap.put( item.getDictLabel(),(JSONObject)item2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(cabinetMap!=null && cabinetMap.size()>0) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<JSONObject> cabinetList = new ArrayList<>();
|
|
|
+ cabinetMap.keySet().forEach(i->{
|
|
|
+ JSONObject c = cabinetMap.get(i);
|
|
|
+ if(c.getStr("location")!=null&&c.getStr("wdcode")!=null){
|
|
|
+ c.put("deviceId", c.getStr("code"));
|
|
|
+ c.put("stationId", c.getStr("wdcode"));
|
|
|
+ c.put("deviceType", "cabinet");
|
|
|
+ cabinetList.add(c);
|
|
|
+ }
|
|
|
+ } );
|
|
|
+
|
|
|
+ SPlatUtils.SysDevice(cabinetList);
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //获取历史
|
|
|
+ try {
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("start_ctime ", DateUtil.format( DateUtil.offsetHour(DateUtil.date(),-2), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ map.put("end_ctime ", DateUtil.format( DateUtil.date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ map.put("page_size", "10000");
|
|
|
+ String data = CabinetUtil.getExpressHistory(map);
|
|
|
+ List<JSONObject> jsonObjectList = new ArrayList<>();
|
|
|
+ JSONArray jsonArray = JSONUtil.parseObj(data).getJSONObject("data").getJSONArray("list");
|
|
|
+ for (JSONObject jsonObject1 : jsonArray.toList(JSONObject.class)) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("deviceId",jsonObject1.getStr("device_number"));
|
|
|
+ json.put("cpCode",jsonObject1.getStr("product_type"));
|
|
|
+
|
|
|
+ json.put("waybillNo",jsonObject1.getStr("order_number"));
|
|
|
+
|
|
|
+ if(jsonObject1.getInt("used_status")==3||jsonObject1.getInt("used_status")==4){
|
|
|
+ if(jsonObject1.getInt("used_status")==3){
|
|
|
+ json.put("scTime",jsonObject1.getStr("save_end_time"));
|
|
|
+ json.put("scType",1);
|
|
|
+ }
|
|
|
+ if(jsonObject1.getInt("used_status")==4){
|
|
|
+ json.put("scType",2);
|
|
|
+ json.put("scTime",jsonObject1.getStr("get_end_time"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jsonObjectList.add(json);
|
|
|
+ }
|
|
|
+ SPlatUtils.pushExpressInfo(jsonObjectList);
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Scheduled(fixedRate = 5*60*1000)
|
|
|
private void resetStationLed() throws UnsupportedEncodingException {
|
|
|
//获取所有站点led
|
|
|
@@ -481,6 +565,16 @@ public class CabinetUtil {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //获取快递历史信息
|
|
|
+ public static String getExpressHistory(Map<String,String> body) throws Exception{
|
|
|
+ int times = (int) (DateUtil.date().getTime()/1000);
|
|
|
+ String str_sign = appid + "=" + times + "=" + appid;
|
|
|
+ str_sign = encrypt(str_sign);
|
|
|
+ String result3= HttpRequest.post(hosts + "/kd/api/v2/search/record_query/").body(JSON.toJSONString(body))
|
|
|
+ .addHeaders(Map.of("timestamp",times+"","Content-Type","application/json","appid",appid,"sign",str_sign)).execute().body();
|
|
|
+ return result3;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|