发表于: 2018-03-31 22:00:36

1 477


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

写比较难写的几个接口.首先是增加时间的工具类.

package com.ptteng.polyFinance.lgd.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
* @author: Arike
* @program: polyFinance-lgd
* @description: 用于获取各个时间点时间戳的工具类
* @create: 2018/3/31 14:53
*/

public class TimeUtil {


/**
    * 获取当天凌晨的时间戳
    * @param currentTime 当前时间戳
    * @return
    */
   public static Long getZeroTimeStamp(Long currentTime){
Calendar calendar = Calendar.getInstance();
       calendar.setTimeInMillis(currentTime);
       calendar.set(Calendar.HOUR_OF_DAY,0);
       calendar.set(Calendar.MINUTE,0);
       calendar.set(Calendar.SECOND, 0);
       calendar.set(Calendar.MILLISECOND,0);
       return calendar.getTime().getTime();
   }

/**
    * 获取约定天数的总毫秒数
    * @param days 天数
    * @return
    */
   public static Long getDaysTimeStamp(int days){
return  days * 24 * 60 * 60 * 1000L;
   }

public static void main(String[] args) {
Date date = new Date();
       SimpleDateFormat sp = new SimpleDateFormat("yyyy/MM/dd/HH/mm/ss");
       System.out.println(sp.format(date));
       System.out.println(sp.format(new Date(getZeroTimeStamp(date.getTime()))));
       System.out.println(new Date().getTime()+ getDaysTimeStamp(6));
   }
}

然后是查询续投列表.


 @RequestMapping(value = "/a/u/investRecord/again", method = RequestMethod.GET)
public String getAgainList(ModelMap modelMap, Long id, Integer page, Integer size) {
if (CommonUtil.isEmpty(id)) {
modelMap.addAttribute("code", -200);
           return "polyFinance-lgd-server/investRecord/json/againRecordListJson";
           
       }
if (CommonUtil.isEmpty(page)) {
page = 1;
       }
if (CommonUtil.isEmpty(size)) {
size = 10;
       }
int start = (page - 1) * size;
       if (start < 0) {
start = 0;
       }
try {
List<Long> ids = investRecordService.getInvestRecordIdsByUserIdOrderByCreateAt(id, start, size);
           List<InvestRecord> investRecords = investRecordService.getObjectsByIds(ids);
           Set<Long> productIds = new HashSet<>();//set是为了给ID去重
           for (InvestRecord investRecord : investRecords) {
productIds.add(investRecord.getProductId());
           }
List<Product> products = productService.getObjectsByIds(new ArrayList<>(productIds));
           Map<Long, Integer> map = new HashMap<>();
           for (Product product : products) {
map.put(product.getId(), product.getProductStatus());
           }
List<InvestRecord> matchRecords = new ArrayList<>();
           for (InvestRecord investRecord : investRecords) {
if (map.get(investRecord.getProductId()) == 0) {
matchRecords.add(investRecord);
               }
}
Set<InvestRecord> set = new TreeSet<>(new Comparator<InvestRecord>() {
@Override
               public int compare(InvestRecord o1, InvestRecord o2) {
if (o1.getValueDay() - o2.getValueDay() > 0) {
return 1;
                   } else if (o1.getValueDay() - o2.getValueDay() < 0) {
return -1;
                   }
return 1;
               }
});
           set.addAll(matchRecords);
           
           Object[] arr = set.toArray();
           InvestRecord noobInvestRecord = (InvestRecord) arr[0];
           System.out.println(noobInvestRecord);
           List<InvestRecord> match1Records = new ArrayList<>();
           Settings settings = settingsService.getObjectById(1L);
           int days = settings.getInvsetExpireWarn();
           for (InvestRecord record : matchRecords) {
if ((record.getValueEndDay() - TimeUtil.getDaysTimeStamp(days)) <= TimeUtil.getZeroTimeStamp(new Date().getTime()) && record.getValueDay() > noobInvestRecord.getValueDay()) {
match1Records.add(record);
               }
}
modelMap.addAttribute("againRecords", match1Records);
           modelMap.addAttribute("code", 0);
//            modelMap.addAttribute("total",)
       } catch (Throwable e) {
modelMap.addAttribute("code", -100);
           e.printStackTrace();
       }
return "polyFinance-lgd-server/investRecord/json/againRecordListJson";
       
   }

逻辑判断非常之多....因为限制条件多.

1,获取到所有产品ID(需要排重)

2.产品需要在售.

3.投资记录第一条的对应产品需要排除.

4.到息时间小于当前时间的进行排除.

5.根据后台设置的提醒时间进行筛选.


明天计划的事情:(一定要写非常细致的内容) 

对逻辑再理一下.
遇到的问题:(遇到什么困难,怎么解决的) 

逻辑一多,代码量多了就容易出错.
收获:(通过今天的学习,学到了什么知识)

对集合框架又做了复习.



返回列表 返回列表
评论

    分享到