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));
|
|
}
|
|
}
|