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