ソースを参照

Merge branch 'V0.0.1' of http://10.87.10.227:4000/jzyd_yyds/soc into V0.0.1

jiawuxian 2 年 前
コミット
56c208cddd
70 ファイル変更4207 行追加616 行削除
  1. 28 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java
  2. 54 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/Org.java
  3. 47 264
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/SysOrg.java
  4. 46 0
      soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteOrgFallbackFactory.java
  5. 2 2
      soc-auth/src/main/resources/bootstrap.yml
  6. 9 0
      soc-common/soc-common-core/pom.xml
  7. 16 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/IdName.java
  8. 49 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/exception/SystemException.java
  9. 45 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/config/HttpConfig.java
  10. 21 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/config/HttpProperty.java
  11. 44 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/CustomHttpClient.java
  12. 52 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/HttpException.java
  13. 25 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpMulitiParam.java
  14. 98 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParams.java
  15. 45 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsGet.java
  16. 46 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsPost.java
  17. 102 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsPostFile.java
  18. 38 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsPostJson.java
  19. 13 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/result/ResultExecute.java
  20. 598 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/snowId/DateHelper.java
  21. 84 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/snowId/IDHelper.java
  22. 131 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/snowId/SnowflaskGenerator.java
  23. 4 0
      soc-common/soc-common-core/src/main/java/com/xunmei/common/core/web/domain/BaseEntity.java
  24. 2 2
      soc-gateway/src/main/resources/bootstrap.yml
  25. 10 0
      soc-modules/soc-modules-sync/pom.xml
  26. 0 7
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/Main.java
  27. 24 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/SocSyncApplication.java
  28. 15 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/config/ThirdPartyUrl.java
  29. 230 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/controller/FjnxSyncController.java
  30. 66 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/domain/FjnxOrgBusinessRelation.java
  31. 267 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/domain/OrgFjnx.java
  32. 166 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXOrgDto.java
  33. 110 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXUserDto.java
  34. 15 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXXmlOrgDto.java
  35. 18 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXXmlUserDto.java
  36. 13 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/SyncFileDto.java
  37. 28 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/SyncResponseDto.java
  38. 18 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/mapper/FjnxOrgBusinessRelationMapper.java
  39. 18 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/mapper/OrgFjnxMapper.java
  40. 19 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IFJNXOrgSyncService.java
  41. 23 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IFJNXSyncService.java
  42. 21 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IFJNXUserSyncService.java
  43. 16 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IOrgJinxService.java
  44. 53 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/api/FjnxApi.java
  45. 145 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/api/FjnxXmlApi.java
  46. 68 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/FJNXOrgSyncServiceImpl.java
  47. 581 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/FJNXSyncServiceImpl.java
  48. 62 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/FJNXUserSyncServiceImpl.java
  49. 20 0
      soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/OrgJinxServiceImpl.java
  50. 2 2
      soc-modules/soc-modules-sync/src/main/resources/bootstrap.yml
  51. 5 0
      soc-modules/soc-modules-sync/src/main/resources/mapper/FjnxOrgBusinessRelationMapper.xml
  52. 7 0
      soc-modules/soc-modules-sync/src/main/resources/mapper/OrgFjnxMapper.xml
  53. 21 13
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysKnowledgeController.java
  54. 24 13
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysLearningMaterialsController.java
  55. 25 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysOrgController.java
  56. 3 26
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/SysLearningMaterials.java
  57. 58 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/vo/SysLearningMaterialsPageVo.java
  58. 30 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/SysLearningMaterialsPageDto.java
  59. 3 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysKnowledgeMapper.java
  60. 6 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysLearningMaterialsMapper.java
  61. 10 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysKnowledgeService.java
  62. 4 1
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysLearningMaterialsService.java
  63. 13 3
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeptServiceImpl.java
  64. 19 0
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysKnowledgeServiceImpl.java
  65. 45 18
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysLearningMaterialsServiceImpl.java
  66. 2 2
      soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java
  67. 2 2
      soc-modules/soc-modules-system/src/main/resources/bootstrap.yml
  68. 66 59
      soc-modules/soc-modules-system/src/main/resources/mapper/system/SysKnowledgeMapper.xml
  69. 50 1
      soc-modules/soc-modules-system/src/main/resources/mapper/system/SysLearningMaterialsMapper.xml
  70. 207 201
      soc-modules/soc-modules-system/src/main/resources/mapper/system/SysOrgMapper.xml

+ 28 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/RemoteOrgService.java

