瀏覽代碼

增加重试

xiewenjie 3 年之前
父節點
當前提交
5dbe891a2f

+ 5 - 0
pom.xml

@@ -360,6 +360,11 @@
                 <artifactId>ehcache</artifactId>
                 <version>3.4.0</version>
             </dependency>
+            <dependency>
+                <groupId>com.github.houbb</groupId>
+                <artifactId>sisyphus-springboot-starter</artifactId>
+                <version>0.0.9</version>
+            </dependency>
             <!-- 钉钉告警 -->
             <!--		<dependency>-->
             <!--			<groupId>com.aliyun</groupId>-->

+ 5 - 0
sxz-base/pom.xml

@@ -258,6 +258,11 @@
             <groupId>net.oschina.j2cache</groupId>
             <artifactId>j2cache-core</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.github.houbb</groupId>
+            <artifactId>sisyphus-springboot-starter</artifactId>
+        </dependency>
     </dependencies>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

+ 15 - 8
sxz-base/src/main/java/com/fdkk/sxz/util/OkHttpUtils.java

@@ -155,20 +155,27 @@ public class OkHttpUtils {
      * @param url
      * @return
      */
-    public static String httpGet(String url) throws Exception {
+    public static String httpGet(String url) {
         if (url == null || "".equals(url)) {
             OkHttpUtils.log.error("url为null!");
             return "";
         }
-
         Request.Builder builder = new Request.Builder();
         Request request = builder.get().url(url).build();
-        Response response = OkHttpUtils.getInstance().newCall(request).execute();
-        if (response.code() == 200) {
-            OkHttpUtils.log.info("http GET 请求成功; [url={}]", url);
-            return response.body().string();
-        } else {
-            OkHttpUtils.log.warn("Http GET 请求失败; [errorCode = {} , url={}]", response.code(), url);
+        Response response = null;
+        try {
+            response = OkHttpUtils.getInstance().newCall(request).execute();
+
+            if (response.code() == 200) {
+                OkHttpUtils.log.info("http GET 请求成功; [url={}]", url);
+                return response.body().string();
+            } else {
+                OkHttpUtils.log.warn("Http GET 请求失败; [errorCode = {} , url={}]", response.code(), url);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw new RuntimeException("同步httpGet请求失败,url:" + url, e);
+
         }
         return null;
     }

+ 10 - 2
sxz-core/src/main/java/com/fdkk/sxz/other/listener/RunBuild.java

@@ -20,6 +20,7 @@ import com.fdkk.sxz.other.mq.TopicRabbitConfig;
 import com.fdkk.sxz.util.*;
 import com.fdkk.sxz.webApi.service.*;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
+import com.github.houbb.sisyphus.core.core.Retryer;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
 import org.springframework.amqp.rabbit.annotation.RabbitHandler;
@@ -32,6 +33,7 @@ import org.springframework.util.CollectionUtils;
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
+import java.util.concurrent.Callable;
 
 /**
  * Created by Hb_zzZ on 2020/7/3.
@@ -831,7 +833,7 @@ public class RunBuild {
                 RunBuild.log.info("开始运行maxToDatasmith");
                 ModelHandelStepEntity modelHandelStep = new ModelHandelStepEntity();
                 modelHandelStep.setStep(1);
-                modelHandelStep.setStepRemarks("开始运行maxToDataSmith");
+                modelHandelStep.setStepRemarks("开始运行maxToDataSmith" + fileId);
                 modelHandelStep.setType(Integer.valueOf(UploadType));
                 modelHandelStep.setParentId(Long.valueOf(modelUploadId));
                 modelHandelStepService.save(modelHandelStep);
@@ -840,7 +842,13 @@ public class RunBuild {
                 timer.start();
                 String maxUrl = maxObjUrl + "maxToDatasmith?uuid=" + fileId + "&max=" + maxName + "&flag=" + flag;
                 RunBuild.log.info("请求maxToDataSmith地址-{}", maxUrl);
-                OkHttpUtils.httpGet(maxUrl);
+                Retryer.<String>newInstance()
+                        .callable(new Callable<String>() {
+                            @Override
+                            public String call() throws Exception {
+                                return OkHttpUtils.httpGet(maxUrl);
+                            }
+                        }).retryCall();
                 RunBuild.log.info("运行maxToDataSmith结束-{}", fileId);
                 modelHandelStep.setUseTime(String.valueOf(timer.intervalMs()));
                 modelHandelStepService.updateById(modelHandelStep);

+ 4 - 1
sxz-core/src/main/java/com/fdkk/sxz/system/controller/SysLogController.java

@@ -20,7 +20,7 @@ import java.util.List;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author jeebase
@@ -35,6 +35,7 @@ public class SysLogController {
 
     @Autowired
     RedisUtil redisUtil;
+
     /**
      * 查询所有用户
      */
@@ -46,6 +47,7 @@ public class SysLogController {
         PageResult<LogInfo> pageResult = new PageResult<LogInfo>(pageLog.getTotal(), pageLog.getList());
         return pageResult;
     }
+
     /**
      * 查询所有用户
      */
@@ -59,4 +61,5 @@ public class SysLogController {
         PageResult<Object> pageResult = new PageResult<>(list.size(), JSON.parseArray(list.toString()));
         return pageResult;
     }
+
 }

+ 84 - 0
sxz-core/src/main/java/com/fdkk/sxz/system/controller/SysModelLogController.java

@@ -0,0 +1,84 @@
+package com.fdkk.sxz.system.controller;
+
+
+import com.alibaba.fastjson.JSON;
+import com.fdkk.sxz.annotation.auth.CurrentUser;
+import com.fdkk.sxz.base.PageResult;
+import com.fdkk.sxz.entity.ModelHandelStepEntity;
+import com.fdkk.sxz.entity.ModelUploadEntity;
+import com.fdkk.sxz.entity.system.User;
+import com.fdkk.sxz.system.dto.QueryModelLog;
+import com.fdkk.sxz.util.RedisUtil;
+import com.fdkk.sxz.vo.request.RequestModelUpload;
+import com.fdkk.sxz.vo.response.ResponseModelUploadEntity;
+import com.fdkk.sxz.webApi.service.IModelHandelStepService;
+import com.fdkk.sxz.webApi.service.IModelUploadService;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author jeebase
+ * @since 2018-10-24
+ */
+@RestController
+@RequestMapping("/common/modelLog")
+public class SysModelLogController {
+
+    @Autowired
+    IModelUploadService modelUploadService;
+
+    @Autowired
+    IModelHandelStepService stepService;
+
+    @Autowired
+    RedisUtil redisUtil;
+
+    /**
+     * 查询所有用户
+     */
+    @GetMapping("/list")
+    @RequiresRoles("SYSADMIN")
+    @ApiOperation(value = "查询操作日志列表")
+    public PageResult<ResponseModelUploadEntity> list(RequestModelUpload param, @CurrentUser User currentUser) {
+        param.setUserId(currentUser.getId());
+        PageInfo<ModelUploadEntity> pageLog = modelUploadService.listByPage(param);
+
+        List<ResponseModelUploadEntity> collect = pageLog.getList().stream().map(a -> {
+            ResponseModelUploadEntity responseModelUploadEntity = new ResponseModelUploadEntity();
+            BeanUtils.copyProperties(a, responseModelUploadEntity);
+            List<ModelHandelStepEntity> modelHandelStepEntityList = stepService.findByParentIdAndType(a.getId(), a.getFileType());
+            responseModelUploadEntity.setStepEntities(modelHandelStepEntityList);
+            return responseModelUploadEntity;
+        }).collect(Collectors.toList());
+        PageResult<ResponseModelUploadEntity> pageResult = new PageResult<ResponseModelUploadEntity>(pageLog.getTotal(), collect);
+        return pageResult;
+    }
+
+    /**
+     * 查询所有用户
+     */
+    @GetMapping("/details")
+    @RequiresRoles("SYSADMIN")
+    @ApiOperation(value = "查询操作日志详情列表")
+    public PageResult<Object> details(QueryModelLog log) {
+
+        List<String> list = redisUtil.lRange(log.getTraceId(), 0, -1);
+
+        PageResult<Object> pageResult = new PageResult<>(list.size(), JSON.parseArray(list.toString()));
+        return pageResult;
+    }
+
+}

+ 14 - 13
sxz-core/src/main/java/com/fdkk/sxz/system/dto/CreateUser.java

@@ -1,4 +1,3 @@
-
 package com.fdkk.sxz.system.dto;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -20,12 +19,11 @@ import java.util.List;
  * @since 2018-05-26
  */
 @Data
-public class CreateUser implements Serializable
-{
+public class CreateUser implements Serializable {
 
     /**
-      * @Fields serialVersionUID :
-      */
+     * @Fields serialVersionUID :
+     */
 
     private static final long serialVersionUID = 1L;
 
@@ -39,21 +37,21 @@ public class CreateUser implements Serializable
      * 账号
      */
     @ApiModelProperty(value = "账号")
-    @NotBlank(message="账号不能为空")
+    @NotBlank(message = "账号不能为空")
     private String userAccount;
 
     /**
      * 昵称
      */
     @ApiModelProperty(value = "昵称")
-    @Size(min=2,max=16,message="昵称长度不正确")
+    @Size(min = 2, max = 16, message = "昵称长度不正确")
     private String userNickName;
 
     /**
      * 姓名
      */
     @ApiModelProperty(value = "姓名")
-    @Size(min=2,max=16,message="姓名长度不正确")
+    @Size(min = 2, max = 16, message = "姓名长度不正确")
     private String userName;
 
     /**
@@ -74,15 +72,15 @@ public class CreateUser implements Serializable
      * 电话
      */
     @ApiModelProperty(value = "手机号码")
-    @NotBlank(message="手机号码不能为空")
-    @Size(min=11,max=11,message="手机号码长度不正确")
+    @NotBlank(message = "手机号码不能为空")
+    @Size(min = 11, max = 11, message = "手机号码长度不正确")
     private String userMobile;
 
     /**
      * 密码
      */
     @ApiModelProperty(value = "密码")
-    @Pattern(regexp = "^[a-zA-Z0-9]{6,18}$", message="密码格式不正确")
+    @Pattern(regexp = "^[a-zA-Z0-9]{6,18}$", message = "密码格式不正确")
     private String userPassword;
 
     /**
@@ -95,7 +93,8 @@ public class CreateUser implements Serializable
      * 头像图片地址
      */
     @ApiModelProperty(value = "头像图片地址")
-    @Pattern(regexp = "^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+(\\?{0,1}(([A-Za-z0-9-~]+\\={0,1})([A-Za-z0-9-~]*)\\&{0,1})*)$", message="头像图片地址格式不正确")
+    @Pattern(regexp = "^([hH][tT]{2}[pP]:/*|[hH][tT]{2}[pP][sS]:/*|[fF][tT][pP]:/*)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\/])+(\\?{0,1}(([A-Za-z0-9-~]+\\={0,1})([A-Za-z0-9-~]*)\\&{0,1})*)$", message =
+            "头像图片地址格式不正确")
     private String headImgUrl;
 
     /**
@@ -132,7 +131,7 @@ public class CreateUser implements Serializable
      * 备注
      */
     @ApiModelProperty(value = "备注")
-    @Size(min=0,max=255,message="备注信息长度不正确")
+    @Size(min = 0, max = 255, message = "备注信息长度不正确")
     private String description;
 
     private Long roleId;
@@ -146,4 +145,6 @@ public class CreateUser implements Serializable
     @ApiModelProperty(value = "用户角色ID数组")
     private List<Long> roleIds;
 
+    private Long fdkkId;
+
 }

+ 53 - 0
sxz-core/src/main/java/com/fdkk/sxz/system/dto/QueryModelLog.java

@@ -0,0 +1,53 @@
+package com.fdkk.sxz.system.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author jeebase
+ * @since 2018-10-24
+ */
+@ApiModel(value = "Log对象", description = "")
+@Data
+public class QueryModelLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "接口名称")
+    private String methodName;
+
+    @ApiModelProperty(value = "日志类型")
+    private String logType;
+
+    @ApiModelProperty(value = "请求连接")
+    private String url;
+
+    @ApiModelProperty(value = "链路id")
+    private String traceId;
+
+    @ApiModelProperty(value = "操作名称")
+    private String operationName;
+
+    @ApiModelProperty(value = "操作的IP")
+    private String operationIp;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "开始日期")
+    private LocalDateTime startTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "结束日期")
+    private LocalDateTime endTime;
+
+    @ApiModelProperty(value = "操作人")
+    private String creator;
+}

