Преглед изворни кода

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

hy пре 7 година
родитељ
комит
ef0d35e1db
30 измењених фајлова са 563 додато и 85 уклоњено
  1. 4 3
      applications/operation/operation-server/src/main/java/com/usoftchina/saas/operation/mapper/AccountMapper.java
  2. 2 1
      applications/operation/operation-server/src/main/java/com/usoftchina/saas/operation/mapper/CompanyMapper.java
  3. 2 1
      applications/operation/operation-server/src/main/java/com/usoftchina/saas/operation/mapper/CustomerfeedbackMapper.java
  4. 4 1
      applications/operation/operation-server/src/main/resources/config/application-dev.yml
  5. 17 3
      applications/operation/operation-server/src/main/resources/mapper/AccoutMapper.xml
  6. 6 1
      applications/operation/operation-server/src/main/resources/mapper/CompanyMapper.xml
  7. 6 1
      applications/operation/operation-server/src/main/resources/mapper/CustomerfeedbackMapper.xml
  8. 0 1
      applications/transfers/mall-api/src/test/java/com/usoftchina/inquiry/test/SearchApiTest.java
  9. 13 0
      applications/transfers/transfers-server/pom.xml
  10. 2 2
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/TransfersApplication.java
  11. 3 1
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/controller/TransfersController.java
  12. 20 0
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/mapper/BrokerMessageLogMapper.java
  13. 29 15
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/po/BrokerMessagelog.java
  14. 2 13
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/po/MessageInfo.java
  15. 26 0
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/po/Status.java
  16. 45 4
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/service/ReceiveService.java
  17. 51 26
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/service/SendService.java
  18. 22 0
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/Executable.java
  19. 12 0
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseInTask.java
  20. 12 0
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseOutTask.java
  21. 12 0
      applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseTask.java
  22. 14 0
      applications/transfers/transfers-server/src/main/resources/application.yml
  23. 3 0
      applications/transfers/transfers-server/src/main/resources/config/application-dev.yml
  24. 128 0
      applications/transfers/transfers-server/src/main/resources/mapper/BrokermessagelogMapper.xml
  25. 2 2
      applications/transfers/transfers-server/src/test/java/com/usoftchina/saas/transfers/service/RabbitSendServiceTest.java
  26. 8 2
      frontend/saas-portal-web/src/components/conenter/enterprise.vue
  27. 114 4
      frontend/saas-portal-web/src/components/conenter/home.vue
  28. 1 1
      frontend/saas-portal-web/static/css/main.css
  29. BIN
      frontend/saas-portal-web/static/img/weiruan@2x.png
  30. 3 3
      frontend/saas-web/electron/package.json

+ 4 - 3
applications/operation/operation-server/src/main/java/com/usoftchina/saas/operation/mapper/AccountMapper.java

@@ -3,16 +3,17 @@ package com.usoftchina.saas.operation.mapper;
 import com.usoftchina.saas.operation.dto.AccountDTO;
 import com.usoftchina.saas.operation.dto.CompanyAnalyzeDTO;
 import com.usoftchina.saas.operation.dto.LoginDTO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 public interface AccountMapper {
 
-    List<AccountDTO> findAccountByCondition(String con);
+    List<AccountDTO> findAccountByCondition(@Param("con") String con);
 
-    List<LoginDTO> getLogin(String con);
+    List<LoginDTO> getLogin(@Param("con") String con);
 
-    List<CompanyAnalyzeDTO> getConpanyAnalyze(String con);
+    List<CompanyAnalyzeDTO> getConpanyAnalyze(@Param("con") String con);
 
     void analyzeCompany();
 }

