zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package cn.autoform.web.controller.epc;
 
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeoutException;
 
import javax.annotation.Resource;
 
import java.util.Date;
import java.util.HashMap;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import cn.autoform.fw.exception.FormClientException;
import cn.autoform.fw.exception.RestResult;
import cn.autoform.fw.utility.RestResultGenerator;
import cn.autoform.util.tool.CodeToNameTool;
import cn.autoform.web.formula.entity.FormulaParam;
import cn.autoform.web.formula.entity.FormulaResult;
import cn.autoform.web.service.epc.EpcService;
import cn.autoform.web.service.formula.FormulaService;
 
/**
 * 接收费用云的请求接口
 * @author liush
 *
 */
@RestController
public class EpcController {
 
    @Autowired
    private CodeToNameTool codeToNameTool; 
    
    @Resource
    EpcService epcService;
    
    @Resource
    FormulaService formulaService;
 
    /**
     * 获取预算列表的code转name
     * @param map
     * @return
     * @throws TimeoutException
     * @throws FormClientException
     */
    @RequestMapping(value = "${request.epc01}", method = RequestMethod.POST)
    public RestResult<List<Map<String, Object>>> getAssociateData(
            @RequestBody Map<String, List<Map<String, Object>>> map) throws TimeoutException, FormClientException {
        List<Map<String, Object>> list = map.get("associateData");
        //设置是否查询主表控件
        this.codeToNameTool.setQueryMain(false);
        this.codeToNameTool.toDo(list);
        return RestResultGenerator.genSuccessResult(list);
    }
 
    /**
     * 获取系统当前时间
     * @param map
     * @return
     * @throws TimeoutException
     * @throws FormClientException
     * @throws ParseException 
     */
    @RequestMapping(value = "${request.epc02}", method = RequestMethod.POST)
    public RestResult<Map<String,Date>> getTime(@RequestBody Map<String, Object> map) throws TimeoutException, FormClientException, ParseException{
        String nowTimeFormat =  Objects.toString(map.get("time"),null);
        Map<String,Date> datamap  = new HashMap<>();
        if(nowTimeFormat != null){
        
            Date now = new Date(); 
            SimpleDateFormat dateFormat = new SimpleDateFormat(nowTimeFormat);
            String timeFoemat = dateFormat.format(now);
            Date date=dateFormat.parse(timeFoemat);
            
            datamap.put("time", date);
            return RestResultGenerator.genSuccessResult(datamap);
        
        
        }else{
            
                Date now = new Date(); 
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                String timeFoemat = dateFormat.format(now);
                Date date = dateFormat.parse(timeFoemat);
                datamap.put("time", date);
                return RestResultGenerator.genSuccessResult(datamap);
    
        }
        
    }
    @RequestMapping(value="${request.epc03}", method = RequestMethod.POST)
    public RestResult<FormulaResult> getFormula(@RequestBody FormulaParam formulaParam){
        return  RestResultGenerator.genSuccessResult(formulaService.execute(formulaParam));
        
    }
    
}