Browse Source

消息迁移

hym 3 years ago
parent
commit
39ede71105

+ 84 - 0
zoniot-pay/zoniot-pay-core/src/main/java/com/zcxk/rmcp/pay/dao/OrgMapper.java

@@ -0,0 +1,84 @@
+package com.zcxk.rmcp.pay.dao;
+
+import com.bz.zoneiot.core.common.pojo.UserCondition;
+
+import com.zcxk.rmcp.pay.entity.Org;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author linqingwei
+ * @date 2021-07-22 10:26
+ */
+@Mapper
+public interface OrgMapper {
+
+    /**
+    * 添加数据
+    * @author Andy
+    * @date 14:56 2021/8/3
+    * @param record:
+    * @return int
+    **/
+    int insertSelective(Org record);
+
+    /**
+    * 更新数据
+    * @author Andy
+    * @date 14:56 2021/8/3
+    * @param record:
+    * @return int
+    **/
+    int updateByPrimaryKeySelective(Org record);
+
+    /**
+    * 如果id存在,则删除再插入,如果不存在则插入
+    * @author Andy
+    * @date 14:57 2021/8/3
+    * @param org:
+    * @return void
+    **/
+    void replaceInsert(Org org);
+
+    /**
+    * 物理删除
+    * @author Andy
+    * @date 14:57 2021/8/3
+    * @param id:
+    * @return int
+    **/
+    int deleteById(int id);
+
+    /**
+    * 查找集合
+    * @author Andy
+    * @date 14:57 2021/8/3
+    * @param userCondition:
+    * @return java.util.List<com.zcxk.rmcp.core.entity.Org>
+    **/
+    List<Org> findList(@Param("orgType") String orgType, @Param("userCondition") UserCondition userCondition);
+
+    /**
+    * 根据名字查找
+    * @author Andy
+    * @date 14:57 2021/8/3
+    * @param tenantId:
+    * @param name:
+    * @return com.zcxk.rmcp.core.entity.Org
+    **/
+    Org findByName(@Param("tenantId") String tenantId, @Param("name") String name);
+
+    /**
+    * 查找父节点
+    * @author Andy
+    * @date 14:57 2021/8/3
+    * @param parentId:
+    * @param name:
+    * @return com.zcxk.rmcp.core.entity.Org
+    **/
+    Org findByParentIdAndName(@Param("parentId") Integer parentId, @Param("name") String name);
+
+
+}

+ 99 - 0
zoniot-pay/zoniot-pay-core/src/main/java/com/zcxk/rmcp/pay/entity/Org.java

@@ -0,0 +1,99 @@
+package com.zcxk.rmcp.pay.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 组织(Org)实体类
+ *
+ * @author makejava
+ * @since 2020-11-19 09:55:20
+ */
+@Data
+@ApiModel
+public class Org implements Serializable {
+    private static final long serialVersionUID = 813791045057448389L;
+    /**
+     * 主键
+     */
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+    /**
+     * 租户标识
+     */
+    @ApiModelProperty(value = "租户标识")
+    private String tenantId;
+    /**
+     * 机构类型
+     */
+    @ApiModelProperty(value = "机构类型")
+    private String orgType;
+    /**
+     * 上级机构
+     */
+    @ApiModelProperty(value = "上级机构")
+    private Integer parentOrgId;
+    /**
+     * 机构所在区域
+     */
+    @ApiModelProperty(value = "机构所在区域")
+    private Integer orgAreaId;
+    /**
+     * 机构名称
+     */
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+    /**
+     * 机构状态
+     */
+    @ApiModelProperty(value = "机构状态")
+    private Integer orgState;
+    /**
+     * 备注
+     */
+    @ApiModelProperty(value = "备注")
+    private String remark;
+    /**
+     * 机构负责人名称
+     */
+    @ApiModelProperty(value = "机构负责人名称")
+    private String orgLeaderName;
+    /**
+     * 机构负责人手机
+     */
+    @ApiModelProperty(value = "机构负责人手机")
+    private String orgLeaderPhone;
+    /**
+     * 机构负责人邮箱
+     */
+    @ApiModelProperty(value = "机构负责人邮箱")
+    private String orgLeaderEmail;
+    /**
+     * 机构负责人性别
+     */
+    @ApiModelProperty(value = "机构负责人性别")
+    private String orgLeaderSex;
+    /**
+     * 数据删除标记
+     */
+    @ApiModelProperty(value = "数据删除标记")
+    private Integer status;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date dateCreate;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    @ApiModelProperty(value = "")
+    private Date dateUpdate;
+    @ApiModelProperty(value = "")
+    private String updateBy;
+}

