瀏覽代碼

灵工部署正式环境

xuqiang 1 年之前
父節點
當前提交
57b4d67201

+ 5 - 11
src/main/java/com/ydtech/modules/fnc/service/impl/InsFeeAuditServiceImpl.java

@@ -2,17 +2,12 @@ package com.ydtech.modules.fnc.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.collection.CollUtil;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.constants.enums.dict.FeeAuditAuditstatus;
 import com.ydtech.constants.enums.dict.ins.InsFeeAuditDistributionStatusEnum;
 import com.ydtech.exception.SystemException;
-import com.ydtech.modules.admin.model.SysDept;
-import com.ydtech.modules.admin.model.SysDeptAccount;
-import com.ydtech.modules.admin.model.SysUser;
-import com.ydtech.modules.admin.model.SysUserRole;
 import com.ydtech.modules.admin.dao.SysPartnerAccountMapper;
 import com.ydtech.modules.admin.dao.SysPremiumDetailsMapper;
 import com.ydtech.modules.admin.model.*;
@@ -21,7 +16,6 @@ import com.ydtech.modules.admin.model.po.SysUserAccount;
 import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
 import com.ydtech.modules.admin.service.*;
 import com.ydtech.modules.base.controller.BaseController;
-import com.ydtech.modules.esm.model.EsmUserReferrer;
 import com.ydtech.modules.esm.service.EsmUserReferrerService;
 import com.ydtech.modules.fnc.dao.FncInsAreaCompanyMapper;
 import com.ydtech.modules.fnc.dao.InsFeeAuditMapper;
@@ -39,12 +33,10 @@ import com.ydtech.modules.ins.model.InsDeptFee;
 import com.ydtech.modules.ins.service.InsCommissionService;
 import com.ydtech.modules.ins.service.InsCompanyFeeService;
 import com.ydtech.modules.ins.service.InsDeptFeeService;
-import com.ydtech.modules.order.constants.BusinessConstant;
+import com.ydtech.modules.lg.service.PushLgDataServerService;
 import com.ydtech.modules.order.dao.InsOrdersMapper;
 import com.ydtech.modules.order.entity.InsFeeOrder;
 import com.ydtech.modules.order.entity.InsOrders;
-import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
-import com.ydtech.modules.order.entity.vo.OrderVo;
 import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
@@ -65,7 +57,6 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
@@ -142,6 +133,9 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     @Autowired
     private SysUserRoleService sysUserRoleService;
 
+    @Autowired
+    private PushLgDataServerService dataServerService;
+
     private ExecutorService executorService= Executors.newCachedThreadPool();
 
 
@@ -403,7 +397,7 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
 
             }
             sysPremiumDetailsMapper.updateStatus(insAreaCompany.getId());