+ 2 - 1
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/LoginController.java

@@ -79,9 +79,10 @@ public class LoginController extends BaseController {
         }
 
         CreateUser createUser = new CreateUser();
-        createUser.setUserName(object.getString("nickName"));
+        createUser.setUserName(object.getJSONObject("data").getJSONObject("user").getString("nickName"));
         createUser.setUserAccount(user.getPhoneNum());
         createUser.setUserMobile(user.getPhoneNum());
+        createUser.setFdkkId(object.getJSONObject("data").getJSONObject("user").getLong("id"));
         boolean usersExists = userService.getUsersExists(createUser);
         if (!usersExists) {
             userService.createUser(createUser);

+ 3 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IModelHandelStepService.java

@@ -3,6 +3,8 @@ package com.fdkk.sxz.webApi.service;
 import com.fdkk.sxz.base.IBaseService;
 import com.fdkk.sxz.entity.ModelHandelStepEntity;
 
+import java.util.List;
+
 
 /**
  * @description: ModelHandelStep 相关的服务接口类
@@ -12,4 +14,5 @@ import com.fdkk.sxz.entity.ModelHandelStepEntity;
 public interface IModelHandelStepService extends IBaseService<ModelHandelStepEntity> {
 
 
+    List<ModelHandelStepEntity> findByParentIdAndType(Long id, Integer fileType);
 }

+ 5 - 3
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/IModelUploadService.java

@@ -3,9 +3,10 @@ package com.fdkk.sxz.webApi.service;
 import com.fdkk.sxz.base.IBaseService;
 import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.entity.ModelUploadEntity;
-import com.fdkk.sxz.entity.custuom.CustomProductFirstclassifyEntity;
 import com.fdkk.sxz.vo.request.RequestModelCustomUpload;
+import com.fdkk.sxz.vo.request.RequestModelUpload;
 import com.fdkk.sxz.vo.response.ResponseModelCustom;
+import com.github.pagehelper.PageInfo;
 
 import java.util.List;
 
@@ -27,11 +28,12 @@ public interface IModelUploadService extends IBaseService<ModelUploadEntity> {
 
     ModelUploadEntity findById(Long id);
 
+    @Override
     boolean updateById(ModelUploadEntity entity);
 
-    boolean removeById(Long id) ;
-
+    boolean removeById(Long id);
 
+    PageInfo<ModelUploadEntity> listByPage(RequestModelUpload param);
 
 
 }

+ 16 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/ModelHandelStepServiceImpl.java

@@ -1,5 +1,8 @@
 package com.fdkk.sxz.webApi.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.ModelHandelStepEntity;
 import com.fdkk.sxz.webApi.mapper.IModelHandelStepMapper;
@@ -7,6 +10,8 @@ import com.fdkk.sxz.webApi.service.IModelHandelStepService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @description: ModelHandelStep 相关的服务实现类
  * @author: Xiewj
@@ -18,4 +23,15 @@ public class ModelHandelStepServiceImpl extends BaseServiceImpl<IModelHandelStep
     @Autowired
     private IModelHandelStepMapper modelHandelStepMapper;
 
+    @Override
+    public List<ModelHandelStepEntity> findByParentIdAndType(Long parentId, Integer fileType) {
+        LambdaQueryWrapper<ModelHandelStepEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(parentId) && parentId > 0) {
+            wrapper.eq(ModelHandelStepEntity::getParentId, parentId);
+        }
+        if (ObjectUtil.isNotNull(fileType) && fileType > 0) {
+            wrapper.eq(ModelHandelStepEntity::getType, fileType);
+        }
+        return list(wrapper);
+    }
 }

+ 16 - 0
sxz-core/src/main/java/com/fdkk/sxz/webApi/service/impl/ModelUploadServiceImpl.java

@@ -5,6 +5,8 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fdkk.sxz.base.Result;
 import com.fdkk.sxz.base.impl.BaseServiceImpl;
 import com.fdkk.sxz.entity.ComponentModelUploadEntity;
@@ -17,12 +19,14 @@ import com.fdkk.sxz.util.CreateObjUtil;
 import com.fdkk.sxz.util.OkHttpUtils;
 import com.fdkk.sxz.util.UploadToOssUtil;
 import com.fdkk.sxz.vo.request.RequestModelCustomUpload;
+import com.fdkk.sxz.vo.request.RequestModelUpload;
 import com.fdkk.sxz.vo.response.ResponseModelCustom;
 import com.fdkk.sxz.webApi.mapper.IModelUploadMapper;
 import com.fdkk.sxz.webApi.service.IComponentModelUploadService;
 import com.fdkk.sxz.webApi.service.IModelUploadService;
 import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
 import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import net.oschina.j2cache.CacheChannel;
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -83,6 +87,18 @@ public class ModelUploadServiceImpl extends BaseServiceImpl<IModelUploadMapper,
     private CacheChannel cacheChannel;
 
     @Override
+    public PageInfo<ModelUploadEntity> listByPage(RequestModelUpload param) {
+        LambdaQueryWrapper<ModelUploadEntity> wrapper = Wrappers.lambdaQuery();
+        if (ObjectUtil.isNotNull(param.getId()) && param.getId() > 0) {
+            wrapper.eq(ModelUploadEntity::getId, param.getId());
+        }
+        if (ObjectUtil.isNotNull(param.getUserId()) && param.getUserId() > 0) {
+            wrapper.eq(ModelUploadEntity::getFileId, param.getUserId());
+        }
+        return super.listByPage(param, wrapper);
+    }
+
+    @Override
     public boolean removeById(Long id) {
         ModelUploadEntity entity = findById(id);
         boolean removeById = super.removeById(id);

+ 6 - 6
sxz-modules/src/main/java/com/fdkk/sxz/entity/system/User.java

@@ -1,14 +1,12 @@
 package com.fdkk.sxz.entity.system;
 
-import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.fdkk.sxz.entity.BaseEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.io.Serializable;
-import java.time.LocalDateTime;
-
 /**
  * <p>
  * 用户表
@@ -18,7 +16,7 @@ import java.time.LocalDateTime;
  * @since 2018-10-24
  */
 @TableName("tb_sys_user")
-@ApiModel(value="User对象", description="用户表")
+@ApiModel(value = "User对象", description = "用户表")
 @Data
 public class User extends BaseEntity {
 
@@ -81,5 +79,7 @@ public class User extends BaseEntity {
     private String description;
 
 
-
+    @ApiModelProperty(value = "四维看看ID")
+    @TableField("FDKK_ID")
+    private Long fdkkId;
 }

+ 21 - 0
sxz-modules/src/main/java/com/fdkk/sxz/vo/request/RequestModelUpload.java

@@ -0,0 +1,21 @@
+package com.fdkk.sxz.vo.request;
+
+import com.fdkk.sxz.base.RequestBase;
+import lombok.Data;
+
+/**
+ * @description: 定制家具——组件 Model
+ * @author: Xiewj
+ * @date: 2021-09-01 14:15:52
+ */
+@Data
+public class RequestModelUpload extends RequestBase {
+
+
+    private Long id;
+
+    private String fileId;
+
+    private Long userId;
+
+}

+ 18 - 0
sxz-modules/src/main/java/com/fdkk/sxz/vo/response/ResponseModelUploadEntity.java

@@ -0,0 +1,18 @@
+package com.fdkk.sxz.vo.response;
+
+import com.fdkk.sxz.entity.ModelHandelStepEntity;
+import com.fdkk.sxz.entity.ModelUploadEntity;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Created by Xiewj
+ * date 2021年9月1日16:20:53
+ */
+@Data
+public class ResponseModelUploadEntity extends ModelUploadEntity {
+
+    List<ModelHandelStepEntity> stepEntities;
+
+}