+ 335 - 0
zoniot-pay/zoniot-pay-core/src/main/resources/mapper/OrgMapper.xml

@@ -0,0 +1,335 @@
+<?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.zcxk.rmcp.pay.dao.OrgMapper">
+  <resultMap id="BaseResultMap" type="com.zcxk.rmcp.pay.entity.Org">
+    <!--@mbg.generated-->
+    <!--@Table rmcp_org-->
+    <id column="ID" property="id" />
+    <result column="TENANT_ID" property="tenantId" />
+    <result column="ORG_TYPE" property="orgType" />
+    <result column="PARENT_ORG_ID" property="parentOrgId" />
+    <result column="ORG_AREA_ID" property="orgAreaId" />
+    <result column="ORG_NAME" property="orgName" />
+    <result column="ORG_STATE" property="orgState" />
+    <result column="REMARK" property="remark" />
+    <result column="ORG_LEADER_NAME" property="orgLeaderName" />
+    <result column="ORG_LEADER_PHONE" property="orgLeaderPhone" />
+    <result column="ORG_LEADER_EMAIL" property="orgLeaderEmail" />
+    <result column="ORG_LEADER_SEX" property="orgLeaderSex" />
+    <result column="STATUS" property="status" />
+    <result column="DATE_CREATE" property="dateCreate" />
+    <result column="CREATE_BY" property="createBy" />
+    <result column="DATE_UPDATE" property="dateUpdate" />
+    <result column="UPDATE_BY" property="updateBy" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    ID, TENANT_ID, ORG_TYPE, PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK, 
+    ORG_LEADER_NAME, ORG_LEADER_PHONE, ORG_LEADER_EMAIL, ORG_LEADER_SEX, `STATUS`, DATE_CREATE, 
+    CREATE_BY, DATE_UPDATE, UPDATE_BY
+  </sql>
+
+  <insert id="replaceInsert" parameterType="com.zcxk.rmcp.pay.entity.Org">
+    REPLACE into rmcp_org
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        ID,
+      </if>
+      <if test="tenantId != null">
+        TENANT_ID,
+      </if>
+      <if test="orgType != null">
+        ORG_TYPE,
+      </if>
+      <if test="parentOrgId != null">
+        PARENT_ORG_ID,
+      </if>
+      <if test="orgAreaId != null">
+        ORG_AREA_ID,
+      </if>
+      <if test="orgName != null">
+        ORG_NAME,
+      </if>
+      <if test="orgState != null">
+        ORG_STATE,
+      </if>
+      <if test="remark != null">
+        REMARK,
+      </if>
+      <if test="orgLeaderName != null">
+        ORG_LEADER_NAME,
+      </if>
+      <if test="orgLeaderPhone != null">
+        ORG_LEADER_PHONE,
+      </if>
+      <if test="orgLeaderEmail != null">
+        ORG_LEADER_EMAIL,
+      </if>
+      <if test="orgLeaderSex != null">
+        ORG_LEADER_SEX,
+      </if>
+      <if test="status != null">
+        `STATUS`,
+      </if>
+      <if test="dateCreate != null">
+        DATE_CREATE,
+      </if>
+      <if test="createBy != null">
+        CREATE_BY,
+      </if>
+      <if test="dateUpdate != null">
+        DATE_UPDATE,
+      </if>
+      <if test="updateBy != null">
+        UPDATE_BY,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id},
+      </if>
+      <if test="tenantId != null">
+        #{tenantId},
+      </if>
+      <if test="orgType != null">
+        #{orgType},
+      </if>
+      <if test="parentOrgId != null">
+        #{parentOrgId},
+      </if>
+      <if test="orgAreaId != null">
+        #{orgAreaId},
+      </if>
+      <if test="orgName != null">
+        #{orgName},
+      </if>
+      <if test="orgState != null">
+        #{orgState},
+      </if>
+      <if test="remark != null">
+        #{remark},
+      </if>
+      <if test="orgLeaderName != null">
+        #{orgLeaderName},
+      </if>
+      <if test="orgLeaderPhone != null">
+        #{orgLeaderPhone},
+      </if>
+      <if test="orgLeaderEmail != null">
+        #{orgLeaderEmail},
+      </if>
+      <if test="orgLeaderSex != null">
+        #{orgLeaderSex},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+    </trim>
+  </insert>
+  <insert id="insertSelective" keyColumn="ID" keyProperty="id" parameterType="com.zcxk.rmcp.pay.entity.Org" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into rmcp_org
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="tenantId != null">
+        TENANT_ID,
+      </if>
+      <if test="orgType != null">
+        ORG_TYPE,
+      </if>
+      <if test="parentOrgId != null">
+        PARENT_ORG_ID,
+      </if>
+      <if test="orgAreaId != null">
+        ORG_AREA_ID,
+      </if>
+      <if test="orgName != null">
+        ORG_NAME,
+      </if>
+      <if test="orgState != null">
+        ORG_STATE,
+      </if>
+      <if test="remark != null">
+        REMARK,
+      </if>
+      <if test="orgLeaderName != null">
+        ORG_LEADER_NAME,
+      </if>
+      <if test="orgLeaderPhone != null">
+        ORG_LEADER_PHONE,
+      </if>
+      <if test="orgLeaderEmail != null">
+        ORG_LEADER_EMAIL,
+      </if>
+      <if test="orgLeaderSex != null">
+        ORG_LEADER_SEX,
+      </if>
+      <if test="status != null">
+        `STATUS`,
+      </if>
+      <if test="dateCreate != null">
+        DATE_CREATE,
+      </if>
+      <if test="createBy != null">
+        CREATE_BY,
+      </if>
+      <if test="dateUpdate != null">
+        DATE_UPDATE,
+      </if>
+      <if test="updateBy != null">
+        UPDATE_BY,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="tenantId != null">
+        #{tenantId},
+      </if>
+      <if test="orgType != null">
+        #{orgType},
+      </if>
+      <if test="parentOrgId != null">
+        #{parentOrgId},
+      </if>
+      <if test="orgAreaId != null">
+        #{orgAreaId},
+      </if>
+      <if test="orgName != null">
+        #{orgName},
+      </if>
+      <if test="orgState != null">
+        #{orgState},
+      </if>
+      <if test="remark != null">
+        #{remark},
+      </if>
+      <if test="orgLeaderName != null">
+        #{orgLeaderName},
+      </if>
+      <if test="orgLeaderPhone != null">
+        #{orgLeaderPhone},
+      </if>
+      <if test="orgLeaderEmail != null">
+        #{orgLeaderEmail},
+      </if>
+      <if test="orgLeaderSex != null">
+        #{orgLeaderSex},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="dateCreate != null">
+        #{dateCreate},
+      </if>
+      <if test="createBy != null">
+        #{createBy},
+      </if>
+      <if test="dateUpdate != null">
+        #{dateUpdate},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.zcxk.rmcp.pay.entity.Org">
+    <!--@mbg.generated-->
+    update rmcp_org
+    <set>
+      <if test="tenantId != null">
+        TENANT_ID = #{tenantId},
+      </if>
+      <if test="orgType != null">
+        ORG_TYPE = #{orgType},
+      </if>
+      <if test="parentOrgId != null">
+        PARENT_ORG_ID = #{parentOrgId},
+      </if>
+      <if test="orgAreaId != null">
+        ORG_AREA_ID = #{orgAreaId},
+      </if>
+      <if test="orgName != null">
+        ORG_NAME = #{orgName},
+      </if>
+      <if test="orgState != null">
+        ORG_STATE = #{orgState},
+      </if>
+      <if test="remark != null">
+        REMARK = #{remark},
+      </if>
+      <if test="orgLeaderName != null">
+        ORG_LEADER_NAME = #{orgLeaderName},
+      </if>
+      <if test="orgLeaderPhone != null">
+        ORG_LEADER_PHONE = #{orgLeaderPhone},
+      </if>
+      <if test="orgLeaderEmail != null">
+        ORG_LEADER_EMAIL = #{orgLeaderEmail},
+      </if>
+      <if test="orgLeaderSex != null">
+        ORG_LEADER_SEX = #{orgLeaderSex},
+      </if>
+      <if test="status != null">
+        `STATUS` = #{status},
+      </if>
+      <if test="dateCreate != null">
+        DATE_CREATE = #{dateCreate},
+      </if>
+      <if test="createBy != null">
+        CREATE_BY = #{createBy},
+      </if>
+      <if test="dateUpdate != null">
+        DATE_UPDATE = #{dateUpdate},
+      </if>
+      <if test="updateBy != null">
+        UPDATE_BY = #{updateBy},
+      </if>
+    </set>
+    where ID = #{id}
+  </update>
+
+  <delete id="deleteById">
+    DELETE FROM rmcp_org where ID = #{id}
+  </delete>
+
+  <select id="findList" resultMap="BaseResultMap">
+    select * from rmcp_org where STATUS = 1
+    <if test="userCondition.tenantId != null">and TENANT_ID = #{userCondition.tenantId}</if>
+    <if test="orgType != null">and ORG_TYPE = #{orgType}</if>
+  </select>
+
+  <select id="findByName" resultMap="BaseResultMap">
+    select id,ORG_NAME from rmcp_org where STATUS = 1 and TENANT_ID = #{tenantId} and ORG_NAME = #{name}
+  </select>
+
+  <select id="findByParentIdAndName" resultMap="BaseResultMap">
+    select id,ORG_NAME from rmcp_org where STATUS = 1 and PARENT_ORG_ID = #{parentId} and ORG_NAME = #{name}
+  </select>
+
+  <select id="selectTrees" resultType="com.zcxk.rmcp.api.vo.OrgTreeVo">
+    select ID, TENANT_ID, ORG_TYPE, PARENT_ORG_ID, ORG_AREA_ID, ORG_NAME, ORG_STATE, REMARK, ORG_LEADER_NAME, ORG_LEADER_PHONE, ORG_LEADER_EMAIL, ORG_LEADER_SEX, STATUS, DATE_CREATE, CREATE_BY, DATE_UPDATE, UPDATE_BY
+    from rmcp_org
+    <where>
+      and status!=0
+      <if test="org.tenantId!=null ">
+        and TENANT_ID=#{org.tenantId}
+      </if>
+      <if test="org.orgType=='company'||org.orgType=='department'">
+        and ORG_TYPE=#{org.orgType}
+      </if>
+      <if test="org.id!=null">
+        and id=#{org.id}
+      </if>
+    </where>
+    </select>
+</mapper>

