Browse Source

资产收益预估

lmstack 3 years ago
parent
commit
14173f3811

+ 35 - 1
src/main/java/cn/fastfun/controller/api/ApiAssetProfitController.java

@@ -217,7 +217,6 @@ public class ApiAssetProfitController {
                     responseDTO.getAllInfoList().add(allInfo);
                 });
             }
-
             if (baseInfo != null) {
                 if (baseInfo.getStatus().equals(0) || baseInfo.getStatus().equals(14))
                     responseDTO.setOpStorageState("未出库");
@@ -524,10 +523,45 @@ public class ApiAssetProfitController {
         // 收益预估信息
         else if (param.getTableOrder() != null && param.getTableOrder().equals(10)) {
             ResponseDTO responseDTO = new ResponseDTO();
+            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
+            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-00 00:00:00");
+            Calendar cal = Calendar.getInstance();
             BaseInfoDTO baseInfo = (BaseInfoDTO) getBaseInfo(param).getData();
+
+            ResponseDTO assetTotalInOutInfo;
+            String oPTime = null;
+            Date now = new Date();
             if (baseInfo != null){
+                oPTime = baseInfo.getOperationTime();
+                Date startTime = sdf1.parse(baseInfo.getOperationTime());
+                Date endTime ;
+                Date lastTime = sdf1.parse(sdf1.format(now));
 
+                if (param.getTimeStart() != null && !param.getTimeStart().equals("")){
+                    startTime = sdf1.parse(sdf1.format(param.getTimeStart()));
+                }
+                if (param.getTimeEnd() != null && !param.getTimeEnd().equals("")){
+                    lastTime = sdf1.parse(sdf1.format(param.getTimeEnd()));
+                }
+                if (StringUtils.hasLength(oPTime)){
+                    while (startTime.getTime() <= lastTime.getTime()) {
+                        param.setTableOrder(9);
+                        // 日期+1月
+                        cal.setTime(startTime);
+                        cal.add(Calendar.MONTH, 1);
+                        endTime = cal.getTime();
+                        param.setTimeStart(sdf2.parse(sdf2.format(startTime)));
+                        param.setTimeEnd(sdf2.parse(sdf2.format(endTime)));
+                        assetTotalInOutInfo = (ResponseDTO) getAssetProfitInfo(param).getData();
+                        ResponseDTO.ProfitPredict profitPredict = new ResponseDTO.ProfitPredict();
+                        profitPredict.setTime(sdf1.format(startTime));
+                        profitPredict.setNetIncome(assetTotalInOutInfo.getNetIncome());
+                        responseDTO.getProfitPredictInfoList().add(profitPredict);
+                        startTime = cal.getTime();
+                    }
+                }
             }
+            response = (ResponseDTO) responseDTO;
 
         }
         return ApiDTO.ok("成功", response);

+ 31 - 0
src/main/java/cn/fastfun/controller/dto/asset/ResponseDTO.java

@@ -36,8 +36,39 @@ public class ResponseDTO {
         private String description;
     }
 
+    @JsonIgnoreType
+    @Setter
+    @Getter
+    public static class ProfitPredict{
+        // 时间
+        private String time;
+
+        // 总价
+        private BigDecimal totalAmount = new BigDecimal(0);
+
+        // 净收入
+        private BigDecimal netIncome = new BigDecimal(0);
+
+        // 当前IRR
+        private String curIRR;
+
+        // 当前毛利
+        private BigDecimal description = new BigDecimal(0);
+
+        // 预估收入
+        private BigDecimal preIncome = new BigDecimal(0);
+
+        // 总体IRR
+        private String preIRR;
+
+        // 预估剩余回本周期
+        private Integer backPeriod = 0;
+    }
+
     private List<AllInfo> allInfoList = new ArrayList<>();
 
+    private List<ProfitPredict> profitPredictInfoList = new ArrayList<>();
+
     // 当前租期开始
     private String orderStartTime;
 

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

@@ -10,6 +10,7 @@ import lombok.Setter;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.util.StringUtils;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 @Setter
@@ -38,5 +39,8 @@ public class AssetProfitParam extends QueryParam {
 
     private Boolean figureOrNot = false;
 
+    // 总价
+    private BigDecimal totalCost = new BigDecimal(3000);
+
 
 }