|
@@ -792,6 +792,43 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据部门和需要的日期(某年某月)来取任务号tasknolist
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<String> getTaskNoListFDepTime2(List<String> sysDepartNames, String timeType, String timeRange){
|
|
|
+ //2.根据部门名称(zrbm、jycs)和实际完成时间查询taskno
|
|
|
+ List<String> taskNoList = new ArrayList<>();
|
|
|
+ for (String sysDepartName : sysDepartNames) {
|
|
|
+ List<String> taskNoList1 = new ArrayList<>();
|
|
|
+ switch (timeType) {
|
|
|
+ case "年"://某年的所有任务
|
|
|
+ taskNoList1 = kyTaskInfoService.getKyTaskNoByYear(sysDepartName, timeRange);
|
|
|
+ break;
|
|
|
+ case "月"://某月的所有任务
|
|
|
+ taskNoList1 = kyTaskInfoService.getKyTaskNoByMonth(sysDepartName, timeRange);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ System.out.println("默认没有任务");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+// List<String> taskNoList1 = kyTaskInfoService.getKyTaskNoByNameCurrYear(sysDepartName);
|
|
|
+ System.out.println(taskNoList1);
|
|
|
+ taskNoList.addAll(taskNoList1);
|
|
|
+ System.out.println(taskNoList);
|
|
|
+ }
|
|
|
+ //新建一个list来给list中的数据去重 防止责任部门和下达部门都为一个部门,可能会信息重复
|
|
|
+ List<String> taskNoListNew = new ArrayList<>();
|
|
|
+ for (String taskNo : taskNoList) {
|
|
|
+ if (!taskNoListNew.contains(taskNo)) {
|
|
|
+ taskNoListNew.add(taskNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return taskNoListNew;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 计算当年的年总利润额、上一年同期总利润额、年同比增长、当月总利润额、当月同比、当月环比
|
|
|
*
|
|
|
* @return
|
|
@@ -914,4 +951,106 @@ public class IndexServiceImpl implements IndexService {
|
|
|
System.out.println(sysDepartNames);
|
|
|
return sysDepartNames;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取年月列表
|
|
|
+ * @Param dateFormat 日期格式 timeType 日期增加的格式(年/月)
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public List<String> getDateList(List<String> timeRangeList, String startString, String endString, String dateFormat, String timeType){
|
|
|
+ //用Calendar 进行日期比较判断
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
|
|
|
+ try {
|
|
|
+ // 转化成日期类型
|
|
|
+ Date startDate = sdf.parse(startString);
|
|
|
+ Date endDate = sdf.parse(endString);
|
|
|
+ while (startDate.getTime()<=endDate.getTime()){
|
|
|
+ // 把日期添加到集合
|
|
|
+ timeRangeList.add(sdf.format(startDate));
|
|
|
+ // 设置日期
|
|
|
+ calendar.setTime(startDate);
|
|
|
+ //把日期增加一天
|
|
|
+ if(timeType.equals("年")){
|
|
|
+ calendar.add(Calendar.YEAR, 1);
|
|
|
+ }
|
|
|
+ else if(timeType.equals("月")){
|
|
|
+ calendar.add(Calendar.MONTH, 1);
|
|
|
+ }
|
|
|
+ // 获取增加后的日期
|
|
|
+ startDate=calendar.getTime();
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return timeRangeList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页二层:前端传送一个时间段,即开始时间和结束时间 Date类型
|
|
|
+ * 如果>31天,则返回按月的利润额
|
|
|
+ * 如果<=31天,则返回按天的利润额
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Result<IndexChartInfoVo<BigDecimal>> countLreByDate(IndexInfoParamDto indexInfoParamDto){
|
|
|
+ //1.创建一个IndexChartInfoVo实例用来存储最后返回前端的信息
|
|
|
+ IndexChartInfoVo<BigDecimal> indexChartInfoVo = new IndexChartInfoVo<>();
|
|
|
+ BigDecimal initValue = BigDecimal.valueOf(0); //某年或某月没有任务,利润额为0
|
|
|
+ //创建一个String列表用来存储横坐标日期
|
|
|
+ List<String> timeRangeList = new ArrayList<>();
|
|
|
+ //创建一个BigDecimal列表用来存储纵坐标利润
|
|
|
+ List<BigDecimal> seriesDataList = new ArrayList<>();
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ //2.计算时间列表 横坐标时间string列表
|
|
|
+ //年/月
|
|
|
+ String timeType = indexInfoParamDto.getTime();
|
|
|
+ //起始时间
|
|
|
+ String startString = indexInfoParamDto.getBeginDate();
|
|
|
+ //结束时间
|
|
|
+ String endString = indexInfoParamDto.getEndDate();
|
|
|
+
|
|
|
+ if(timeType.equals("年")){
|
|
|
+ timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy", timeType);
|
|
|
+ }
|
|
|
+ else if (timeType.equals("月")){
|
|
|
+ timeRangeList = getDateList(timeRangeList, startString, endString, "yyyy-MM", timeType);
|
|
|
+ }
|
|
|
+ System.out.println("获取的日期列表为:");
|
|
|
+ System.out.println(timeRangeList);
|
|
|
+ if(timeRangeList.size() != 0){
|
|
|
+ //添加横坐标列表
|
|
|
+ indexChartInfoVo.setXAxisData(timeRangeList);
|
|
|
+ //3.通过登录的用户找到相应的部门,可能一个或两个
|
|
|
+ List<String> sysDepartNames = getDepNameBySysUser();
|
|
|
+ //4.计算该时间列表中某年或某月对应的总利润额
|
|
|
+ for(String timeRange:timeRangeList){
|
|
|
+ //根据时间和部门去查找任务号
|
|
|
+ List<String> taskNoListNew = getTaskNoListFDepTime2(sysDepartNames, timeType, timeRange);
|
|
|
+ System.out.println(timeRange + "的任务号列表:");
|
|
|
+ System.out.println(taskNoListNew);
|
|
|
+ if(taskNoListNew.size() != 0){
|
|
|
+ BigDecimal sumLreYear = countLre(taskNoListNew);
|
|
|
+ System.out.println(timeRange + "的利润额为:");
|
|
|
+ System.out.println(sumLreYear);
|
|
|
+ seriesDataList.add(sumLreYear);
|
|
|
+ System.out.println("----------------------------------------------------");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ System.out.println(timeRange + "的利润额为:" + initValue);
|
|
|
+ seriesDataList.add(initValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //添加纵坐标列表
|
|
|
+ indexChartInfoVo.setSeriesData(seriesDataList);
|
|
|
+
|
|
|
+ }
|
|
|
+ return Result.OK(indexChartInfoVo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|