-
+            dataServerService.sendLgDataServer(insOrderNo);
         } catch (Exception e) {
             throw new SystemException("当前业务繁忙,请稍后重试");
         } finally {

+ 57 - 0
src/main/java/com/ydtech/modules/lg/LgDataServer.java

@@ -0,0 +1,57 @@
+package com.ydtech.modules.lg;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.ydtech.modules.lg.dao.PushLgDataServerMapper;
+import com.ydtech.modules.lg.model.PushLgDataServer;
+import com.ydtech.modules.ttqf.QuartzManager;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobDataMap;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import java.util.Date;
+
+
+@Slf4j
+public class LgDataServer  implements Job {
+
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        try {
+            Integer executionFrequency = (Integer) QuartzManager.getInstance().getContext().get("executionFrequency");
+            JobDataMap mergedJobDataMap = jobExecutionContext.getMergedJobDataMap();
+            Object object = mergedJobDataMap.get("dataServer");
+            PushLgDataServer lgDataServer = JSONObject.parseObject((JSONObject.toJSONString(object)), PushLgDataServer.class);
+            JSONObject jsonObject = JSONObject.parseObject(SendUtils.send(JSONObject.toJSONString(lgDataServer)));
+            if (null != jsonObject){
+                if (String.valueOf(jsonObject.getInteger("code")).equals("200")){
+                    lgDataServer.setPushStatus(String.valueOf(jsonObject.getInteger("code")));
+                    lgDataServer.setMsg(jsonObject.getString("msg"));
+                    lgDataServer.setSendNumber(executionFrequency);
+                    lgDataServer.setSuccessPushTime(new Date());
+                    SpringUtil.getBean(PushLgDataServerMapper.class).updateById(lgDataServer);
+                    try {
+                        QuartzManager.getInstance().removeJob(jobExecutionContext);
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }
+                }
+            }
+            if (executionFrequency > 4){
+                lgDataServer.setSendNumber(executionFrequency);
+                SpringUtil.getBean(PushLgDataServerMapper.class).updateById(lgDataServer);
+                QuartzManager.getInstance().removeJob(jobExecutionContext);
+            }
+            executionFrequency ++;
+            log.info("lg推送重试任务执行{}",executionFrequency);
+            QuartzManager.getInstance().getContext().put("executionFrequency",executionFrequency);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
+}

+ 60 - 1
src/main/java/com/ydtech/modules/lg/PushLgLogUtils.java

@@ -1,14 +1,18 @@
 package com.ydtech.modules.lg;
 
-
 import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.lg.dao.PushLgEntityMapper;
+import com.ydtech.modules.lg.dao.PushLgDataServerMapper;
+import com.ydtech.modules.lg.model.PushLgDataServer;
 import com.ydtech.modules.lg.model.PushLgEntity;
+import com.ydtech.modules.order.entity.vo.OrderVo;
 import com.ydtech.modules.ttqf.QuartzManager;
 import com.ydtech.utils.StringUtils;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
 
 import java.util.Date;
 import java.util.HashMap;
@@ -16,6 +20,7 @@ import java.util.HashMap;
 @Component
 public class PushLgLogUtils {
 
+
     @Async
     public void pushLg(PushLgEntity lgEntity){
         int insert = SpringUtil.getBean(PushLgEntityMapper.class).insert(lgEntity);
@@ -52,4 +57,58 @@ public class PushLgLogUtils {
     }
 
 
+
+    @Async
+    public void pushLgDataServer(HttpResult<OrderVo> orderNo){
+        if (ObjectUtils.isEmpty(orderNo)){
+            return;
+        }
+        OrderVo accountingUser = orderNo.getData();
+        if (!StringUtils.equals(accountingUser.getSource(),"个代")){
+            return;
+        }
+        PushLgDataServer lgDataServer = new PushLgDataServer();
+        lgDataServer.setOrderNo(accountingUser.getOrderno());
+        lgDataServer.setUserName(String.valueOf(accountingUser.getInsureinfo().get("name")));
+        lgDataServer.setUserCarNum(String.valueOf(accountingUser.getCarinfo().get("licenseNo")));
+        lgDataServer.setUserPhone(String.valueOf(accountingUser.getInsureinfo().get("mobile")));
+        lgDataServer.setGiveBudget(accountingUser.getSumFee());
+        lgDataServer.setBelongingName(accountingUser.getUsername());
+        lgDataServer.setBelongingNo(accountingUser.getUserid());
+        lgDataServer.setSendTime(new Date());
+        PushLgDataServerMapper mapper = SpringUtil.getBean(PushLgDataServerMapper.class);
+        if (mapper.insert(lgDataServer) > 0){
+            lgDataServer.setZgUuid(lgDataServer.getSid());
+            JSONObject jsonObject = JSONObject.parseObject(SendUtils.sendDataServer(JSONObject.toJSONString(lgDataServer)));
+            if (!ObjectUtils.isEmpty(jsonObject) && String.valueOf(jsonObject.getInteger("code")).equals("200")){
+                lgDataServer.setPushStatus(String.valueOf(jsonObject.getInteger("code")));
+                lgDataServer.setMsg(jsonObject.getString("msg"));
+                lgDataServer.setSuccessPushTime(new Date());
+            }else {
+                lgDataServer.setPushStatus("");
+                lgDataServer.setMsg("推送失败");
+            }
+            mapper.updateById(lgDataServer);
+            if (!StringUtils.equals(lgDataServer.getPushStatus(),"200")){
+                pushLgDateServerRetry(lgDataServer);
+            }
+        }
+    }
+
+
+
+    public void pushLgDateServerRetry(PushLgDataServer dataServer){
+        try {
+            HashMap<String, Object> map = new HashMap<>();
+            map.put("dataServer", dataServer);
+            QuartzManager manager = QuartzManager.getInstance();
+            manager.getContext().put("executionFrequency",1);
+            manager.addJob(String.valueOf(dataServer.getSid()),"jobGroup" + dataServer.getSid(), LgDataServer.class,"*/30 * * * * ?",map);
+            manager.start();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+
 }

+ 1 - 1
src/main/java/com/ydtech/modules/lg/PushRetry.java

@@ -34,7 +34,7 @@ public class PushRetry implements Job {
                     }
                 }
             }
-            if (executionFrequency > 10){
+            if (executionFrequency > 4){
                 lgEntity.setSendNumber(executionFrequency);
                 SpringUtil.getBean(PushLgEntityMapper.class).updateById(lgEntity);
                 QuartzManager.getInstance().removeJob(jobExecutionContext);

+ 42 - 5
src/main/java/com/ydtech/modules/lg/SendUtils.java

@@ -19,17 +19,25 @@ public class SendUtils {
 
     private static String sendMessageIP;
 
-    @Value("${sendMessage-zg-yggl-IP}")
+    private static String sendMessageDataServerIP;
+
+    @Value("${lg-ip.withdrawal}")
     private void setSendMessageIP(String sendMessageIP){
         SendUtils.sendMessageIP = sendMessageIP;
     };
 
 
+    @Value("${lg-ip.dateServer}")
+    private void setSendMessageDataServerIP(String dataServerIp){
+        SendUtils.sendMessageDataServerIP = dataServerIp;
+    };
+
+
     public static String send(String data){
         // 获得Http客户端(可以理解为:你得先有一个浏览器;注意:实际上HttpClient与浏览器是不一样的)
         CloseableHttpClient httpClient = HttpClientBuilder.create().build();
         // 创建Post请求
-        HttpPost httpPost = new HttpPost(sendMessageIP + "/withdrawal/record/acceptPushWithdrawalData");
+        HttpPost httpPost = new HttpPost(sendMessageIP);
         StringEntity entity = new StringEntity(data, "UTF-8");
         // post请求是将参数放在请求体里面传过去的;这里将entity放入post请求体中
         httpPost.setEntity(entity);
@@ -43,8 +51,6 @@ public class SendUtils {
             HttpEntity responseEntity = response.getEntity();
             //从响应实体中截取状态码
             return EntityUtils.toString(responseEntity);
-//            String responseString = string.substring(string.lastIndexOf(":") + 1);
-//            String responseCode = responseString.substring(0, responseString.length() - 1);
         }catch (Exception e){
             e.printStackTrace();
             return "";
@@ -61,9 +67,40 @@ public class SendUtils {
                 e.printStackTrace();
             }
         }
+    }
 
 
-
+    public static String sendDataServer(String data){
+        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
+        HttpPost httpPost = new HttpPost(sendMessageDataServerIP);
+        StringEntity entity = new StringEntity(data, "UTF-8");
+        httpPost.setEntity(entity);
+        httpPost.setHeader("Content-Type", "application/json;charset=utf8");
+        // 响应模型
+        CloseableHttpResponse response = null;
+        try {
+            // 由客户端执行(发送)Post请求
+            response = httpClient.execute(httpPost);
+            // 从响应模型中获取响应实体
+            HttpEntity responseEntity = response.getEntity();
+            //从响应实体中截取状态码
+            return EntityUtils.toString(responseEntity);
+        }catch (Exception e){
+            e.printStackTrace();
+        }finally {
+            try {
+                // 释放资源
+                if (httpClient != null) {
+                    httpClient.close();
+                }
+                if (response != null) {
+                    response.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return "";
     }
 
 

+ 7 - 0
src/main/java/com/ydtech/modules/lg/dao/PushLgDataServerMapper.java

@@ -0,0 +1,7 @@
+package com.ydtech.modules.lg.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.lg.model.PushLgDataServer;
+
+public interface PushLgDataServerMapper extends BaseMapper<PushLgDataServer> {
+}

+ 46 - 0
src/main/java/com/ydtech/modules/lg/model/PushLgDataServer.java

@@ -0,0 +1,46 @@
+package com.ydtech.modules.lg.model;
+
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("push_lg_data_server")
+public class PushLgDataServer {
+
+    @TableId(type = IdType.ASSIGN_ID)
+    private Long sid;
+
+    private String orderNo;
+
+    private String userName;
+
+    private String userCarNum;
+
+    private String userPhone;
+
+    private String giveBudget;
+
+    private String belongingName;
+
+    private String belongingNo;
+
+    private String pushStatus;
+
+    private String msg;
+
+    private int sendNumber;
+
+    private Date sendTime;
+
+    private Date successPushTime;
+
+    @TableField(exist = false)
+    private Long zgUuid;
+
+}

+ 9 - 0
src/main/java/com/ydtech/modules/lg/service/PushLgDataServerService.java

@@ -0,0 +1,9 @@
+package com.ydtech.modules.lg.service;
+
+public interface PushLgDataServerService {
+
+
+
+    void sendLgDataServer(String  orderNum);
+
+}

+ 30 - 0
src/main/java/com/ydtech/modules/lg/service/impl/PushLgDataServerServiceImpl.java

@@ -0,0 +1,30 @@
+package com.ydtech.modules.lg.service.impl;
+
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.lg.PushLgLogUtils;
+import com.ydtech.modules.lg.service.PushLgDataServerService;
+import com.ydtech.modules.order.entity.vo.OrderVo;
+import com.ydtech.modules.order.service.InsOrdersService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class PushLgDataServerServiceImpl implements PushLgDataServerService {
+
+
+    @Autowired
+    private InsOrdersService insOrdersService;
+
+
+    @Autowired
+    private PushLgLogUtils pushLgLogUtils;
+
+    @Override
+    public void sendLgDataServer(String orderNum) {
+        HttpResult<OrderVo> accountingUser = insOrdersService.getByCompanyId(orderNum, "accountingUser");
+        pushLgLogUtils.pushLgDataServer(accountingUser);
+    }
+
+
+}

+ 5 - 3
src/main/java/com/ydtech/modules/ttqf/service/impl/TtqfServiceImpl.java

@@ -248,9 +248,11 @@ public class TtqfServiceImpl implements TtqfService {
         try {
             boolean sign = false;
             QueryPresignResultModel resultModel = RetrieveTTQFApi.queryPressing(sysUser.getIdentity());
-            if (Objects.equals(PayConstantStatus.SIGN_STATUS,resultModel.getSignStatus()) &&
-                    Objects.equals(PayConstantStatus.AUTH_STATUS,resultModel.getAuthStatus())){
-                sign = true;
+            if (ObjectUtils.isNotEmpty(resultModel)){
+                if (Objects.equals(PayConstantStatus.SIGN_STATUS,resultModel.getSignStatus()) &&
+                        Objects.equals(PayConstantStatus.AUTH_STATUS,resultModel.getAuthStatus())){
+                    sign = true;
+                }
             }
             return HttpResult.ok(WithdrawalFRes.builder().bizCode(sign ? "3" : "1").url("").msg(sign ? "已签约" : "未签约").build());
         }catch (Exception e){

+ 3 - 1
src/main/resources/application-pre.yml

@@ -457,4 +457,6 @@ ttqf:
   tokenUrl: https://test.baoxianzhanggui.com/web-api
 
 #灵活用工平台实时推送ip地址
-sendMessage-zg-yggl-IP: https://test.baoxianzhanggui.com/prod-api
+lg-ip:
+  dateServer: http://192.168.0.59:8081/system/record/receiveDistributeServices
+  withdrawal: http://192.168.0.59:8081/withdrawal/record/acceptPushWithdrawalData

+ 3 - 1
src/main/resources/application-prod.yml

@@ -462,4 +462,6 @@ ttqf:
   tokenUrl: https://test.baoxianzhanggui.com/web-api
 
 #灵活用工平台实时推送ip地址
-sendMessage-zg-yggl-IP: https://test.baoxianzhanggui.com/prod-api
+lg-ip:
+  dateServer: http://172.24.144.219:8081/system/record/receiveDistributeServices
+  withdrawal: http://172.24.144.219:8081/withdrawal/record/acceptPushWithdrawalData

+ 3 - 1
src/main/resources/application-test.yml

@@ -539,4 +539,6 @@ customer:
 httpUrl: https://test.baoxianzhanggui.com/copartnerH5/#/pages/index/result?
 
 #灵活用工平台实时推送ip地址
-sendMessage-zg-yggl-IP: https://test.baoxianzhanggui.com/prod-api
+lg-ip:
+  dateServer: https://test.baoxianzhanggui.com/prod-api/system/record/receiveDistributeServices
+  withdrawal: https://test.baoxianzhanggui.com/prod-api/withdrawal/record/acceptPushWithdrawalData