@@ -0,0 +1,28 @@
+package com.xunmei.system.api;
+
+import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.constant.ServiceNameConstants;
+import com.xunmei.common.core.domain.R;
+import com.xunmei.system.api.domain.Org;
+import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.factory.RemoteOrgFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@FeignClient(contextId = "remoteOrgService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteOrgFallbackFactory.class)
+public interface RemoteOrgService {
+    /**
+     * 通过用户名查询用户信息
+     *
+     * @param source 请求来源
+     * @return 结果
+     */
+    @GetMapping("/org/list/nopage")
+    public R<List<SysOrg>> getAllOrg(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+    @PostMapping("/org/sync/batch")
+    public R<Boolean> batchSaveSyncOrg(@RequestBody List<SysOrg> orgList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
+}

+ 54 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/Org.java

@@ -60,6 +60,11 @@ public class Org extends BaseEntity {
     private String guid;
 
     /**
+     * 父节点GUID
+     */
+    private String parentGuid;
+
+    /**
      * 路径
      */
     private String path;
@@ -70,6 +75,21 @@ public class Org extends BaseEntity {
     private Integer deleted;
 
     /**
+     * 排序
+     */
+    private Double sort;
+
+    /**
+     * 机构简称
+     */
+    private String shortName;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
      * 子机构
      */
     private List<Org> children = new ArrayList<Org>();
@@ -216,6 +236,40 @@ public class Org extends BaseEntity {
         this.deleted = deleted;
     }
 
+    public String getShortName() {
+        return shortName;
+    }
+
+    public void setShortName(String shortName) {
+        this.shortName = shortName;
+    }
+
+
+    public String getParentGuid() {
+        return parentGuid;
+    }
+
+    public void setParentGuid(String parentGuid) {
+        this.parentGuid = parentGuid;
+    }
+
+
+    public Double getSort() {
+        return sort;
+    }
+
+    public void setSort(Double sort) {
+        this.sort = sort;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
 /*
     public Integer getTemporarilyClosed() {
         return temporarilyClosed;

+ 47 - 264
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/domain/SysOrg.java

@@ -1,9 +1,9 @@
 package com.xunmei.system.api.domain;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.StringSerializer;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.xunmei.common.core.web.domain.BaseEntity;
 import io.swagger.annotations.ApiModel;
@@ -32,343 +32,126 @@ import java.util.List;
 public class SysOrg extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /**
-     * $column.columnComment
-     */
+    @TableId
     @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long orgExtendId;
 
-    /**
-     * $column.columnComment
-     */
-    @ApiModelProperty(value = "${comment}", notes = "$column.readConverterExp()")
+    @ApiModelProperty(value = "地址")
+    @TableField(value = "address")
     private String address;
 
-    /**
-     * code
-     */
     @ApiModelProperty(value = "code")
+    @TableField(value = "code")
     private String code;
 
-    /**
-     * 设备数量
-     */
-    @ApiModelProperty(value = "设备数量")
-    private Long deviceCount;
-
-    /**
-     * guid
-     */
     @ApiModelProperty(value = "guid")
+    @TableField(value = "guid")
     private String guid;
 
-    /**
-     * 禁用
-     */
     @ApiModelProperty(value = "禁用")
-    private String isLock;
+    @TableField(value = "is_lock")
+    private Integer isLock;
 
-    /**
-     * 负责人
-     */
     @ApiModelProperty(value = "负责人")
+    @TableField(value = "manager")
     private String manager;
 
-    /**
-     * 负责人电话
-     */
     @ApiModelProperty(value = "负责人电话")
+    @TableField(value = "manager_phone")
     private String managerPhone;
 
-    /**
-     * nh名称
-     */
     @ApiModelProperty(value = "nh名称")
+    @TableField(value = "name")
     private String name;
 
-    /**
-     * 上级nh
-     */
     @ApiModelProperty(value = "上级nh")
     @JsonSerialize(using = ToStringSerializer.class)
+    @TableField(value = "parent_id")
     private Long parentId;
 
-    /**
-     * 联系电话
-     */
+    @ApiModelProperty(value = "父节点GUID")
+    @TableField(value = "parent_guid")
+    private String parentGuid;
+
     @ApiModelProperty(value = "联系电话")
+    @TableField(value = "phone")
     private String phone;
 
-    /**
-     * 行政区域编码
-     */
     @ApiModelProperty(value = "行政区域编码")
+    @TableField(value = "city_code")
     private String cityCode;
 
-    /**
-     * 开业年份
-     */
-    @ApiModelProperty(value = "开业年份")
-    private Long openYear;
-
-    /**
-     * 装修年份
-     */
-    @ApiModelProperty(value = "装修年份")
-    private Long fitYear;
-
-    /**
-     * 建筑面积
-     */
-    @ApiModelProperty(value = "建筑面积")
-    private String floorage;
-
-    /**
-     * 员工人数
-     */
-    @ApiModelProperty(value = "员工人数")
-    private Long employee;
-
-    /**
-     * 是否自有产权
-     */
-    @ApiModelProperty(value = "是否自有产权")
-    private Long isOwnRight;
-
-    /**
-     * 是否为租赁场所
-     */
-    @ApiModelProperty(value = "是否为租赁场所")
-    private Long isRent;
-
-    /**
-     * 是否独自占用建筑
-     */
-    @ApiModelProperty(value = "是否独自占用建筑")
-    private Long isOnly;
-
-    /**
-     * 与其他单位共用建筑的,所处的建筑建成年份
-     */
-    @ApiModelProperty(value = "与其他单位共用建筑的,所处的建筑建成年份")
-    private Long buildYear;
-
-    /**
-     * 场所类型
-     */
-    @ApiModelProperty(value = "场所类型")
-    private Long placeType;
-
-    /**
-     * 所在建筑的总高度
-     */
-    @ApiModelProperty(value = "所在建筑的总高度")
-    private Long buildHeight;
-
-    /**
-     * 周边主要社会环境
-     */
-    @ApiModelProperty(value = "周边主要社会环境")
-    private Long social;
-
-    /**
-     * 周边主要自然环境
-     */
-    @ApiModelProperty(value = "周边主要自然环境")
-    private Long naturalEnvir;
-
-    /**
-     * 机构类型
-     */
     @ApiModelProperty(value = "机构类型")
-    private Long type;
-
-    /**
-     * 修改人名称
-     */
-    @ApiModelProperty(value = "修改人名称")
-    private String modifiedName;
+    @TableField(value = "type")
+    private Integer type;
 
-    /**
-     * 最后修改人id
-     */
-    @ApiModelProperty(value = "最后修改人id")
-    private Long modifiedId;
-
-    /**
-     * 路径
-     */
     @ApiModelProperty(value = "路径")
+    @TableField(value = "path")
     private String path;
 
-    /**
-     * vmns的id
-     */
-    @ApiModelProperty(value = "vmns的id")
-    private Long vid;
-
-    /**
-     * 层级
-     */
-    @ApiModelProperty(value = "层级")
-    private Long level;
+    @ApiModelProperty(value = "是否删除")
+    @TableField(value = "deleted")
+    private Integer deleted;
 
-    /**
-     * nh唯一编码
-     */
-    @ApiModelProperty(value = "nh唯一编码")
-    private String oid;
+    @TableField(value = "sort")
+    @ApiModelProperty(value = "排序")
+    private Double sort;
+    @ApiModelProperty(value = "天气城市区域编码")
+    @TableField(value = "weather_city_code")
+    private String weatherCityCode;
 
-    /**
-     * 父节点GUID
-     */
-    @ApiModelProperty(value = "父节点GUID")
-    private String parentGuid;
+    @JsonSerialize(using = ToStringSerializer.class)
+    @TableField(value = "org_extend_id")
+    private Long orgExtendId;
+    @ApiModelProperty(value = "机构来源, 0:系统新增 1:fjnx同步")
+    @TableField(value = "source")
+    private Integer source;
 
     /**
-     * 是否删除
+     * 机构简称
      */
-    @ApiModelProperty(value = "是否删除")
-    private Long deleted;
+    @ApiModelProperty(value = "机构简称")
+    @TableField(value = "short_name")
+    private String shortName;
 
     /**
-     * 排序
+     * 备注
      */
-    @ApiModelProperty(value = "排序")
-    private BigDecimal sort;
+    @ApiModelProperty(value = "备注")
+    @TableField(value = "remark")
+    private String remark;
 
     /**
-     * 位置信息 1城区2县城3乡镇
-     */
-    @ApiModelProperty(value = "位置信息 1城区2县城3乡镇")
-    private Long location;
-    /**
      * 子机构
      */
     @TableField(exist = false)
     private List<SysOrg> children = new ArrayList<SysOrg>();
 
+
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-
-
                 .append("id", getId())
-
-
                 .append("address", getAddress())
-
-
                 .append("code", getCode())
-
-
-                .append("deviceCount", getDeviceCount())
-
-
                 .append("guid", getGuid())
-
-
                 .append("isLock", getIsLock())
-
-
                 .append("manager", getManager())
-
-
                 .append("managerPhone", getManagerPhone())
-
-
                 .append("name", getName())
-
-
                 .append("parentId", getParentId())
-
-
                 .append("phone", getPhone())
-
-
                 .append("cityCode", getCityCode())
-
-
-                .append("openYear", getOpenYear())
-
-
-                .append("fitYear", getFitYear())
-
-
-                .append("floorage", getFloorage())
-
-
-                .append("employee", getEmployee())
-
-
-                .append("isOwnRight", getIsOwnRight())
-
-
-                .append("isRent", getIsRent())
-
-
-                .append("isOnly", getIsOnly())
-
-
-                .append("buildYear", getBuildYear())
-
-
-                .append("placeType", getPlaceType())
-
-
-                .append("buildHeight", getBuildHeight())
-
-
-                .append("social", getSocial())
-
-
-                .append("naturalEnvir", getNaturalEnvir())
-
-
                 .append("type", getType())
-
-
                 .append("createTime", getCreateTime())
-
-
-                .append("modifiedName", getModifiedName())
-
-
                 .append("updateTime", getUpdateTime())
-
-
-                .append("modifiedId", getModifiedId())
-
-
                 .append("path", getPath())
-
-
-                .append("vid", getVid())
-
-
-                .append("level", getLevel())
-
-
-                .append("oid", getOid())
-
-
                 .append("parentGuid", getParentGuid())
-
-
                 .append("deleted", getDeleted())
-
-
                 .append("sort", getSort())
-
-
-                .append("location", getLocation())
-
-
+                .append("source", getSource())
                 .append("createBy", getCreateBy())
-
-
                 .append("updateBy", getUpdateBy())
                 .toString();
     }

+ 46 - 0
soc-api/soc-api-system/src/main/java/com/xunmei/system/api/factory/RemoteOrgFallbackFactory.java

@@ -0,0 +1,46 @@
+package com.xunmei.system.api.factory;
+
+import com.xunmei.common.core.domain.R;
+import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.RemoteUserService;
+import com.xunmei.system.api.domain.Org;
+import com.xunmei.system.api.domain.SysOperLog;
+import com.xunmei.system.api.domain.SysOrg;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 用户服务降级处理
+ * 
+ * @author xunmei
+ */
+@Component
+public class RemoteOrgFallbackFactory implements FallbackFactory<RemoteOrgService>
+{
+    private static final Logger log = LoggerFactory.getLogger(RemoteOrgFallbackFactory.class);
+
+    @Override
+    public RemoteOrgService create(Throwable throwable)
+    {
+        log.error("用户服务调用失败:{}", throwable.getMessage());
+        return new RemoteOrgService()
+        {
+            @Override
+            public R<List<SysOrg>> getAllOrg(String source)
+            {
+                return R.fail("获取获取机构失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public R<Boolean> batchSaveSyncOrg(List<SysOrg> orgList, String source) {
+                return null;
+            }
+
+
+        };
+    }
+}

+ 2 - 2
soc-auth/src/main/resources/bootstrap.yml

@@ -15,7 +15,7 @@ spring:
       discovery:
         # 服务注册地址
         server-addr: 10.87.10.54:8848
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
       config:
         # 配置中心地址
         server-addr: 10.87.10.54:8848
@@ -24,7 +24,7 @@ spring:
         # 共享配置
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
 logging:
   file:
     name: logs/${spring.application.name}/info.log

+ 9 - 0
soc-common/soc-common-core/pom.xml

@@ -115,5 +115,14 @@
             <artifactId>hutool-all</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.10.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-common</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 16 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/domain/IdName.java

@@ -0,0 +1,16 @@
+package com.xunmei.common.core.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class IdName<K, V> {
+    private K id;
+    private V name;
+}

+ 49 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/exception/SystemException.java

@@ -0,0 +1,49 @@
+package com.xunmei.common.core.exception;
+
+import io.jsonwebtoken.lang.Objects;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Tkk
+ */
+@Getter
+@Setter
+public class SystemException extends RuntimeException {
+
+    private String errorCode;
+
+    private Object[] params;
+
+    public SystemException(final String errorCode) {
+        super(errorCode);
+        this.errorCode = errorCode;
+    }
+
+    public SystemException(final String errorCode, final Object... params) {
+        super(errorCode);
+        this.errorCode = errorCode;
+        this.params = params;
+    }
+
+    public SystemException(final String errorCode, final Throwable cause) {
+        super(cause);
+        this.errorCode = errorCode;
+    }
+
+    public SystemException(final String errorCode, final Object[] params, final Throwable cause) {
+        super(cause);
+        this.errorCode = errorCode;
+        this.params = params;
+    }
+
+    @Override
+    public String toString() {
+        return this.errorCode + " => " + Objects.nullSafeToString(this.params);
+    }
+
+    @Override
+    public void printStackTrace() {
+        super.printStackTrace();
+    }
+}

+ 45 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/config/HttpConfig.java

@@ -0,0 +1,45 @@
+package com.xunmei.common.core.http.config;
+
+import okhttp3.ConnectionPool;
+import okhttp3.OkHttpClient;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Tkk
+ */
+@Configuration
+@EnableConfigurationProperties(HttpProperty.class)
+public class HttpConfig {
+
+    @Autowired
+    private HttpProperty sdkProperty;
+
+    @Bean
+    OkHttpClient okHttpClient() {
+        final OkHttpClient.Builder builder = new OkHttpClient.Builder()
+                .connectTimeout(10, TimeUnit.SECONDS) //
+                .followRedirects(false) //
+                .readTimeout(1, TimeUnit.MINUTES) //
+                .retryOnConnectionFailure(false) //
+                .writeTimeout(1, TimeUnit.MINUTES)
+                .connectionPool(new ConnectionPool(this.sdkProperty.getHttpMaxConnect(), this.sdkProperty.getHttpKeepAlice(), TimeUnit.MINUTES));
+
+        // 代理
+        if (StringUtils.isNotBlank(this.sdkProperty.getProxy())) {
+            builder.proxy(new Proxy(
+                    this.sdkProperty.getProxyType(),
+                    new InetSocketAddress(this.sdkProperty.getProxy(), this.sdkProperty.getProxyPort()))
+            );
+        }
+        return builder.build();
+    }
+
+}

+ 21 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/config/HttpProperty.java

@@ -0,0 +1,21 @@
+package com.xunmei.common.core.http.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.net.Proxy;
+
+/**
+ * Tkk
+ */
+@Data
+@ConfigurationProperties(prefix = "app.http")
+public class HttpProperty {
+
+    private int httpMaxConnect = 10;
+    private long httpKeepAlice = 1;
+
+    private String proxy;
+    private int proxyPort;
+    private Proxy.Type proxyType;
+}

+ 44 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/CustomHttpClient.java

@@ -0,0 +1,44 @@
+package com.xunmei.common.core.http.service;
+
+import com.xunmei.common.core.http.service.params.HttpParams;
+import com.xunmei.common.core.http.service.result.ResultExecute;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+
+/**
+ * Tkk
+ */
+@Component
+public class CustomHttpClient {
+
+    @Autowired
+    private OkHttpClient client;
+
+    public <T> T execute(final HttpParams params, final ResultExecute resultExecute) {
+        final Request request = params.toRequest();
+        final StopWatch stopWatch = new StopWatch();
+        stopWatch.start();
+        Response response = null;
+        try {
+            response = this.client.newCall(request)
+                                  .execute();
+            stopWatch.stop();
+            return (T) resultExecute.toBody(response, params, stopWatch);
+        } catch (final HttpException e) {
+            throw e;
+        } catch (final Exception e) {
+            throw HttpException.make(e, request, stopWatch);
+        } finally {
+            if (response != null) {
+                response.close();
+            }
+        }
+    }
+}

+ 52 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/HttpException.java

@@ -0,0 +1,52 @@
+package com.xunmei.common.core.http.service;
+
+import lombok.Getter;
+import lombok.Setter;
+import okhttp3.Request;
+import org.springframework.util.StopWatch;
+
+/**
+ * Tkk
+ */
+@Setter
+@Getter
+public class HttpException extends RuntimeException {
+
+    private Request request;
+
+    private StopWatch stopWatch;
+
+    public HttpException() {
+    }
+
+    public HttpException(final String message) {
+        super(message);
+    }
+
+    public HttpException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+
+    public HttpException(final Throwable cause) {
+        super(cause);
+    }
+
+    public HttpException(final String message, final Throwable cause, final boolean enableSuppression, final boolean writableStackTrace) {
+        super(message, cause, enableSuppression, writableStackTrace);
+    }
+
+    public static HttpException make(final String msg, final Request req, final StopWatch s) {
+        final HttpException exception = new HttpException(msg);
+        exception.setRequest(req);
+        exception.setStopWatch(s);
+        return exception;
+    }
+
+    public static HttpException make(final Exception e, final Request req, final StopWatch s) {
+        final HttpException exception = new HttpException(e);
+        exception.setRequest(req);
+        exception.setStopWatch(s);
+        return exception;
+    }
+
+}

+ 25 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpMulitiParam.java

@@ -0,0 +1,25 @@
+package com.xunmei.common.core.http.service.params;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import okhttp3.MediaType;
+
+import java.io.InputStream;
+
+/**
+ * Tkk
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class HttpMulitiParam {
+
+    private String fileName;
+
+    private InputStream inputStream;
+
+    private MediaType mediaType;
+}

+ 98 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParams.java

@@ -0,0 +1,98 @@
+package com.xunmei.common.core.http.service.params;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import okhttp3.Request;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Tkk
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public abstract class HttpParams {
+
+    /**
+     * @param url
+     * @return
+     */
+    public static HttpParams get(final String url) {
+        return new HttpParamsGet(url, Collections.emptyMap());
+    }
+
+    /**
+     * @param url
+     * @return
+     */
+    public static HttpParams get(final String url, final Map<String, Object> params) {
+        return new HttpParamsGet(url, params);
+    }
+
+    /**
+     * @param url
+     * @return
+     */
+    public static HttpParams post(final String url, final Map<String, Object> params) {
+        return new HttpParamsPost(url, params);
+    }
+
+    /**
+     * @param url
+     * @return
+     */
+    public static HttpParams postFile(final String url, final Map<String, Object> params) {
+        return new HttpParamsPostFile(url, params);
+    }
+
+    /**
+     * @param url
+     * @return
+     */
+    public static HttpParams postJson(final String url, final Object params) {
+        return new HttpParamsPostJson(url, params);
+    }
+
+
+    private String url;
+
+    private String userAgent;
+
+    private Map<String, String> heads;
+
+    public Request toRequest() {
+        final Request.Builder request = this.toBuild();
+        if (StringUtils.isNotBlank(this.userAgent)) {
+            request.addHeader("User-Agent", this.userAgent);
+        }
+        if (this.heads != null) {
+            this.heads.forEach(request::addHeader);
+        }
+        return request.build();
+    }
+
+    public HttpParams putHead(final String k, final String v) {
+        if (this.heads == null) {
+            this.heads = new TreeMap<>();
+        }
+        this.heads.put(k, v);
+        return this;
+    }
+
+    protected abstract Request.Builder toBuild();
+
+    public abstract HttpParams put(final String key, final Object page);
+
+    @Override
+    public String toString() {
+        return this.url;
+    }
+}
+
+

+ 45 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsGet.java

@@ -0,0 +1,45 @@
+package com.xunmei.common.core.http.service.params;
+
+import okhttp3.HttpUrl;
+import okhttp3.Request;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+
+public class HttpParamsGet extends HttpParams {
+
+
+    private final Map<String, Object> params;
+
+    public HttpParamsGet(final String url, final Map<String, Object> params) {
+        this.setUrl(url);
+        this.params = Optional.ofNullable(params)
+                              .orElse(Collections.emptyMap());
+    }
+
+    @Override
+    protected Request.Builder toBuild() {
+        final HttpUrl.Builder builder = HttpUrl.parse(this.getUrl())
+                                               .newBuilder();
+        this.params.forEach((k, v) -> {
+            if (v == null) {
+                return;
+            }
+            builder.addEncodedQueryParameter(k, v.toString());
+        });
+        return new Request.Builder().url(builder.build());
+    }
+
+    @Override
+    public HttpParams put(final String key, final Object page) {
+        this.params.put(key, page);
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return this.getUrl() + " " + this.params;
+    }
+}

+ 46 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsPost.java

@@ -0,0 +1,46 @@
+package com.xunmei.common.core.http.service.params;
+
+import okhttp3.FormBody;
+import okhttp3.Request;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+
+public class HttpParamsPost extends HttpParams {
+
+
+    private final Map<String, Object> params;
+
+    public HttpParamsPost(final String url, final Map<String, Object> params) {
+        this.setUrl(url);
+        this.params = Optional.ofNullable(params)
+                              .orElse(Collections.emptyMap());
+    }
+
+    @Override
+    protected Request.Builder toBuild() {
+        final FormBody.Builder builder = new FormBody.Builder();
+        this.params.forEach((k, v) -> {
+            if (v == null) {
+                return;
+            }
+            builder.addEncoded(k, v.toString());
+        });
+        return new Request.Builder().url(this.getUrl())
+                                    .post(builder.build());
+    }
+
+    @Override
+    public HttpParams put(final String key, final Object page) {
+        this.params.put(key, page);
+        return this;
+    }
+
+
+    @Override
+    public String toString() {
+        return this.getUrl() + " " + this.params;
+    }
+}

+ 102 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsPostFile.java

@@ -0,0 +1,102 @@
+package com.xunmei.common.core.http.service.params;
+
+import okhttp3.MediaType;
+import okhttp3.MultipartBody;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okio.BufferedSink;
+import okio.Okio;
+import okio.Source;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+
+public class HttpParamsPostFile extends HttpParams {
+
+    private static final MediaType MEDIA_TYPE_FILE = MediaType.parse("application/oct-stream");
+
+    /**
+     * @param mediaType
+     * @param inputStream
+     * @return
+     */
+    private static RequestBody create(final MediaType mediaType, final InputStream inputStream) {
+        return new RequestBody() {
+            @Override
+            public MediaType contentType() {
+                return mediaType;
+            }
+
+            @Override
+            public long contentLength() {
+                try {
+                    return inputStream.available();
+                } catch (final IOException e) {
+                    return 0;
+                }
+            }
+
+            @Override
+            public void writeTo(final BufferedSink sink) throws IOException {
+                Source source = null;
+                try {
+                    source = Okio.source(inputStream);
+                    sink.writeAll(source);
+                } finally {
+                }
+            }
+        };
+    }
+
+
+    private final Map<String, Object> params;
+
+    public HttpParamsPostFile(final String url, final Map<String, Object> params) {
+        this.setUrl(url);
+        this.params = Optional.ofNullable(params)
+                              .orElse(Collections.emptyMap());
+    }
+
+    @Override
+    protected Request.Builder toBuild() {
+        final MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
+        this.params.forEach((k, v) -> {
+            if (v == null) {
+                return;
+            }
+            if (v instanceof File) {
+                final File f = (File) v;
+                builder.addFormDataPart(
+                        k, f.getName(), RequestBody.create(MEDIA_TYPE_FILE, f)
+                );
+            } else if (v instanceof InputStream) {
+                builder.addFormDataPart(
+                        k, k, create(MEDIA_TYPE_FILE, (InputStream) v)
+                );
+            } else if (v instanceof HttpMulitiParam) {
+                final HttpMulitiParam p = (HttpMulitiParam) v;
+                builder.addFormDataPart(
+                        k, p.getFileName(), create(p.getMediaType(), p.getInputStream())
+                );
+            }
+            //
+            else {
+                builder.addFormDataPart(k, v.toString());
+            }
+        });
+        return new Request.Builder().url(this.getUrl())
+                                    .post(builder.build());
+    }
+
+    @Override
+    public HttpParams put(final String key, final Object page) {
+        this.params.put(key, page);
+        return this;
+    }
+
+}

+ 38 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/params/HttpParamsPostJson.java

@@ -0,0 +1,38 @@
+package com.xunmei.common.core.http.service.params;
+
+import com.alibaba.fastjson2.JSON;
+import okhttp3.MediaType;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+
+
+public class HttpParamsPostJson extends HttpParams {
+
+    private static final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8");
+
+    private final Object object;
+
+
+    public HttpParamsPostJson(final String url, final Object params) {
+        this.setUrl(url);
+        this.object = params;
+    }
+
+    @Override
+    protected Request.Builder toBuild() {
+        final String jsonString = JSON.toJSONString(this.object);
+        final RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, jsonString);
+        return new Request.Builder().url(this.getUrl())
+                                    .post(body);
+    }
+
+    @Override
+    public HttpParams put(final String key, final Object page) {
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return this.getUrl() + " " + JSON.toJSONString(this.object);
+    }
+}

+ 13 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/http/service/result/ResultExecute.java

@@ -0,0 +1,13 @@
+package com.xunmei.common.core.http.service.result;
+
+import com.xunmei.common.core.http.service.params.HttpParams;
+import okhttp3.Response;
+import org.springframework.util.StopWatch;
+
+/**
+ * Tkk
+ */
+public interface ResultExecute<T> {
+
+    T toBody(Response response, HttpParams request, StopWatch stopWatch) throws Exception;
+}

+ 598 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/snowId/DateHelper.java

@@ -0,0 +1,598 @@
+package com.xunmei.common.core.utils.snowId;
+
+import cn.hutool.core.date.DateField;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import io.netty.util.internal.StringUtil;
+import org.apache.commons.lang3.time.DateUtils;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * Created by Tkk on 2018/8/15.
+ */
+public class DateHelper {
+
+    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    private static final SimpleDateFormat dateStrFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+
+    private static final SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
+    private static final SimpleDateFormat HmsFormat = new SimpleDateFormat("HH:mm");
+
+    private final Calendar calendar;
+
+    public DateHelper(final Date date) {
+        if (date == null) {
+            this.calendar = Calendar.getInstance();
+            this.calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        } else {
+            this.calendar = Calendar.getInstance();
+            this.calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+            this.calendar.setTime(date);
+        }
+        this.calendar.setFirstDayOfWeek(Calendar.MONDAY);
+    }
+
+    public DateHelper() {
+        this(new Date());
+    }
+
+    public int getYear() {
+        return this.calendar.get(Calendar.YEAR);
+    }
+
+    public int getMonth() {
+        return this.calendar.get(Calendar.MONTH) + 1;
+    }
+
+    public int getDay() {
+        return this.calendar.get(Calendar.DAY_OF_MONTH);
+    }
+
+    public int quarter() {
+        return this.getMonth() / 3 + 1;
+    }
+
+    private Integer halfYear() {
+        Integer half = this.getMonth();
+        if (half >= 0 && half <= 6) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public int getDate() {
+        return this.calendar.get(Calendar.DATE);
+    }
+
+    public int getHour() {
+        return this.calendar.get(Calendar.HOUR_OF_DAY);
+    }
+
+    public int getMin() {
+        return this.calendar.get(Calendar.MINUTE);
+    }
+
+    public void addDays(final int i) {
+        this.calendar.add(Calendar.DATE, i);
+    }
+
+    public void addMin(final int i) {
+        this.calendar.add(Calendar.MINUTE, i);
+    }
+
+    public void setSecond(final int i) {
+        this.calendar.set(Calendar.SECOND, i);
+    }
+
+    public void setMin(final int i) {
+        this.calendar.set(Calendar.MINUTE, i);
+    }
+
+    public void setHour(final int i) {
+        this.calendar.set(Calendar.HOUR_OF_DAY, i);
+    }
+
+    public void setDate(final int i) {
+        this.calendar.set(Calendar.DAY_OF_MONTH, i);
+    }
+
+    public void addMonth(final int i) {
+        this.calendar.add(Calendar.MONTH, i);
+    }
+
+    public boolean isToday() {
+        return DateUtils.isSameDay(this.calendar, Calendar.getInstance());
+    }
+
+    public void setMonth(final int month) {
+        this.calendar.set(Calendar.MONTH, month);
+    }
+
+    public Date getDateTime() {
+        this.calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        return this.calendar.getTime();
+    }
+
+    public int getWeek() {
+        calendar.setMinimalDaysInFirstWeek(6);
+        return this.calendar.get(Calendar.WEEK_OF_YEAR);
+    }
+
+    public Date monthStart() {
+        this.calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        this.calendar.set(Calendar.DAY_OF_MONTH, 1);
+        return this.calendar.getTime();
+    }
+
+    public Date monthEnd() {
+        this.calendar.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        this.calendar.set(Calendar.DAY_OF_MONTH, this.calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return this.calendar.getTime();
+    }
+
+    public Date weekStart() {
+        // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
+        this.calendar.setFirstDayOfWeek(Calendar.MONDAY);
+        // 获得当前日期是一个星期的第几天
+        int dayWeek = this.calendar.get(Calendar.DAY_OF_WEEK);
+        // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        this.calendar.add(Calendar.DATE, this.calendar.getFirstDayOfWeek() - dayWeek);
+        return this.calendar.getTime();
+    }
+
+    public Date weekEnd() {
+        // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
+        this.calendar.setFirstDayOfWeek(Calendar.MONDAY);
+        // 获得当前日期是一个星期的第几天
+        int dayWeek = this.calendar.get(Calendar.DAY_OF_WEEK);
+        // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        this.calendar.add(Calendar.DATE, this.calendar.getFirstDayOfWeek() - dayWeek);
+        this.calendar.add(Calendar.DATE, 6);
+        return this.calendar.getTime();
+    }
+
+    public static Date getThisWeekMonday(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        // 获得当前日期是一个星期的第几天 使用cal.get(Calendar.DAY_OF_WEEK);
+        //获取的数表示的是每个星期的第几天,不能改变,其中星期日为第一天
+        // 如果是星期日则获取天数时获取到的数字为1 在后面进行相减的时候出错
+        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
+        if (1 == dayWeek) {
+            cal.add(Calendar.DAY_OF_MONTH, -1);
+        }
+        // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        // 获得当前日期是一个星期的第几天
+        int day = cal.get(Calendar.DAY_OF_WEEK);
+        // 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
+        //  cal.getFirstDayOfWeek()根据前面的设置 来动态的改变此值
+        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
+        return cal.getTime();
+    }
+
+    public Date quarterStart() {
+        Integer year = this.calendar.get(Calendar.YEAR);
+        int month = this.calendar.get(Calendar.MONTH) + 1;
+        int quarter = 0;
+        if (month >= 1 && month <= 3) {
+            quarter = 1;
+        } else if (month >= 4 && month <= 6) {
+            quarter = 2;
+        } else if (month >= 7 && month <= 9) {
+            quarter = 3;
+        } else {
+            quarter = 4;
+        }
+        return this.getFirstDayOfQuarter(year, quarter);
+    }
+
+    public Date quarterEnd() {
+        Integer year = this.calendar.get(Calendar.YEAR);
+        int month = this.calendar.get(Calendar.MONTH) + 1;
+        int quarter = 0;
+        if (month >= 1 && month <= 3) {
+            quarter = 1;
+        } else if (month >= 4 && month <= 6) {
+            quarter = 2;
+        } else if (month >= 7 && month <= 9) {
+            quarter = 3;
+        } else {
+            quarter = 4;
+        }
+        return this.getLastDayOfQuarter(year, quarter);
+    }
+
+    public Date halfyearStart() {
+        Integer year = this.calendar.get(Calendar.YEAR);
+        int month = this.calendar.get(Calendar.MONTH) + 1;
+        if (month >= 1 && month <= 6) {
+            return getFirstDayOfMonth(year, 1);
+        } else {
+            return getFirstDayOfMonth(year, 7);
+        }
+    }
+
+    public Date halfyearEnd() {
+        Integer year = this.calendar.get(Calendar.YEAR);
+        int month = this.calendar.get(Calendar.MONTH) + 1;
+        if (month >= 1 && month <= 6) {
+            return getLastDayOfMonth(year, 6);
+        } else {
+            return getLastDayOfMonth(year, 12);
+        }
+    }
+
+    public Date yearStart() {
+        Integer year = this.calendar.get(Calendar.YEAR);
+        return getFirstDayOfMonth(year, 1);
+    }
+
+    public Date yearEnd() {
+        Integer year = this.calendar.get(Calendar.YEAR);
+        return getLastDayOfMonth(year, 12);
+    }
+
+    public static String toStr(Date date) {
+        if (date == null) {
+            return StringUtil.EMPTY_STRING;
+        }
+        return dateFormat.format(date);
+    }
+
+    public static String toStrWithoutHms(Date date) {
+        if (date == null) {
+            return StringUtil.EMPTY_STRING;
+        }
+        return dayFormat.format(date);
+    }
+    public static String toStrWithoutYmd(Date date) {
+        if (date == null) {
+            return StringUtil.EMPTY_STRING;
+        }
+        return HmsFormat.format(date);
+    }
+
+    /**
+     * 获取某一周的第一天
+     *
+     * @param year
+     * @param week
+     * @return
+     */
+    public static Date getLastDayOfWeek(final int year, final int week) {
+        final Calendar cal = Calendar.getInstance();
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置周
+        cal.set(Calendar.WEEK_OF_YEAR, week);
+        //设置该周第一天为星期一
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        //设置最后一天是星期日
+        cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek() + 6); // Sunday
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 1);
+        return cal.getTime();
+    }
+
+    /**
+     * 获取某周第一天
+     *
+     * @param year
+     * @param week
+     * @return
+     */
+    public static Date getFirstDayOfWeek(final int year, final int week) {
+        final Calendar cal = Calendar.getInstance();
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置周
+        cal.set(Calendar.WEEK_OF_YEAR, week);
+        //设置该周第一天为星期一
+        cal.setFirstDayOfWeek(Calendar.MONDAY);
+        //设置最后一天是星期日
+        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 1);
+        return cal.getTime();
+    }
+
+    /**
+     * 获取某一月的第一天
+     *
+     * @param year
+     * @param month
+     * @return
+     */
+    public static Date getFirstDayOfMonth(final int year, final int month) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置月份
+        cal.set(Calendar.MONTH, month - 1);
+        //设置日历中月份的最大天数
+        cal.set(Calendar.DAY_OF_MONTH, 1);
+        cal.set(Calendar.HOUR_OF_DAY, 0);
+        cal.set(Calendar.MINUTE, 0);
+        cal.set(Calendar.SECOND, 1);
+        return cal.getTime();
+    }
+
+    /**
+     * 获取某一月的第一天
+     *
+     * @param year
+     * @param month
+     * @return
+     */
+    public static Date getLastDayOfMonth(final int year, final int month) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置月份
+        cal.set(Calendar.MONTH, month - 1);
+        //获取某月最大天数
+        final int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
+        //设置日历中月份的最大天数
+        cal.set(Calendar.DAY_OF_MONTH, lastDay);
+        cal.set(Calendar.HOUR_OF_DAY, 23);
+        cal.set(Calendar.MINUTE, 59);
+        cal.set(Calendar.SECOND, 59);
+        return cal.getTime();
+    }
+
+
+    /**
+     * 获取某个季度的最后一天
+     *
+     * @param year
+     * @param quarter
+     * @return
+     */
+    public static Date getLastDayOfQuarter(final Integer year, final Integer quarter) {
+        switch (quarter) {
+            case 1:
+                return getLastDayOfMonth(year, 3);
+            case 2:
+                return getLastDayOfMonth(year, 6);
+            case 3:
+                return getLastDayOfMonth(year, 9);
+            default:
+                return getLastDayOfMonth(year, 12);
+        }
+    }
+
+    /**
+     * 获取某个季度的第一天
+     *
+     * @param year
+     * @param quarter
+     * @return
+     */
+    public static Date getFirstDayOfQuarter(final Integer year, final Integer quarter) {
+        switch (quarter) {
+            case 1:
+                return getFirstDayOfMonth(year, 1);
+            case 2:
+                return getFirstDayOfMonth(year, 4);
+            case 3:
+                return getFirstDayOfMonth(year, 7);
+            default:
+                return getFirstDayOfMonth(year, 10);
+        }
+    }
+
+    /**
+     * 获取某个半年的最后一天
+     *
+     * @param year
+     * @param halfyear
+     * @return
+     */
+    public static Date getLastDayOfHalfyear(final Integer year, final Integer halfyear) {
+        switch (halfyear) {
+            case 1:
+                return getLastDayOfMonth(year, 6);
+            default:
+                return getLastDayOfMonth(year, 12);
+        }
+    }
+
+    /**
+     * 获取某个半年的第一天
+     *
+     * @param year
+     * @param halfyear
+     * @return
+     */
+    public static Date getFirstDayOfHalfyear(final Integer year, final Integer halfyear) {
+        switch (halfyear) {
+            case 1:
+                return getFirstDayOfMonth(year, 1);
+            default:
+                return getFirstDayOfMonth(year, 7);
+        }
+    }
+
+    /**
+     * 获取某年的最后一天
+     *
+     * @param year
+     * @return
+     */
+    public static Date getLastDayOfYear(final Integer year) {
+        return getLastDayOfMonth(year, 12);
+    }
+
+    /**
+     * 获取某年的最后一天
+     *
+     * @param year
+     * @return
+     */
+    public static Date getFirstDayOfYear(final Integer year) {
+        return getFirstDayOfMonth(year, 1);
+    }
+
+    /**
+     * @param date
+     */
+    public static List<DateTime> fromMonthStart(final Date date) {
+        DateHelper dateHelper = new DateHelper(date);
+        dateHelper.setHour(23);
+        dateHelper.setMin(59);
+        dateHelper.setDate(1);
+        final Date startDate = dateHelper.getDateTime();
+
+        dateHelper = new DateHelper(date);
+        dateHelper.setHour(23);
+        final Date endDate = dateHelper.getDateTime();
+        return DateUtil.rangeToList(startDate, endDate, DateField.DAY_OF_MONTH);
+    }
+
+    public int getQuarter() {
+        final int m = this.getMonth();
+        if (m >= 1 && m <= 3) {
+            return 1;
+        } else if (m >= 4 && m <= 6) {
+            return 2;
+        } else if (m >= 7 && m <= 9) {
+            return 3;
+        } else {
+            return 4;
+        }
+    }
+
+    public int getHalfyear() {
+        final int m = this.getMonth();
+        if (m >= 1 && m <= 6) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public void setYear(final Integer ys) {
+        this.calendar.set(Calendar.YEAR, ys);
+    }
+
+    public static String getDateString(Date date) {
+        dateStrFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        return dateStrFormat.format(date);
+    }
+
+    public static String getDayString(Date date) {
+        dayFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        return dayFormat.format(date);
+    }
+
+    public static Date getDate(Date date) {
+        dayFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
+        Date temp = null;
+        try {
+            temp = dayFormat.parse(dayFormat.format(date));
+        } catch (Exception e) {
+            temp = date;
+        }
+        return temp;
+    }
+
+
+    public static Map<String, Date> getStartAndEnd(DateHelper dateHelper, Integer planCycle) {
+        if (planCycle == null) {
+            return new HashMap<>();
+        }
+        Map<String, Date> map = new HashMap<>();
+        Date startTime = null;
+        Date endTime = null;
+        final Date dateTime = dateHelper.getDateTime();
+        switch (planCycle) {
+            case 0:
+                //每天
+                startTime = DateUtil.beginOfDay(dateTime);
+                endTime = DateUtil.endOfDay(dateTime);
+                break;
+            case 1:
+                //每周
+                startTime = DateUtil.beginOfWeek(dateTime);
+                endTime = DateUtil.endOfWeek(dateTime);
+                break;
+            case 2:
+                //每月
+                startTime = DateUtil.beginOfMonth(dateTime);
+                endTime = DateUtil.endOfMonth(dateTime);
+                break;
+            case 3:
+                //每季
+                startTime = DateHelper.getFirstDayOfQuarter(DateUtil.year(dateTime), DateUtil.quarter(dateTime));
+                endTime = DateHelper.getLastDayOfQuarter(DateUtil.year(dateTime), DateUtil.quarter(dateTime));
+                break;
+            case 4:
+                //每半年
+                startTime = DateHelper.getFirstDayOfHalfyear(DateUtil.year(dateTime), DateUtil.quarter(dateTime));
+                endTime = DateHelper.getLastDayOfHalfyear(DateUtil.year(dateTime), DateUtil.quarter(dateTime));
+                break;
+            //每年
+            case 5:
+                startTime = DateUtil.beginOfYear(dateTime);
+                endTime = DateUtil.endOfYear(dateTime);
+                break;
+            default:
+                break;
+        }
+        map.put("start", getPreciseTime(startTime));
+        map.put("end", getPreciseTime(endTime));
+        return map;
+    }
+
+
+    public static Date getPreciseTime(Date date) {
+        // 日历对象
+        Calendar c = Calendar.getInstance();
+        // 设置时间
+        c.setTime(date);
+        // 设置毫秒值为0
+        c.set(Calendar.MILLISECOND, 0);
+        return c.getTime();
+    }
+
+
+    public static String getUpcastNumber(int number) {
+        if (number == 1) {
+            return "一";
+        }
+        if (number == 2) {
+            return "二";
+        }
+        if (number == 3) {
+            return "三";
+        }
+        if (number == 4) {
+            return "四";
+        }
+        if (number == 5) {
+            return "五";
+        }
+        if (number == 6) {
+            return "六";
+        }
+        if (number == 7) {
+            return "天";
+        }
+        return StringUtil.EMPTY_STRING;
+    }
+
+    public static int getMonth(DateTime date) {
+        final Calendar instance = Calendar.getInstance();
+        instance.setTime(date);
+        return instance.get(Calendar.MONTH) + 1;
+    }
+}

+ 84 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/snowId/IDHelper.java

@@ -0,0 +1,84 @@
+package com.xunmei.common.core.utils.snowId;
+
+import cn.hutool.core.date.DateUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static cn.hutool.core.date.DatePattern.PURE_DATETIME_PATTERN;
+
+public class IDHelper {
+
+    private static final SnowflaskGenerator snowflaskGenerator = new SnowflaskGenerator(0L, 0L);
+
+    public static Long id() {
+        return snowflaskGenerator.nextId();
+    }
+
+    public static String dateTime(final Date date) {
+        return DateUtil.format(date, PURE_DATETIME_PATTERN);
+    }
+
+    public static String dateTime(final Date date, final Serializable other) {
+        return DateUtil.format(date, PURE_DATETIME_PATTERN) + "|" + other.toString();
+    }
+
+    public static String date(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "D" + dateHelper.getMonth() + "" + dateHelper.getDate() + "|" + other.toString();
+    }
+
+    public static String month(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "M" + dateHelper.getMonth() + "|" + other.toString();
+    }
+
+    public static String week(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "W" + dateHelper.getWeek() + "|" + other.toString();
+    }
+
+    public static String quarter(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "Q" + dateHelper.getQuarter() + "|" + other.toString();
+    }
+
+    public static String halfyear(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "H" + dateHelper.getHalfyear() + "|" + other.toString();
+    }
+
+    public static String year(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "Y" + dateHelper.getYear() + "|" + other.toString();
+    }
+
+    public static String hour(final Date date, final Serializable other) {
+        final DateHelper dateHelper = new DateHelper(date);
+        return dateHelper.getYear() + "R" + dateHelper.getMonth() + "" + dateHelper.getDate() + "" + dateHelper.getHour() + "|" + other.toString();
+    }
+
+    public static Long pad(final Serializable code, final Serializable id, final int i) {
+        return Long.parseLong(code + StringUtils.leftPad(id.toString(), i, "0"));
+    }
+
+    public static Long and(final Object... pp) {
+        return Long.parseLong(Stream.of(pp)
+                                    .filter(Objects::nonNull)
+                                    .map(Object::toString)
+                                    .collect(Collectors.joining()));
+    }
+
+//    public static String md5(final Serializable... os) {
+//        final StringBuilder stringBuilder = new StringBuilder(os.length * 10);
+//        for (final Serializable o : os) {
+//            stringBuilder.append(o.toString());
+//        }
+//        stringBuilder.trimToSize();
+//        return DigestUtils.md5Hex(stringBuilder.toString());
+//    }
+}

+ 131 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/utils/snowId/SnowflaskGenerator.java

@@ -0,0 +1,131 @@
+package com.xunmei.common.core.utils.snowId;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Long类型ID生成器,固定为19位长度
+ * 生成ID,采用snowflake算法,64bit整数,1秒可以生成800万个ID
+ * 0-41bit毫秒时间戳-10bit机器ID-12bit序列化
+ * 42bit的毫秒时间戳,2000年算起可以支持该算法使用到2068年,10bit的工作机器id可以支持1024台机器,12序列号支持1毫秒产生4096个自增序列id
+ */
+@Slf4j
+public class SnowflaskGenerator {
+
+    /** 开始时间截 (2015-01-01) */
+    private final long twepoch = 1420041600000L;
+
+    /** 机器id所占的位数 */
+    private final long workerIdBits = 1L;
+
+    /** 数据标识id所占的位数 */
+    private final long datacenterIdBits = 1L;
+
+    /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
+    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
+
+    /** 支持的最大数据标识id,结果是31 */
+    private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
+
+    /** 序列在id中占的位数 */
+    private final long sequenceBits = 12L;
+
+    /** 机器ID向左移12位 */
+    private final long workerIdShift = sequenceBits;
+
+    /** 数据标识id向左移17位(12+5) */
+    private final long datacenterIdShift = sequenceBits + workerIdBits;
+
+    /** 时间截向左移22位(5+5+12) */
+    private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
+
+    /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
+    private final long sequenceMask = -1L ^ (-1L << sequenceBits);
+
+    /** 工作机器ID(0~31) */
+    private long workerId;
+
+    /** 数据中心ID(0~31) */
+    private long datacenterId;
+
+    /** 毫秒内序列(0~4095) */
+    private long sequence = 0L;
+
+    /** 上次生成ID的时间截 */
+    private long lastTimestamp = -1L;
+
+    //==============================Constructors=====================================
+    /**
+     * 构造函数
+     * @param workerId 工作ID (0~31)
+     * @param datacenterId 数据中心ID (0~31)
+     */
+    public SnowflaskGenerator(long workerId, long datacenterId) {
+        if (workerId > maxWorkerId || workerId < 0) {
+            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
+        }
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
+            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
+        }
+        this.workerId = workerId;
+        this.datacenterId = datacenterId;
+    }
+
+    // ==============================Methods==========================================
+    /**
+     * 获得下一个ID (该方法是线程安全的)
+     * @return SnowflakeId
+     */
+    public synchronized long nextId() {
+        long timestamp = timeGen();
+
+        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
+        if (timestamp < lastTimestamp) {
+            throw new RuntimeException(
+                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
+        }
+
+        //如果是同一时间生成的,则进行毫秒内序列
+        if (lastTimestamp == timestamp) {
+            sequence = (sequence + 1) & sequenceMask;
+            //毫秒内序列溢出
+            if (sequence == 0) {
+                //阻塞到下一个毫秒,获得新的时间戳
+                timestamp = tilNextMillis(lastTimestamp);
+            }
+        }
+        //时间戳改变,毫秒内序列重置
+        else {
+            sequence = 0L;
+        }
+
+        //上次生成ID的时间截
+        lastTimestamp = timestamp;
+
+        //移位并通过或运算拼到一起组成64位的ID
+        return ((timestamp - twepoch) << timestampLeftShift) //
+                | (datacenterId << datacenterIdShift) //
+                | (workerId << workerIdShift) //
+                | sequence;
+    }
+
+    /**
+     * 阻塞到下一个毫秒,直到获得新的时间戳
+     * @param lastTimestamp 上次生成ID的时间截
+     * @return 当前时间戳
+     */
+    protected long tilNextMillis(long lastTimestamp) {
+        long timestamp = timeGen();
+        while (timestamp <= lastTimestamp) {
+            timestamp = timeGen();
+        }
+        return timestamp;
+    }
+
+    /**
+     * 返回以毫秒为单位的当前时间
+     * @return 当前时间(毫秒)
+     */
+    protected long timeGen() {
+        return System.currentTimeMillis();
+    }
+}

+ 4 - 0
soc-common/soc-common-core/src/main/java/com/xunmei/common/core/web/domain/BaseEntity.java

@@ -41,22 +41,26 @@ public class BaseEntity implements Serializable {
     /**
      * 创建者
      */
+    @TableField(value = "create_by")
     private String createBy;
 
     /**
      * 创建时间
      */
+    @TableField(value = "create_time")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
     /**
      * 更新者
      */
+    @TableField(value = "update_by")
     private String updateBy;
 
     /**
      * 更新时间
      */
+    @TableField(value = "update_time")
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
 

+ 2 - 2
soc-gateway/src/main/resources/bootstrap.yml

@@ -15,7 +15,7 @@ spring:
       discovery:
         # 服务注册地址
         server-addr: 10.87.10.54:8848
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
       config:
         # 配置中心地址
         server-addr: 10.87.10.54:8848
@@ -24,7 +24,7 @@ spring:
         # 共享配置
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
     sentinel:
       #取消控制台懒加载
       eager: true

+ 10 - 0
soc-modules/soc-modules-sync/pom.xml

@@ -79,6 +79,16 @@
             <version>${soc.version}</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.xunmei</groupId>
+            <artifactId>soc-common-core</artifactId>
+            <version>${soc.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.xunmei</groupId>
+            <artifactId>soc-api-system</artifactId>
+            <version>${soc.version}</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 0 - 7
soc-modules/soc-modules-sync/src/main/java/com/xunmei/Main.java

@@ -1,7 +0,0 @@
-package com.xunmei;
-
-public class Main {
-    public static void main(String[] args) {
-        System.out.println("Hello world!");
-    }
-}

+ 24 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/SocSyncApplication.java

@@ -0,0 +1,24 @@
+package com.xunmei.sync;
+
+import com.xunmei.common.security.annotation.EnableCustomConfig;
+import com.xunmei.common.security.annotation.EnableSocFeignClients;
+import com.xunmei.common.swagger.annotation.EnableCustomSwagger2;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScans;
+import org.springframework.stereotype.Component;
+
+//同步机构、用户等信息
+@EnableCustomConfig
+@EnableCustomSwagger2
+@EnableSocFeignClients
+@ComponentScan({"com.xunmei.*"})
+@SpringBootApplication
+public class SocSyncApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(SocSyncApplication.class, args);
+        System.out.println("Hello world! SocSyncApplication");
+    }
+}

+ 15 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/config/ThirdPartyUrl.java

@@ -0,0 +1,15 @@
+package com.xunmei.sync.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+@ConfigurationProperties(prefix = "app.device")
+public class ThirdPartyUrl {
+
+    private String fjnxPortalIp;
+
+    private String fjnxPasswordIp;
+}

+ 230 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/controller/FjnxSyncController.java

@@ -0,0 +1,230 @@
+package com.xunmei.sync.controller;
+
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.sync.dto.fjnxsync.SyncFileDto;
+import com.xunmei.sync.dto.fjnxsync.SyncResponseDto;
+import com.xunmei.sync.service.IFJNXSyncService;
+import io.netty.util.internal.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ *
+ */
+@Slf4j
+@Api(description = "机构")
+@Controller
+@ApiOperation(value = "同步机构")
+@RequestMapping("/api/fjnx/sync")
+class FjnxSyncController {
+
+//    @Autowired
+//    private OrgService orgService;
+
+    @Autowired
+    private IFJNXSyncService ifjnxSyncService;
+
+    @GetMapping("/org")
+    @ResponseBody
+    AjaxResult SyncOrg() throws IOException {
+        try {
+            String resultMsg= ifjnxSyncService.SyncOrgInfo();
+            if(StringUtil.isNullOrEmpty(resultMsg)){
+                return AjaxResult.success("同步成功");
+            }
+            else
+            {
+                return AjaxResult.error("同步失败:"+resultMsg);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error("机构同步失败" + e.getMessage());
+        }
+    }
+
+//    @GetMapping("/refresh/orgbusinesspath")
+//    @ResponseBody
+//    JsonResponse<String> refreshBusinesspath() throws IOException {
+//        try {
+//            ifjnxSyncService.RefreshBusinessPath();
+//            return JsonResponse.success("刷新机构业务Path成功");
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            return JsonResponse.fail("刷新机构业务Path失败" + e.getMessage());
+//        }
+//    }
+
+//    @GetMapping("/refresh/orgpath")
+//    @ResponseBody
+//    JsonResponse<String> refreshPath() throws IOException {
+//        try {
+//            List<Org> topOrgList = this.orgService.getTopOrg();
+//            topOrgList.forEach(topOrg -> {
+//                updateChild(topOrg.getId());
+//            });
+//            return JsonResponse.success("刷新机构path成功");
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            return JsonResponse.fail("刷新机构path失败" + e.getMessage());
+//        }
+//    }
+//
+//    private void updateChild(Long parentOrgId) {
+//        List<Org> children = this.orgService.children(parentOrgId);
+//        for (final Org org : children) {
+//            this.orgService.resetPath(org);
+//            this.updateChild(org.getId());
+//        }
+//    }
+
+
+    /**
+     * 同步机构测试接口
+     *
+     * @return
+     * @throws IOException
+     */
+    @GetMapping("/test/org")
+    @ResponseBody
+    AjaxResult SyncOrgTest() throws IOException {
+        try {
+//          String a="{\n" +
+//                  "    \"code\": 0,\n" +
+//                  "    \"total\": 0,\n" +
+//                  "    \"message\": null,\n" +
+//                  "    \"level\": null,\n" +
+//                  "    \"data\": {\n" +
+//                  "        \"fileName\": \"Users20230525000100444107.xml\",\n" +
+//                  "        \"fileId\": \"8d604f4a6c4c4bela6b777e09286d084\"\n" +
+//                  "    },\n" +
+//                  "    \"i18nData\": null\n" +
+//                  "}";
+            SyncResponseDto syncResponseDto = new SyncResponseDto();
+            syncResponseDto.setCode(0);
+            syncResponseDto.setTotal(0);
+            SyncFileDto fileDto = new SyncFileDto();
+            fileDto.setFileId("8d604f4a6c4c4bela6b777e09286d084");
+            fileDto.setFileName("Users20230525000100444107.xml");
+            syncResponseDto.setData(fileDto);
+            return AjaxResult.success(syncResponseDto);
+        } catch (Exception e) {
+            return AjaxResult.error("机构同步失败" + e.getMessage());
+        }
+    }
+
+    @ApiOperation(value = "模拟返回机构数据接口")
+    @GetMapping("/test/orgxmldata")
+    public void orgxmldata(HttpServletResponse response, HttpServletRequest request) {
+        try {
+            FileInputStream in = null;
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/octet-stream;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment;filename=file.xml");
+
+            try {
+                String path = this.getClass().getClassLoader().getResource("fjnxorg.xml").getPath();
+                in = new FileInputStream(path);
+                byte[] a = new byte[1024];
+                int b;
+                while ((b = in.read(a)) != -1) {
+                    response.getOutputStream().write(a, 0, b);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (null != in) {
+                    try {
+                        in.close();
+                    } catch (IOException e2) {
+                        System.out.println("关闭输入流错误");
+                    }
+                    try {
+                        response.getOutputStream().close();
+                    } catch (IOException e) {
+                        System.out.println("输出流关闭错误");
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            log.error("Exception", ex);
+            throw new RuntimeException("导出时发生异常");
+        }
+    }
+
+
+    @ApiOperation(value = "模拟返回机构数据接口")
+    @GetMapping("/test/userxmldata")
+    public void userxmldata(HttpServletResponse response, HttpServletRequest request) {
+        try {
+            FileInputStream in = null;
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/octet-stream;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment;filename=file.xml");
+
+            try {
+                String path = this.getClass().getClassLoader().getResource("fjnxuser.xml").getPath();
+                in = new FileInputStream(path);
+                byte[] a = new byte[1024];
+                int b;
+                while ((b = in.read(a)) != -1) {
+                    response.getOutputStream().write(a, 0, b);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (null != in) {
+                    try {
+                        in.close();
+                    } catch (IOException e2) {
+                        System.out.println("关闭输入流错误");
+                    }
+                    try {
+                        response.getOutputStream().close();
+                    } catch (IOException e) {
+                        System.out.println("输出流关闭错误");
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            log.error("Exception", ex);
+            throw new RuntimeException("导出时发生异常");
+        }
+    }
+
+//    @GetMapping("/user")
+//    @ResponseBody
+//    JsonResponse<String> SyncUser() throws Exception {
+//
+//        try {
+//            ifjnxSyncService.SyncUserInfo();
+//            return JsonResponse.success("同步成功");
+//        } catch (Exception e) {
+//            return JsonResponse.fail("人员同步失败" + e.getMessage());
+//        }
+//    }
+//
+//    @GetMapping("/organduser")
+//    @ResponseBody
+//    JsonResponse<String> SyncOrgAndUser(final MultipartFile file) throws IOException {
+//
+//        try {
+//            ifjnxSyncService.SyncOrgAndUserInfo();
+//            return JsonResponse.success("同步成功");
+//        } catch (Exception e) {
+//            return JsonResponse.fail("机构人员同步失败" + e.getMessage());
+//        }
+//    }
+}

+ 66 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/domain/FjnxOrgBusinessRelation.java

@@ -0,0 +1,66 @@
+package com.xunmei.sync.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 机构业务关系表
+ */
+
+@Data
+@TableName("t_fjnx_org_business_relation")
+@ApiModel(value = "OrgBusinessRelation对象", description = "")
+public class FjnxOrgBusinessRelation implements Serializable {
+
+
+    @ApiModelProperty(value = "编码")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    @ApiModelProperty(value = "机构id")
+    @TableField("org_id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long orgId;
+
+    @ApiModelProperty(value = "机构编码")
+    @TableField("org_code")
+    private String orgCode;
+
+    @ApiModelProperty(value = "业务父级Id")
+    @TableField("business_parent_id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long businessParentId;
+
+    @ApiModelProperty(value = "业务父级机构编码")
+    @TableField("business_parent_code")
+    private String businessParentCode;
+
+    @ApiModelProperty(value = "机构层级")
+    @TableField("org_level")
+    private Integer orgLevel;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField("create_time")
+    private Date createTime;
+
+    @ApiModelProperty(value = "最后修改人id")
+    @TableField("modified_id")
+    private Long modifiedId;
+
+    @ApiModelProperty(value = "修改人名称")
+    @TableField("modified_name")
+    private String modifiedName;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField("update_time")
+    private Date updateTime;
+
+}

+ 267 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/domain/OrgFjnx.java

@@ -0,0 +1,267 @@
+package com.xunmei.sync.domain;
+
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author zhulu
+ * @since 2023-06-05
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("t_fjnx_org")
+@ApiModel(value="同步FJNX机构保存对象", description="")
+public class OrgFjnx implements Serializable {
+
+//    private static final long serialVersionUID = 1L;
+//
+//    @ApiModelProperty(value = "机构Id")
+//      @TableId("org_id")
+//    private Long orgId;
+//
+//    @ApiModelProperty(value = "机构编码")
+//    @TableField("org_code")
+//    private String orgCode;
+//
+//    @ApiModelProperty(value = "所属法人机构编号")
+//    @TableField("corporCode")
+//    private String corporcode;
+//
+//    @ApiModelProperty(value = "承接机构编码")
+//    @TableField("belong_code")
+//    private String belongCode;
+//
+//    @ApiModelProperty(value = "承接日期")
+//    @TableField("belong_date")
+//    private DateTime belongDate;
+//
+//    @ApiModelProperty(value = "银行类别 ")
+//    @TableField("bank_type")
+//    private String bankType;
+//
+//    @ApiModelProperty(value = "主发银行")
+//    @TableField("major_back")
+//    private String majorBack;
+//
+//    @ApiModelProperty(value = "机构性质")
+//    @TableField("org_nature")
+//    private String orgNature;
+//
+//    @ApiModelProperty(value = "负责人类型")
+//    @TableField("principal_type")
+//    private String principalType;
+//
+//    @ApiModelProperty(value = "负责人编号")
+//    @TableField("org_chief")
+//    private String orgChief;
+//
+//    @ApiModelProperty(value = "负责人岗位")
+//    @TableField("principal_duty")
+//    private String principalDuty;
+//
+//    @ApiModelProperty(value = "机构层级")
+//    @TableField("org_level")
+//    private String orgLevel;
+//
+//    @ApiModelProperty(value = "社会信用编号")
+//    @TableField("social_trust_code")
+//    private String socialTrustCode;
+//
+//    @ApiModelProperty(value = "机构类型,扩展信息非业务机构类型 ")
+//    @TableField("org_extend_type")
+//    private String orgExtendType;
+
+    /*
+ 机构代码
+  */
+    @ApiModelProperty(value = "机构代码")
+    @TableId("org_code")
+    private String orgCode;
+
+    /*
+    机构名称
+     */
+    @ApiModelProperty(value = "机构名称")
+    @TableField("org_name")
+    private String orgName;
+
+    /*
+   机构简称
+    */
+    @ApiModelProperty(value = "机构简称")
+    @TableField("short_name")
+    private String shortName;
+
+
+
+    /*
+  机构类型 0001 部门、0002 机构、0003 村镇银行 0010 自定义
+   */
+    @ApiModelProperty(value = "机构类型 0001 部门、0002 机构、0003 村镇银行 0010 自定义")
+    @TableField("org_type")
+    private String orgType;
+
+    /*
+  上级机构代码
+   */
+    @ApiModelProperty(value = "上级机构代码")
+    @TableField("org_parent")
+    private String orgParent;
+
+    /*
+  部门机构电话
+   */
+    @ApiModelProperty(value = "部门机构电话")
+    @TableField("org_phone")
+    private String orgPhone;
+
+    /**
+     部门机构地址
+     */
+    @ApiModelProperty(value = "部门机构地址")
+    @TableField("org_address")
+    private String orgAddress;
+
+    /**
+     * 备注说明
+     */
+    @ApiModelProperty(value = "备注说明")
+    @TableField("remark")
+    private String remark;
+
+    /**
+     * 排序号
+     */
+    @ApiModelProperty(value = "排序号")
+    @TableField("org_order")
+    private Double orgOrder;
+
+    /**
+     * 是否可用 0 禁用 1 可用 2 撤并
+     */
+    @ApiModelProperty(value = "是否可用 0 禁用 1 可用 2 撤并")
+    @TableField("usable_flag")
+    private Integer usableFlag;
+
+    /**
+     * 机构路径
+     */
+    @ApiModelProperty(value = "机构路径")
+    @TableField("org_path")
+    private String  orgPath;
+
+    /**
+     * 所属法人机构号
+     */
+    @ApiModelProperty(value = "所属法人机构号")
+    @TableField("corpor_code")
+    private String corporCode;
+
+    /**
+     * 承接机构
+     */
+    @ApiModelProperty(value = "承接机构")
+    @TableField("belong_code")
+    private String belongCode;
+
+    /**
+     * 承接日期
+     */
+    @ApiModelProperty(value = "承接日期")
+    @TableField("belong_date")
+    private Date belongDate;
+
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 银行类别 1 农信银行、2 农信社、3 省联社、4 其他、5 村镇银行
+     */
+    @ApiModelProperty(value = "银行类别 1 农信银行、2 农信社、3 省联社、4 其他、5 村镇银行")
+    @TableField("bank_type")
+    private String bankType;
+
+    /**
+     * 主发银行
+     */
+    @ApiModelProperty(value = "主发银行")
+    @TableField("major_bank")
+    private String majorBank;
+
+    /**
+     * 机构性质 1 营业网点、2 非营业网点、3 虚拟网点(总账汇总)
+     */
+    @ApiModelProperty(value = "机构性质 1 营业网点、2 非营业网点、3 虚拟网点(总账汇总)")
+    @TableField("org_nature")
+    private String orgNature;
+
+    /**
+     * 负责人类型  1、法定代表人、2 负责人
+     */
+    @ApiModelProperty(value = "负责人类型  1、法定代表人、2 负责人")
+    @TableField("principal_type")
+    private String principalType;
+
+    /**
+     * 负责人编号
+     */
+    @ApiModelProperty(value = "负责人编号")
+    @TableField("org_chief")
+    private String orgChief;
+
+    /**
+     * 负责人岗位
+     */
+    @ApiModelProperty(value = "负责人岗位")
+    @TableField("principal_duty")
+    private String principalDuty;
+
+    /**
+     * 机构层级 0 未定级、1 一级、2 二级、3 三级
+     */
+    @ApiModelProperty(value = "机构层级 0 未定级、1 一级、2 二级、3 三级")
+    @TableField("org_level")
+    private String orgLevel;
+
+
+    @ApiModelProperty(value = "机构状态")
+    @TableField("org_state")
+    private String orgState;
+
+    @ApiModelProperty(value = "")
+    @TableField("localtion_flag")
+    private String localtionFlag;
+
+    /**
+     *  社会信用编号
+     */
+    @ApiModelProperty(value = "社会信用编号")
+    @TableField("social_trustCode")
+    private String socialTrustCode;
+
+    @ApiModelProperty(value = "最后同步时间")
+    @TableField("last_sync_time")
+    private Date lastSyncTime;
+
+
+    @ApiModelProperty(value = "业务父级编码")
+    @TableField("business_parent_code")
+    private String businessParentCode;
+}

+ 166 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXOrgDto.java

@@ -0,0 +1,166 @@
+package com.xunmei.sync.dto.fjnxsync;
+
+import cn.hutool.core.date.DateTime;
+import lombok.Data;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * FJNX统计运营门户返回机构数据
+ */
+@Data
+@XmlRootElement(name = "PubOrg")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class FJNXOrgDto implements Serializable {
+
+    /*
+    机构名称
+     */
+    @XmlElement(name = "orgName")
+    private String orgName;
+
+    /*
+   机构简称
+    */
+    @XmlElement(name = "shortName")
+    private String shortName;
+
+    /*
+  机构代码
+   */
+    @XmlElement(name = "orgCode")
+    private String orgCode;
+
+    /*
+  机构类型 0001 部门、0002 机构、0003 村镇银行 0010 自定义
+   */
+    @XmlElement(name = "orgType")
+    private String orgType;
+
+    /*
+  上级机构代码
+   */
+    @XmlElement(name = "orgParent")
+    private String orgParent;
+
+    /*
+  部门机构电话
+   */
+    @XmlElement(name = "orgPhone")
+    private String orgPhone;
+
+    /**
+  部门机构地址
+   */
+    @XmlElement(name = "orgAddress")
+    private String orgAddress;
+
+    /**
+     * 备注说明
+     */
+    @XmlElement(name = "remark")
+    private String remark;
+
+    /**
+     * 排序号
+     */
+    @XmlElement(name = "orgOrder")
+    private Double orgOrder;
+
+    /**
+     * 是否可用 0 禁用 1 可用 2 撤并
+     */
+    @XmlElement(name = "usableFlag")
+    private Integer usableFlag;
+
+    /**
+     * 机构路径
+     */
+    @XmlElement(name = "orgPath")
+    private String  orgPath;
+
+    /**
+     * 所属法人机构号
+     */
+    @XmlElement(name = "corporCode")
+    private String corporCode;
+
+    /**
+     * 承接机构
+     */
+    @XmlElement(name = "belongCode")
+    private String belongCode;
+
+    /**
+     * 承接日期
+     */
+    @XmlElement(name = "belongDate")
+    private DateTime belongDate;
+
+    /**
+     * 更新时间
+     */
+    @XmlElement(name = "updateTime")
+    private DateTime updateTime;
+
+    /**
+     * 银行类别 1 农信银行、2 农信社、3 省联社、4 其他、5 村镇银行
+     */
+    @XmlElement(name = "bankType")
+    private String bankType;
+
+    /**
+     * 主发银行
+     */
+    @XmlElement(name = "majorBank")
+    private String majorBank;
+
+    /**
+     * 机构性质 1 营业网点、2 非营业网点、3 虚拟网点(总账汇总)
+     */
+    @XmlElement(name = "orgNature")
+    private String orgNature;
+
+    /**
+     * 负责人类型  1、法定代表人、2 负责人
+     */
+    @XmlElement(name = "principalType")
+    private String principalType;
+
+    /**
+     * 负责人编号
+     */
+    @XmlElement(name = "orgChief")
+    private String orgChief;
+
+    /**
+     * 负责人岗位
+     */
+    @XmlElement(name = "principalDuty")
+    private String principalDuty;
+
+    /**
+     * 机构层级 0 未定级、1 一级、2 二级、3 三级
+     */
+    @XmlElement(name = "orgLevel")
+    private String orgLevel;
+
+
+    @XmlElement(name = "orgState")
+    private String orgState;
+
+    @XmlElement(name = "localtionFlag")
+    private String localtionFlag;
+
+    /**
+     *  社会信用编号
+     */
+    @XmlElement(name = "socialTrustCode")
+    private String socialTrustCode;
+
+}

+ 110 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXUserDto.java

@@ -0,0 +1,110 @@
+package com.xunmei.sync.dto.fjnxsync;
+
+import cn.hutool.core.date.DateTime;
+import lombok.Data;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * FJNX统计运营门户返回用户数据
+ */
+@Data
+@XmlRootElement(name = "PubUser")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class FJNXUserDto implements Serializable {
+
+    /**
+     * 人员ID
+     */
+    @XmlElement(name = "userId")
+    private String userId;
+
+    /**
+     * 人员名称
+     */
+    @XmlElement(name = "userName")
+    private String userName;
+
+    /**
+     * 登录名
+     */
+    @XmlElement(name = "loginName")
+    private String loginName;
+
+    /**
+     * 用户状态
+     */
+    @XmlElement(name = "userStatus")
+    private String userStatus;
+
+    /**
+     * 手机号
+     */
+    @XmlElement(name = "mobile")
+    private String mobile;
+
+    /**
+     * 邮件系统账号
+     */
+    @XmlElement(name = "mail")
+    private String mail;
+
+    /**
+     * 证件类型
+     */
+    @XmlElement(name = "certType")
+    private String certType;
+
+
+    /**
+     * 证件号码
+     */
+    @XmlElement(name = "idCard")
+    private String idCard;
+
+
+    /**
+     * 性别
+     */
+    @XmlElement(name = "sex")
+    private String sex;
+
+
+    /**
+     * 联系地址
+     */
+    @XmlElement(name = "address")
+    private String address;
+
+
+    /**
+     * 更新时间
+     */
+    @XmlElement(name = "updateTime")
+    private DateTime updateTime;
+
+    /**
+     * 所属机构代码
+     */
+    @XmlElement(name = "depCode")
+    private String depCode;
+
+    /**
+     * 法人机构号
+     */
+    @XmlElement(name = "corporCode")
+    private String corporCode;
+
+    /**
+     * 柜员号
+     */
+    @XmlElement(name = "teller")
+    private String teller;
+
+
+
+}

+ 15 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXXmlOrgDto.java

@@ -0,0 +1,15 @@
+package com.xunmei.sync.dto.fjnxsync;
+
+import lombok.Data;
+
+import javax.xml.bind.annotation.*;
+import java.util.List;
+
+@Data
+@XmlRootElement(name = "findAllPubOrg") //根节点
+@XmlAccessorType(XmlAccessType.FIELD)
+public class FJNXXmlOrgDto {
+    //XmlElement 表示当前节点 name对应节点名称
+    @XmlElement(name = "PubOrg")
+    private List<FJNXOrgDto> orgVos;
+}

+ 18 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/FJNXXmlUserDto.java

@@ -0,0 +1,18 @@
+package com.xunmei.sync.dto.fjnxsync;
+
+
+import lombok.Data;
+
+import javax.xml.bind.annotation.*;
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@XmlRootElement(name = "findAllPubUser") //根节点
+@XmlAccessorType(XmlAccessType.FIELD)
+public class FJNXXmlUserDto implements Serializable {
+
+    //XmlElement 表示当前节点 name对应节点名称
+    @XmlElement(name = "PubUser")
+    private List<FJNXUserDto> userVos;
+}

+ 13 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/SyncFileDto.java

@@ -0,0 +1,13 @@
+package com.xunmei.sync.dto.fjnxsync;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class SyncFileDto {
+    @ApiModelProperty("文件名称")
+    private String fileName;
+
+    @ApiModelProperty("文件Id")
+    private String fileId;
+}

+ 28 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/dto/fjnxsync/SyncResponseDto.java

@@ -0,0 +1,28 @@
+package com.xunmei.sync.dto.fjnxsync;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ *
+ */
+@Data
+public class SyncResponseDto {
+    @ApiModelProperty("编号")
+    private Integer code;
+
+    @ApiModelProperty("总数")
+    private Integer total;
+
+    @ApiModelProperty("消息")
+    private String message;
+
+    @ApiModelProperty("级别")
+    private String level;
+
+    @ApiModelProperty("国际化")
+    private String i18nData;
+
+    @ApiModelProperty("数据")
+    private SyncFileDto data;
+}

+ 18 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/mapper/FjnxOrgBusinessRelationMapper.java

@@ -0,0 +1,18 @@
+package com.xunmei.sync.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.sync.domain.FjnxOrgBusinessRelation;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author zhulu
+ * @since 2023-06-05
+ */
+@Mapper
+public interface FjnxOrgBusinessRelationMapper extends BaseMapper<FjnxOrgBusinessRelation> {
+
+}

+ 18 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/mapper/OrgFjnxMapper.java

@@ -0,0 +1,18 @@
+package com.xunmei.sync.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.sync.domain.OrgFjnx;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author zhulu
+ * @since 2023-06-05
+ */
+@Mapper
+public interface OrgFjnxMapper extends BaseMapper<OrgFjnx> {
+
+}

+ 19 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IFJNXOrgSyncService.java

@@ -0,0 +1,19 @@
+package com.xunmei.sync.service;
+
+import com.xunmei.sync.dto.fjnxsync.FJNXXmlOrgDto;
+import com.xunmei.sync.dto.fjnxsync.SyncResponseDto;
+
+/**
+ * @author zhulu
+ * @date 2022/5/30 16:02
+ */
+public interface IFJNXOrgSyncService {
+
+    /**
+     * 获取到同步机构数据
+     * @return
+     */
+    SyncResponseDto getOrgSyncFileInfo();
+
+    FJNXXmlOrgDto getOrgInfoByFileInfo();
+}

+ 23 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IFJNXSyncService.java

@@ -0,0 +1,23 @@
+package com.xunmei.sync.service;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author zhulu
+ * @date 2022/5/30 16:02
+ */
+public interface IFJNXSyncService {
+
+    /**
+     *
+     * @return
+     */
+    String SyncUserInfo();
+
+    String SyncOrgInfo();
+
+    String SyncOrgAndUserInfo();
+
+    @Transactional
+    void RefreshBusinessPath();
+}

+ 21 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IFJNXUserSyncService.java

@@ -0,0 +1,21 @@
+package com.xunmei.sync.service;
+
+import com.xunmei.sync.dto.fjnxsync.FJNXXmlUserDto;
+import com.xunmei.sync.dto.fjnxsync.SyncResponseDto;
+
+import java.util.List;
+
+/**
+ * @author zhulu
+ * @date 2022/5/30 16:02
+ */
+public interface IFJNXUserSyncService {
+
+    /**
+     * 获取到同步用户数据
+     * @return
+     */
+    SyncResponseDto getUserSyncFileInfo();
+
+    FJNXXmlUserDto getUserInfoByFileInfo();
+}

+ 16 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/IOrgJinxService.java

@@ -0,0 +1,16 @@
+package com.xunmei.sync.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xunmei.sync.domain.OrgFjnx;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author zhulu
+ * @since 2023-06-05
+ */
+public interface IOrgJinxService extends IService<OrgFjnx> {
+
+}

+ 53 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/api/FjnxApi.java

@@ -0,0 +1,53 @@
+package com.xunmei.sync.service.api;
+
+import com.alibaba.fastjson.JSON;
+import com.xunmei.common.core.exception.SystemException;
+import com.xunmei.common.core.http.service.CustomHttpClient;
+import com.xunmei.common.core.http.service.params.HttpParams;
+import com.xunmei.common.core.http.service.result.ResultExecute;
+import com.xunmei.sync.config.ThirdPartyUrl;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Component
+public class FjnxApi implements ResultExecute {
+    @Autowired
+    private CustomHttpClient httpClient;
+
+    @Autowired
+    private ThirdPartyUrl thirdPartyUrl;
+
+    public <T> T get(final HttpParams httpParams) {
+        httpParams.setUrl(this.thirdPartyUrl.getFjnxPortalIp() + httpParams.getUrl());
+        return this.httpClient.execute(httpParams, this);
+    }
+
+    @Override
+    public Object toBody(final Response response, final HttpParams request, final StopWatch stopWatch) throws Exception {
+        final String body = response.body()
+                .string();
+        if (response.code() != 200) {
+            throw new SystemException("100002", String.format("[ %s ] => [ %s ]", request, body));
+        }
+        Object result = null;
+        if (StringUtils.isBlank(body)) {
+            return null;
+        }
+        if (body.startsWith("[")) {
+            result = JSON.parseArray(body);
+        } else {
+            result = JSON.parseObject(body);
+        }
+        if (result == null) {
+            log.warn("[ {} ]无法获取到数据 => [ {} ]", request, body);
+        }
+        return result;
+    }
+}

+ 145 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/api/FjnxXmlApi.java

@@ -0,0 +1,145 @@
+package com.xunmei.sync.service.api;
+
+import com.xunmei.common.core.exception.SystemException;
+import com.xunmei.common.core.http.service.CustomHttpClient;
+import com.xunmei.common.core.http.service.params.HttpParams;
+import com.xunmei.common.core.http.service.result.ResultExecute;
+import com.xunmei.sync.config.ThirdPartyUrl;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.Response;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+@Slf4j
+@Component
+public class FjnxXmlApi implements ResultExecute {
+    @Autowired
+    private CustomHttpClient httpClient;
+
+    @Autowired
+    private ThirdPartyUrl thirdPartyUrl;
+
+    public <T> T get(final HttpParams httpParams) {
+        httpParams.setUrl(this.thirdPartyUrl.getFjnxPortalIp() + httpParams.getUrl());
+        return this.httpClient.execute(httpParams, this);
+    }
+
+    @Override
+    public Object toBody(final Response response, final HttpParams request, final StopWatch stopWatch) throws Exception {
+
+        final String body = response.body()
+                .string();
+        if (response.code() != 200 && response.code()!=0 ) {
+            throw new SystemException("100002", String.format("[ %s ] => [ %s ]", request, body));
+        }
+        else if(response.code() == 1)
+        {
+            // 文件下载失败
+        } else if (response.code() == 500) {
+            // 统一运营门户系统服务异常
+        }
+        return body;
+    }
+
+    public static String httpGet(String urlStr)
+    {
+        try
+        {
+            URL url = new URL(urlStr);
+            // 建立http连接
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            // 设置允许输出
+            conn.setDoOutput(true);
+
+            conn.setDoInput(true);
+
+            // 设置不用缓存
+            conn.setUseCaches(false);
+            // 设置传递方式
+            conn.setRequestMethod("Get");
+            // 设置维持长连接
+            conn.setRequestProperty("Connection", "Keep-Alive");
+            // 设置文件字符集:
+            conn.setRequestProperty("Charset", "UTF-8");
+            // 转换为字节数组
+//            byte[] data = xml.getBytes();
+            // 设置文件长度
+            //conn.setRequestProperty("Content-Length", String.valueOf(data.length));
+            // 设置文件类型:
+            conn.setRequestProperty("contentType", "text/xml");
+            // 开始连接请求
+            conn.connect();
+//            OutputStream out = conn.getOutputStream();
+            // 写入请求的字符串
+//            out.write(data);
+//            out.flush();
+//            out.close();
+
+            // 请求返回的状态
+            if (conn.getResponseCode() == 200)
+            {
+                // 请求返回的数据
+                InputStream in = conn.getInputStream();
+                try
+                {
+                    ByteArrayOutputStream s = new ByteArrayOutputStream();
+                    int length = 0;
+                    byte[] buffer = new byte[1024 * 1024];
+                    while ((length = in.read(buffer)) != -1)
+                    {
+                        s.write(buffer, 0, length);
+                    }
+                    return s.toString("UTF-8");
+
+                }
+                catch (Exception e1)
+                {
+                    e1.printStackTrace();
+                }
+                finally
+                {
+                    in.close();
+                }
+            }
+            else if(conn.getResponseCode() == 1)
+            {
+                // 文件下载失败
+            } else if (conn.getResponseCode() == 500) {
+                // 统一运营门户系统服务异常
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static <T> T convertXmlToJavaBean(String xml, Class<T> t) throws Exception
+    {
+        T obj;
+        JAXBContext context = JAXBContext.newInstance(t);
+        StringReader stringReader = new StringReader(xml);
+        SAXParserFactory sax = SAXParserFactory.newInstance();
+        sax.setNamespaceAware(false);// 设置忽略明明空间
+        XMLReader xmlReader = sax.newSAXParser().getXMLReader();
+        Source source = new SAXSource(xmlReader, new InputSource(stringReader));
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        obj = (T) unmarshaller.unmarshal(source);
+        return obj;
+    }
+}

+ 68 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/FJNXOrgSyncServiceImpl.java

@@ -0,0 +1,68 @@
+package com.xunmei.sync.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.xunmei.common.core.http.service.params.HttpParamsGet;
+import com.xunmei.sync.dto.fjnxsync.FJNXXmlOrgDto;
+import com.xunmei.sync.dto.fjnxsync.SyncResponseDto;
+import com.xunmei.sync.service.IFJNXOrgSyncService;
+import com.xunmei.sync.service.api.FjnxApi;
+import com.xunmei.sync.service.api.FjnxXmlApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author zhulu
+ * @date 2022/5/30 16:02
+ */
+@Service
+@Slf4j
+public class FJNXOrgSyncServiceImpl implements IFJNXOrgSyncService {
+
+    @Autowired
+    FjnxApi fjnxApi;
+
+    @Autowired
+    FjnxXmlApi fjnxXmlApi;
+
+    @Override
+    public SyncResponseDto getOrgSyncFileInfo() {
+        final Map<String, Object> params = new HashMap<>();
+        // TODO 后期将参数和地址 放在数据库中,放在配置文件中如果不是多套需要修改多个配置文件,可以放在数据库中 获取一次后放入Redis缓存
+        params.put("systemCode", 61303);
+        params.put("orgCode", "900000000");
+//        final JSONObject data = this.fjnxApi.get(HttpParamsGet.get("/sp-app-batch/api/syncout/orgdirect", params));
+        final JSONObject data = this.fjnxApi.get(HttpParamsGet.get("/api/fjnx/sync/test/org", params));
+        if (data == null) {
+            return null;
+        }
+        return  JSONObject.toJavaObject(data.getJSONObject("data"),SyncResponseDto.class);
+    }
+
+    @Override
+    public FJNXXmlOrgDto getOrgInfoByFileInfo() {
+        SyncResponseDto syncResponseDto =getOrgSyncFileInfo();
+        if(syncResponseDto==null) return null;
+
+        // TODO 后期将参数和地址 放在数据库中,放在配置文件中如果不是多套需要修改多个配置文件,可以放在数据库中 获取一次后放入Redis缓存
+        final Map<String, Object> params = new HashMap<>();
+        params.put("systemCode", "61303");
+        params.put("fileName", syncResponseDto.getData().getFileName());
+        params.put("fileId", syncResponseDto.getData().getFileId());
+        params.put("storageType", "localdisk");
+//        final String data= fjnxXmlApi.get(HttpParamsGet.get("/yusp-file/api/file/download", params));
+        final String data= fjnxXmlApi.get(HttpParamsGet.get("/api/fjnx/sync/test/orgxmldata", params));
+
+        try {
+            return FjnxXmlApi.convertXmlToJavaBean(data, FJNXXmlOrgDto.class);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}

+ 581 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/FJNXSyncServiceImpl.java

@@ -0,0 +1,581 @@
+package com.xunmei.sync.service.impl;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.xunmei.common.core.constant.SecurityConstants;
+import com.xunmei.common.core.domain.R;
+import com.xunmei.common.core.utils.bean.BeanUtils;
+import com.xunmei.common.core.utils.snowId.IDHelper;
+import com.xunmei.sync.domain.FjnxOrgBusinessRelation;
+import com.xunmei.sync.domain.OrgFjnx;
+import com.xunmei.sync.dto.fjnxsync.FJNXOrgDto;
+import com.xunmei.sync.dto.fjnxsync.FJNXXmlOrgDto;
+import com.xunmei.sync.mapper.FjnxOrgBusinessRelationMapper;
+import com.xunmei.sync.service.IFJNXOrgSyncService;
+import com.xunmei.sync.service.IFJNXSyncService;
+import com.xunmei.sync.service.IFJNXUserSyncService;
+import com.xunmei.sync.service.IOrgJinxService;
+import com.xunmei.system.api.RemoteOrgService;
+import com.xunmei.system.api.domain.Org;
+import com.xunmei.system.api.domain.SysOrg;
+import io.netty.util.internal.StringUtil;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.internal.Internal;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author zhulu
+ * @date 2022/5/30 16:02
+ */
+@Slf4j
+@Service
+public class FJNXSyncServiceImpl implements IFJNXSyncService {
+
+    @Autowired
+    IFJNXOrgSyncService ifjnxOrgSyncService;
+
+    @Autowired
+    IFJNXUserSyncService ifjnxUserSyncService;
+
+    @Autowired
+    IOrgJinxService iOrgJinxService;
+
+
+    @Autowired
+    RemoteOrgService remoteOrgService;
+
+    @Resource
+    FjnxOrgBusinessRelationMapper fjnxOrgBusinessRelationMapper;
+
+//    @Autowired
+//    OrgService orgService;
+//
+//    @Autowired
+//    private OrgRepository orgRepository;
+//
+//    @Autowired
+//    private UserRepository userRepository;
+//
+//    @Resource
+//    FjnxOrgBusinessRelationMapper orgBusinessRelationMapper;
+//
+//    @Resource
+//    private OrgExtendInfoMapper orgExtendInfoMapper;
+//
+//    @Autowired
+//    private OrgExtendInfoServiceImpl orgExtendInfoService;
+
+
+    @Override
+    public String SyncUserInfo() {
+//        FJNXXmlUserDto fjnxXmlUserDto = ifjnxUserSyncService.getUserInfoByFileInfo();
+//        if (fjnxXmlUserDto == null || ObjectUtil.isEmpty(fjnxXmlUserDto.getUserVos())) return "未获取到用户信息数据";
+//
+//        List<User> existUserList = userRepository.findAll();
+//        List<Org> existOrgList = orgRepository.findAll();
+//
+//        if (ObjectUtil.isEmpty(existUserList)) {
+//            userRepository.saveAll(FjnxUsersConvertToUsers(fjnxXmlUserDto.getUserVos(), existOrgList));
+//        } else {
+//            List<User> addList = new ArrayList<>();
+//            List<User> updateList = new ArrayList<>();
+//            List<User> deleteList = new ArrayList<>();
+//            List<String> fjnxUserCodeList = new ArrayList<>();
+//
+//            fjnxXmlUserDto.getUserVos().stream().forEach(fjnxUser -> {
+//                String orgCode = fjnxUser.getDepCode();
+//                if (!StringUtil.isNullOrEmpty(orgCode) && !StringUtil.isNullOrEmpty(fjnxUser.getUserId())) {
+//                    Optional<Org> optionalOrg = existOrgList.stream().filter(x -> orgCode.equals(x.getCode())).findFirst();
+//                    if (optionalOrg.isPresent()) {
+//                        Optional<User> optionalUser = existUserList.stream().filter(x -> fjnxUser.getUserId().equals(x.getCode())).findFirst();
+//                        if (optionalUser.isPresent()) {
+//                            updateList.add(FjnxUserConvertToUser(fjnxUser, optionalUser.get(), optionalOrg.get()));
+//                        } else {
+//                            addList.add(FjnxUserConvertToUser(fjnxUser, optionalOrg.get()));
+//                        }
+//                    } else {
+//                        log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", fjnxUser.getUserId() + fjnxUser.getUserName(), fjnxUser.getDepCode(), fjnxUser);
+//                    }
+//                    fjnxUserCodeList.add(fjnxUser.getUserId());
+//                }
+//
+//            });
+//
+//            // 人员在本系统中存在 但是在统一运营门户中不存在
+//            deleteList = existUserList.stream().filter(entity -> !fjnxUserCodeList.contains(entity.getCode())).collect(Collectors.toList());
+//            deleteList.forEach(x -> x.setDeleted(true));
+//
+//            if (ObjectUtil.isNotEmpty(addList)) {
+//                userRepository.saveAll(addList);
+//            }
+//
+//            if (ObjectUtil.isNotEmpty(updateList)) {
+//                userRepository.saveAll(updateList);
+//            }
+//
+//            if (ObjectUtil.isNotEmpty(deleteList)) {
+//                userRepository.saveAll(deleteList);
+//            }
+
+
+//        }
+
+
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public String SyncOrgInfo() {
+        /*
+         * 1、从统一门户接口获取机构数据,得到FJNXOrgDto 数组对象
+         * 2、保存FJNXOrgDto数组到 t_fjnx_org表,根据机构业务关系表转换机构businessParentCode
+         * 3、获取系统当前现有所有机构
+         * 4、数据对比,判断出新增、删除、修改数组
+         * 5、调用机构接口保存机构数据
+         * */
+        FJNXXmlOrgDto fjnxXmlOrgDto = ifjnxOrgSyncService.getOrgInfoByFileInfo();
+        if (fjnxXmlOrgDto == null || ObjectUtil.isEmpty(fjnxXmlOrgDto.getOrgVos())) return "未获取到机构信息数据";
+
+
+        List<OrgFjnx>  fjnxOrgList=ConvertXmlOrgDtoToOrgJinx(fjnxXmlOrgDto.getOrgVos());
+        iOrgJinxService.saveOrUpdateBatch(fjnxOrgList);
+
+
+        R<List<SysOrg>> existAllOrgResult = remoteOrgService.getAllOrg(SecurityConstants.INNER);
+        if(existAllOrgResult.getCode()!=200){
+            return existAllOrgResult.getMsg();
+        }
+        List<SysOrg> existOrgList = existAllOrgResult.getData();
+
+
+//        List<OrgExtendInfo> orgExtendInfoList = new ArrayList<>();
+        // 第一同步所有机构
+        if (ObjectUtil.isEmpty(existOrgList)) {
+            List<SysOrg> rList = FjnxOrgsConvertToSysOrgs(fjnxOrgList);
+            resetParentIdAndPath(rList);
+            final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(rList, SecurityConstants.INNER);
+            if(listR.getCode()!=200)
+            {
+                log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{0}",listR.getMsg());
+                return listR.getMsg();
+            }
+            return null;
+        }
+
+        List<SysOrg> addList = new ArrayList<>();
+        List<SysOrg> updateList = new ArrayList<>();
+        List<SysOrg> deleteList;
+        List<String> fjnxOrgCodeList = new ArrayList<>();
+        fjnxOrgList.stream().forEach(fjnxOrg -> {
+            String fjnxorgCode = fjnxOrg.getOrgCode();
+            if (!StringUtil.isNullOrEmpty(fjnxorgCode)) {
+                if(ObjectUtil.isNotEmpty(existOrgList)){
+                    Optional<SysOrg> optional = existOrgList.stream().filter(x -> fjnxOrg.getOrgCode().equals(x.getCode())).findFirst();
+                    if (optional.isPresent()) {
+                        updateList.add(FjnxOrgConvertToSysOrg(optional.get(), fjnxOrg));
+                    }else {
+                        addList.add(FjnxOrgConvertToSysOrg(fjnxOrg));
+                    }
+                }
+                else {
+                    addList.add(FjnxOrgConvertToSysOrg(fjnxOrg));
+                }
+                fjnxOrgCodeList.add(fjnxOrg.getOrgCode());
+            }
+            else
+            {
+                log.error("机构编码为空停止转换为系统机构,机构名称{0}", fjnxOrg.getOrgName());
+            }
+        });
+
+        // 机构在本系统中存在 但是在统一运营门户中不存在
+        deleteList = existOrgList.stream().filter(entity -> !fjnxOrgCodeList.contains(entity.getCode()) && !StringUtil.isNullOrEmpty(entity.getCode())).collect(Collectors.toList());
+        deleteList.forEach(x -> x.setDeleted(1));
+
+        existOrgList.addAll(addList);
+
+        resetParentIdAndPath(existOrgList);
+
+        final R<Boolean> listR = remoteOrgService.batchSaveSyncOrg(existOrgList, SecurityConstants.INNER);
+        if(ObjectUtil.isNotEmpty(listR) && listR.getCode()!=200)
+        {
+            log.error("调用远程服务接口remoteOrgService.batchSaveSyncOrg 失败:{0}",listR.getMsg());
+            return listR.getMsg();
+        }
+        return null;
+    }
+
+    @Override
+    public String SyncOrgAndUserInfo() {
+        this.SyncOrgInfo();
+        this.SyncUserInfo();
+        return null;
+    }
+
+
+    /**
+     * 刷新机构业务Path
+     */
+    @Transactional
+    @Override
+    public void RefreshBusinessPath() {
+//        List<Org> allOrgList = orgRepository.findAll();
+//        // 将所有的 BusinessPath 先刷成跟 path字段值一致
+//        allOrgList.forEach(x -> x.setBusinessPath(x.getPath()));
+//
+//        List<FjnxOrgBusinessRelation> orgBusinessRelationList = orgBusinessRelationMapper.selectList(Wrappers.emptyWrapper());
+//        if (ObjectUtil.isEmpty(orgBusinessRelationList)) {
+//            orgRepository.saveAll(allOrgList);
+//            return;
+//        }
+//
+//        // 从顶层机构往下开始刷新businessPath 根据机构业务管理数据 调整某些机构BusinessPath
+//        // TODO 目前只支持平级机构可以标记为业务父级
+//        orgBusinessRelationList.stream().sorted(Comparator.comparing(FjnxOrgBusinessRelation::getOrgLevel)).forEach(obr -> {
+//            Optional<Org> currentOrgOpt = allOrgList.stream().filter(org -> obr.getOrgId().equals(org.getId())).findFirst();
+//            Optional<Org> businessParentOrgOpt = allOrgList.stream().filter(org -> obr.getBusinessParentId().equals(org.getId())).findFirst();
+//            if (currentOrgOpt.isPresent() && businessParentOrgOpt.isPresent()) {
+//                Org currentOrg = currentOrgOpt.get();
+//                resetBusinessPath(currentOrg, businessParentOrgOpt.get());
+//                updateChildBusinessPath(currentOrg, allOrgList);
+//            }
+//        });
+//        orgRepository.saveAll(allOrgList);
+//        return;
+    }
+
+    public void resetParentIdAndPath(List<SysOrg> orgList) {
+
+        final List<SysOrg> collect = orgList.stream().filter(topOrg -> StringUtil.isNullOrEmpty(topOrg.getParentGuid()) && 0==topOrg.getDeleted()).collect(Collectors.toList());
+        collect.stream().forEach(org -> {
+            org.setParentId(-1L);
+//            org.setLevel(1);
+            org.setPath(org.getId() + "-");
+        });
+
+        orgList.stream().forEach(org -> {
+
+            if (org.getParentId() != null) {
+                return;
+            }
+
+            if(org.getDeleted().equals(1))
+            {
+                // 已删除
+                return;
+            }
+
+            if (!StringUtil.isNullOrEmpty(org.getParentGuid())) {
+                Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg ->!StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(org.getParentGuid())).findFirst();
+                if (parentOrgOptional.isPresent()) {
+                    org.setParentId(parentOrgOptional.get().getId());
+                    if (StringUtil.isNullOrEmpty(parentOrgOptional.get().getPath())) {
+                        List<SysOrg> childOrg = new ArrayList<>();
+                        childOrg.add(org);
+                        resetParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
+                    } else {
+
+                    }
+                } else {
+                    log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", org.getName(), org.getGuid(), org.getParentGuid(), org);
+                }
+            } else {
+                org.setParentId(-1L);
+//                org.setLevel(1);
+                org.setPath(org.getId() + "-");
+            }
+        });
+    }
+
+    public void resetParentOrgPath(SysOrg parentOrg, List<SysOrg> childOrg, List<SysOrg> orgList) {
+        Optional<SysOrg> parentOrgOptional = orgList.stream().filter(pOrg ->!StringUtil.isNullOrEmpty(pOrg.getGuid()) && pOrg.getGuid().equals(parentOrg.getParentGuid())).findFirst();
+        if (parentOrgOptional.isPresent()) {
+            parentOrg.setParentId(parentOrgOptional.get().getId());
+            if (!StringUtil.isNullOrEmpty(parentOrgOptional.get().getPath())) {
+                retOrgPath(parentOrgOptional.get(), parentOrg);
+                retChildOrgPath(parentOrg, childOrg);
+            } else {
+
+                childOrg.add(parentOrg);
+                resetParentOrgPath(parentOrgOptional.get(), childOrg, orgList);
+            }
+        } else {
+            log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", parentOrg.getName(), parentOrg.getGuid(), parentOrg.getParentGuid(), parentOrg);
+        }
+    }
+
+    public void retOrgPath(SysOrg parentOrg, SysOrg org) {
+        org.setParentId(parentOrg.getId());
+//        if (parentOrg.getLevel() != null) {
+//            parentOrg.setLevel(parentOrg.getLevel() + 1);
+//        }
+        org.setPath(parentOrg.getPath() + parentOrg.getId() + "-");
+    }
+
+    public void retChildOrgPath(SysOrg parentOrg, List<SysOrg> childOrgs) {
+        if (ObjectUtil.isNotEmpty(childOrgs)) {
+            if (ObjectUtil.isNotEmpty(parentOrg)) {
+                Optional<SysOrg> orgOptional = childOrgs.stream().filter(org -> org.getParentId().equals(parentOrg.getId())).findFirst();
+                if (orgOptional.isPresent()) {
+                    SysOrg childOrg = orgOptional.get();
+                    retOrgPath(parentOrg, childOrg);
+                    childOrgs.remove(childOrg);
+                    retChildOrgPath(childOrg, childOrgs);
+                } else {
+                    log.error("机构【{}】机构编码【{}】父级机构编码【{}】,父级机构未找到;{}", parentOrg.getName(), parentOrg.getGuid(), parentOrg.getParentGuid(), parentOrg);
+                }
+            }
+        }
+    }
+
+//    private void updateChildBusinessPath(Org businessParentOrg, List<Org> allOrgList) {
+//        List<Org> childrenOrgs = allOrgList.stream().filter(aorg -> businessParentOrg.getId().equals(aorg.getParentId())).collect(Collectors.toList());
+//        for (final Org org : childrenOrgs) {
+//            resetBusinessPath(org, businessParentOrg);
+//            this.updateChildBusinessPath(org, allOrgList);
+//        }
+//    }
+//
+//    public Org resetBusinessPath(Org org, Org businessParentOrg) {
+//
+//        org.setBusinessPath(businessParentOrg.getBusinessPath() + org.getId() + "-");
+//        System.out.println(org.getBusinessPath());
+//        return org;
+//    }
+//
+//    private List<SysOrg> FjnxOrgsConvertToSysOrgs(List<OrgFjnx> fjnxOrgDtoList) {
+//        List<SysOrg> result = new ArrayList<>();
+//        if (ObjectUtil.isNotEmpty(fjnxOrgDtoList)) {
+//            fjnxOrgDtoList.stream().forEach(x -> {
+//                result.add(FjnxOrgConvertToSysOrg(x));
+//            });
+//        }
+//        return result;
+//    }
+
+    private SysOrg FjnxOrgConvertToOrg(OrgFjnx fjnxOrgDto) {
+        SysOrg org = new SysOrg();
+        org.setId(IDHelper.id());
+        org.setName(fjnxOrgDto.getOrgName());
+        org.setShortName(fjnxOrgDto.getShortName());
+        org.setGuid(fjnxOrgDto.getOrgCode());
+        org.setParentGuid(fjnxOrgDto.getOrgParent());
+        org.setCode(fjnxOrgDto.getOrgCode());
+        org.setPhone(fjnxOrgDto.getOrgPhone());
+        org.setAddress(fjnxOrgDto.getOrgAddress());
+//        org.setCodePath(fjnxOrgDto.getOrgPath());
+        org.setSort(fjnxOrgDto.getOrgOrder());
+        org.setUpdateTime(fjnxOrgDto.getUpdateTime());
+        org.setRemark(fjnxOrgDto.getRemark());
+//        org.setLevel(fjnxOrgDto.getOrgPath().split("/").length);
+        // TODO 机构状态和机构类型转换
+        //org.setIsLock(fjnxOrgDto.getUsableFlag());
+        org.setIsLock(fjnxOrgDto.getUsableFlag());
+        return org;
+
+    }
+
+    private List<SysOrg> FjnxOrgsConvertToSysOrgs(List<OrgFjnx> fjnxOrgList) {
+        List<SysOrg> result = new ArrayList<>();
+        if (ObjectUtil.isNotEmpty(fjnxOrgList)) {
+            fjnxOrgList.stream().forEach(x -> {
+                result.add(FjnxOrgConvertToSysOrg(x));
+            });
+        }
+        return result;
+    }
+
+    private SysOrg FjnxOrgConvertToSysOrg(OrgFjnx fjnxOrgDto) {
+        SysOrg org = new SysOrg();
+        org.setId(IDHelper.id());
+        org.setName(fjnxOrgDto.getOrgName());
+        org.setShortName(fjnxOrgDto.getShortName());
+        org.setCode(fjnxOrgDto.getOrgCode());
+        org.setGuid(fjnxOrgDto.getOrgCode());
+        org.setParentGuid(fjnxOrgDto.getBusinessParentCode());
+        org.setPhone(fjnxOrgDto.getOrgPhone());
+        org.setAddress(fjnxOrgDto.getOrgAddress());
+        org.setSort(fjnxOrgDto.getOrgOrder());
+        org.setUpdateTime(fjnxOrgDto.getUpdateTime());
+        org.setRemark(fjnxOrgDto.getRemark());
+        //org.setLevel(fjnxOrgDto.getOrgPath().split("/").length);
+        org.setIsLock(fjnxOrgDto.getUsableFlag());
+        org.setDeleted(0);
+        org.setSource(1);
+        return org;
+    }
+//
+//    private OrgExtendInfo FjnxOrgConvertToOrgExtendInfo(Long orgId, FJNXOrgDto fjnxOrgDto) {
+//        OrgExtendInfo orgExtendInfo = new OrgExtendInfo();
+//        orgExtendInfo.setOrgId(orgId);
+//        orgExtendInfo.setOrgCode(fjnxOrgDto.getOrgCode());
+//        orgExtendInfo.setBankType(fjnxOrgDto.getBankType());
+//        orgExtendInfo.setBelongCode(fjnxOrgDto.getBelongCode());
+//        orgExtendInfo.setBelongDate(fjnxOrgDto.getBelongDate());
+//        orgExtendInfo.setCorporcode(fjnxOrgDto.getCorporCode());
+//        orgExtendInfo.setMajorBack(fjnxOrgDto.getMajorBank());
+//        orgExtendInfo.setOrgNature(fjnxOrgDto.getOrgNature());
+//        orgExtendInfo.setPrincipalType(fjnxOrgDto.getPrincipalType());
+//        orgExtendInfo.setPrincipalDuty(fjnxOrgDto.getPrincipalDuty());
+//        orgExtendInfo.setSocialTrustCode(fjnxOrgDto.getSocialTrustCode());
+//        orgExtendInfo.setOrgLevel(fjnxOrgDto.getOrgLevel());
+//        orgExtendInfo.setOrgChief(fjnxOrgDto.getOrgChief());
+//        return orgExtendInfo;
+//
+//    }
+//
+//    private OrgExtendInfo FjnxOrgConvertToOrgExtendInfo(OrgExtendInfo orgExtendInfo, FJNXOrgDto fjnxOrgDto) {
+////        OrgExtendInfo orgExtendInfo = new OrgExtendInfo();
+////        orgExtendInfo.setOrgId(orgId);
+////        orgExtendInfo.setOrgCode(fjnxOrgDto.getOrgCode());
+//        orgExtendInfo.setBankType(fjnxOrgDto.getBankType());
+//        orgExtendInfo.setBelongCode(fjnxOrgDto.getBelongCode());
+//        orgExtendInfo.setBelongDate(fjnxOrgDto.getBelongDate());
+//        orgExtendInfo.setCorporcode(fjnxOrgDto.getCorporCode());
+//        orgExtendInfo.setMajorBack(fjnxOrgDto.getMajorBank());
+//        orgExtendInfo.setOrgNature(fjnxOrgDto.getOrgNature());
+//        orgExtendInfo.setPrincipalType(fjnxOrgDto.getPrincipalType());
+//        orgExtendInfo.setPrincipalDuty(fjnxOrgDto.getPrincipalDuty());
+//        orgExtendInfo.setSocialTrustCode(fjnxOrgDto.getSocialTrustCode());
+//        orgExtendInfo.setOrgLevel(fjnxOrgDto.getOrgLevel());
+//        orgExtendInfo.setOrgChief(fjnxOrgDto.getOrgChief());
+//        return orgExtendInfo;
+//
+//    }
+
+
+    private Org FjnxOrgConvertToOrg(Org org, FJNXOrgDto fjnxOrgDto) {
+        org.setName(fjnxOrgDto.getOrgName());
+        org.setShortName(fjnxOrgDto.getShortName());
+        org.setGuid(fjnxOrgDto.getOrgCode());
+        org.setParentGuid(fjnxOrgDto.getOrgParent());
+        org.setCode(fjnxOrgDto.getOrgCode());
+        org.setPhone(fjnxOrgDto.getOrgPhone());
+        org.setAddress(fjnxOrgDto.getOrgAddress());
+//        org.setCodePath(fjnxOrgDto.getOrgPath());
+        org.setSort(fjnxOrgDto.getOrgOrder());
+        org.setUpdateTime(fjnxOrgDto.getUpdateTime());
+        org.setRemark(fjnxOrgDto.getRemark());
+        org.setLevel(fjnxOrgDto.getOrgPath().split("/").length);
+        // TODO 机构状态和机构类型转换
+        org.setIsLock(fjnxOrgDto.getUsableFlag());
+        return org;
+
+    }
+
+    private SysOrg FjnxOrgConvertToSysOrg(SysOrg org, OrgFjnx fjnxOrg) {
+        org.setName(fjnxOrg.getOrgName());
+        org.setShortName(fjnxOrg.getShortName());
+        org.setCode(fjnxOrg.getOrgCode());
+        org.setGuid(fjnxOrg.getOrgCode());
+        org.setParentGuid(fjnxOrg.getBusinessParentCode());
+        org.setPhone(fjnxOrg.getOrgPhone());
+        org.setAddress(fjnxOrg.getOrgAddress());
+        org.setSort(fjnxOrg.getOrgOrder());
+        org.setUpdateTime(fjnxOrg.getUpdateTime());
+        org.setRemark(fjnxOrg.getRemark());
+//        org.setLevel(fjnxOrg.getOrgPath().split("/").length);
+        // TODO 机构状态和机构类型转换
+        org.setIsLock(fjnxOrg.getUsableFlag());
+        org.setSource(1);
+        return org;
+
+    }
+
+//    private List<User> FjnxUsersConvertToUsers(List<FJNXUserDto> fjnxUserDtoList, List<Org> orgList) {
+//        List<User> result = new ArrayList<>();
+//        if (ObjectUtil.isNotEmpty(fjnxUserDtoList)) {
+//            fjnxUserDtoList.stream().forEach(x -> {
+//                Optional<Org> optionalOrg = orgList.stream().filter(org -> org.getCode().equals(x.getDepCode())).findFirst();
+//                if (optionalOrg.isPresent()) {
+//                    result.add(FjnxUserConvertToUser(x, optionalOrg.get()));
+//                } else {
+//                    log.error("同步人员【{}】所属机构编码【{}】在当前数据库中未找到,{}", x.getUserId() + x.getUserName(), x.getDepCode(), x);
+//                }
+//
+//            });
+//        }
+//        return result;
+//    }
+//
+//    private User FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, Org org) {
+//        User user = new User();
+//        user.setCode(fjnxUserDto.getUserId());
+//        user.setName(fjnxUserDto.getUserName());
+//        user.setUsername(fjnxUserDto.getLoginName());
+//        user.setPhone(fjnxUserDto.getMobile());
+//        user.setGender(fjnxUserDto.getSex().equals("1") ? Gender.MAN : Gender.WOMAN);
+//        user.setCard(fjnxUserDto.getIdCard());
+//        user.setJobNumber(fjnxUserDto.getTeller());
+//        user.setApproveStatus(ApproveStatus.PASS);
+//        user.setUpdateTime(fjnxUserDto.getUpdateTime());
+//        user.setOrgId(org.getId());
+//        user.setOrgName(org.getName());
+//        user.setOrgPath(org.getPath());
+//        //0 禁用 1 启用已改密码 2 启用未改密码
+//        user.setIsLock(fjnxUserDto.getUserStatus().equals("0") ? true : false);
+//        // TODO 机构状态和机构类型转换
+//        //user.setIsLock(fjnxOrgDto.getUsableFlag());
+//        return user;
+//
+//    }
+//
+//    private User FjnxUserConvertToUser(FJNXUserDto fjnxUserDto, User user, Org org) {
+//        user.setCode(fjnxUserDto.getUserId());
+//        user.setName(fjnxUserDto.getUserName());
+//        user.setUsername(fjnxUserDto.getLoginName());
+//        user.setPhone(fjnxUserDto.getMobile());
+//        user.setGender(fjnxUserDto.getSex().equals("1") ? Gender.MAN : Gender.WOMAN);
+//        user.setCard(fjnxUserDto.getIdCard());
+//        user.setJobNumber(fjnxUserDto.getTeller());
+//        user.setApproveStatus(ApproveStatus.PASS);
+//        user.setUpdateTime(fjnxUserDto.getUpdateTime());
+//        user.setOrgId(org.getId());
+//        user.setOrgName(org.getName());
+//        user.setOrgPath(org.getPath());
+//        //0 禁用 1 启用已改密码 2 启用未改密码
+//        user.setIsLock(fjnxUserDto.getUserStatus().equals("0") ? true : false);
+//        // TODO 机构状态和机构类型转换
+//        //user.setIsLock(fjnxOrgDto.getUsableFlag());
+//        return user;
+//
+//    }
+
+    private List<OrgFjnx> ConvertXmlOrgDtoToOrgJinx(List<FJNXOrgDto> list) {
+        if (ObjectUtil.isEmpty(list)) {
+            return new ArrayList<OrgFjnx>();
+        }
+        List<FjnxOrgBusinessRelation> fjnxOrgBusinessRelationList = fjnxOrgBusinessRelationMapper.selectList(Wrappers.emptyWrapper());
+        final ArrayList<OrgFjnx> resultList = new ArrayList<>();
+        Date syncDateTime=new Date();
+        list.stream().forEach(item -> {
+            OrgFjnx tempOrg = new OrgFjnx();
+            BeanUtils.copyBeanProp(tempOrg, item);
+
+            tempOrg.setLastSyncTime(syncDateTime);
+            tempOrg.setBusinessParentCode(tempOrg.getOrgParent());
+
+            Optional<FjnxOrgBusinessRelation> first = fjnxOrgBusinessRelationList.stream().filter(b -> b.getOrgCode().equals(item.getOrgCode())).findFirst();
+            if(first.isPresent())
+            {
+               if( list.stream().anyMatch(y->y.getOrgCode().equals(first.get().getBusinessParentCode()))){
+                   tempOrg.setBusinessParentCode(first.get().getBusinessParentCode());
+               }
+               else{
+                   log.error("设置fjnx业务父级机构失败,机构名称:{0},机构编码:{1},业务父级机构编码:{2}", item.getOrgName(),first.get().getOrgCode(), first.get().getBusinessParentCode());
+               }
+            }
+            resultList.add(tempOrg);
+        });
+        return resultList;
+    }
+
+}

+ 62 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/FJNXUserSyncServiceImpl.java

@@ -0,0 +1,62 @@
+package com.xunmei.sync.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.xunmei.common.core.http.service.params.HttpParamsGet;
+import com.xunmei.sync.dto.fjnxsync.FJNXXmlUserDto;
+import com.xunmei.sync.dto.fjnxsync.SyncResponseDto;
+import com.xunmei.sync.service.IFJNXUserSyncService;
+import com.xunmei.sync.service.api.FjnxApi;
+import com.xunmei.sync.service.api.FjnxXmlApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author zhulu
+ * @date 2022/5/30 16:02
+ */
+@Service
+@Slf4j
+public class FJNXUserSyncServiceImpl implements IFJNXUserSyncService {
+    @Autowired
+    FjnxApi fjnxApi;
+    @Autowired
+    FjnxXmlApi fjnxXmlApi;
+    @Override
+    public SyncResponseDto getUserSyncFileInfo() {
+        final Map<String, Object> params = new HashMap<>();
+        // TODO 放在数据库中,放在配置文件中如果不是多套需要修改多个配置文件,可以放在数据库中 获取一次后放入Redis缓存
+        params.put("systemCode", 61303);
+        final JSONObject data = this.fjnxApi.get(HttpParamsGet.get("/sp-app-batch/api/syncout/userdirect", params));
+//        final JSONObject data = this.fjnxApi.get(HttpParamsGet.get("/api/fjnx/sync/test/org", params));
+        if (data == null) {
+            return null;
+        }
+        return  JSONObject.toJavaObject(data,SyncResponseDto.class);
+    }
+
+    @Override
+    public FJNXXmlUserDto getUserInfoByFileInfo() {
+        SyncResponseDto syncResponseDto =getUserSyncFileInfo();
+        if(syncResponseDto==null) return null;
+
+        // TODO 后期将参数和地址 放在数据库中,放在配置文件中如果不是多套需要修改多个配置文件,可以放在数据库中 获取一次后放入Redis缓存
+        final Map<String, Object> params = new HashMap<>();
+        params.put("systemCode", "61303");
+        params.put("fileName", syncResponseDto.getData().getFileName());
+        params.put("fileId", syncResponseDto.getData().getFileId());
+        params.put("storageType", "localdisk");
+        final String data= fjnxXmlApi.get(HttpParamsGet.get("/yusp-file/api/file/download", params));
+
+//        final String data= fjnxXmlApi.get(HttpParamsGet.get("/api/fjnx/sync/test/userxmldata", params));
+
+        try {
+            return FjnxXmlApi.convertXmlToJavaBean(data, FJNXXmlUserDto.class);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}

+ 20 - 0
soc-modules/soc-modules-sync/src/main/java/com/xunmei/sync/service/impl/OrgJinxServiceImpl.java

@@ -0,0 +1,20 @@
+package com.xunmei.sync.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xunmei.sync.domain.OrgFjnx;
+import com.xunmei.sync.mapper.OrgFjnxMapper;
+import com.xunmei.sync.service.IOrgJinxService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author zhulu
+ * @since 2023-06-05
+ */
+@Service
+public class OrgJinxServiceImpl extends ServiceImpl<OrgFjnxMapper, OrgFjnx> implements IOrgJinxService {
+
+}

+ 2 - 2
soc-modules/soc-modules-sync/src/main/resources/bootstrap.yml

@@ -13,11 +13,11 @@ spring:
   cloud:
     nacos:
       discovery:
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
         # 服务注册地址
         server-addr: 10.87.10.54:8848
       config:
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
         # 配置中心地址
         server-addr: 10.87.10.54:8848
         # 配置文件格式

+ 5 - 0
soc-modules/soc-modules-sync/src/main/resources/mapper/FjnxOrgBusinessRelationMapper.xml

@@ -0,0 +1,5 @@
+<?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.xunmei.sync.domain.FjnxOrgBusinessRelation">
+
+</mapper>

+ 7 - 0
soc-modules/soc-modules-sync/src/main/resources/mapper/OrgFjnxMapper.xml

@@ -0,0 +1,7 @@
+<?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.xunmei.sync.domain.OrgFjnx">
+
+</mapper>

+ 21 - 13
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysKnowledgeController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
 
+import com.xunmei.common.core.domain.IdName;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -31,26 +32,24 @@ import com.xunmei.common.core.web.page.TableDataInfo;
  * @author xunmei
  * @date 2023-08-21
  */
-@Api(tags = {"SysKnowledge" })
+@Api(tags = {"SysKnowledge"})
 @RestController
 @RequestMapping("/knowledge")
 public class SysKnowledgeController extends BaseController {
     @Autowired
     private ISysKnowledgeService sysKnowledgeService;
 
-/**
- * 查询知识库标签列表
- */
-@ApiOperation(value = "查询SysKnowledge列表")
-@RequiresPermissions("system:knowledge:list")
-@GetMapping("/list")
+    /**
+     * 查询知识库标签列表
+     */
+    @ApiOperation(value = "查询SysKnowledge列表")
+    @RequiresPermissions("system:knowledge:list")
+    @GetMapping("/list")
     public TableDataInfo list(SysKnowledge sysKnowledge) {
-
-        return sysKnowledgeService.selectPage( sysKnowledge);
+        return sysKnowledgeService.selectPage(sysKnowledge);
     }
 
 
-
     /**
      * 获取知识库标签详细信息
      */
@@ -66,7 +65,7 @@ public class SysKnowledgeController extends BaseController {
      */
     @ApiOperation(value = "新增SysKnowledge")
     @RequiresPermissions("system:knowledge:add")
-    @Log(title = "知识库标签" , businessType = BusinessType.INSERT)
+    @Log(title = "知识库标签", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody SysKnowledge sysKnowledge) {
         return toAjax(sysKnowledgeService.insertSysKnowledge(sysKnowledge));
@@ -77,7 +76,7 @@ public class SysKnowledgeController extends BaseController {
      */
     @ApiOperation(value = "修改SysKnowledge")
     @RequiresPermissions("system:knowledge:edit")
-    @Log(title = "知识库标签" , businessType = BusinessType.UPDATE)
+    @Log(title = "知识库标签", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody SysKnowledge sysKnowledge) {
         return toAjax(sysKnowledgeService.updateSysKnowledge(sysKnowledge));
@@ -88,9 +87,18 @@ public class SysKnowledgeController extends BaseController {
      */
     @ApiOperation(value = "删除SysKnowledge")
     @RequiresPermissions("system:knowledge:remove")
-    @Log(title = "知识库标签" , businessType = BusinessType.DELETE)
+    @Log(title = "知识库标签", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(sysKnowledgeService.deleteSysKnowledgeByIds(ids));
     }
+
+    /**
+     * 查询知识库标签列表
+     */
+    @ApiOperation(value = "查询SysKnowledge列表")
+    @GetMapping("/dataList")
+    public List<IdName<String,String>> dataList() {
+        return sysKnowledgeService.dataList();
+    }
 }

+ 24 - 13
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysLearningMaterialsController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
 
+import com.xunmei.system.dto.SysLearningMaterialsPageDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -31,25 +32,24 @@ import com.xunmei.common.core.web.page.TableDataInfo;
  * @author xunmei
  * @date 2023-08-21
  */
-@Api(tags = {"SysLearningMaterials" })
+@Api(tags = {"SysLearningMaterials"})
 @RestController
 @RequestMapping("/materials")
 public class SysLearningMaterialsController extends BaseController {
     @Autowired
     private ISysLearningMaterialsService sysLearningMaterialsService;
 
-/**
- * 查询学习资料列表
- */
-@ApiOperation(value = "查询SysLearningMaterials列表")
-@RequiresPermissions("system:materials:list")
-@GetMapping("/list")
-    public TableDataInfo list(SysLearningMaterials sysLearningMaterials) {
-        return sysLearningMaterialsService.selectPage( sysLearningMaterials);
+    /**
+     * 查询学习资料列表
+     */
+    @ApiOperation(value = "查询SysLearningMaterials列表")
+    @RequiresPermissions("system:materials:list")
+    @GetMapping("/list")
+    public TableDataInfo list(SysLearningMaterialsPageDto sysLearningMaterials) {
+        return sysLearningMaterialsService.selectPage(sysLearningMaterials);
     }
 
 
-
     /**
      * 获取学习资料详细信息
      */
@@ -65,7 +65,7 @@ public class SysLearningMaterialsController extends BaseController {
      */
     @ApiOperation(value = "新增SysLearningMaterials")
     @RequiresPermissions("system:materials:add")
-    @Log(title = "学习资料" , businessType = BusinessType.INSERT)
+    @Log(title = "学习资料", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@RequestBody SysLearningMaterials sysLearningMaterials) {
         return toAjax(sysLearningMaterialsService.insertSysLearningMaterials(sysLearningMaterials));
@@ -76,7 +76,7 @@ public class SysLearningMaterialsController extends BaseController {
      */
     @ApiOperation(value = "修改SysLearningMaterials")
     @RequiresPermissions("system:materials:edit")
-    @Log(title = "学习资料" , businessType = BusinessType.UPDATE)
+    @Log(title = "学习资料", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody SysLearningMaterials sysLearningMaterials) {
         return toAjax(sysLearningMaterialsService.updateSysLearningMaterials(sysLearningMaterials));
@@ -87,9 +87,20 @@ public class SysLearningMaterialsController extends BaseController {
      */
     @ApiOperation(value = "删除SysLearningMaterials")
     @RequiresPermissions("system:materials:remove")
-    @Log(title = "学习资料" , businessType = BusinessType.DELETE)
+    @Log(title = "学习资料", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(sysLearningMaterialsService.deleteSysLearningMaterialsByIds(ids));
     }
+
+    /**
+     * 修改学习资料,设置未公开/公开
+     */
+    @ApiOperation(value = "修改SysLearningMaterials")
+    @RequiresPermissions("system:materials:edit")
+    @Log(title = "学习资料", businessType = BusinessType.UPDATE)
+    @GetMapping("/{id}/{isOpen}")
+    public AjaxResult editOpen(@PathVariable Long id, @PathVariable Integer isOpen) {
+        return toAjax(sysLearningMaterialsService.editOpen(id, isOpen));
+    }
 }

+ 25 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysOrgController.java

@@ -1,18 +1,23 @@
 package com.xunmei.system.controller;
 
+import com.xunmei.common.core.domain.R;
 import com.xunmei.common.core.web.controller.BaseController;
 import com.xunmei.common.core.web.domain.AjaxResult;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.log.annotation.Log;
 import com.xunmei.common.log.enums.BusinessType;
+import com.xunmei.common.security.annotation.InnerAuth;
 import com.xunmei.common.security.annotation.RequiresPermissions;
 import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.api.model.LoginUser;
 import com.xunmei.system.service.ISysOrgService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * 【请填写功能名称】Controller
  *
@@ -80,4 +85,24 @@ public class SysOrgController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(sysOrgService.deleteSysOrgByIds(ids));
     }
+
+    /**
+     * 查询机构列表
+     */
+    @ApiOperation(value = "查询SysOrg列表")
+    @InnerAuth
+    @GetMapping("/list/nopage")
+    public R<List<SysOrg>> listNotPage(SysOrg sysOrg) {
+        return R.ok(sysOrgService.selectSysOrgList(sysOrg));
+    }
+
+    /**
+     * 查询机构列表
+     */
+    @ApiOperation(value = "批量保存同步机构数据")
+    @InnerAuth
+    @PostMapping("/sync/batch")
+    public R<Boolean> batchSaveSyncSysOrgs(@RequestBody List<SysOrg> sysOrgList) {
+        return R.ok(sysOrgService.saveOrUpdateBatch(sysOrgList));
+    }
 }

+ 3 - 26
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/SysLearningMaterials.java

@@ -55,6 +55,9 @@ public class SysLearningMaterials extends BaseEntity {
     @ApiModelProperty(value = "附件")
     private String file;
 
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
     @TableLogic(value = "0", delval = "1")
     @ApiModelProperty(value = "是否删除,0:未删除,1:已删除")
     private Integer deleted;
@@ -63,44 +66,18 @@ public class SysLearningMaterials extends BaseEntity {
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-
-
                 .append("id", getId())
-
-
                 .append("title", getTitle())
-
-
                 .append("knowledgeId", getKnowledgeId())
-
-
                 .append("orgId", getOrgId())
-
-
                 .append("orgName", getOrgName())
-
-
                 .append("orgPath", getOrgPath())
-
-
                 .append("isOpen", getIsOpen())
-
-
                 .append("file", getFile())
-
-
                 .append("deleted", getDeleted())
-
-
                 .append("createBy", getCreateBy())
-
-
                 .append("createTime", getCreateTime())
-
-
                 .append("updateBy", getUpdateBy())
-
-
                 .append("updateTime", getUpdateTime())
                 .toString();
     }

+ 58 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/domain/vo/SysLearningMaterialsPageVo.java

@@ -0,0 +1,58 @@
+package com.xunmei.system.domain.vo;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.xunmei.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/22 10:26
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "SysLearningMaterials分页Vo", description = "学习资料分页Vo")
+public class SysLearningMaterialsPageVo {
+
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
+    private Long id;
+
+    @ApiModelProperty(value = "资料标题")
+    private String title;
+
+    @JsonSerialize(using = com.fasterxml.jackson.databind.ser.std.ToStringSerializer.class)
+    @ApiModelProperty(value = "资料类型名称(知识库标签名称)")
+    private String knowledgeName;
+
+    @ApiModelProperty(value = "所属机构")
+    private Long orgId;
+
+    @ApiModelProperty(value = "机构名称")
+    private String orgName;
+
+    @ApiModelProperty(value = "是否公开,0:未公开,1:已公开")
+    private Integer isOpen;
+
+    @ApiModelProperty(value = "上传人")
+    private String createBy;
+
+    @ApiModelProperty(value = "上传时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    @ApiModelProperty(value = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "附件")
+    private String file;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+}

+ 30 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/dto/SysLearningMaterialsPageDto.java

@@ -0,0 +1,30 @@
+package com.xunmei.system.dto;
+
+import com.xunmei.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * @author jingyuanchao
+ * @date 2023/8/22 11:09
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SysLearningMaterialsPageDto extends BaseEntity {
+    @ApiModelProperty(value = "资料类型(知识库标签)")
+    private Long knowledgeId;
+    @ApiModelProperty(value = "公开状态,0:未公开,1:已公开")
+    private Integer isOpen;
+    @ApiModelProperty(value = "资料标题")
+    private String title;
+    @ApiModelProperty(value = "资料标题")
+    private Long orgId;
+
+    @ApiModelProperty(value = "上级机构id集合",notes = "学习资料分页列表默认查询上级机构且公开的数据")
+    private List<Long> orgIdList;
+}

+ 3 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysKnowledgeMapper.java

@@ -59,4 +59,7 @@ public interface SysKnowledgeMapper extends BaseMapper<SysKnowledge> {
      * @return 结果
      */
     public int deleteSysKnowledgeByIds(Long[] ids);
+
+    List<SysKnowledge> dataList();
+
 }

+ 6 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysLearningMaterialsMapper.java

@@ -2,8 +2,12 @@ package com.xunmei.system.mapper;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.system.domain.SysLearningMaterials;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xunmei.system.domain.vo.SysLearningMaterialsPageVo;
+import com.xunmei.system.dto.SysLearningMaterialsPageDto;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 学习资料Mapper接口
@@ -59,4 +63,6 @@ public interface SysLearningMaterialsMapper extends BaseMapper<SysLearningMateri
      * @return 结果
      */
     public int deleteSysLearningMaterialsByIds(Long[] ids);
+
+    Page<SysLearningMaterialsPageVo> selectPageData(@Param("page") Page<SysLearningMaterialsPageVo> page, @Param("request") SysLearningMaterialsPageDto sysLearningMaterials);
 }

+ 10 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysKnowledgeService.java

@@ -2,6 +2,7 @@ package com.xunmei.system.service;
 
 import java.util.List;
 
+import com.xunmei.common.core.domain.IdName;
 import com.xunmei.system.domain.SysKnowledge;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -69,4 +70,13 @@ public interface ISysKnowledgeService extends IService<SysKnowledge> {
      * @return Page
      */
     public TableDataInfo selectPage(SysKnowledge sysKnowledge);
+
+    /**
+     * 查询知识库标签列表数据
+     *
+     * @param
+     * @return List
+     */
+    List<IdName<String, String>> dataList();
+
 }

+ 4 - 1
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysLearningMaterialsService.java

@@ -6,6 +6,7 @@ import com.xunmei.system.domain.SysLearningMaterials;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.system.dto.SysLearningMaterialsPageDto;
 
 /**
  * 学习资料Service接口
@@ -68,5 +69,7 @@ public interface ISysLearningMaterialsService extends IService<SysLearningMateri
      * @param sysLearningMaterials 查询条件对象
      * @return Page
      */
-    public TableDataInfo selectPage(SysLearningMaterials sysLearningMaterials);
+    public TableDataInfo selectPage(SysLearningMaterialsPageDto sysLearningMaterials);
+
+    int editOpen(Long id, Integer isOpen);
 }

+ 13 - 3
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeptServiceImpl.java

@@ -1,5 +1,7 @@
 package com.xunmei.system.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -47,7 +49,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     private SysOrgMapper orgMapper;
 
 
-
     /**
      * 查询部门管理数据
      *
@@ -59,6 +60,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     public List<SysDept> selectDeptList(SysDept dept) {
         return deptMapper.selectDeptList(dept);
     }
+
     /**
      * 查询部门树结构信息
      *
@@ -67,14 +69,20 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
      */
     @Override
     public List<SysOrg> selectDeptTreeList(SysOrg dept) {
-        List<SysOrg> depts = orgMapper.selectList(new QueryWrapper<>(dept));
+        final LambdaQueryWrapper<SysOrg> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SysOrg::getDeleted, 0L);
+        wrapper.isNotNull(SysOrg::getParentId);
+        List<SysOrg> depts = orgMapper.selectList(new QueryWrapper<>());
         return recursionMethod(depts);
     }
 
     @Override
     public List<SysDept> selectDeptTreeList(SysDept dept) {
+        final LambdaQueryWrapper<SysDept> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SysDept::getDelFlag, 0L);
+        wrapper.isNotNull(SysDept::getParentId);
         List<SysDept> sysDepts = deptMapper.selectList(new QueryWrapper<>(dept));
-        return  recursionDept(sysDepts);
+        return recursionDept(sysDepts);
     }
 
 
@@ -113,6 +121,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         }
         return trees;
     }
+
     /**
      * dept递归方法
      *
@@ -132,6 +141,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         }
         return tree;
     }
+
     /**
      * 递归方法
      *

+ 19 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysKnowledgeServiceImpl.java

@@ -1,9 +1,11 @@
 package com.xunmei.system.service.impl;
 
+import java.util.Collections;
 import java.util.List;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.xunmei.common.core.domain.IdName;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +13,7 @@ import org.springframework.stereotype.Service;
 import com.xunmei.system.service.ISysOrgService;
 
 import java.util.Arrays;
+import java.util.stream.Collectors;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -133,4 +136,20 @@ public class SysKnowledgeServiceImpl extends ServiceImpl<SysKnowledgeMapper, Sys
     public int deleteSysKnowledgeById(Long id) {
         return sysKnowledgeMapper.deleteById(id);
     }
+
+    /**
+     * 查询知识库标签列表数据
+     *
+     * @param
+     * @return List
+     */
+    @Override
+    public List<IdName<String, String>> dataList() {
+        final List<SysKnowledge> sysKnowledge = sysKnowledgeMapper.dataList();
+        if (sysKnowledge == null || sysKnowledge.isEmpty()) {
+            return Collections.emptyList();
+        }
+        return sysKnowledge.stream().map(e -> new IdName<>(e.getId().toString(), e.getName())).collect(Collectors.toList());
+
+    }
 }

+ 45 - 18
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysLearningMaterialsServiceImpl.java

@@ -1,14 +1,21 @@
 package com.xunmei.system.service.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.xunmei.common.core.utils.DateUtils;
+import com.xunmei.common.security.utils.SecurityUtils;
+import com.xunmei.system.api.domain.SysOrg;
+import com.xunmei.system.domain.vo.SysLearningMaterialsPageVo;
+import com.xunmei.system.dto.SysLearningMaterialsPageDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.xunmei.system.service.ISysOrgService;
 
 import java.util.Arrays;
+import java.util.stream.Stream;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -32,30 +39,17 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
     private ISysOrgService orgService;
 
     @Override
-    public TableDataInfo selectPage(SysLearningMaterials sysLearningMaterials) {
-        //未删除
-        sysLearningMaterials.setDeleted(0);
-        Page<SysLearningMaterials> page;
+    public TableDataInfo selectPage(SysLearningMaterialsPageDto sysLearningMaterials) {
+        Page<SysLearningMaterialsPageVo> page;
         //分页
-        if (sysLearningMaterials.getPageNum() != null && sysLearningMaterials.getPageSize() != null) {
+        if (ObjectUtil.isAllNotEmpty(sysLearningMaterials.getPageNum(), sysLearningMaterials.getPageSize())) {
             page = new Page<>(sysLearningMaterials.getPageNum(), sysLearningMaterials.getPageSize());
         } else {
             page = new Page<>();
         }
-        //查询条件
-        LambdaQueryWrapper<SysLearningMaterials> query = new LambdaQueryWrapper<SysLearningMaterials>(sysLearningMaterials);
-        //下穿
-        if (sysLearningMaterials.getCheckSub()) {
-            String orgPath = orgService.selectPathById(sysLearningMaterials.getOrgId());
-            sysLearningMaterials.setOrgId(null);
-            query.likeRight(SysLearningMaterials::getOrgPath, orgPath);
-        }
-        //时间范围查询
-        if (sysLearningMaterials.getParams().get("beginTime") != null && sysLearningMaterials.getParams().get("endTime") != null) {
-            query.between(SysLearningMaterials::getCreateTime, sysLearningMaterials.getParams().get("beginTime"), sysLearningMaterials.getParams().get("endTime"));
-        }
+        dealParentOrgId(sysLearningMaterials);
         //获取数据
-        page = sysLearningMaterialsMapper.selectPage(page, query);
+        page = sysLearningMaterialsMapper.selectPageData(page, sysLearningMaterials);
         //抓换为TableDataInfo适配前端
         TableDataInfo tableDataInfo = new TableDataInfo();
         tableDataInfo.setMsg("操作成功");
@@ -65,6 +59,17 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
         return tableDataInfo;
     }
 
+    private void dealParentOrgId(SysLearningMaterialsPageDto sysLearningMaterials) {
+        SysOrg sysOrg = orgService.selectSysOrgById(sysLearningMaterials.getOrgId());
+        if (sysOrg == null || ObjectUtil.isEmpty(sysOrg.getPath())) {
+            return;
+        }
+        String[] split = sysOrg.getPath().split("-");
+        List<Long> list = new ArrayList<>();
+        Stream.of(split).forEach(s -> list.add(Long.valueOf(s)));
+        sysLearningMaterials.setOrgIdList(list);
+    }
+
 
     /**
      * 查询学习资料
@@ -96,7 +101,16 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
      */
     @Override
     public int insertSysLearningMaterials(SysLearningMaterials sysLearningMaterials) {
+        sysLearningMaterials.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
         sysLearningMaterials.setCreateTime(DateUtils.getNowDate());
+        sysLearningMaterials.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
+        sysLearningMaterials.setUpdateTime(DateUtils.getNowDate());
+        sysLearningMaterials.setIsOpen(0);
+        final SysOrg sysOrg = orgService.selectSysOrgById(sysLearningMaterials.getOrgId());
+        if (sysOrg != null) {
+            sysLearningMaterials.setOrgName(sysOrg.getName());
+            sysLearningMaterials.setOrgPath(sysOrg.getPath());
+        }
         return sysLearningMaterialsMapper.insert(sysLearningMaterials);
     }
 
@@ -108,6 +122,7 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
      */
     @Override
     public int updateSysLearningMaterials(SysLearningMaterials sysLearningMaterials) {
+        sysLearningMaterials.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
         sysLearningMaterials.setUpdateTime(DateUtils.getNowDate());
         return sysLearningMaterialsMapper.updateById(sysLearningMaterials);
     }
@@ -133,4 +148,16 @@ public class SysLearningMaterialsServiceImpl extends ServiceImpl<SysLearningMate
     public int deleteSysLearningMaterialsById(Long id) {
         return sysLearningMaterialsMapper.deleteById(id);
     }
+
+    @Override
+    public int editOpen(Long id, Integer isOpen) {
+        SysLearningMaterials sysLearningMaterials = sysLearningMaterialsMapper.selectById(id);
+        if (sysLearningMaterials != null) {
+            sysLearningMaterials.setIsOpen(isOpen);
+            sysLearningMaterials.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
+            sysLearningMaterials.setUpdateTime(DateUtils.getNowDate());
+            return sysLearningMaterialsMapper.updateById(sysLearningMaterials);
+        }
+        return 0;
+    }
 }

+ 2 - 2
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

@@ -31,7 +31,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     @Override
     public TableDataInfo selectPage(SysOrg org) {
         //未删除
-        org.setDeleted(0L);
+        org.setDeleted(0);
         Page<SysOrg> page;
         //分页
         if (org.getPageNum() != null && org.getPageSize() != null) {
@@ -81,7 +81,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
      */
     @Override
     public SysOrg selectSysOrgById(Long id) {
-        return sysOrgMapper.selectSysOrgById(id);
+        return sysOrgMapper.selectById(id);
     }
     @Override
     public List<Long> findListByOrgType(Integer execOrgType){

+ 2 - 2
soc-modules/soc-modules-system/src/main/resources/bootstrap.yml

@@ -13,11 +13,11 @@ spring:
   cloud:
     nacos:
       discovery:
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
         # 服务注册地址
         server-addr: 10.87.10.54:8848
       config:
-        namespace: 34306a91-1bb7-45ce-b80d-4092dd08ea64
+        namespace: 083dc0cf-7829-4914-9d5c-d48f1a31015d
         # 配置中心地址
         server-addr: 10.87.10.54:8848
         # 配置文件格式

+ 66 - 59
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysKnowledgeMapper.xml

@@ -5,13 +5,13 @@
 <mapper namespace="com.xunmei.system.mapper.SysKnowledgeMapper">
 
     <resultMap type="com.xunmei.system.domain.SysKnowledge" id="SysKnowledgeResult">
-                <result property="id" column="id"/>
-                <result property="name" column="name"/>
-                <result property="createBy" column="create_by"/>
-                <result property="createTime" column="create_time"/>
-                <result property="updateBy" column="update_by"/>
-                <result property="updateTime" column="update_time"/>
-                <result property="deleted" column="deleted"/>
+        <result property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="deleted" column="deleted"/>
     </resultMap>
 
     <sql id="selectSysKnowledgeVo">
@@ -23,81 +23,88 @@
             resultMap="SysKnowledgeResult">
         <include refid="selectSysKnowledgeVo"/>
         <where>
-                        <if test="name != null  and name != ''">
-                            and name like concat('%', #{name}, '%')
-                        </if>
-                        <if test="deleted != null ">
-                            and deleted = #{deleted}
-                        </if>
+            <if test="name != null  and name != ''">
+                and name like concat('%', #{name}, '%')
+            </if>
+            <if test="deleted != null ">
+                and deleted = #{deleted}
+            </if>
         </where>
     </select>
 
     <select id="selectSysKnowledgeById" parameterType="Long"
             resultMap="SysKnowledgeResult">
-            <include refid="selectSysKnowledgeVo"/>
-            where id = #{id}
+        <include refid="selectSysKnowledgeVo"/>
+        where id = #{id}
+    </select>
+    <select id="dataList" resultType="com.xunmei.system.domain.SysKnowledge">
+        select id as id, `name` as name
+        from sys_knowledge
+        where deleted = 0
     </select>
 
-    <insert id="insertSysKnowledge" parameterType="com.xunmei.system.domain.SysKnowledge"            useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertSysKnowledge" parameterType="com.xunmei.system.domain.SysKnowledge" useGeneratedKeys="true"
+            keyProperty="id">
         insert into sys_knowledge
         <trim prefix="(" suffix=")" suffixOverrides=",">
-                    <if test="name != null and name != ''">name,
-                    </if>
-                    <if test="createBy != null">create_by,
-                    </if>
-                    <if test="createTime != null">create_time,
-                    </if>
-                    <if test="updateBy != null">update_by,
-                    </if>
-                    <if test="updateTime != null">update_time,
-                    </if>
-                    <if test="deleted != null">deleted,
-                    </if>
+            <if test="name != null and name != ''">name,
+            </if>
+            <if test="createBy != null">create_by,
+            </if>
+            <if test="createTime != null">create_time,
+            </if>
+            <if test="updateBy != null">update_by,
+            </if>
+            <if test="updateTime != null">update_time,
+            </if>
+            <if test="deleted != null">deleted,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-                    <if test="name != null and name != ''">#{name},
-                    </if>
-                    <if test="createBy != null">#{createBy},
-                    </if>
-                    <if test="createTime != null">#{createTime},
-                    </if>
-                    <if test="updateBy != null">#{updateBy},
-                    </if>
-                    <if test="updateTime != null">#{updateTime},
-                    </if>
-                    <if test="deleted != null">#{deleted},
-                    </if>
+            <if test="name != null and name != ''">#{name},
+            </if>
+            <if test="createBy != null">#{createBy},
+            </if>
+            <if test="createTime != null">#{createTime},
+            </if>
+            <if test="updateBy != null">#{updateBy},
+            </if>
+            <if test="updateTime != null">#{updateTime},
+            </if>
+            <if test="deleted != null">#{deleted},
+            </if>
         </trim>
     </insert>
 
     <update id="updateSysKnowledge" parameterType="com.xunmei.system.domain.SysKnowledge">
         update sys_knowledge
         <trim prefix="SET" suffixOverrides=",">
-                    <if test="name != null and name != ''">name =
-                        #{name},
-                    </if>
-                    <if test="createBy != null">create_by =
-                        #{createBy},
-                    </if>
-                    <if test="createTime != null">create_time =
-                        #{createTime},
-                    </if>
-                    <if test="updateBy != null">update_by =
-                        #{updateBy},
-                    </if>
-                    <if test="updateTime != null">update_time =
-                        #{updateTime},
-                    </if>
-                    <if test="deleted != null">deleted =
-                        #{deleted},
-                    </if>
+            <if test="name != null and name != ''">name =
+                #{name},
+            </if>
+            <if test="createBy != null">create_by =
+                #{createBy},
+            </if>
+            <if test="createTime != null">create_time =
+                #{createTime},
+            </if>
+            <if test="updateBy != null">update_by =
+                #{updateBy},
+            </if>
+            <if test="updateTime != null">update_time =
+                #{updateTime},
+            </if>
+            <if test="deleted != null">deleted =
+                #{deleted},
+            </if>
         </trim>
         where id = #{id}
     </update>
 
     <delete id="deleteSysKnowledgeById" parameterType="Long">
         delete
-        from sys_knowledge where id = #{id}
+        from sys_knowledge
+        where id = #{id}
     </delete>
 
     <delete id="deleteSysKnowledgeByIds" parameterType="String">

+ 50 - 1
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysLearningMaterialsMapper.xml

@@ -36,10 +36,19 @@
                create_by,
                create_time,
                update_by,
-               updateTime
+               update_time
         from sys_learning_materials
     </sql>
 
+    <sql id="pageRequest">
+        <if test="request.knowledgeId != null">
+            and m.knowledge_id = #{request.knowledgeId}
+        </if>
+        <if test="request.title != null ">
+            and m.title = #{request.title}
+        </if>
+    </sql>
+
     <select id="selectSysLearningMaterialsList" parameterType="com.xunmei.system.domain.SysLearningMaterials"
             resultMap="SysLearningMaterialsResult">
         <include refid="selectSysLearningMaterialsVo"/>
@@ -82,6 +91,46 @@
         <include refid="selectSysLearningMaterialsVo"/>
         where id = #{id}
     </select>
+    <select id="selectPageData" resultType="com.xunmei.system.domain.vo.SysLearningMaterialsPageVo">
+        select m.id,
+        title,
+        k.name as knowledgeName,
+        org_id,
+        org_name,
+        is_open,
+        file,
+        remark as remark,
+        m.create_by,
+        m.create_time,
+        m.update_time as updateTime
+        from sys_learning_materials m
+        inner join sys_knowledge k on m.knowledge_id = k.id
+        where m.deleted = 0
+        and k.deleted = 0
+        <choose>
+            <when test="request.checkSub==false">
+                and m.org_id = #{request.orgId}
+            </when>
+            <otherwise>
+                and m.org_path like concat((select path from sys_org where id=#{request.orgId}), '%')
+            </otherwise>
+        </choose>
+        <include refid="pageRequest"/>
+        <if test="request.isOpen != null ">
+            and m.is_open = #{request.isOpen}
+        </if>
+        <if test="request.orgIdList != null and  request.orgIdList.size()>0">
+            or (
+            m.org_id in
+            <foreach collection="request.orgIdList" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            and m.is_open = 1
+            <include refid="pageRequest"/>
+            )
+        </if>
+        order by m.org_id, m.create_time desc
+    </select>
 
     <insert id="insertSysLearningMaterials" parameterType="com.xunmei.system.domain.SysLearningMaterials">
         insert into sys_learning_materials

+ 207 - 201
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysOrgMapper.xml

@@ -8,7 +8,6 @@
                 <result property="id" column="id"/>
                 <result property="address" column="address"/>
                 <result property="code" column="code"/>
-                <result property="deviceCount" column="device_count"/>
                 <result property="guid" column="guid"/>
                 <result property="isLock" column="is_lock"/>
                 <result property="manager" column="manager"/>
@@ -17,37 +16,23 @@
                 <result property="parentId" column="parent_id"/>
                 <result property="phone" column="phone"/>
                 <result property="cityCode" column="city_code"/>
-                <result property="openYear" column="open_year"/>
-                <result property="fitYear" column="fit_year"/>
-                <result property="floorage" column="floorage"/>
-                <result property="employee" column="employee"/>
-                <result property="isOwnRight" column="is_own_right"/>
-                <result property="isRent" column="is_rent"/>
-                <result property="isOnly" column="is_only"/>
-                <result property="buildYear" column="build_year"/>
-                <result property="placeType" column="place_type"/>
-                <result property="buildHeight" column="build_height"/>
-                <result property="social" column="social"/>
-                <result property="naturalEnvir" column="natural_envir"/>
                 <result property="type" column="type"/>
                 <result property="createTime" column="create_time"/>
-                <result property="modifiedName" column="modified_name"/>
                 <result property="updateTime" column="update_time"/>
-                <result property="modifiedId" column="modified_id"/>
                 <result property="path" column="path"/>
-                <result property="vid" column="vid"/>
-                <result property="level" column="level"/>
-                <result property="oid" column="oid"/>
                 <result property="parentGuid" column="parent_guid"/>
                 <result property="deleted" column="deleted"/>
                 <result property="sort" column="sort"/>
-                <result property="location" column="location"/>
+                <result property="source" column="source"/>
+                <result property="shortName" column="short_name"/>
+                <result property="remark" column="remark"/>
+                <result property="source" column="source"/>
                 <result property="createBy" column="create_by"/>
                 <result property="updateBy" column="update_by"/>
     </resultMap>
 
     <sql id="selectSysOrgVo">
-        select id, address, code, device_count, guid, is_lock, manager, manager_phone, name, parent_id, phone, city_code, open_year, fit_year, floorage, employee, is_own_right, is_rent, is_only, build_year, place_type, build_height, social, natural_envir, type, create_time, modified_name, update_time, modified_id, path, vid, level, oid, parent_guid, deleted, sort, location, create_by, update_by
+        select id, address, code, guid, is_lock, manager, manager_phone, name, parent_id, phone, city_code , type, create_time, update_time, parent_guid, deleted, sort,  create_by, update_by,weather_city_code,org_extend_id,source,short_name,remark
         from sys_org
     </sql>
 
@@ -61,9 +46,9 @@
                         <if test="code != null  and code != ''">
                             and code = #{code}
                         </if>
-                        <if test="deviceCount != null ">
-                            and device_count = #{deviceCount}
-                        </if>
+<!--                        <if test="deviceCount != null ">-->
+<!--                            and device_count = #{deviceCount}-->
+<!--                        </if>-->
                         <if test="guid != null  and guid != ''">
                             and guid = #{guid}
                         </if>
@@ -88,63 +73,63 @@
                         <if test="cityCode != null  and cityCode != ''">
                             and city_code = #{cityCode}
                         </if>
-                        <if test="openYear != null ">
-                            and open_year = #{openYear}
-                        </if>
-                        <if test="fitYear != null ">
-                            and fit_year = #{fitYear}
-                        </if>
-                        <if test="floorage != null  and floorage != ''">
-                            and floorage = #{floorage}
-                        </if>
-                        <if test="employee != null ">
-                            and employee = #{employee}
-                        </if>
-                        <if test="isOwnRight != null ">
-                            and is_own_right = #{isOwnRight}
-                        </if>
-                        <if test="isRent != null ">
-                            and is_rent = #{isRent}
-                        </if>
-                        <if test="isOnly != null ">
-                            and is_only = #{isOnly}
-                        </if>
-                        <if test="buildYear != null ">
-                            and build_year = #{buildYear}
-                        </if>
-                        <if test="placeType != null ">
-                            and place_type = #{placeType}
-                        </if>
-                        <if test="buildHeight != null ">
-                            and build_height = #{buildHeight}
-                        </if>
-                        <if test="social != null ">
-                            and social = #{social}
-                        </if>
-                        <if test="naturalEnvir != null ">
-                            and natural_envir = #{naturalEnvir}
-                        </if>
+<!--                        <if test="openYear != null ">-->
+<!--                            and open_year = #{openYear}-->
+<!--                        </if>-->
+<!--                        <if test="fitYear != null ">-->
+<!--                            and fit_year = #{fitYear}-->
+<!--                        </if>-->
+<!--                        <if test="floorage != null  and floorage != ''">-->
+<!--                            and floorage = #{floorage}-->
+<!--                        </if>-->
+<!--                        <if test="employee != null ">-->
+<!--                            and employee = #{employee}-->
+<!--                        </if>-->
+<!--                        <if test="isOwnRight != null ">-->
+<!--                            and is_own_right = #{isOwnRight}-->
+<!--                        </if>-->
+<!--                        <if test="isRent != null ">-->
+<!--                            and is_rent = #{isRent}-->
+<!--                        </if>-->
+<!--                        <if test="isOnly != null ">-->
+<!--                            and is_only = #{isOnly}-->
+<!--                        </if>-->
+<!--                        <if test="buildYear != null ">-->
+<!--                            and build_year = #{buildYear}-->
+<!--                        </if>-->
+<!--                        <if test="placeType != null ">-->
+<!--                            and place_type = #{placeType}-->
+<!--                        </if>-->
+<!--                        <if test="buildHeight != null ">-->
+<!--                            and build_height = #{buildHeight}-->
+<!--                        </if>-->
+<!--                        <if test="social != null ">-->
+<!--                            and social = #{social}-->
+<!--                        </if>-->
+<!--                        <if test="naturalEnvir != null ">-->
+<!--                            and natural_envir = #{naturalEnvir}-->
+<!--                        </if>-->
                         <if test="type != null ">
                             and type = #{type}
                         </if>
-                        <if test="modifiedName != null  and modifiedName != ''">
-                            and modified_name like concat('%', #{modifiedName}, '%')
-                        </if>
-                        <if test="modifiedId != null ">
-                            and modified_id = #{modifiedId}
+                        <if test="updateBy != null  and updateBy != ''">
+                            and update_by like concat('%', #{updateBy}, '%')
                         </if>
+<!--                        <if test="modifiedId != null ">-->
+<!--                            and modified_id = #{modifiedId}-->
+<!--                        </if>-->
                         <if test="path != null  and path != ''">
                             and path = #{path}
                         </if>
-                        <if test="vid != null ">
-                            and vid = #{vid}
-                        </if>
-                        <if test="level != null ">
-                            and level = #{level}
-                        </if>
-                        <if test="oid != null  and oid != ''">
-                            and oid = #{oid}
-                        </if>
+<!--                        <if test="vid != null ">-->
+<!--                            and vid = #{vid}-->
+<!--                        </if>-->
+<!--                        <if test="level != null ">-->
+<!--                            and level = #{level}-->
+<!--                        </if>-->
+<!--                        <if test="oid != null  and oid != ''">-->
+<!--                            and oid = #{oid}-->
+<!--                        </if>-->
                         <if test="parentGuid != null  and parentGuid != ''">
                             and parent_guid = #{parentGuid}
                         </if>
@@ -154,9 +139,9 @@
                         <if test="sort != null ">
                             and sort = #{sort}
                         </if>
-                        <if test="location != null ">
-                            and location = #{location}
-                        </if>
+<!--                        <if test="location != null ">-->
+<!--                            and location = #{location}-->
+<!--                        </if>-->
         </where>
     </select>
 
@@ -182,8 +167,8 @@
                     </if>
                     <if test="code != null">code,
                     </if>
-                    <if test="deviceCount != null">device_count,
-                    </if>
+<!--                    <if test="deviceCount != null">device_count,-->
+<!--                    </if>-->
                     <if test="guid != null">guid,
                     </if>
                     <if test="isLock != null">is_lock,
@@ -194,52 +179,54 @@
                     </if>
                     <if test="name != null">name,
                     </if>
+                    <if test="shortName != null">short_name,
+                    </if>
                     <if test="parentId != null">parent_id,
                     </if>
                     <if test="phone != null">phone,
                     </if>
                     <if test="cityCode != null">city_code,
                     </if>
-                    <if test="openYear != null">open_year,
-                    </if>
-                    <if test="fitYear != null">fit_year,
-                    </if>
-                    <if test="floorage != null">floorage,
-                    </if>
-                    <if test="employee != null">employee,
-                    </if>
-                    <if test="isOwnRight != null">is_own_right,
-                    </if>
-                    <if test="isRent != null">is_rent,
-                    </if>
-                    <if test="isOnly != null">is_only,
-                    </if>
-                    <if test="buildYear != null">build_year,
-                    </if>
-                    <if test="placeType != null">place_type,
-                    </if>
-                    <if test="buildHeight != null">build_height,
-                    </if>
-                    <if test="social != null">social,
-                    </if>
-                    <if test="naturalEnvir != null">natural_envir,
-                    </if>
+<!--                    <if test="openYear != null">open_year,-->
+<!--                    </if>-->
+<!--                    <if test="fitYear != null">fit_year,-->
+<!--                    </if>-->
+<!--                    <if test="floorage != null">floorage,-->
+<!--                    </if>-->
+<!--                    <if test="employee != null">employee,-->
+<!--                    </if>-->
+<!--                    <if test="isOwnRight != null">is_own_right,-->
+<!--                    </if>-->
+<!--                    <if test="isRent != null">is_rent,-->
+<!--                    </if>-->
+<!--                    <if test="isOnly != null">is_only,-->
+<!--                    </if>-->
+<!--                    <if test="buildYear != null">build_year,-->
+<!--                    </if>-->
+<!--                    <if test="placeType != null">place_type,-->
+<!--                    </if>-->
+<!--                    <if test="buildHeight != null">build_height,-->
+<!--                    </if>-->
+<!--                    <if test="social != null">social,-->
+<!--                    </if>-->
+<!--                    <if test="naturalEnvir != null">natural_envir,-->
+<!--                    </if>-->
                     <if test="type != null">type,
                     </if>
                     <if test="createTime != null">create_time,
                     </if>
-                    <if test="modifiedName != null">modified_name,
+                    <if test="updateBy != null">update_by,
                     </if>
                     <if test="updateTime != null">update_time,
                     </if>
-                    <if test="modifiedId != null">modified_id,
-                    </if>
+<!--                    <if test="modifiedId != null">modified_id,-->
+<!--                    </if>-->
                     <if test="path != null">path,
                     </if>
-                    <if test="vid != null">vid,
-                    </if>
-                    <if test="level != null">level,
-                    </if>
+<!--                    <if test="vid != null">vid,-->
+<!--                    </if>-->
+<!--                    <if test="level != null">level,-->
+<!--                    </if>-->
                     <if test="oid != null">oid,
                     </if>
                     <if test="parentGuid != null">parent_guid,
@@ -248,8 +235,12 @@
                     </if>
                     <if test="sort != null">sort,
                     </if>
-                    <if test="location != null">location,
+                    <if test="source != null">source,
+                    </if>
+                    <if test="remark != null">remark,
                     </if>
+<!--                    <if test="location != null">location,-->
+<!--                    </if>-->
                     <if test="createBy != null">create_by,
                     </if>
                     <if test="updateBy != null">update_by,
@@ -260,8 +251,8 @@
                     </if>
                     <if test="code != null">#{code},
                     </if>
-                    <if test="deviceCount != null">#{deviceCount},
-                    </if>
+<!--                    <if test="deviceCount != null">#{deviceCount},-->
+<!--                    </if>-->
                     <if test="guid != null">#{guid},
                     </if>
                     <if test="isLock != null">#{isLock},
@@ -272,62 +263,68 @@
                     </if>
                     <if test="name != null">#{name},
                     </if>
+                    <if test="shortName != null">#{shortName},
+                    </if>
                     <if test="parentId != null">#{parentId},
                     </if>
                     <if test="phone != null">#{phone},
                     </if>
                     <if test="cityCode != null">#{cityCode},
                     </if>
-                    <if test="openYear != null">#{openYear},
-                    </if>
-                    <if test="fitYear != null">#{fitYear},
-                    </if>
-                    <if test="floorage != null">#{floorage},
-                    </if>
-                    <if test="employee != null">#{employee},
-                    </if>
-                    <if test="isOwnRight != null">#{isOwnRight},
-                    </if>
-                    <if test="isRent != null">#{isRent},
-                    </if>
-                    <if test="isOnly != null">#{isOnly},
-                    </if>
-                    <if test="buildYear != null">#{buildYear},
-                    </if>
-                    <if test="placeType != null">#{placeType},
-                    </if>
-                    <if test="buildHeight != null">#{buildHeight},
-                    </if>
-                    <if test="social != null">#{social},
-                    </if>
-                    <if test="naturalEnvir != null">#{naturalEnvir},
-                    </if>
+<!--                    <if test="openYear != null">#{openYear},-->
+<!--                    </if>-->
+<!--                    <if test="fitYear != null">#{fitYear},-->
+<!--                    </if>-->
+<!--                    <if test="floorage != null">#{floorage},-->
+<!--                    </if>-->
+<!--                    <if test="employee != null">#{employee},-->
+<!--                    </if>-->
+<!--                    <if test="isOwnRight != null">#{isOwnRight},-->
+<!--                    </if>-->
+<!--                    <if test="isRent != null">#{isRent},-->
+<!--                    </if>-->
+<!--                    <if test="isOnly != null">#{isOnly},-->
+<!--                    </if>-->
+<!--                    <if test="buildYear != null">#{buildYear},-->
+<!--                    </if>-->
+<!--                    <if test="placeType != null">#{placeType},-->
+<!--                    </if>-->
+<!--                    <if test="buildHeight != null">#{buildHeight},-->
+<!--                    </if>-->
+<!--                    <if test="social != null">#{social},-->
+<!--                    </if>-->
+<!--                    <if test="naturalEnvir != null">#{naturalEnvir},-->
+<!--                    </if>-->
                     <if test="type != null">#{type},
                     </if>
                     <if test="createTime != null">#{createTime},
                     </if>
-                    <if test="modifiedName != null">#{modifiedName},
+                    <if test="updateBy != null">#{updateBy},
                     </if>
                     <if test="updateTime != null">#{updateTime},
                     </if>
-                    <if test="modifiedId != null">#{modifiedId},
-                    </if>
+<!--                    <if test="modifiedId != null">#{modifiedId},-->
+<!--                    </if>-->
                     <if test="path != null">#{path},
                     </if>
-                    <if test="vid != null">#{vid},
-                    </if>
-                    <if test="level != null">#{level},
-                    </if>
-                    <if test="oid != null">#{oid},
-                    </if>
+<!--                    <if test="vid != null">#{vid},-->
+<!--                    </if>-->
+<!--                    <if test="level != null">#{level},-->
+<!--                    </if>-->
+<!--                    <if test="oid != null">#{oid},-->
+<!--                    </if>-->
                     <if test="parentGuid != null">#{parentGuid},
                     </if>
                     <if test="deleted != null">#{deleted},
                     </if>
                     <if test="sort != null">#{sort},
                     </if>
-                    <if test="location != null">#{location},
+                    <if test="source != null">#{source},
+                    </if>
+                    <if test="remark != null">#{remark},
                     </if>
+<!--                    <if test="location != null">#{location},-->
+<!--                    </if>-->
                     <if test="createBy != null">#{createBy},
                     </if>
                     <if test="updateBy != null">#{updateBy},
@@ -344,9 +341,9 @@
                     <if test="code != null">code =
                         #{code},
                     </if>
-                    <if test="deviceCount != null">device_count =
-                        #{deviceCount},
-                    </if>
+<!--                    <if test="deviceCount != null">device_count =-->
+<!--                        #{deviceCount},-->
+<!--                    </if>-->
                     <if test="guid != null">guid =
                         #{guid},
                     </if>
@@ -362,6 +359,9 @@
                     <if test="name != null">name =
                         #{name},
                     </if>
+                    <if test="shortName != null">short_name =
+                        #{shortName},
+                    </if>
                     <if test="parentId != null">parent_id =
                         #{parentId},
                     </if>
@@ -371,69 +371,69 @@
                     <if test="cityCode != null">city_code =
                         #{cityCode},
                     </if>
-                    <if test="openYear != null">open_year =
-                        #{openYear},
-                    </if>
-                    <if test="fitYear != null">fit_year =
-                        #{fitYear},
-                    </if>
-                    <if test="floorage != null">floorage =
-                        #{floorage},
-                    </if>
-                    <if test="employee != null">employee =
-                        #{employee},
-                    </if>
-                    <if test="isOwnRight != null">is_own_right =
-                        #{isOwnRight},
-                    </if>
-                    <if test="isRent != null">is_rent =
-                        #{isRent},
-                    </if>
-                    <if test="isOnly != null">is_only =
-                        #{isOnly},
-                    </if>
-                    <if test="buildYear != null">build_year =
-                        #{buildYear},
-                    </if>
-                    <if test="placeType != null">place_type =
-                        #{placeType},
-                    </if>
-                    <if test="buildHeight != null">build_height =
-                        #{buildHeight},
-                    </if>
-                    <if test="social != null">social =
-                        #{social},
-                    </if>
-                    <if test="naturalEnvir != null">natural_envir =
-                        #{naturalEnvir},
-                    </if>
+<!--                    <if test="openYear != null">open_year =-->
+<!--                        #{openYear},-->
+<!--                    </if>-->
+<!--                    <if test="fitYear != null">fit_year =-->
+<!--                        #{fitYear},-->
+<!--                    </if>-->
+<!--                    <if test="floorage != null">floorage =-->
+<!--                        #{floorage},-->
+<!--                    </if>-->
+<!--                    <if test="employee != null">employee =-->
+<!--                        #{employee},-->
+<!--                    </if>-->
+<!--                    <if test="isOwnRight != null">is_own_right =-->
+<!--                        #{isOwnRight},-->
+<!--                    </if>-->
+<!--                    <if test="isRent != null">is_rent =-->
+<!--                        #{isRent},-->
+<!--                    </if>-->
+<!--                    <if test="isOnly != null">is_only =-->
+<!--                        #{isOnly},-->
+<!--                    </if>-->
+<!--                    <if test="buildYear != null">build_year =-->
+<!--                        #{buildYear},-->
+<!--                    </if>-->
+<!--                    <if test="placeType != null">place_type =-->
+<!--                        #{placeType},-->
+<!--                    </if>-->
+<!--                    <if test="buildHeight != null">build_height =-->
+<!--                        #{buildHeight},-->
+<!--                    </if>-->
+<!--                    <if test="social != null">social =-->
+<!--                        #{social},-->
+<!--                    </if>-->
+<!--                    <if test="naturalEnvir != null">natural_envir =-->
+<!--                        #{naturalEnvir},-->
+<!--                    </if>-->
                     <if test="type != null">type =
                         #{type},
                     </if>
                     <if test="createTime != null">create_time =
                         #{createTime},
                     </if>
-                    <if test="modifiedName != null">modified_name =
-                        #{modifiedName},
+                    <if test="updateBy != null">update_by =
+                        #{updateBy},
                     </if>
                     <if test="updateTime != null">update_time =
                         #{updateTime},
                     </if>
-                    <if test="modifiedId != null">modified_id =
-                        #{modifiedId},
-                    </if>
+<!--                    <if test="modifiedId != null">modified_id =-->
+<!--                        #{modifiedId},-->
+<!--                    </if>-->
                     <if test="path != null">path =
                         #{path},
                     </if>
-                    <if test="vid != null">vid =
-                        #{vid},
-                    </if>
-                    <if test="level != null">level =
-                        #{level},
-                    </if>
-                    <if test="oid != null">oid =
-                        #{oid},
-                    </if>
+<!--                    <if test="vid != null">vid =-->
+<!--                        #{vid},-->
+<!--                    </if>-->
+<!--                    <if test="level != null">level =-->
+<!--                        #{level},-->
+<!--                    </if>-->
+<!--                    <if test="oid != null">oid =-->
+<!--                        #{oid},-->
+<!--                    </if>-->
                     <if test="parentGuid != null">parent_guid =
                         #{parentGuid},
                     </if>
@@ -443,9 +443,15 @@
                     <if test="sort != null">sort =
                         #{sort},
                     </if>
-                    <if test="location != null">location =
-                        #{location},
+                    <if test="source != null">source =
+                        #{source},
+                    </if>
+                    <if test="remark != null">remark =
+                        #{remark},
                     </if>
+<!--                    <if test="location != null">location =-->
+<!--                        #{location},-->
+<!--                    </if>-->
                     <if test="createBy != null">create_by =
                         #{createBy},
                     </if>