+ 2 - 1
applications/operation/operation-server/src/main/java/com/usoftchina/saas/operation/mapper/CompanyMapper.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.operation.mapper;
 import com.usoftchina.saas.operation.dto.CompanyAnalyzeDTO;
 import com.usoftchina.saas.operation.dto.CompanyAnalyzedetailDTO;
 import com.usoftchina.saas.operation.dto.CompanyDTO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -13,7 +14,7 @@ import java.util.Map;
  **/
 public interface CompanyMapper {
 
-    List<CompanyDTO> findCompanyByCondition(String con);
+    List<CompanyDTO> findCompanyByCondition(@Param("con") String con);
 
     CompanyAnalyzeDTO selectCompanyAnalyze(Long id);
 

+ 2 - 1
applications/operation/operation-server/src/main/java/com/usoftchina/saas/operation/mapper/CustomerfeedbackMapper.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.operation.mapper;
 
 import com.usoftchina.saas.operation.po.CustomerFeedBack;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -17,5 +18,5 @@ public interface CustomerfeedbackMapper {
 
     int updateByPrimaryKey(CustomerFeedBack record);
 
-    List<CustomerFeedBack> selectByCondition(String con);
+    List<CustomerFeedBack> selectByCondition(@Param("con") String con);
 }

+ 4 - 1
applications/operation/operation-server/src/main/resources/config/application-dev.yml

@@ -10,4 +10,7 @@ eureka:
   client:
     registryFetchIntervalSeconds: 5
     serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:8500/eureka/
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:8500/eureka/
+logging:
+  level:
+    com.usoftchina.saas.operation.mapper : debug

+ 17 - 3
applications/operation/operation-server/src/main/resources/mapper/AccoutMapper.xml

@@ -38,15 +38,29 @@
     </resultMap>
 
     <select id="findAccountByCondition" parameterType="string" resultMap="BaseResultMap">
-        select * from saas_account.ac_account  where #{con}
+        select * from saas_account.ac_account  <where>
+        <if test="con != null">
+            ${con}
+        </if>
+    </where>
     </select>
     <select id="getLogin" parameterType="string" resultMap="loginMap">
         SELECT * FROM (select account_id  ,count(account_id) login_num,max(ac_account.realname) username,max(login_time) lastesttime, max(ac_account.mobile) mobile from au_authorize_log left join saas_account.ac_account on account_id= ac_account.id  where login_time >  date_sub(now(),interval 3 MONTH) GROUP BY account_id order by lastesttime desc
-        )login_info where #{con}
+        )login_info
+        <where>
+            <if test="con != null">
+                ${con}
+            </if>
+        </where>
     </select>
 
     <select id="getConpanyAnalyze" parameterType="string" resultMap="companymap">
-        select  *  from company_analyze  where #{con} order by ca_createtime desc
+        select  *  from company_analyze  <where>
+        <if test="con != null">
+            ${con}
+        </if>
+    </where>
+        order by ca_createtime desc
     </select>
 
     <select id="analyzeCompany"  statementType="CALLABLE">

+ 6 - 1
applications/operation/operation-server/src/main/resources/mapper/CompanyMapper.xml

@@ -15,7 +15,12 @@
 
     <select id="findCompanyByCondition" parameterType="string" resultMap="baseMap">
          select name,business_code,address,tel,fax,realname,mobile,ac_company.create_time,ac_company.uu from saas_account.ac_company
-        left join saas_account.ac_account on ac_account.id = ac_company.creator_id where #{con}
+        left join saas_account.ac_account on ac_account.id = ac_company.creator_id
+        <where>
+            <if test="con != null">
+                ${con}
+            </if>
+        </where>
     </select>
 
 

+ 6 - 1
applications/operation/operation-server/src/main/resources/mapper/CustomerfeedbackMapper.xml

@@ -165,6 +165,11 @@
     where cf_id = #{cf_id,jdbcType=INTEGER}
   </update>
   <select id="selectByCondition" parameterType="string" resultMap="BaseResultMap">
-      select * from saas_manage.customerfeedback where #{con} order by cf_creatime desc
+      select * from saas_manage.customerfeedback
+    <where>
+    <if test="con != null">
+      ${con}
+    </if>
+  </where> order by cf_creatime desc
   </select>
 </mapper>

+ 0 - 1
applications/transfers/mall-api/src/test/java/com/usoftchina/inquiry/test/SearchApiTest.java

@@ -1,7 +1,6 @@
 package com.usoftchina.inquiry.test;
 
 import com.usoftchina.inquiry.api.SearchApi;
-import com.usoftchina.inquiry.po.*;
 import com.usoftchina.inquiry.po.search.SearchComponentResp;
 import com.usoftchina.saas.utils.JsonUtils;
 import org.junit.FixMethodOrder;

+ 13 - 0
applications/transfers/transfers-server/pom.xml

@@ -48,6 +48,19 @@
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>commons-dto</artifactId>
+        </dependency>
+        <!-- db -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 2 - 2
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/TransfersApplication.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.transfers;
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@@ -8,10 +9,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 @SpringBootApplication
 @EnableEurekaClient
 @EnableFeignClients("com.usoftchina.saas")
+@MapperScan("com.usoftchina.saas.transfers.mapper")
 public class TransfersApplication {
     public static void main(String[] args) {
         SpringApplication.run(TransfersApplication.class, args);
     }
-
-
 }

+ 3 - 1
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/controller/TransfersController.java

@@ -5,6 +5,7 @@ import com.usoftchina.saas.transfers.po.MessageInfo;
 import com.usoftchina.saas.transfers.service.SendService;
 import com.usoftchina.saas.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -14,12 +15,13 @@ import org.springframework.web.bind.annotation.RestController;
  * @create: 2019-01-06 22:15
  **/
 @RestController
