|  | @@ -139,10 +139,81 @@ public class TWhgenlegServiceImpl implements ITWhgenlegService {
 | 
	
		
			
				|  |  |          String frontday = format.format(c.getTime());
 | 
	
		
			
				|  |  |          // 当前日期
 | 
	
		
			
				|  |  |          String nowadays=DateUtils.getDate();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |          map.put("frontday", frontday);
 | 
	
		
			
				|  |  |          map.put("nowadays", nowadays);
 | 
	
		
			
				|  |  | -        return tWhgenlegMapper.selectDateFQtyblcListList(map);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<Map<String, Object>>  list= tWhgenlegMapper.selectDateFQtyblcListList(map);
 | 
	
		
			
				|  |  | +        // 对比 日期 为空入库赋值0
 | 
	
		
			
				|  |  | +        ArrayList<String> pastDaysList=dayList(8);
 | 
	
		
			
				|  |  | +        for(String day:pastDaysList){
 | 
	
		
			
				|  |  | +            if(!day.equals(nowadays)){
 | 
	
		
			
				|  |  | +                Map<String, Object> map1 = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +                map1.put("fOriginalbilldate",day);
 | 
	
		
			
				|  |  | +                map1.put("fQtyblc",0);
 | 
	
		
			
				|  |  | +                list.add(map1);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<Map<String,Object>> countList = combineMap("fOriginalbilldate", list);
 | 
	
		
			
				|  |  | +        return countList;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param combineField 根据该字段进行合并
 | 
	
		
			
				|  |  | +     * @param dataList 原始数据
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public static List<Map<String, Object>> combineMap(String combineField, List<Map<String, Object>> dataList){
 | 
	
		
			
				|  |  | +        //用于存放最后的结果
 | 
	
		
			
				|  |  | +        List<Map<String, Object>> countList = new ArrayList<Map<String,Object>>();
 | 
	
		
			
				|  |  | +        for (int i = 0; i < dataList.size(); i++) {
 | 
	
		
			
				|  |  | +            String oldCombineField = String.valueOf(dataList.get(i).get(combineField));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            int flag = 0;//0为新增数据,1为增加count
 | 
	
		
			
				|  |  | +            for (int j = 0; j < countList.size(); j++) {
 | 
	
		
			
				|  |  | +                String newCombineField = String.valueOf(countList.get(j).get(combineField));
 | 
	
		
			
				|  |  | +                if (oldCombineField.equals(newCombineField)) {
 | 
	
		
			
				|  |  | +                    //做累加的操作
 | 
	
		
			
				|  |  | +                    Integer afterSaleProfit = Integer.parseInt(String.valueOf(dataList.get(i).get("fQtyblc"))) + Integer.parseInt(String.valueOf(countList.get(j).get("fQtyblc")));
 | 
	
		
			
				|  |  | +                    countList.get(j).put("fQtyblc", afterSaleProfit);
 | 
	
		
			
				|  |  | +                    flag = 1;
 | 
	
		
			
				|  |  | +                    break;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (flag == 0) {
 | 
	
		
			
				|  |  | +                countList.add(dataList.get(i));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return countList;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 获取过去 任意天内的日期数组
 | 
	
		
			
				|  |  | +     * @param intervals      intervals天内
 | 
	
		
			
				|  |  | +     * @return              日期数组
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public static ArrayList<String> dayList(int intervals ) {
 | 
	
		
			
				|  |  | +        ArrayList<String> pastDaysList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (int i = 0; i <intervals; i++) {
 | 
	
		
			
				|  |  | +            pastDaysList.add(getPastDate(i));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return pastDaysList;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 获取过去第几天的日期
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param past
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public static String getPastDate(int past) {
 | 
	
		
			
				|  |  | +        Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  | +        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
 | 
	
		
			
				|  |  | +        Date today = calendar.getTime();
 | 
	
		
			
				|  |  | +        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  | +        String result = format.format(today);
 | 
	
		
			
				|  |  | +        return result;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |