25
0

2 Commits 2595a91a94 ... 5eb409a47f

Autor SHA1 Nachricht Datum
  linhuili 5eb409a47f Merge remote-tracking branch 'origin/develop' into develop vor 2 Jahren
  linhuili 064e7d0d5b BOSS对接增加拦截器 vor 2 Jahren

+ 4 - 1
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/interceptor/AppContextConfig.java

@@ -20,7 +20,10 @@ public class AppContextConfig implements WebMvcConfigurer {
         InterceptorRegistration registration1 = registry.addInterceptor(new TraceIdInterceptor());
         registration1.addPathPatterns("/**");
 
-        registry.addInterceptor(tokenInterceptor).order(Integer.MAX_VALUE).addPathPatterns("/adm/**").excludePathPatterns("/adm/getUserInfo");
+        InterceptorRegistration StewardRegistration = registry.addInterceptor(new StewardInterceptor());
+        StewardRegistration.addPathPatterns("/deliver/plan/relayDeliverPlan");
+
+        registry.addInterceptor(tokenInterceptor).order(Integer.MAX_VALUE).addPathPatterns("/adm/**").excludePathPatterns("/adm/getUserInfo","/deliver/plan/**");
 
     }
 }

+ 55 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/custom/interceptor/StewardInterceptor.java

@@ -0,0 +1,55 @@
+package com.persagy.adm.server.custom.interceptor;
+import com.persagy.adm.steward.basic.utils.RSAUtils;
+import com.persagy.dmp.common.helper.SpringHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * 解密拦截器
+ *
+ * @author:linhuili
+ * @date:2022/1/25
+ */
+@Slf4j
+@Component
+public class StewardInterceptor extends HandlerInterceptorAdapter {
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String body = getBody(request);
+        log.info("BOSS交付范围加密请求参数:{}"+body);
+        String string = SpringHelper.getString("boss.rsa.publicKey");
+        RSAUtils.decode(body,string);
+        return super.preHandle(request, response, handler);
+    }
+
+    /**
+     * 获取请求体
+     * @param request
+     * @return
+     * @throws IOException
+     */
+    public String getBody(HttpServletRequest request) throws IOException {
+        // 获取请求体
+        BufferedReader br = request.getReader();
+        String inputLine;
+        String body = "";
+        try {
+            while ((inputLine = br.readLine()) != null) {
+                body += inputLine;
+            }
+            br.close();
+        } catch (IOException e) {
+            System.out.println("IOException: " + e);
+        }
+        return body;
+    }
+
+}

+ 19 - 7
adm-business/adm-server/src/main/java/com/persagy/adm/server/delivery/controller/AdmDeliverPlanController.java

@@ -1,9 +1,13 @@
 package com.persagy.adm.server.delivery.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.persagy.adm.server.delivery.entity.BossProjectDeliveryPlan;
 import com.persagy.adm.server.delivery.service.AdmDeliverPlanService;
+import com.persagy.adm.steward.basic.model.response.BossResponse;
 import com.persagy.adm.steward.basic.utils.RSAUtils;
+import com.persagy.adm.steward.entity.ProductFinishNumReq;
 import com.persagy.adm.steward.entity.ProjectDeliverReq;
+import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import lombok.RequiredArgsConstructor;
@@ -31,9 +35,6 @@ public class AdmDeliverPlanController {
 
     private final AdmDeliverPlanService admDeliverPlanService;
 
-    @Value("${adm.rsa.privateKey}")
-    private String privateKey;
-
     /**
      * 020101-交付计划-处理BOSS产生的交付计划
      * @param projectDeliverReqStr : 交付计划信息
@@ -43,13 +44,24 @@ public class AdmDeliverPlanController {
      */
     @PostMapping(value = "/relayDeliverPlan")
     public CommonResult<List<Void>> relayDeliverPlan(@RequestBody String projectDeliverReqStr) {
-        //todo 测试
-        String decode = RSAUtils.decode(projectDeliverReqStr, privateKey);
-        log.info("接受BOSS产生的交付计划入参:{}"+decode);
-        ProjectDeliverReq projectDeliverReq = JSONObject.parseObject(decode, ProjectDeliverReq.class);
+     /*   log.info("未解密参数:{}"+projectDeliverReqStr);
+        String decode = RSAUtils.decode(projectDeliverReqStr, publicKey);*/
+        log.info("接收BOSS交付计划入参:{}"+projectDeliverReqStr);
+        ProjectDeliverReq projectDeliverReq = JSONObject.parseObject(projectDeliverReqStr, ProjectDeliverReq.class);
         admDeliverPlanService.relayDeliverPlan(projectDeliverReq);
         return ResultHelper.multi(new ArrayList<>());
     }
 
+    /**
+     * 交付完成-测试
+     * @param deliveryPlan
+     * @return
+     */
+    @PostMapping(value = "/finishDeliverPlan")
+    public BossResponse<List<ProductFinishNumReq>> finishDeliverPlan(@RequestBody BossProjectDeliveryPlan deliveryPlan) {
+        List<ProductFinishNumReq> finishDeliverPlan = admDeliverPlanService.finishDeliverPlan(deliveryPlan);
+        return BossResponse.success(finishDeliverPlan);
+    }
+
 
 }

+ 11 - 0
adm-business/adm-server/src/main/java/com/persagy/adm/server/delivery/service/AdmDeliverPlanService.java

@@ -1,7 +1,11 @@
 package com.persagy.adm.server.delivery.service;
 
+import com.persagy.adm.server.delivery.entity.BossProjectDeliveryPlan;
+import com.persagy.adm.steward.entity.ProductFinishNumReq;
 import com.persagy.adm.steward.entity.ProjectDeliverReq;
 
+import java.util.List;
+
 /**
  * 对接BOSS的交付计划逻辑处理接口
  * @author : lijie
@@ -15,4 +19,11 @@ public interface AdmDeliverPlanService {
      * Update By 2022/1/14 17:22
      */
     void relayDeliverPlan(ProjectDeliverReq projectDeliverReq);
+
+    /**
+     * 交付完成
+     * @param deliveryPlan
+     * @return
+     */
+    List<ProductFinishNumReq> finishDeliverPlan(BossProjectDeliveryPlan deliveryPlan);
 }

+ 48 - 1
adm-business/adm-server/src/main/java/com/persagy/adm/server/delivery/service/impl/AdmDeliverPlanServiceImpl.java

@@ -1,17 +1,21 @@
 package com.persagy.adm.server.delivery.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.persagy.adm.server.delivery.entity.BossProjectDeliveryPlan;
 import com.persagy.adm.server.delivery.entity.BossSkuDictRel;
 import com.persagy.adm.server.delivery.service.AdmDeliverPlanService;
 import com.persagy.adm.server.delivery.service.BossProjectDeliveryPlanService;
 import com.persagy.adm.server.delivery.service.BossSkuDictRelService;
+import com.persagy.adm.steward.client.BossStewardFacade;
+import com.persagy.adm.steward.entity.ProductFinishNumReq;
 import com.persagy.adm.steward.entity.ProjectDeliverReq;
 import com.persagy.dmp.delivery.client.DigitalObjectTypeCollectFacade;
 import com.persagy.dmp.delivery.dto.DeliveryPlanDTO;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -43,6 +47,49 @@ public class AdmDeliverPlanServiceImpl implements AdmDeliverPlanService {
     }
 
     /**
+     * 交付完成-测试
+     * @param deliveryPlan
+     * @return
+     */
+    @Override
+    public List<ProductFinishNumReq> finishDeliverPlan(BossProjectDeliveryPlan deliveryPlan) {
+        //组装查询条件
+        LambdaQueryWrapper<BossProjectDeliveryPlan> queryWrapper = new LambdaQueryWrapper<>();
+        if(deliveryPlan.getProjectId()!=null){
+            queryWrapper.eq(BossProjectDeliveryPlan::getProjectId,deliveryPlan.getProjectId());
+        }
+        if(deliveryPlan.getPlanId() != null){
+            queryWrapper.eq(BossProjectDeliveryPlan::getPlanId,deliveryPlan.getPlanId());
+        }
+        if(deliveryPlan.getPlanInfoId() != null){
+            queryWrapper.eq(BossProjectDeliveryPlan::getPlanInfoId,deliveryPlan.getPlanInfoId());
+        }
+        queryWrapper.eq(BossProjectDeliveryPlan::getValid,true);
+        //查询BOSS交付任务
+        List<BossProjectDeliveryPlan> bossProjectDeliveryPlans = bossDeliveryPlanService.queryByCondition(queryWrapper);
+        if(CollUtil.isEmpty(bossProjectDeliveryPlans)){
+            return new ArrayList<>();
+        }
+
+        List<ProductFinishNumReq> result = new ArrayList<>();
+        //组装BOSS所需参数
+        bossProjectDeliveryPlans.forEach(item->{
+            ProductFinishNumReq finishNumReq = new ProductFinishNumReq();
+            finishNumReq.setPlanInfoId(item.getProjectId());
+            Long productNum = item.getProductNum();
+            if(productNum == null){
+                finishNumReq.setFinishNum(0);
+            }else{
+                finishNumReq.setFinishNum(item.getProductNum().intValue());
+            }
+            result.add(finishNumReq);
+        });
+        //通过FeignClient调用回调接口
+        BossStewardFacade.finishDeliverPlan(result);
+        return result;
+    }
+
+    /**
      * 生成项目交付计划
      * @param projectDeliverReq
      */
@@ -96,7 +143,7 @@ public class AdmDeliverPlanServiceImpl implements AdmDeliverPlanService {
             }
         }
         //生成项目交付信息
-        DigitalObjectTypeCollectFacade.createProjectDelivery(groupCode,"Pj"+ projectId, null, null, result);
+        DigitalObjectTypeCollectFacade.createProjectDelivery("HR","Pj4403050002", null, null, result);
         //存储原BOSS订单信息
         bossDeliveryPlanService.insert(bossProjectDeliveryPlan);
     }

+ 17 - 17
adm-business/adm-server/src/main/resources/db/init/schema.sql

@@ -408,7 +408,7 @@ CREATE TABLE IF NOT EXISTS `adm_model_file` (
 CREATE TABLE IF NOT EXISTS `boss_sku_dict_rel` (
     `id` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
     `sku_code` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'BOSS:商品编码',
-    `type_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'BDTP:对象类型编码',
+    `class_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'BDTP:对象类型编码',
     `obj_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '对象类型',
     `creator` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
     `creation_time` char(14) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建时间',
@@ -419,19 +419,19 @@ CREATE TABLE IF NOT EXISTS `boss_sku_dict_rel` (
     PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='BOSS商品sku与数据字典关系映射表';
 
-CREATE TABLE IF NOT EXISTS `boss_project_delivery_plan` (
-  `id` varchar(40) COLLATE utf8mb4_general_ci NOT NULL,
-  `project_id` int DEFAULT NULL COMMENT '项目id(BOSS)',
-  `plan_id` int DEFAULT NULL COMMENT '商品所属计划Id',
-  `plan_info_id` int NOT NULL COMMENT '验收商品id',
-  `product_sku_code` varchar(40) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '商品编码',
-  `product_num` int DEFAULT NULL COMMENT '商品对应的实施数量',
-  `steward_account` varchar(40) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '管家账号',
-  `creator` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
-  `creation_time` char(14) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建时间',
-  `modifier` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最后修改人',
-  `modified_time` char(14) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最后修改时间',
-  `valid` tinyint NOT NULL DEFAULT '1' COMMENT '合法标识',
-  `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '乐观锁',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci='BOSS项目交付计划';
+CREATE TABLE IF NOT EXISTS "boss_project_delivery_plan" (
+  "id" varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+  "project_id" int DEFAULT NULL COMMENT '项目id(BOSS)',
+  "plan_id" int DEFAULT NULL COMMENT '商品所属计划Id',
+  "plan_info_id" int NOT NULL COMMENT '验收商品id',
+  "product_sku_code" varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '商品编码',
+  "product_num" int DEFAULT NULL COMMENT '商品对应的实施数量',
+  "steward_account" varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '管家账号',
+  "creator" varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
+  "creation_time" char(14) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建时间',
+  "modifier" varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最后修改人',
+  "modified_time" char(14) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最后修改时间',
+  "valid" tinyint NOT NULL DEFAULT '1' COMMENT '合法标识',
+  "ts" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '乐观锁',
+  PRIMARY KEY ("id")
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

+ 3 - 2
adm-comp/adm-steward-starter/src/main/java/com/persagy/adm/steward/basic/config/StewardEncodeInterceptor.java

@@ -27,7 +27,8 @@ public class StewardEncodeInterceptor implements RequestInterceptor {
         }
         // 更改请求体中的content的值
         Request.Body body = template.requestBody();
-        JSONObject temp = JSONObject.parseObject(body.asString());
-        template.body(RSAUtils.decode(body.asString(), SpringHelper.getString("adm.rsa.privateKey")));
+        template.body(RSAUtils.encode(body.asString(), SpringHelper.getString("boss.rsa.privateKey")));
+        log.info("template:{}",template);
+        log.info("body.asString():{}",body.asString());
     }
 }

+ 10 - 0
adm-comp/adm-steward-starter/src/main/java/com/persagy/adm/steward/client/BossStewardClient.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.adm.steward.basic.config.StewardFeignConfig;
 import com.persagy.adm.steward.basic.model.response.BossResponse;
+import com.persagy.adm.steward.entity.ProductFinishNumReq;
 import com.persagy.dmp.common.model.response.CommonResult;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -32,4 +33,13 @@ public interface BossStewardClient {
     @PostMapping("test")
     BossResponse<Void> test(@RequestHeader(value = "encryption-rsa", required = false,defaultValue = "true") Boolean rsaFlag,
                             @RequestBody Set<String> projectIds);
+
+    /**
+     * 项目交付完成接口回调
+     * @param productFinishNumReqList: 交付完成信息
+     * @return 对象数组
+     */
+    @PostMapping("test")
+    BossResponse<List<ProductFinishNumReq>> finishDeliverPlan(@RequestHeader(value = "encryption-rsa", required = false,defaultValue = "true") Boolean rsaFlag,
+                                                              @RequestBody List<ProductFinishNumReq> productFinishNumReqList);
 }

+ 12 - 0
adm-comp/adm-steward-starter/src/main/java/com/persagy/adm/steward/client/BossStewardFacade.java

@@ -1,6 +1,9 @@
 package com.persagy.adm.steward.client;
 
 import cn.hutool.extra.spring.SpringUtil;
+import com.persagy.adm.steward.entity.ProductFinishNumReq;
+
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -20,4 +23,13 @@ public class BossStewardFacade {
     public static void test(Set<String> projectIds) {
         client.test(Boolean.TRUE,projectIds);
     }
+
+    /**
+     * feign调用回调
+     * @param productFinishNumReqList: 交付内容
+     * @return 对象数组
+     */
+    public static void finishDeliverPlan(List<ProductFinishNumReq> productFinishNumReqList) {
+        client.finishDeliverPlan(Boolean.TRUE,productFinishNumReqList);
+    }
 }

+ 1 - 1
adm-comp/adm-steward-starter/src/main/java/com/persagy/adm/steward/entity/ProjectDeliverReq.java

@@ -140,7 +140,7 @@ public class ProjectDeliverReq implements Serializable {
         /**
          * 楼层id
          */
-        private Integer storeyId;
+        private String storeyId;
 
         private String storeyName;
     }