+@RequestMapping("/send")
 public class TransfersController {
 
     @Autowired
     private SendService sendService;
 
-    @RequestMapping("/sendMsg")
+    @PostMapping("/Message")
     public Result sendMsg(@RequestBody MessageInfo info) {
         if (StringUtils.isEmpty(info)) {
             return Result.error("信息为空");

+ 20 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/mapper/BrokerMessageLogMapper.java

@@ -8,4 +8,24 @@ import com.usoftchina.saas.transfers.po.BrokerMessagelog;
  **/
 public interface BrokerMessageLogMapper {
     BrokerMessagelog getMessage(String msgId);
+
+    BrokerMessagelog getLiveMessage(String msgId);
+
+    BrokerMessagelog getDeadMessage(String msgId);
+
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(BrokerMessagelog record);
+
+    int insertSelective(BrokerMessagelog record);
+
+    BrokerMessagelog selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(BrokerMessagelog record);
+
+    int updateByPrimaryKey(BrokerMessagelog record);
+
+    int updateMessageLogandAddRetry(BrokerMessagelog record);
+
+    void updateSuccess(String msgId);
 }

+ 29 - 15
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/po/BrokerMessagelog.java

@@ -1,19 +1,41 @@
 package com.usoftchina.saas.transfers.po;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
  * @author: guq
  * @create: 2018-12-29 09:46
  **/
-public class BrokerMessagelog {
+public class BrokerMessagelog implements Serializable{
 
     private Long id;
-    private String messageId;
+    private String msgId;
     private String message;
-    private Integer tryCount;
     private String status;
+
     private Date createTime;
+    private int retry;
+    /**
+     * 失败原因
+     */
+    private String reason;
+    public String getReason() {
+        return reason;
+    }
+
+    public void setReason(String reason) {
+        this.reason = reason;
+    }
+
+
+    public int getRetry() {
+        return retry;
+    }
+
+    public void setRetry(int retry) {
+        this.retry = retry;
+    }
 
     public Long getId() {
         return id;
@@ -23,12 +45,12 @@ public class BrokerMessagelog {
         this.id = id;
     }
 
-    public String getMessageId() {
-        return messageId;
+    public String getMsgId() {
+        return msgId;
     }
 
-    public void setMessageId(String messageId) {
-        this.messageId = messageId;
+    public void setMsgId(String msgId) {
+        this.msgId = msgId;
     }
 
     public String getMessage() {
@@ -39,14 +61,6 @@ public class BrokerMessagelog {
         this.message = message;
     }
 
-    public Integer getTryCount() {
-        return tryCount;
-    }
-
-    public void setTryCount(Integer tryCount) {
-        this.tryCount = tryCount;
-    }
-
     public String getStatus() {
         return status;
     }

+ 2 - 13
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/po/MessageInfo.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.transfers.po;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * @Description 消息内容
@@ -49,19 +50,6 @@ public class MessageInfo implements Serializable {
         this.timestamp = timestamp;
     }
 
-    public int getRetryCount() {
-        return retryCount;
-    }
-
-    public void setRetryCount(int retryCount) {
-        this.retryCount = retryCount;
-    }
-
-    /**
-     * 重试次数
-     */
-    private int retryCount;
-
     public String getMsgId() {
         return msgId;
     }
@@ -107,6 +95,7 @@ public class MessageInfo implements Serializable {
         this.appId = appId;
         this.bizType = bizType;
         this.bizId = bizId;
+        this.timestamp = new Date().getTime();
     }
 
     public MessageInfo() {

+ 26 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/po/Status.java

@@ -0,0 +1,26 @@
+package com.usoftchina.saas.transfers.po;
+
+public enum Status {
+
+    SEND("已发送"),
+
+    RETRY("重新发送"),
+
+    FAILURE("投递失败"),
+
+    SUCCESS("投递成功");
+
+    private String display;
+
+    public String getDisplay() {
+        return display;
+    }
+
+    public void setDisplay(String display) {
+        this.display = display;
+    }
+
+    Status(String display) {
+        this.display = display;
+    }
+}

+ 45 - 4
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/service/ReceiveService.java

@@ -1,8 +1,16 @@
 package com.usoftchina.saas.transfers.service;
 
 import com.rabbitmq.client.Channel;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.transfers.config.RabbitConfig;
+import com.usoftchina.saas.transfers.mapper.BrokerMessageLogMapper;
+import com.usoftchina.saas.transfers.po.BrokerMessagelog;
 import com.usoftchina.saas.transfers.po.MessageInfo;
+import com.usoftchina.saas.transfers.task.*;
+import com.usoftchina.saas.utils.JsonUtils;
+import com.usoftchina.saas.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.amqp.rabbit.annotation.*;
 import org.springframework.amqp.support.AmqpHeaders;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +19,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
 import org.springframework.messaging.handler.annotation.Headers;
 import org.springframework.messaging.handler.annotation.Payload;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
 import java.util.Map;
@@ -22,31 +31,62 @@ import java.util.Map;
 @Service
 public class ReceiveService {
 
+    @Autowired
+    private SendService sendService;
+
+    @Autowired
+    private BrokerMessageLogMapper brokerMessageLogMapper;
+
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
     private final static String EXCHANGE = "saas_trade_dev_exchange";
     private final static String DLEXCHANGE = "saas_trade_dev_dlexchange";
     private final static String QUEUE = "saas_trade_dev_queue";
     private final static String DLQUEUE = "saas_trade_dev_dlqueue";
     private final static String ROUTINGKEY = "saas_trade_dev_dl.*";
 
+
     //配置监听的哪一个队列,同时在没有queue和exchange的情况下会去创建并建立绑定关系
     @RabbitListener(bindings = @QueueBinding(value = @Queue(value = QUEUE,durable = "true"),
             exchange = @Exchange(name= DLEXCHANGE ,durable = "true",type = "topic"),
             key = ROUTINGKEY))
     @RabbitHandler
+    @Transactional
     public void onMessage(@Payload MessageInfo info, @Headers Map<String,Object> headers, Channel channel)
             throws IOException {
         //消费者操作
-        System.out.println("---------收到消息,开始消费---------");
-        System.out.println("订单ID:" + info.getBizId());
-        System.out.println("信息ID:" + info.getMsgId());
+       logger.info("---------收到消息,消息id={},开始消费---------", info.getMsgId());
+        Executable task = null;
+       try {
+           switch(BillCodeSeq.valueOf(info.getBizType())) {
+               case PURCHASE:
+                   task = new SendPurchaseTask();
+                   break;
+               case PURCHASEIN:
+                   task = new SendPurchaseInTask();
+                   break;
+               case PURCHASEOUT:
+                   task = new SendPurchaseOutTask();
+                   break;
+           }
+
+           task.execute();
 
+           //更新状态
+           brokerMessageLogMapper.updateSuccess(info.getMsgId());
+        } catch (Exception e) {
+            BrokerMessagelog message = brokerMessageLogMapper.getLiveMessage(info.getMsgId());
+            if (null != message && !StringUtils.isEmpty(message.getMessage())) {
+                MessageInfo messageInfo = JsonUtils.fromJsonString(message.getMessage(), MessageInfo.class);
+                sendService.sendDelayMessage(messageInfo, e.getMessage());
+            }
+        }
         /**
          * Delivery Tag 用来标识信道中投递的消息。RabbitMQ 推送消息给 Consumer 时,会附带一个 Delivery Tag,
          * 以便 Consumer 可以在消息确认时告诉 RabbitMQ 到底是哪条消息被确认了。
          * RabbitMQ 保证在每个信道中,每条消息的 Delivery Tag 从 1 开始递增。
          */
         Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
-
         /**
          *  multiple 取值为 false 时,表示通知 RabbitMQ 当前消息被确认
          *  如果为 true,则额外将比第一个参数指定的 delivery tag 小的消息一并确认
@@ -55,6 +95,7 @@ public class ReceiveService {
 
         //ACK,确认一条消息已经被消费
         channel.basicAck(deliveryTag,multiple);
+        //重新返回队列 重新消费
         //channel.basicNack(deliveryTag,false,true);
     }
 }

+ 51 - 26
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/service/SendService.java

@@ -5,6 +5,9 @@ import com.usoftchina.saas.transfers.config.RabbitConfig;
 import com.usoftchina.saas.transfers.mapper.BrokerMessageLogMapper;
 import com.usoftchina.saas.transfers.po.BrokerMessagelog;
 import com.usoftchina.saas.transfers.po.MessageInfo;
+import com.usoftchina.saas.transfers.po.Status;
+import com.usoftchina.saas.utils.JsonUtils;
+import com.usoftchina.saas.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -13,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+
 /**
  * @author: guq
  * @create: 2019-01-06 22:04
@@ -35,58 +40,78 @@ public class SendService {
 
     //发送消息方法调用: 构建自定义对象消息
     public void sendMessage(MessageInfo info) {
+        String messageId = info.getMsgId();
+        //消息入库
+        BrokerMessagelog messagelog = new BrokerMessagelog();
+        messagelog.setCreateTime(new Date());
+        messagelog.setMessage(JsonUtils.toJsonString(info));
+        messagelog.setMsgId(messageId);
+        messagelog.setStatus(Status.SEND.getDisplay());
+        messagelog.setRetry(0);
+        brokerMessageLogMapper.insertSelective(messagelog);
+
         // 通过实现 ConfirmCallback 接口,消息发送到 Broker 后触发回调,确认消息是否到达 Broker 服务器,也就是只确认是否正确到达 Exchange 中
         rabbitTemplate.setConfirmCallback(confirmCallback);
         //消息唯一ID
-        CorrelationData correlationData = new CorrelationData(info.getMsgId());
+        CorrelationData correlationData = new CorrelationData(messageId);
         rabbitTemplate.convertAndSend(rabbitConfig.getDlexchange(), rabbitConfig.getRoutingkey(), info, correlationData);
-    }
-
-    //发送消息方法调用: 构建自定义对象消息
-    public void sendDelayMessage(MessageInfo info) {
-        // 通过实现 ConfirmCallback 接口,消息发送到 Broker 后触发回调,确认消息是否到达 Broker 服务器,也就是只确认是否正确到达 Exchange 中
-        rabbitTemplate.setConfirmCallback(delayConfirmCallback);
-        //消息唯一ID
-        CorrelationData correlationData = new CorrelationData(info.getMsgId());
-        rabbitTemplate.convertAndSend(rabbitConfig.getExchange(), rabbitConfig.getRoutingkey(), info,
-                new ExpirationMessagePostProcessor(rabbitConfig.getExpired()), correlationData);
+        logger.info("msgId={}, 消息发送", messageId);
     }
 
     //回调函数: confirm确认
     final RabbitTemplate.ConfirmCallback confirmCallback = new RabbitTemplate.ConfirmCallback() {
         @Override
         public void confirm(CorrelationData correlationData, boolean confirm, String cause) {
-            System.out.println("correlationData: " + correlationData);
             String messageId = correlationData.getId();
             if (confirm) {
-                logger.info("msgId={},已发送服务器", correlationData.getId());
-                //如果confirm返回成功 则进行更新
-                // brokerMessageLogMapper.changeBrokerMessageLogStatus(messageId, Constants.ORDER_SEND_SUCCESS, new Date());
+                logger.info("msgId={},已发送服务器", messageId);
             } else {
-                //失败则进行具体的后续操作:重试 或者补偿等手段
-                BrokerMessagelog message = brokerMessageLogMapper.getMessage(correlationData.getId());
-                // sendDelayMessage((MessageInfo) message.getMessage());
+                //失败则进行具体的后续操作:进入延迟队列
+                BrokerMessagelog message = brokerMessageLogMapper.getLiveMessage(messageId);
+                String info = message.getMessage();
+                if (!StringUtils.isEmpty(info)) {
+                    MessageInfo messageInfo = JsonUtils.fromJsonString(info, MessageInfo.class);
+                    sendDelayMessage(messageInfo, cause);
+                }
                 logger.error("msgId={},发送失败:{}", correlationData.getId(), cause);
-
             }
         }
     };
 
-    //回调函数: confirm确认
+    //发送消息方法调用: 构建自定义对象消息
+    public void sendDelayMessage(MessageInfo info, String error) {
+        if (StringUtils.isEmpty(info) || StringUtils.isEmpty(info.getMsgId())) {
+            logger.error("消息为空");
+            return;
+        }
+        String messageId = info.getMsgId();
+        //更新状态且失败次数加1
+        BrokerMessagelog messagelog = new BrokerMessagelog();
+        messagelog.setMsgId(messageId);
+        messagelog.setStatus(Status.RETRY.getDisplay());
+        messagelog.setReason(error);
+        brokerMessageLogMapper.updateMessageLogandAddRetry(messagelog);
+
+        //发送至延迟队列
+        rabbitTemplate.setConfirmCallback(confirmCallback);
+        //消息唯一ID
+        CorrelationData correlationData = new CorrelationData(info.getMsgId());
+        rabbitTemplate.convertAndSend(rabbitConfig.getExchange(), rabbitConfig.getRoutingkey(), info,
+                new ExpirationMessagePostProcessor(rabbitConfig.getExpired()), correlationData);
+    }
+
+    /*//回调函数: confirm确认
     final RabbitTemplate.ConfirmCallback delayConfirmCallback = new RabbitTemplate.ConfirmCallback() {
         @Override
         public void confirm(CorrelationData correlationData, boolean confirm, String cause) {
-            System.err.println("correlationData: " + correlationData);
             String messageId = correlationData.getId();
             if (confirm) {
-                System.out.println("发射成功");
-                //如果confirm返回成功 则进行更新
-                // brokerMessageLogMapper.changeBrokerMessageLogStatus(messageId, Constants.ORDER_SEND_SUCCESS, new Date());
+                logger.info("msgId={},已发送延迟队列", messageId);
             } else {
                 //失败则进行具体的后续操作:重试 或者补偿等手段
-                System.err.println("发送失败,原因:" + cause);
+                logger.info("msgId={},发送延迟队列失败:{}", messageId, cause);
             }
         }
-    };
+    };*/
 
 }

+ 22 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/Executable.java

@@ -0,0 +1,22 @@
+package com.usoftchina.saas.transfers.task;
+
+/**
+ * @author: guq
+ * @create: 2019-01-08 13:38
+ **/
+public abstract class Executable {
+
+
+
+    /**
+     * @return 任务名称
+     */
+    protected String getTaskName() {
+        return this.getClass().getSimpleName();
+    }
+
+    /**
+     * 执行任务
+     */
+    public abstract void execute();
+}

+ 12 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseInTask.java

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.transfers.task;
+
+/**
+ * @author: guq
+ * @create: 2019-01-08 13:53
+ **/
+public class SendPurchaseInTask extends Executable{
+    @Override
+    public void execute() {
+        //TODO
+    }
+}

+ 12 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseOutTask.java

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.transfers.task;
+
+/**
+ * @author: guq
+ * @create: 2019-01-08 13:53
+ **/
+public class SendPurchaseOutTask extends Executable{
+    @Override
+    public void execute() {
+        //TODO
+    }
+}

+ 12 - 0
applications/transfers/transfers-server/src/main/java/com/usoftchina/saas/transfers/task/SendPurchaseTask.java

@@ -0,0 +1,12 @@
+package com.usoftchina.saas.transfers.task;
+
+/**
+ * @author: guq
+ * @create: 2019-01-08 13:45
+ **/
+public class SendPurchaseTask extends Executable {
+    @Override
+    public void execute() {
+        //TODO
+    }
+}

+ 14 - 0
applications/transfers/transfers-server/src/main/resources/application.yml

@@ -5,6 +5,17 @@ spring:
     user:
       name: admin
       password: select111***
+  datasource:
+      driver-class-name: com.mysql.jdbc.Driver
+      url: jdbc:mysql://10.1.81.79:3306/saas_biz?characterEncoding=utf-8&useSSL=false&allowMultiQueries=true
+      username: root
+      password: select111***
+      hikari:
+        minimum-idle: 5
+        maximum-pool-size: 50
+        idle-timeout: 30000
+        max-lifetime: 1800000
+        connection-timeout: 30000
   messages:
     basename: i18n/messages
     encoding: UTF-8
@@ -60,6 +71,9 @@ info:
   version: '@project.version@'
   spring-boot-version: '@spring.boot.version@'
   spring-cloud-version: '@spring.cloud.version@'
+mybatis:
+  type-aliases-package: com.usoftchina.saas.transfers.po
+  mapper-locations: classpath:mapper/*.xml
 auth:
   public-key: auth/pub.key
 ribbon:

+ 3 - 0
applications/transfers/transfers-server/src/main/resources/config/application-dev.yml

@@ -11,3 +11,6 @@ eureka:
     registryFetchIntervalSeconds: 5
     serviceUrl:
       defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@127.0.0.1:8500/eureka/
+logging:
+  level:
+    com.usoftchina.saas.transfers.mapper : debug

+ 128 - 0
applications/transfers/transfers-server/src/main/resources/mapper/BrokermessagelogMapper.xml

@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.transfers.mapper.BrokerMessageLogMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.transfers.po.BrokerMessagelog" >
+    <id column="id" property="id" jdbcType="INTEGER" />
+    <result column="msgId" property="msgId" jdbcType="VARCHAR" />
+    <result column="message" property="message" jdbcType="VARCHAR" />
+    <result column="status" property="status" jdbcType="VARCHAR" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
+    <result column="reason" property="reason" jdbcType="VARCHAR" />
+    <result column="retry" property="retry" jdbcType="INTEGER" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    id, msgId, message, status, createTime, reason, retry
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+    select 
+    <include refid="Base_Column_List" />
+    from brokermessagelog
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
+    delete from brokermessagelog
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.saas.transfers.po.BrokerMessagelog" >
+    insert into brokermessagelog (msgId, message,
+      status, createTime, reason
+      )
+    values ( #{msgId,jdbcType=VARCHAR}, #{message,jdbcType=VARCHAR},
+      #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{reason,jdbcType=VARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.transfers.po.BrokerMessagelog" >
+    insert into brokermessagelog
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="msgId != null" >
+        msgId,
+      </if>
+      <if test="message != null" >
+        message,
+      </if>
+      <if test="status != null" >
+        status,
+      </if>
+      <if test="createTime != null" >
+        createTime,
+      </if>
+      <if test="reason != null" >
+        reason,
+      </if>
+      <if test="retry != null" >
+        retry,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="msgId != null" >
+        #{msgId,jdbcType=VARCHAR},
+      </if>
+      <if test="message != null" >
+        #{message,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null" >
+        #{status,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="reason != null" >
+        #{reason,jdbcType=VARCHAR},
+      </if>
+      <if test="retry != null" >
+        #{retry},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.transfers.po.BrokerMessagelog" >
+    update brokermessagelog
+    <set >
+      <if test="message != null" >
+        message = #{message,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null" >
+        status = #{status,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        createTime = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="reason != null" >
+        reason = #{reason,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where msgId = #{msgId,jdbcType=VARCHAR}
+  </update>
+
+  <update id="updateMessageLogandAddRetry" parameterType="com.usoftchina.saas.transfers.po.BrokerMessagelog" >
+    update brokermessagelog
+    set  status = #{status}, reason = #{reason}, retry = retry + 1
+    where msgId = #{msgId,jdbcType=VARCHAR}
+  </update>
+
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.transfers.po.BrokerMessagelog" >
+    update brokermessagelog
+    set msgId = #{msgId,jdbcType=VARCHAR},
+      message = #{message,jdbcType=VARCHAR},
+      status = #{status,jdbcType=VARCHAR},
+      createTime = #{createTime,jdbcType=TIMESTAMP},
+      reason = #{reason,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+
+  <select id="getMessage" parameterType="string" resultMap="BaseResultMap">
+    select * from BrokerMessagelog where msgId = #{msgId}
+  </select>
+
+  <select id="getLiveMessage" parameterType="string" resultMap="BaseResultMap">
+    select * from BrokerMessagelog where msgId = #{msgId} and retry &lt; 3
+  </select>
+
+  <select id="getDeadMessage" parameterType="string" resultMap="BaseResultMap">
+    select * from BrokerMessagelog where msgId = #{msgId} and retry &gt; 3
+  </select>
+
+  <update id="updateSuccess" parameterType="string">
+    update BrokerMessagelog set status='投递成功',reason='' where msgid = #{msgId}
+  </update>
+</mapper>

+ 2 - 2
applications/transfers/transfers-server/src/test/java/com/usoftchina/saas/transfers/service/RabbitSendServiceTest.java

@@ -25,7 +25,7 @@ public class RabbitSendServiceTest {
     public void TestA_Send() {
         MessageInfo msg = new MessageInfo();
         msg.setBizId("测试");
-        msg.setMsgId("测试0001");
+        msg.setMsgId("测试00001");
         sendService.sendMessage(msg);
     }
 
@@ -34,7 +34,7 @@ public class RabbitSendServiceTest {
         MessageInfo msg = new MessageInfo();
         msg.setBizId("测试");
         msg.setMsgId("测试延迟0001");
-        sendService.sendDelayMessage(msg);
+        sendService.sendDelayMessage(msg, "测试");
     }
 
 

+ 8 - 2
frontend/saas-portal-web/src/components/conenter/enterprise.vue

@@ -38,6 +38,7 @@
                 <li><router-link to="/home"><a @click="setTurnHome"><span style="color: white">首页</span></a></router-link></li>
                 <li><a href="#" @click="feature"><span>特色</span></a></li>
                 <li><a href="#" @click="service"><span>功能</span></a></li>
+                <!-- <li><a href="#" @click="download"><span>下载</span></a></li> -->
                 <!-- <router-link to="/invitation"><a ><span style="color: white">邀请</span></a></router-link> -->
                 <li>
                     <el-menu  
@@ -450,12 +451,17 @@ import { setTimeout } from 'timers';
             },
             // 特色
             feature(){
-                this.$router.push({name: 'Home', params: {isfeature: 700}});
+                this.$router.push({name: 'Home', params: {isfeature: 730}});
                 this.setTurnHome();
             },
             //功能
             service(){
-                this.$router.push({name: 'Home', params: {isfeature: 3550}});
+                this.$router.push({name: 'Home', params: {isfeature: 3670}});
+                this.setTurnHome();
+            },
+            // 下载
+            download(){
+                this.$router.push({name: 'Home', params: {isfeature: 4400}});
                 this.setTurnHome();
             },
             gohome(e){

+ 114 - 4
frontend/saas-portal-web/src/components/conenter/home.vue

@@ -47,6 +47,7 @@
             <li><a href="#" @click="setTurnHome"><span>首页</span></a></li>
             <li class="xs"><a @click="feature2"><span>特色</span></a></li>
             <li class="xs"><a @click="service2"><span>功能</span></a></li>
+            <!-- <li class="xs"><a @click="download"><span>下载</span></a></li> -->
             <li>
               <el-menu  
               class="el-menu-demo" 
@@ -252,6 +253,45 @@
         </div>
       </section>
       <!-- end Service section -->
+      <!-- 下载 -->
+      <!-- <section>
+        <div class="container ts-worp">
+          <div class="section-title text-center" style="margin-bottom: 50px">
+            <p class="ts-title">下载</p>
+            <p class="ts-text">下载U企云服客户端</p>
+          </div>
+          <div class="download-conenter">
+            <div class="left download-box">
+              <div class="download-box-shang">
+                <img style="width:140px" src="/static/img/weiruan@2x.png" alt="">
+              </div>
+              <div class="download-box-xia">
+                <p class="download-title">U企云服PC版</p>
+                <p>适用于Windows86</p>
+                <p class="download-Edition">
+                  <span>-最新版:16.30.0</span> <br/>
+                  <span>-发布时间:2018-10-20</span>
+                </p>
+                <button class="download-btn" @click="downloadOne">立即下载</button>
+              </div>
+            </div>
+            <div class="right download-box">
+              <div class="download-box-shang">
+                <img style="width:140px" src="/static/img/weiruan@2x.png" alt="">
+              </div>
+              <div class="download-box-xia">
+                <p class="download-title">U企云服PC版</p>
+                <p>适用于Windows64</p>
+                <p class="download-Edition">
+                  <span>-最新版:16.30.0</span> <br/>
+                  <span>-发布时间:2018-10-20</span>
+                </p>
+                <button class="download-btn">立即下载</button>
+              </div>
+            </div>
+          </div>
+        </div>
+      </section> -->
     </main>
     <problem v-else></problem>
   </div>
@@ -316,7 +356,7 @@
               const me = this || _this;
               //点击首页按钮时不跳转企业列表
               if(!me.$parent.turnHome){
-                me.$router.push({path: '/enterprise'})
+                me.$router.push({path: '/enterprise'});
               }else{
                 me.$parent.turnHome = false
               }
@@ -331,7 +371,6 @@
       document.documentElement.scrollTop = this.isfeature;
       $(window).scroll(function() {
         let Y = $(window).scrollTop();
-        console.log(Y);
         if (Y >= 500 && Y <= 1500) {
           $(".animate1").stop();
           $(".animate1").animate({
@@ -482,6 +521,21 @@
           me.isRegister = false
         })
       },
+      // 下载1
+      downloadOne(){
+        console.log('我是下载按钮')
+        let url = '/static/img/banner--X.jpg';
+        // let url = 'http://h.hiphotos.baidu.com/image/h%3D300/sign=f2db86688ccb39dbdec06156e01709a7/2f738bd4b31c87018e9450642a7f9e2f0708ff16.jpg';
+        let alink = document.createElement("a");
+        alink.style.display = 'none';
+        // let blob = new Blob([url]);
+        // alink.href = URL.createObjectURL(blob);
+        alink.href = url;//下载地址
+        alink.download = "pic"; //文件名(自定义)
+        document.body.appendChild(alink);
+        alink.click();
+        // URL.revokeObjectURL(alink.href);
+      },
       //体验
       experience(){
         if (this.account) {
@@ -546,14 +600,21 @@
       //特色
       feature2(){
         setTimeout(()=>{
-          document.documentElement.scrollTop = 700;
+          document.documentElement.scrollTop = 730;
         },5);
         this.setTurnHome();
       },
       //功能
       service2(){
         setTimeout(()=>{
-          document.documentElement.scrollTop = 3550;
+          document.documentElement.scrollTop = 3670;
+        },5);
+        this.setTurnHome();
+      },
+      // 下载
+      download(){
+        setTimeout(()=>{
+          document.documentElement.scrollTop = 4400;
         },5);
         this.setTurnHome();
       },
@@ -674,4 +735,53 @@
   display: inline-block;
   height: 16px;
 }
+/* 下载 */
+.download-conenter {
+  width: 55%;
+  height: 420px;
+  position: relative;
+  left: 50%;
+  transform: translateX(-50%);
+  margin-bottom: 100px;
+}
+.download-box {
+  width: 49%;
+  height: 100%;
+  border: 1px solid #5DA9F8;
+}
+.download-box-shang {
+  height: 50%;
+  background: #1E88F5;
+  text-align: center;
+  line-height: 210px;
+}
+.download-title {
+  font-size: 18px;
+  color: #0D253E;
+  font-weight: 550;
+}
+.download-box-xia {
+  text-align: center;
+  padding: 20px;
+  line-height: 30px;
+  color: rgb(103, 107, 112);
+  font-size: 14px;
+}
+.download-Edition {
+  text-align: left;
+  margin-left: 28%;
+  line-height: 20px;
+}
+.download-btn {
+  font-family: PingFangSC-Regular;
+  font-size: 14px;
+  color: #FFFFFF;
+  letter-spacing: 0.7px;
+  background: #1E88F5;
+  box-shadow: 0 0 99px 0 #E4F2FF;
+  border-radius: 4px;
+  padding: 2px 30px;
+  border: 0;
+  margin-top: 5%
+}
 </style>

+ 1 - 1
frontend/saas-portal-web/static/css/main.css

@@ -38,7 +38,7 @@ h1, h2, h3, h4, h5, h6,
     color: #252525;
 }
 p {
-    font-size: 15px;
+    font-size: 14px;
 }
 li {
     list-style: none;

BIN
frontend/saas-portal-web/static/img/weiruan@2x.png


+ 3 - 3
frontend/saas-web/electron/package.json

@@ -1,14 +1,14 @@
 {
   "name": "UsoftchinaSaasClient",
-  "version": "0.0.2",
+  "version": "0.0.3",
   "description": "saas在线进销存系统",
   "main": "./main.js",
   "scripts": {
     "dev-start": "electron . dev",
     "local-start": "electron . local",
     "build": "cd ../ && sencha app build --build prod --destination electron/dist/ --production",
-    "pack": "npm run build && electron-builder --dir",
-    "dist": "npm run build && electron-builder"
+    "pack": "npm run build && electron-builder --win --x64 --ia32 --dir",
+    "dist": "npm run build && electron-builder --win --x64 --ia32"
   },
   "author": "深圳市优软科技有限公司",
   "license": "ISC",