CalcDlbController.java 1.48 KB
package com.bsth.controller.calc;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bsth.common.ResponseCode;
import com.bsth.service.calc.CalcDlbService;

/**
 * Created by 20/05/27.
 */
@RestController
@RequestMapping("calc_dlb")
public class CalcDlbController {
	
	@Autowired
	CalcDlbService service;
	
	@RequestMapping(value="/updateDlb")
	public Map<String, Object> generateDaliy(@RequestParam Map<String, Object> map) throws Exception{
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date d = new Date();
		d.setTime(d.getTime() - (1l*1000*60*60*24));	//默认前一天
		String date = "";
		if(map.containsKey("date") && map.get("date")!=null){
			date=map.get("date").toString().trim();
		}
		
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("date", date);
		try {
			sdf.format(sdf.parse(date));	//校验日期格式
			
//			m.put("status", service.impElectric(date));
			service.impElectric(date);
			m.put("status", ResponseCode.SUCCESS);
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			m.put("status", ResponseCode.ERROR);
			return m;
		}
		return m;
	}
	
}