| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.mq.MessageProducer; | |||||
| import com.iformall.service.WxFlowService; | import com.iformall.service.WxFlowService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -21,6 +22,15 @@ public class WxFlowAbleController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxFlowService wxFlowService; | private WxFlowService wxFlowService; | ||||
| @Autowired | |||||
| private MessageProducer messageProducer; | |||||
| @ApiOperation(value = "mqSend",notes = "") | |||||
| @PostMapping("/mqSend") | |||||
| public ResultData mqSend() { | |||||
| messageProducer.sendMessage("aaaa","topic-1","tag1","key1"); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation(value = "启动流程",notes = "{\"businessId\":\"221178539888607232\",\"businessType\":1,\"remark\":\"意见意见。\",\"taskAssignee\":[{\"taskKey\":\"firstTaskUser\",\"assignee\":\"243650055783841792\"},{\"taskKey\":\"secondTaskUser\",\"assignee\":\"\"}],\"variables\":[{\"key\":\"contractType\",\"value\":\"1\"},{\"key\":\"contractNumber\",\"value\":\"1111\"}]}") | @ApiOperation(value = "启动流程",notes = "{\"businessId\":\"221178539888607232\",\"businessType\":1,\"remark\":\"意见意见。\",\"taskAssignee\":[{\"taskKey\":\"firstTaskUser\",\"assignee\":\"243650055783841792\"},{\"taskKey\":\"secondTaskUser\",\"assignee\":\"\"}],\"variables\":[{\"key\":\"contractType\",\"value\":\"1\"},{\"key\":\"contractNumber\",\"value\":\"1111\"}]}") | ||||
| @PostMapping("/start") | @PostMapping("/start") | ||||
| @@ -22,7 +22,7 @@ spring: | |||||
| redis: | redis: | ||||
| time-to-live: 60000ms #很重要,缓存的有效时间,以便缓存的过期(单位为毫秒) | time-to-live: 60000ms #很重要,缓存的有效时间,以便缓存的过期(单位为毫秒) | ||||
| rocketmq: | rocketmq: | ||||
| nameServer: 127.0.0.1:9876 | |||||
| nameServer: 202.165.179.86:9876 | |||||
| producer: | producer: | ||||
| retry-times-when-send-async-failed: 0 | retry-times-when-send-async-failed: 0 | ||||
| send-msg-timeout: 300000 | send-msg-timeout: 300000 | ||||
| @@ -31,6 +31,7 @@ spring: | |||||
| retry-another-broker-when-not-store-ok: false | retry-another-broker-when-not-store-ok: false | ||||
| retry-times-when-send-failed: 2 | retry-times-when-send-failed: 2 | ||||
| # @{link} https://github.com/abel533 | # @{link} https://github.com/abel533 | ||||
| #Mybatis | #Mybatis | ||||
| mybatis: | mybatis: | ||||
| @@ -6,6 +6,8 @@ import org.apache.rocketmq.client.producer.SendCallback; | |||||
| import org.apache.rocketmq.client.producer.SendResult; | import org.apache.rocketmq.client.producer.SendResult; | ||||
| import org.apache.rocketmq.common.message.Message; | import org.apache.rocketmq.common.message.Message; | ||||
| import org.apache.rocketmq.remoting.common.RemotingHelper; | import org.apache.rocketmq.remoting.common.RemotingHelper; | ||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -19,6 +21,8 @@ import javax.annotation.PostConstruct; | |||||
| @Service | @Service | ||||
| @Slf4j | @Slf4j | ||||
| public class MessageProducer { | public class MessageProducer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | |||||
| @Value("${spring.rocketmq.nameServer}") | @Value("${spring.rocketmq.nameServer}") | ||||
| private String namesrvAddr; | private String namesrvAddr; | ||||
| @@ -3,12 +3,15 @@ package com.iformall.mq; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.rocketmq.starter.annotation.RocketMQListener; | import org.rocketmq.starter.annotation.RocketMQListener; | ||||
| import org.rocketmq.starter.annotation.RocketMQMessage; | import org.rocketmq.starter.annotation.RocketMQMessage; | ||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @Slf4j | @Slf4j | ||||
| @Service | @Service | ||||
| @RocketMQListener(topic = "topic-1") | @RocketMQListener(topic = "topic-1") | ||||
| public class MqConsumer { | public class MqConsumer { | ||||
| private final Logger log = LoggerFactory.getLogger(this.getClass()); | |||||
| @RocketMQMessage(messageClass = String.class, tag = "tag-1") | @RocketMQMessage(messageClass = String.class, tag = "tag-1") | ||||
| public void onMessage(String message) { | public void onMessage(String message) { | ||||
| @@ -216,7 +216,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| message = "更新物业合同信息成功"; | message = "更新物业合同信息成功"; | ||||
| } | } | ||||
| try { | |||||
| // 启动审批流 | |||||
| if(record.getFlowParams() != null){ | |||||
| record.getFlowParams().put("businessId",record.getId().toString()); | record.getFlowParams().put("businessId",record.getId().toString()); | ||||
| wxFlowService.start(record.getFlowParams(),userId,userName,record.getTenantId()); | wxFlowService.start(record.getFlowParams(),userId,userName,record.getTenantId()); | ||||
| @@ -226,9 +227,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||||
| updateRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | updateRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | ||||
| wxPropertyContractMapper.updateStatus(updateRentContract); | wxPropertyContractMapper.updateStatus(updateRentContract); | ||||
| logger.info("id:{},启动审批流成功",record.getId().toString()); | logger.info("id:{},启动审批流成功",record.getId().toString()); | ||||
| } catch (Exception e) { | |||||
| logger.error("启动审批流失败,e:" + e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.FLOW_FAIL.getCode(), "FLOW FAILD " + e.getMessage()); | |||||
| } | } | ||||
| return new ResultData(Result.SUCCESS, message, record); | return new ResultData(Result.SUCCESS, message, record); | ||||
| } | } | ||||
| @@ -13,12 +13,11 @@ | |||||
| <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/> | <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/> | ||||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | ||||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | <result column="phone" jdbcType="VARCHAR" property="phone"/> | ||||
| <result column="open_id" jdbcType="VARCHAR" property="openId"/> | |||||
| <result column="flow_permission" property="flowPermission"/> | <result column="flow_permission" property="flowPermission"/> | ||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone`,`open_id`,`flow_permission` | |||||
| `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone`,`flow_permission` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||