commit | author | age
|
a18bfa
|
1 |
package com.changhong.epc.admin.controller.mq; |
Z |
2 |
|
|
3 |
import com.changhong.epc.admin.service.mq.AutoFormConsumer; |
|
4 |
import com.changhong.epc.constter.base.BaseConst; |
|
5 |
import com.changhong.epc.constter.base.Context; |
|
6 |
import com.iemsoft.framework.cloud.core.thread.ThreadData; |
|
7 |
import com.iemsoft.framework.cloud.core.tools.JSONTool; |
|
8 |
import com.iemsoft.framework.cloud.core.tools.ObjectUtil; |
|
9 |
import lombok.Data; |
|
10 |
import lombok.extern.slf4j.Slf4j; |
|
11 |
import org.springframework.data.redis.connection.Message; |
|
12 |
import org.springframework.ui.ModelMap; |
|
13 |
import org.springframework.web.bind.annotation.GetMapping; |
|
14 |
import org.springframework.web.bind.annotation.PathVariable; |
|
15 |
import org.springframework.web.bind.annotation.RestController; |
|
16 |
|
|
17 |
import java.util.Map; |
|
18 |
|
|
19 |
@RestController |
|
20 |
@Slf4j |
|
21 |
public class AutoFormController implements BaseConst { |
|
22 |
|
|
23 |
@GetMapping("autoForm/{tenantId}/{companyId}") |
|
24 |
public Object autoFormId(@PathVariable String tenantId, @PathVariable Integer companyId){ |
|
25 |
ThreadData.set(TENANT_ID, tenantId); |
|
26 |
ThreadData.set(COMPANY_ID, companyId); |
|
27 |
|
|
28 |
TestAutoFormConsumer test = new TestAutoFormConsumer(); |
|
29 |
test.onMessage(new Message(){ |
|
30 |
|
|
31 |
@Override |
|
32 |
public byte[] getBody() { |
|
33 |
return ObjectUtil.objectToByte( |
|
34 |
Context.getMQParam( |
|
35 |
new ModelMap("tenantID", tenantId) |
|
36 |
.addAttribute("formID", "Ug12TTbi") |
|
37 |
.addAttribute("id", "4") |
|
38 |
.addAttribute("field", "number_expend") |
|
39 |
.addAttribute("fieldKey", "Rt") |
|
40 |
.addAttribute("fieldSize", "8") |
|
41 |
) |
|
42 |
); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public byte[] getChannel() { |
|
47 |
return new byte[0]; |
|
48 |
} |
|
49 |
}, new byte[0]); |
|
50 |
return test.getVal(); |
|
51 |
} |
|
52 |
|
|
53 |
@Data |
|
54 |
class TestAutoFormConsumer extends AutoFormConsumer { |
|
55 |
|
|
56 |
private Object val; |
|
57 |
|
|
58 |
@Override |
|
59 |
public Object getFromRest(String fs, Object parm) { |
|
60 |
log.debug(fs); |
|
61 |
log.debug(JSONTool.toJson(parm)); |
|
62 |
this.val = ((Map)parm).get("number_expend"); |
|
63 |
return null; |
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
} |
|
68 |
} |