CalcDlbController.java
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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;
}
}