+ 5 - 0
zoniot-pay/zoniot-pay-web/pom.xml

@@ -40,6 +40,7 @@
         <groupId>com.zcxk</groupId>
         <artifactId>zoniot-pay-core</artifactId>
     </dependency>
+
     <dependency>
         <groupId>com.zcxk</groupId>
         <artifactId>zoniot-core-common</artifactId>
@@ -96,6 +97,10 @@
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-openfeign</artifactId>
     </dependency>
+    <dependency>
+        <groupId>com.zcxk</groupId>
+        <artifactId>zoniot-core-mq</artifactId>
+    </dependency>
 </dependencies>
     <build>
         <resources>

+ 1 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/commom/constant/MqConstant.java

@@ -16,4 +16,5 @@ public class MqConstant {
      * 同步小区队列
      */
     public static final String SYNC_USER_QUEUE = "canal-t-user-queue";
+    public static final String SYNC_ORG_QUEUE="canal-t-org-charge";
 }

+ 66 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/compoent/MessageComponent.java

@@ -0,0 +1,66 @@
+package com.zcxk.rmcp.pay.compoent;
+
+import com.alibaba.fastjson.JSONObject;
+import com.bz.zoneiot.core.common.pojo.Message;
+import com.bz.zoneiot.core.utils.MqService;
+import com.zcxk.rmcp.pay.entity.Import;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.Assert;
+
+import javax.annotation.Resource;
+import java.util.UUID;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: TODO
+ * @date 2021/10/25
+ **/
+@Component
+@Slf4j
+public class MessageComponent {
+
+    @Resource
+    private MqService rabbitService;
+    @Value("${receive.exchange.name}")
+    private String receiveExchangeName;
+    @Value("${dispath.routing.key}")
+    private String dispatchRoutingKey;
+
+
+    /**
+    * 推送单个
+    * @author Andy
+    * @date 11:52 2021/11/11
+    * @param message:
+
+    * @return void
+    **/
+    public void sendMessageToUser(Message message ){
+        Assert.notNull(message.getUserId(), "用户ID为空");
+        this.send(message);
+    }
+
+    private void send(Message message){
+        log.debug("消息发送 exchange={}  routingkey={} 用户id={}",receiveExchangeName, dispatchRoutingKey, message.getUserId());
+        rabbitService.send(receiveExchangeName, dispatchRoutingKey, JSONObject.toJSONString(message));
+    }
+    public void sendMsg(Import record, boolean flag, String content, String url,String title){
+        Message message=new Message();
+        message.setAppId(1017);
+        message.setUserId(record.getUserId());
+        message.setMessageType(10);
+        message.setMessageContent(content);
+        message.setTitle(title);
+        message.setMessageId(UUID.randomUUID().toString());
+        if(flag){
+            message.setUrl(url);
+        }
+        sendMessageToUser(message);
+    }
+
+
+
+}

