Browse Source

绘图接口

lmstack 3 years ago
parent
commit
d42c912189

+ 22 - 3
src/main/java/cn/fastfun/controller/api/ApiAssetProfitController.java

@@ -2,6 +2,7 @@ package cn.fastfun.controller.api;
 
 import cn.fastfun.controller.dto.asset.BaseInfoDTO;
 import cn.fastfun.controller.dto.asset.RentInfoDTO;
+import cn.fastfun.controller.dto.asset.RentInfoFigureDTO;
 import cn.fastfun.controller.param.*;
 import cn.fastfun.service.impl.AppAssetProfitServiceImpl;
 import com.bridge.dto.*;
@@ -36,20 +37,38 @@ public class ApiAssetProfitController {
         return ApiDTO.ok("成功", baseInfo);
     }
 
-    @ApiOperation(value = "其他信息")
+    @ApiOperation(value = "其他信息列表")
     @RequestMapping(value = "getProfitInfo", method = RequestMethod.POST)
-    public ApiDTO getAssetProfitInfo(@RequestBody @ApiParam(name = "设备信息对象", value = "传入json格式", required = true) AssetProfitParam param) {
+    public ApiDTO getAssetProfitInfo(@RequestBody @ApiParam(name = "设备信息对象", value = "传入json格式", required = true) AssetProfitParam param) throws Exception {
 
         // 租赁信息
         Object response = null;
         if (param.getTableOrder() != null && param.getTableOrder().equals(1)){
-            RentInfoDTO rentInfoDTO = appAssetService.getRentInfo(param.getSn(), param.getTimeStart().toString(), param.getTimeEnd().toString(), param.getLength(), param.getIndex());
+            param.setFigureOrNot(false);
+            Object rentInfoDTO = appAssetService.getRentInfo(param);
             response = (RentInfoDTO) rentInfoDTO;
         }
 
         return ApiDTO.ok("成功", response);
     }
 
+    @ApiOperation(value = "其他信息绘图")
+    @RequestMapping(value = "getProfitInfoFigure", method = RequestMethod.POST)
+    public ApiDTO getAssetProfitInfoFigure(@RequestBody @ApiParam(name = "设备信息对象", value = "传入json格式", required = true) AssetProfitParam param) throws Exception {
+
+        // 租赁信息
+        Object response = null;
+        if (param.getTableOrder() != null && param.getTableOrder().equals(1)){
+            param.setFigureOrNot(true);
+            param.setIndex(0);
+            param.setLength(0);
+            Object rentInfoFigureDTO = appAssetService.getRentInfo(param);
+            response = (RentInfoFigureDTO) rentInfoFigureDTO;
+        }
+
+        return ApiDTO.ok("成功", response);
+    }
+
 
 
 

+ 24 - 7
src/main/java/cn/fastfun/controller/dto/asset/BaseInfoDTO.java

@@ -1,10 +1,14 @@
 package cn.fastfun.controller.dto.asset;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreType;
+import lombok.Data;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 @Setter
 @Getter
@@ -33,25 +37,25 @@ public class BaseInfoDTO {
     private String voltPlatform;
 
     // 容量
-    private Float capacity;
+    private Integer capacity;
 
     // 生产时间
     private String productTime;
 
     // 发货时间
-    private String deliverTime;
+//    private String deliverTime;
 
     // 入库时间
-    private String storageTime;
+//    private String storageTime;
 
     // 投营时间
     private String operationTime;
 
     // 首次租赁时间
-    private String firstRentTime;
+//    private String firstRentTime;
 
     // 回调时间
-    private String recallTime;
+//    private String recallTime;
 
     // 采购价格
     private BigDecimal price;
@@ -63,10 +67,23 @@ public class BaseInfoDTO {
     private String region;
 
     // 已采购天数
-    private Integer purchaseDay;
+    private Long purchaseDay;
 
     // 已投营天数
-    private Integer operationDay;
+    private Long operationDay;
+
+    @JsonIgnoreType
+    @Data
+    public static class TimeLine{
+        // 时间
+        private String time;
+
+        // 动作
+        private String title;
+
+    }
+
+    private List<TimeLine> timeLine = new ArrayList<>();
 
 
 

+ 5 - 1
src/main/java/cn/fastfun/controller/dto/asset/BasicAssetDto.java

@@ -1,9 +1,11 @@
 package cn.fastfun.controller.dto.asset;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.List;
 
 /**
  * 资产基础信息
@@ -85,10 +87,12 @@ public class BasicAssetDto implements Serializable {
     /**
      * 生产时间:2021-8-6
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private String createTime;
     /**
      * 投营时间:2021-8-15
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private String operationTime;
     /**
      * 采购价格:3250元
@@ -107,7 +111,7 @@ public class BasicAssetDto implements Serializable {
      */
     private String location;
     /**
-     * 投营地区名称:北京
+     * 投营地区名称
      */
     private String locationText;
 }

+ 35 - 0
src/main/java/cn/fastfun/controller/dto/asset/DeviceLineDto.java

@@ -0,0 +1,35 @@
+package cn.fastfun.controller.dto.asset;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author user
+ */
+@Data
+public class DeviceLineDto {
+    /**
+     * 设备sn
+     */
+    private String sn;
+    /**
+     * 事件发生时间
+     */
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private String actionTime;
+    /**
+     * 事件动作编码
+     */
+    private String action;
+    /**
+     * 事件动作名称
+     */
+    private String actionName;
+
+    /**
+     * 调拨接收对象
+     */
+    private String destination;
+}

+ 39 - 0
src/main/java/cn/fastfun/controller/dto/asset/MarketingInformationDto.java

@@ -0,0 +1,39 @@
+package cn.fastfun.controller.dto.asset;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author user
+ */
+@Data
+public class MarketingInformationDto {
+    /**
+     * 设备sn
+     */
+    private String sn;
+    /**
+     * 使用时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date usedTime;
+    /**
+     * 类型编码 1 优惠券 2 其他
+     */
+    private String type;
+    /**
+     * 类型名称
+     */
+    private String typeName;
+    /**
+     * 金额
+     */
+    private BigDecimal amount;
+    /**
+     * 说明
+     */
+    private String remark;
+}

+ 27 - 0
src/main/java/cn/fastfun/controller/dto/asset/RentAndDepositChartDto.java

@@ -0,0 +1,27 @@
+package cn.fastfun.controller.dto.asset;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author user
+ */
+@Data
+public class RentAndDepositChartDto {
+    /**
+     * 事件发生时间
+     */
+    @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8")
+    private String month;
+    /**
+     * 总金额
+     */
+    private BigDecimal amountMonth;
+    /**
+     * 1 押金-收 2押金-支 3租金-收 4租金-支 5丢失保障金
+     */
+    private Integer type;
+}

+ 40 - 0
src/main/java/cn/fastfun/controller/dto/asset/RentAndDepositDto.java

@@ -0,0 +1,40 @@
+package cn.fastfun.controller.dto.asset;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author user
+ */
+@Data
+public class RentAndDepositDto {
+    /**
+     * 设备sn
+     */
+    private String sn;
+    /**
+     * 事件发生时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private String orderTime;
+    /**
+     * 金额
+     */
+    private BigDecimal amount;
+    /**
+     * 事件动作名称
+     */
+    private String orderNo;
+    /**
+     * 1 押金-收 2押金-支 3租金-收 4租金-支 5丢失保障金
+     */
+    private Integer type;
+
+    /**
+     * 说明
+     */
+    private String remark;
+}

+ 6 - 2
src/main/java/cn/fastfun/controller/dto/asset/RentInfoDTO.java

@@ -38,8 +38,11 @@ public class RentInfoDTO {
 
     private List<AllInfo> allInfoList = new ArrayList<>();
 
-    // 当前租期
-    private String time;
+    // 当前租期开始
+    private String orderStartTime;
+
+    // 当前租期结束
+    private String orderEndTime;
 
     // 当前租金
     private BigDecimal rental;
@@ -60,4 +63,5 @@ public class RentInfoDTO {
     private BigDecimal netRental;
 
 
+
 }

+ 26 - 0
src/main/java/cn/fastfun/controller/dto/asset/RentInfoFigureDTO.java

@@ -0,0 +1,26 @@
+package cn.fastfun.controller.dto.asset;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreType;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+public class RentInfoFigureDTO {
+    private static final long serialVersionUID = -1821068317406106793L;
+
+    // 时间
+    private List<String> timeList = new ArrayList<>();
+    // 时间
+    private List<List<BigDecimal>> dataList = new ArrayList<>();
+
+    // 图例
+    private List<String> legendList = new ArrayList<>();
+
+}

+ 45 - 0
src/main/java/cn/fastfun/controller/dto/asset/SummaryCentAndDepositDto.java

@@ -0,0 +1,45 @@
+package cn.fastfun.controller.dto.asset;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author zyg
+ * @date 2021年11月11日 15:46
+ */
+@Data
+public class SummaryCentAndDepositDto {
+    /**
+     * 租金收入
+     */
+    private BigDecimal cent;
+    /**
+     * 押金收取
+     */
+    private BigDecimal deposit;
+    /**
+     * 丢失保障金
+     */
+    private BigDecimal security;
+    /**
+     * 净收入
+     */
+    private BigDecimal netIncome;
+    /**
+     * 当前租期开始时间
+     */
+    private String orderStartTime;
+    /**
+     * 当前租期结束时间
+     */
+    private String orderEndTime;
+    /**
+     * 当前租金
+     */
+    private BigDecimal currentCent;
+    /**
+     * 当前押金
+     */
+    private BigDecimal currentDeposit;
+}

+ 2 - 0
src/main/java/cn/fastfun/controller/param/AssetProfitParam.java

@@ -36,4 +36,6 @@ public class AssetProfitParam extends QueryParam {
     @ApiModelProperty(value = "类型(1:押金收, 2:押金支, 3:租金收, 4:租金支, 5:丢失保障金, 多个用逗号隔开", name = "type", required = true)
     private String type;
 
+    private Boolean figureOrNot = false;
+
 }

+ 22 - 0
src/main/java/cn/fastfun/controller/param/OrgSnParam.java

@@ -0,0 +1,22 @@
+package cn.fastfun.controller.param;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author user
+ */
+@Getter
+@Setter
+public class OrgSnParam {
+
+    private String sn;
+    private Integer pageIndex;
+    private Integer pageSize;
+    private String startTime;
+    private String endTime;
+    //1 押金-收 2押金-支 3租金-收 4租金-支 5丢失保障金
+    private String type;
+}

+ 6 - 3
src/main/java/cn/fastfun/service/enums/EnumDeviceAction.java

@@ -11,9 +11,14 @@ public enum EnumDeviceAction {
      * 设备动作
      */
     PRODUCTION(0, "生产"),
+    OSS_STORAGE(20, "OSS入库"),
+    OSS_HANDLE(21, "OSS处置"),
+    OSS_CALLBACK(22, "OSS回调"),
     STORAGE_TRANSPORTATION(1, "入库运输"),
-    STORAGE(2, "入库"),
+    STORAGE(2, "平台入库"),
     TO_STORE(3, "发货至网点"),
+    SWAP_STORE(24, "网点换货"),
+    TO_PLANT(23, "回货"),
     TO_MERCHANT(4, "发货至商户"),
     STORE_RECEIVED(5, "网点到货"),
     MERCHANT_RECEIVED(6, "商户到货"),
@@ -21,8 +26,6 @@ public enum EnumDeviceAction {
     STORE_RETURN(8, "网点归还"),
     MERCHANT_RENT(9, "商户出租"),
     MERCHANT_RETURN(10, "商户归还"),
-    STORE_REPLACE(11, "网点设备更换"),
-    RECALL(12, "回调"),
     REPAIR(13, "送修"),
     REPAIR_START(14, "维修开始"),
     REPAIR_DONE(15, "维修完成"),

+ 3 - 1
src/main/java/cn/fastfun/service/enums/EnumDeviceStatus.java

@@ -11,7 +11,8 @@ public enum EnumDeviceStatus {
      * 设备状态
      */
     PRODUCTION(0, "生产"),
-    STORAGE_TRANSPORTATION(1, "入库运输中"),
+    OSS_INVENTORY(14, "OSS库存"),
+    STORAGE_TRANSPORTATION(1, "OSS-平台运输中"),
     PLATFORM_INVENTORY(2, "平台库存"),
     TO_STORE_TRANSPORTATION(3, "发货至网点运输中"),
     TO_MERCHANT_TRANSPORTATION(4, "发货至商户运输中"),
@@ -23,6 +24,7 @@ public enum EnumDeviceStatus {
     IN_REPAIR(10, "维修中"),
     REPAIR_DONE(11, "维修完成"),
     SCRAP(12, "报废"),
+    HANDLE(15, "处置"),
     LOSE(13, "丢失"),
     ;
     Integer value;

+ 283 - 20
src/main/java/cn/fastfun/service/impl/AppAssetProfitServiceImpl.java

@@ -1,7 +1,6 @@
 package cn.fastfun.service.impl;
 
-import cn.fastfun.controller.dto.asset.BaseInfoDTO;
-import cn.fastfun.controller.dto.asset.RentInfoDTO;
+import cn.fastfun.controller.dto.asset.*;
 import cn.fastfun.controller.param.*;
 import cn.fastfun.service.AppDeviceLogService;
 import cn.fastfun.service.AppDeviceService;
@@ -11,6 +10,8 @@ import cn.fastfun.service.entity.AppDeviceLog;
 import cn.fastfun.service.entity.AppImeiHistory;
 import cn.fastfun.util.ObjectUtil;
 import cn.fastfun.util.OkHttpCli;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.bridge.dto.ApiPageDTO;
 import com.bridge.dto.QueryParam;
@@ -21,6 +22,7 @@ import com.bridge.service.impl.JpaServiceImp;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.BooleanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Async;
@@ -34,6 +36,7 @@ import javax.transaction.Transactional;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.Future;
 
@@ -43,6 +46,13 @@ public class AppAssetProfitServiceImpl {
     @Autowired
     OkHttpCli okHttpCli;
 
+    @Value("${openapi.ip}")
+    private String openApiIp;
+
+    @Value("${openapi.port}")
+    private String openApiPort;
+
+
     //基础信息
     @Async
     public Future<String> assetBatteryBasicInfo(AssetProfitParam param) {
@@ -50,7 +60,7 @@ public class AppAssetProfitServiceImpl {
 //        mapHeaders.put("Cookie", cookie);
         JSONObject json = new JSONObject();
         json.put("sn", param.getSn());
-        String response = okHttpCli.doPostTokenJson("http://192.168.0.131:8082/admin/v1/assetBatteryBasicInfo", json.toJSONString(), mapHeaders);
+        String response = okHttpCli.doPostTokenJson(String.format("http://%s:%s/admin/v1/assetBatteryBasicInfo", openApiIp, openApiPort), json.toJSONString(), mapHeaders);
         Future<String> result = new AsyncResult<>(response);
         return result;
     }
@@ -62,19 +72,39 @@ public class AppAssetProfitServiceImpl {
 //        mapHeaders.put("Cookie", cookie);
         JSONObject json = new JSONObject();
         json.put("sn", param.getSn());
-        String response = okHttpCli.doPostTokenJson("http://192.168.0.131:8082/admin/v1/getDateLine", json.toJSONString(), mapHeaders);
+        String response = okHttpCli.doPostTokenJson(String.format("http://%s:%s/admin/v1/getDateLine", openApiIp, openApiPort), json.toJSONString(), mapHeaders);
         Future<String> result = new AsyncResult<>(response);
         return result;
     }
 
-    // 租赁信息列表
+    // 租赁信息列表/绘图
     @Async
-    public Future<String> marketingInformation(AssetProfitParam param) {
+    public Future<String> getDepositAndEnt(AssetProfitParam param) {
         Map<String, String> mapHeaders = new HashMap<>();
+        String response;
 //        mapHeaders.put("Cookie", cookie);
         JSONObject json = new JSONObject();
-        json.put("sn", param.getSn());
-        String response = okHttpCli.doPostTokenJson("http://192.168.0.131:8082/admin/v1/marketingInformation", json.toJSONString(), mapHeaders);
+        // 请求表单
+        if (param.getFigureOrNot() == false) {
+            json.put("sn", param.getSn());
+
+            json.put("pageSize", param.getLength());
+            json.put("pageIndex", param.getIndex());
+
+            if (param.getType() == null || param.getType() == "") {
+                json.put("type", "1,2,3,4,5");
+            } else {
+                json.put("type", param.getType());
+            }
+            response = okHttpCli.doPostTokenJson(String.format("http://%s:%s/admin/v1/getDepositAndEnt", openApiIp, openApiPort), json.toJSONString(), mapHeaders);
+        } else {
+            json.put("sn", param.getSn());
+            json.put("type", "1,2,3,4,5");
+            json.put("startTime", new SimpleDateFormat("yyyy-MM-dd").format(param.getTimeStart()));
+            json.put("endTime", new SimpleDateFormat("yyyy-MM-dd").format(param.getTimeEnd()));
+            response = okHttpCli.doPostTokenJson(String.format("http://%s:%s/admin/v1/getDepositAndEntChart", openApiIp, openApiPort), json.toJSONString(), mapHeaders);
+        }
+
         Future<String> result = new AsyncResult<>(response);
         return result;
     }
@@ -97,7 +127,7 @@ public class AppAssetProfitServiceImpl {
                 //每隔200毫秒判断一次
                 Thread.sleep(200);
             }
-            for (Future<String> future:futures){
+            for (Future<String> future : futures) {
                 String string = future.get();
                 response.add(string);
             }
@@ -106,20 +136,253 @@ public class AppAssetProfitServiceImpl {
             throw new Exception("" + e.getMessage());
         }
 
-        baseInfo.setSn("");
+        // 开放平台返回数据解析
+        JSONObject baseData = JSONObject.parseObject(response.get(0));
+        BasicAssetDto basicAssetDto = new BasicAssetDto();
+        if (baseData.get("data") != null) {
+            basicAssetDto = JSONObject.parseObject(baseData.get("data").toString(), BasicAssetDto.class);
+        }
+        baseInfo.setSn(basicAssetDto.getSn());
+        baseInfo.setCategory(basicAssetDto.getDeviceTypeText());
+        baseInfo.setType(basicAssetDto.getDeviceType());
+        baseInfo.setFactory(basicAssetDto.getFactory());
+        baseInfo.setCellFactory(basicAssetDto.getElectricCore());
+        baseInfo.setCellType(basicAssetDto.getElectricCoreTypeText());
+        baseInfo.setVoltPlatform(basicAssetDto.getVoltageText());
+        baseInfo.setCapacity(basicAssetDto.getCapacity());
+        baseInfo.setProductTime(basicAssetDto.getCreateTime());
+        baseInfo.setOperationTime(basicAssetDto.getOperationTime());
+        baseInfo.setPrice(basicAssetDto.getPurchasePrice());
+        baseInfo.setStatus(basicAssetDto.getStatusText());
+        baseInfo.setRegion(basicAssetDto.getLocationText());
+        JSONObject dataLine = JSONObject.parseObject(response.get(1));
+        List<DeviceLineDto> deviceLineDtos = new ArrayList<>();
+        if (dataLine.get("data") != null) {
+            deviceLineDtos = JSONArray.parseArray(dataLine.get("data").toString(), DeviceLineDto.class);
+        }
+
+        // 返回时间线
+        BaseInfoDTO.TimeLine deliverTimeline = new BaseInfoDTO.TimeLine();
+        deliverTimeline.setTime("发货时间");
+        BaseInfoDTO.TimeLine storageTimeline = new BaseInfoDTO.TimeLine();
+        storageTimeline.setTime("入库时间");
+        BaseInfoDTO.TimeLine rentTimeline = new BaseInfoDTO.TimeLine();
+        rentTimeline.setTime("首次租赁时间");
+        BaseInfoDTO.TimeLine recallTimeline = new BaseInfoDTO.TimeLine();
+        recallTimeline.setTime("回调时间");
+        Collections.reverse(deviceLineDtos);
+        Boolean storageFlag = false;
+        Boolean rentFlag = false;
+        if (deviceLineDtos.size() > 0) {
+            for (DeviceLineDto d : deviceLineDtos) {
+                // 入库时间
+                if (d.getAction().equals(20) && !storageFlag) {
+                    deliverTimeline.setTime(d.getActionTime());
+                    storageFlag = true;
+                }
+                // 首次租赁时间
+                if ((d.getAction().equals(7) || d.getAction().equals(8)) && !rentFlag) {
+                    rentTimeline.setTime(d.getActionTime());
+                    rentFlag = true;
+                }
+                // 回调时间
+                if (d.getAction().equals(22)) {
+                    recallTimeline.setTime(d.getActionTime());
+
+                }
+            }
+        }
+        baseInfo.getTimeLine().add(new BaseInfoDTO.TimeLine() {{
+            setTime(baseInfo.getProductTime());
+            setTime("生产时间");
+        }});
+        baseInfo.getTimeLine().add(deliverTimeline);
+        baseInfo.getTimeLine().add(storageTimeline);
+        baseInfo.getTimeLine().add(new BaseInfoDTO.TimeLine() {{
+            setTime(baseInfo.getOperationTime());
+            setTime("投营时间");
+        }});
+        baseInfo.getTimeLine().add(rentTimeline);
+        baseInfo.getTimeLine().add(recallTimeline);
+
+
+        // 采购和投营时间
+        if (baseInfo.getOperationTime() != null) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:MM:SS");
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(sdf.parse(baseInfo.getOperationTime()));
+            long time1 = cal.getTimeInMillis();
+            cal.setTime(new Date());
+            long time2 = cal.getTimeInMillis();
+            long between_days = (time2 - time1) / (1000 * 3600 * 24);
+            baseInfo.setOperationDay(between_days);
+        }
+
+
+//        baseInfo.setDeliverTime();
+
+
         return baseInfo;
     }
 
     // 租赁信息
-    public RentInfoDTO getRentInfo(String sn, String startTime, String endTime, Integer pageSize, Integer pageIndex){
-        RentInfoDTO rentInfo = new RentInfoDTO();
-        RentInfoDTO.AllInfo allInfo = new RentInfoDTO.AllInfo();
-        allInfo.setAmount(new BigDecimal(10));
-        allInfo.setTime("2021-10-21:00:00:00");
-        allInfo.setDescription("测试");
-        allInfo.setOrder("R123456");
-        allInfo.setType("押金-收");
-        rentInfo.getAllInfoList().add(allInfo);
-        return rentInfo;
+    public Object getRentInfo(AssetProfitParam param) throws Exception {
+        Object result = null;
+        String response;
+        try {
+            Future<String> future;
+            future = getDepositAndEnt(param);
+            //死循环,每隔2000ms执行一次,判断一下这三个异步调用的方法是否全都执行完了。
+            while (true) {
+                //使用Future的isDone()方法返回该方法是否执行完成
+                if (future.isDone()) {
+                    //如果异步方法全部执行完,跳出循环
+                    break;
+                }
+                //每隔200毫秒判断一次
+                Thread.sleep(200);
+            }
+            response = future.get();
+        } catch (Exception e) {
+            throw new Exception("" + e.getMessage());
+        }
+
+        // 请求的是列表
+        if (param.getFigureOrNot() == false) {
+            RentInfoDTO rentInfoDTO = new RentInfoDTO();
+            JSONObject rentInfo = JSONObject.parseObject(response);
+            SummaryCentAndDepositDto summaryCentAndDepositDto = new SummaryCentAndDepositDto();
+            List<RentAndDepositDto> rentAndDepositDtos = new ArrayList<>();
+            if (rentInfo.get("data") != null && rentInfo.get("data") != "") {
+                JSONObject responseData = JSONObject.parseObject(rentInfo.get("data").toString());
+                if (responseData.get("summary") != null && responseData.get("summary") != "") {
+                    summaryCentAndDepositDto = JSONObject.parseObject(responseData.get("summary").toString(), SummaryCentAndDepositDto.class);
+                }
+                if (responseData.get("data") != null && responseData.get("data") != "") {
+                    rentAndDepositDtos = JSONArray.parseArray(responseData.get("data").toString(), RentAndDepositDto.class);
+                }
+            }
+            for (RentAndDepositDto r : rentAndDepositDtos) {
+                RentInfoDTO.AllInfo allInfo = new RentInfoDTO.AllInfo();
+                allInfo.setTime(r.getOrderTime());
+                allInfo.setOrder(r.getOrderNo());
+                allInfo.setDescription(r.getRemark());
+                allInfo.setAmount(r.getAmount());
+                switch (r.getType()) {
+                    case 1:
+                        allInfo.setType("押金-收");
+                        break;
+                    case 2:
+                        allInfo.setType("押金-支");
+                        break;
+                    case 3:
+                        allInfo.setType("租金-收");
+                        break;
+                    case 4:
+                        allInfo.setType("租金-支");
+                        break;
+                    case 5:
+                        allInfo.setType("丢失保障金");
+                        break;
+                    default:
+                        allInfo.setType("");
+                }
+                rentInfoDTO.getAllInfoList().add(allInfo);
+            }
+            rentInfoDTO.setOrderStartTime(summaryCentAndDepositDto.getOrderStartTime());
+            rentInfoDTO.setOrderEndTime(summaryCentAndDepositDto.getOrderEndTime());
+            rentInfoDTO.setRental(summaryCentAndDepositDto.getCurrentCent());
+            rentInfoDTO.setCash(summaryCentAndDepositDto.getCurrentDeposit());
+            rentInfoDTO.setIncome(summaryCentAndDepositDto.getCent());
+            rentInfoDTO.setCashIn(summaryCentAndDepositDto.getDeposit());
+            rentInfoDTO.setSecurityCash(summaryCentAndDepositDto.getSecurity());
+            rentInfoDTO.setNetRental(summaryCentAndDepositDto.getNetIncome());
+            result = (RentInfoDTO)rentInfoDTO;
+        }
+        // 请求的是图表
+        else {
+            RentInfoFigureDTO rentInfoFigureDTO = new RentInfoFigureDTO();
+            JSONObject responseData = JSONObject.parseObject(response);
+            if (responseData.get("data") != null && responseData.get("data") != "") {
+                JSONObject rentFigureInfo = JSONObject.parseObject(responseData.get("data").toString());
+                Boolean timeListDone = false;
+                List<String> timeList = new ArrayList<>();
+                if (rentFigureInfo.get("securityChartList") != null && rentFigureInfo.get("securityChartList") != "") {
+                    List<RentAndDepositChartDto> chartList = new ArrayList<>();
+                    chartList = JSONArray.parseArray(rentFigureInfo.get("securityChartList").toString(), RentAndDepositChartDto.class);
+                    if (chartList.size() > 0){
+                        rentInfoFigureDTO.getLegendList().add("丢失保障金");
+                        List<BigDecimal> dataList = new ArrayList<>();
+                        if (!timeListDone){
+                            chartList.forEach(p->timeList.add(p.getMonth()));
+                            timeListDone = true;
+                        }
+                        chartList.forEach(p->dataList.add(p.getAmountMonth()));
+                        rentInfoFigureDTO.getDataList().add(dataList);
+                    }
+                }
+                if (rentFigureInfo.get("centReduceChartList") != null && rentFigureInfo.get("centReduceChartList") != "") {
+                    List<RentAndDepositChartDto> chartList = new ArrayList<>();
+                    chartList = JSONArray.parseArray(rentFigureInfo.get("centReduceChartList").toString(), RentAndDepositChartDto.class);
+                    if (chartList.size() > 0){
+                        rentInfoFigureDTO.getLegendList().add("租金-支");
+                        List<BigDecimal> dataList = new ArrayList<>();
+                        if (!timeListDone){
+                            chartList.forEach(p->timeList.add(p.getMonth()));
+                            timeListDone = true;
+                        }
+                        chartList.forEach(p->dataList.add(p.getAmountMonth()));
+                        rentInfoFigureDTO.getDataList().add(dataList);
+                    }
+                }
+                if (rentFigureInfo.get("centAddChartList") != null && rentFigureInfo.get("centAddChartList") != "") {
+                    List<RentAndDepositChartDto> chartList = new ArrayList<>();
+                    chartList = JSONArray.parseArray(rentFigureInfo.get("centAddChartList").toString(), RentAndDepositChartDto.class);
+                    if (chartList.size() > 0){
+                        rentInfoFigureDTO.getLegendList().add("租金-收");
+                        List<BigDecimal> dataList = new ArrayList<>();
+                        if (!timeListDone){
+                            chartList.forEach(p->timeList.add(p.getMonth()));
+                            timeListDone = true;
+                        }
+                        chartList.forEach(p->dataList.add(p.getAmountMonth()));
+                        rentInfoFigureDTO.getDataList().add(dataList);
+                    }
+                }
+                if (rentFigureInfo.get("depositReduceChartList") != null && rentFigureInfo.get("depositReduceChartList") != "") {
+                    List<RentAndDepositChartDto> chartList = new ArrayList<>();
+                    chartList = JSONArray.parseArray(rentFigureInfo.get("depositReduceChartList").toString(), RentAndDepositChartDto.class);
+                    if (chartList.size() > 0){
+                        rentInfoFigureDTO.getLegendList().add("押金-支");
+                        List<BigDecimal> dataList = new ArrayList<>();
+                        if (!timeListDone){
+                            chartList.forEach(p->timeList.add(p.getMonth()));
+                            timeListDone = true;
+                        }
+                        chartList.forEach(p->dataList.add(p.getAmountMonth()));
+                        rentInfoFigureDTO.getDataList().add(dataList);
+                    }
+                }
+                if (rentFigureInfo.get("depositAddChartList") != null && rentFigureInfo.get("depositAddChartList") != "") {
+                    List<RentAndDepositChartDto> chartList = new ArrayList<>();
+                    chartList = JSONArray.parseArray(rentFigureInfo.get("depositAddChartList").toString(), RentAndDepositChartDto.class);
+                    if (chartList.size() > 0){
+                        rentInfoFigureDTO.getLegendList().add("押金-收");
+                        List<BigDecimal> dataList = new ArrayList<>();
+                        if (!timeListDone){
+                            chartList.forEach(p->timeList.add(p.getMonth()));
+                            timeListDone = true;
+                        }
+                        chartList.forEach(p->dataList.add(p.getAmountMonth()));
+                        rentInfoFigureDTO.getDataList().add(dataList);
+                    }
+                }
+                rentInfoFigureDTO.setTimeList(timeList);
+            }
+            result = (RentInfoFigureDTO) rentInfoFigureDTO;
+
+        }
+        return result;
     }
+
 }

+ 5 - 1
src/main/resources/application-dev.yml

@@ -39,4 +39,8 @@ ok:
     # 连接池中整体的空闲连接的最大数量
     max-idle-connections: 200
     # 连接空闲时间最多为 300 秒
-    keep-alive-duration: 300
+    keep-alive-duration: 300
+
+openapi:
+  ip: 192.168.0.131
+  port: 8082