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
package com.changhong.epc.admin.controller.mq;
 
import com.changhong.epc.admin.service.mq.AutoFormConsumer;
import com.changhong.epc.constter.base.BaseConst;
import com.changhong.epc.constter.base.Context;
import com.iemsoft.framework.cloud.core.thread.ThreadData;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Map;
 
@RestController
@Slf4j
public class AutoFormController implements BaseConst {
 
    @GetMapping("autoForm/{tenantId}/{companyId}")
    public Object autoFormId(@PathVariable String tenantId, @PathVariable Integer companyId){
        ThreadData.set(TENANT_ID, tenantId);
        ThreadData.set(COMPANY_ID, companyId);
 
        TestAutoFormConsumer test = new TestAutoFormConsumer();
        test.onMessage(new Message(){
 
            @Override
            public byte[] getBody() {
                return ObjectUtil.objectToByte(
                        Context.getMQParam(
                                new ModelMap("tenantID", tenantId)
                                        .addAttribute("formID", "Ug12TTbi")
                                        .addAttribute("id", "4")
                                        .addAttribute("field", "number_expend")
                                        .addAttribute("fieldKey", "Rt")
                                        .addAttribute("fieldSize", "8")
                        )
                );
            }
 
            @Override
            public byte[] getChannel() {
                return new byte[0];
            }
        }, new byte[0]);
        return test.getVal();
    }
 
    @Data
    class TestAutoFormConsumer extends AutoFormConsumer {
 
        private Object val;
 
        @Override
        public Object getFromRest(String fs, Object parm) {
            log.debug(fs);
            log.debug(JSONTool.toJson(parm));
            this.val = ((Map)parm).get("number_expend");
            return null;
        }
 
 
    }
}