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
package com.changhong.epc.tenant.service.accounting.impl;
 
import com.changhong.epc.bean.form.FormDataEntity;
import com.changhong.epc.bean.form.ProcessBudget;
import com.changhong.epc.constter.form.utf.FormUrlConst;
import com.changhong.epc.constter.system.SystemClients;
import com.changhong.epc.constter.system.run.EpcRestInterface;
import com.changhong.epc.rely.api.service.CscApiService;
import com.changhong.epc.tenant.service.accounting.AccountingService;
import com.iemsoft.framework.cloud.core.base.ResMsg;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
import com.iemsoft.framework.cloud.ribbon.RestInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Map;
 
 
@Service("accountingServiceImpl")
public class AccountingServiceImpl implements SystemClients,AccountingService {
    
    @Autowired
    private CscApiService cscApiService;
 
    /**
     * 进入记账方法
     */
    @Override
    public int record(ProcessBudget processBudget) {
        return orderAccount(selectFormData(processBudget)) == true ? 1 : -1;
    }
 
    /**
     * 发送记账请求 
     * @param selectFormData
     */
    private boolean orderAccount(Map<String, Object> selectFormData) {
        return cscApiService.orderAccount(selectFormData) != null ? true : false;
    }
 
    /**
     * 查询表单数据
     * @param processBudget
     */
    private Map<String,Object> selectFormData(ProcessBudget processBudget){
        RestInterface restInterface = SpringUtil.getBean(SERVER_FORM.getBeanName(), RestInterface.class);
        FormDataEntity formData = new FormDataEntity();
        formData.setFormId(processBudget.getFormID());
        formData.setTenantId(processBudget.getTenantId());
        formData.setDataRowNum(processBudget.getDataRowNUm());
//        Map<String,Object> map = new HashMap<String,Object>();
//        map.put("companyId",processBudget.getCompanyId());
//        Map<String,Object> map1 = new HashMap<String,Object>();
//        map1.put("openId",processBudget.getOpenId());
//        formData.setMap(map);
//        formData.setMap(map1);
        Object data = restInterface.post(FormUrlConst.FORM_DATA_SEARCH,formData ,ResMsg.class, EpcRestInterface.getEpcHeads()).getData();
        // System.err.println(JSONTool.toJson(data));
        Map<String,Object> Co =  JSONTool.toObj(JSONTool.toJson(data),Map.class);
//        Map<String,Object> map = new HashMap<String,Object>();
//        map.put("processBudget", data);
        // System.err.println(JSONTool.toJson(Co));
        
        return Co;
    }
    
    
}