+ 16 - 10
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/config/SwaggerConfig.java

@@ -4,30 +4,35 @@ import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorContro
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.ApiKey;
-import springfox.documentation.service.AuthorizationScope;
-import springfox.documentation.service.SecurityReference;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.*;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import static com.google.common.collect.Lists.newArrayList;
 
-/**
- * @author Andy
- * @version V1.0
- **/
 @Configuration
 @EnableSwagger2
 public class SwaggerConfig {
     @Bean
     public Docket api() {
+
+        //添加请求信息
+        List<Parameter> pars = new ArrayList<Parameter>();
+        //添加sign
+        ParameterBuilder accessToken = new ParameterBuilder();
+        accessToken.name("access_token").description("access_token").modelRef(new ModelRef("string")).parameterType("query").required(false).build();
+
+        pars.add(accessToken.build());
+
         return new Docket(DocumentationType.SWAGGER_2)
                 .ignoredParameterTypes(BasicErrorController.class)
                 .groupName("api")
@@ -35,6 +40,7 @@ public class SwaggerConfig {
                 .apis(RequestHandlerSelectors.any())
                 .paths(PathSelectors.any())
                 .build()
+                //.globalOperationParameters(pars)
                 .apiInfo(apiInfo())
                 .securitySchemes(securitySchemes())
                 .securityContexts(securityContexts());
@@ -43,8 +49,8 @@ public class SwaggerConfig {
 
     private ApiInfo apiInfo() {
         return new ApiInfoBuilder()
-                .title("营收缴费Api")
-                .description("营收缴费")
+                .title("用户中心Api")
+                .description("用户中心")
                 .version("1.0")
                 .build();
     }

+ 11 - 22
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/excel/AbstractResolverExcelTemplate.java

@@ -6,6 +6,7 @@ package com.zcxk.rmcp.pay.excel;
 
 import com.zcxk.rmcp.pay.commom.util.FileUtil;
 import com.zcxk.rmcp.pay.commom.util.Util;
+import com.zcxk.rmcp.pay.compoent.MessageComponent;
 import com.zcxk.rmcp.pay.entity.Import;
 import com.zcxk.rmcp.pay.entity.Message;
 import com.zcxk.rmcp.pay.service.ImportService;
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -32,7 +34,8 @@ public abstract class AbstractResolverExcelTemplate {
 
     @Value("${files.path}")
     private String filesPath;
-
+    @Resource
+    private MessageComponent messageComponent;
     @Value("${service.domain}")
     private String domain;
 
@@ -81,15 +84,9 @@ public abstract class AbstractResolverExcelTemplate {
         } catch (Exception e) {
             e.printStackTrace();
             messageContent.append("导入失败,读取文件错误。");
-            Message message = new Message();
-            message.setSiteId(record.getUserId());
-            message.setUserId(record.getUserId());
-            message.setMessageType(record.getType());
-            message.setMessageTitle(messageTitle);
-            message.setMessageContent(messageContent.toString());
-            message.setObjId(record.getId());
-            message.setRead(0);
-            messageService.insertSelective(message);
+            messageComponent.sendMsg(record,false,messageContent.toString()
+                    ,null,messageTitle);
+
             log.error("read excel error = " + e.getMessage());
         }finally {
             FileUtil.deleteFile(record.getImportFilePath());
@@ -153,17 +150,9 @@ public abstract class AbstractResolverExcelTemplate {
         }
 
         //更新完成生成消息
-        Message message = new Message();
-        message.setSiteId(record.getUserId());
-        message.setUserId(record.getUserId());
-        message.setMessageType(record.getType());
-        message.setMessageTitle(messageTitle);
-        message.setMessageContent(messageContent.toString());
-        if(isDownload && failTime.get() > 0){
-            message.setMessageUrl(domain+"/api/import/downloadFailTemplate?objId="+record.getId());
-        }
-        message.setObjId(record.getId());
-        message.setRead(0);
-        messageService.insertSelective(message);
+        messageComponent.sendMsg(record,isDownload && failTime.get() > 0,messageContent.toString()
+                ,domain+"/api/import/downloadFailTemplate?objId="+record.getId(),messageTitle);
+
+
     }
 }

+ 111 - 0
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/mq/SyncOrgConsumer.java

@@ -0,0 +1,111 @@
+package com.zcxk.rmcp.pay.mq;
+
+import com.bz.zoneiot.core.common.exception.BusinessException;
+
+import com.zcxk.rmcp.pay.commom.BaseSync;
+import com.zcxk.rmcp.pay.commom.constant.MqConstant;
+import com.zcxk.rmcp.pay.dao.OrgMapper;
+import com.zcxk.rmcp.pay.entity.Org;
+import com.zcxk.rmcp.pay.enums.SqlType;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Andy
+ * @version V1.0
+ * @description: 同步org
+ * @date 2021/7/28
+ **/
+@Slf4j
+@Component
+public class SyncOrgConsumer extends BaseSync<Org> {
+
+    @Resource
+    private OrgMapper orgMapper;
+
+    /**
+     * 确定同步来的表名字
+     */
+    private static final String TABLE_NAME = "uims_org";
+
+    /**
+    * @author Andy
+    * @description mq入口
+    * @date 11:33 2021/7/29
+    * @param message
+    * @return void
+    **/
+    @RabbitListener(queues = MqConstant.SYNC_ORG_QUEUE)
+    @RabbitHandler
+    public void exec(Message message) {
+        log.info("======================同步org机构数据 begin======================");
+        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+        if (StringUtils.isEmpty(msg)) {
+            log.info("同步org机构数据 消费为空");
+            return;
+        }
+        try {
+            exec(msg);
+        } catch (Exception e) {
+            log.error("同步org机构数据异常:{}", msg);
+        }
+        log.info("======================同步org机构数据  end=======================");
+    }
+
+    /**
+    * @author Andy
+    * @description 执行入口
+    * @date 11:33 2021/7/29
+    * @param msg
+    * @return void
+    **/
+    private void exec(String msg) throws Exception {
+        try {
+            Map<String, List<Org>> mmp = super.stringConvertMap(msg, TABLE_NAME, Org.class);
+            mmp.forEach((key, value) -> {
+                log.info("同步org机构数据{}操作,需要执行:{}条", key, value.size());
+                tableOperation(key, value);
+                log.info("同步org机构数据{}操作,执行成功:{}条", key, value.size());
+            });
+        } catch (BusinessException e) {
+            log.error(e.getMsg());
+        }
+    }
+
+    /**
+    * @author Andy
+    * @description 执行表操作
+    * @date 10:19 2021/7/29
+    * @param operationType, orgs
+    * @return void
+    **/
+    private void tableOperation (String operationType, List<Org> orgs){
+        switch (SqlType.valueOf(operationType)) {
+            case INSERT:
+            case UPDATE:
+                for (Org org : orgs) {
+                    orgMapper.replaceInsert(org);
+                    log.info("同步org机构数据,"+ operationType +"操作,操作数据:{}", org.toString());
+                }
+                break;
+            case DELETE:
+                for (Org org : orgs) {
+                    orgMapper.deleteById(org.getId());
+                    log.info("同步org机构数据,DELETE操作,操作数据:Id:{}", org.getId());
+                }
+                break;
+            default:
+                return;
+        }
+    }
+
+}

+ 1 - 1
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/mq/SyncUserConsumer.java

@@ -45,7 +45,7 @@ public class SyncUserConsumer extends BaseSync<User> {
     * @param message
     * @return void
     **/
-    @RabbitListener(queues = MqConstant.SYNC_COMMUNITY_QUEUE)
+    @RabbitListener(queues = MqConstant.SYNC_USER_QUEUE)
     @RabbitHandler
     public void exec(Message message) {
         log.info("======================同步用户数据 begin======================");

+ 18 - 7
zoniot-pay/zoniot-pay-web/src/main/java/com/zcxk/rmcp/pay/service/importfile/AsyncTaskImportService.java

@@ -1,8 +1,12 @@
 package com.zcxk.rmcp.pay.service.importfile;
 
+
+import com.bz.zoneiot.core.common.pojo.Message;
+
 import com.zcxk.rmcp.pay.commom.exception.ServiceException;
 import com.zcxk.rmcp.pay.commom.util.FileUtil;
 import com.zcxk.rmcp.pay.commom.util.Util;
+import com.zcxk.rmcp.pay.compoent.MessageComponent;
 import com.zcxk.rmcp.pay.dao.pay.PayBaseAccountMapper;
 import com.zcxk.rmcp.pay.dao.pay.PayControlRuleMapper;
 import com.zcxk.rmcp.pay.dao.pay.PayRechargeaccountMapper;
@@ -11,7 +15,7 @@ import com.zcxk.rmcp.pay.dao.pay.archives.PayBaseCustomerandmeterrelaMapper;
 import com.zcxk.rmcp.pay.dto.LoginUser;
 import com.zcxk.rmcp.pay.dto.pay.PayRechargeaccountDto;
 import com.zcxk.rmcp.pay.entity.Import;
-import com.zcxk.rmcp.pay.entity.Message;
+
 import com.zcxk.rmcp.pay.entity.pay.PayBaseAccount;
 import com.zcxk.rmcp.pay.entity.pay.PayControlRule;
 import com.zcxk.rmcp.pay.entity.pay.PayControlValve;
@@ -22,6 +26,7 @@ import com.zcxk.rmcp.pay.service.MessageService;
 import com.zcxk.rmcp.pay.service.pay.PayBaseAccountService;
 import com.zcxk.rmcp.pay.service.pay.PaySysDictService;
 import com.zcxk.rmcp.pay.service.pay.archives.impl.PayBaseCustomerandmeterrelaServiceImpl;
+
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
@@ -42,6 +47,7 @@ import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -51,8 +57,7 @@ import static com.google.common.collect.Lists.newArrayList;
 @Service
 public class AsyncTaskImportService {
 
-    @Autowired
-    private MessageService messageService;
+
     @Autowired
     private ImportService importService;
     @Resource
@@ -73,7 +78,8 @@ public class AsyncTaskImportService {
     private PayControlRuleMapper payControlRuleMapper;
     @Resource
     private PaySysDictMapper paySysDictMapper;
-
+    @Resource
+    private MessageComponent messageComponent;
     @Value("${files.path}")
     private String filesPath;
 
@@ -459,6 +465,7 @@ public class AsyncTaskImportService {
                 messageContent.append("导入失败");
                 messageContent.append(failTime);
                 messageContent.append("条。");
+
                 //失败列表
                 if(failTime > 0){
                     String FailFilePath = this.getFilePath();
@@ -494,20 +501,24 @@ public class AsyncTaskImportService {
         }
 
         log.info("insert message");
+
         //更新完成生成消息
-        Message message = new Message();
+      /*  Message message = new Message();
         message.setSiteId(record.getUserId());
         message.setUserId(record.getUserId());
         message.setMessageType(record.getType());
         message.setMessageTitle(messageTitle);
         message.setMessageContent(messageContent.toString());
-        if(isDownload && failTime > 0){
+        if(){
             message.setMessageUrl(domain+"/api/import/downloadFailTemplate?objId="+record.getId());
         }
 
         message.setObjId(record.getId());
         message.setRead(0);
-        messageService.insertSelective(message);
+        messageService.insertSelective(message);*/
+
+        messageComponent.sendMsg(record,isDownload && failTime > 0,messageContent.toString()
+                ,domain+"/api/import/downloadFailTemplate?objId="+record.getId(),messageTitle);
         log.info("end executeAsyncCustomerTask!");
     }