Browse Source

完善出库和迁移公众号到思康

hfxc226 2 years ago
parent
commit
85ba7df88b

+ 2 - 2
platform-rest/src/main/java/com/platform/rest/controller/yongyou/YongyouController.java

@@ -80,7 +80,7 @@ public class YongyouController {
     @SysLog("发起用友出库单")
     @PutMapping("/spare/pick/form/{id}")
     public R addSparePickForm(@PathVariable("id") String id) {
-        yongyouService.addOutForm(id);
+        yongyouService.addOutForm(id, false);
         return new R<>();
     }
 
@@ -109,7 +109,7 @@ public class YongyouController {
     @SysLog("发起用友退库单")
     @PutMapping("/spare/restore/form/{id}")
     public R addSpareRestoreForm(@PathVariable("id") String id) {
-        yongyouService.addOutForm(id);
+        yongyouService.addOutForm(id, false);
         return new R<>();
     }
 

+ 19 - 17
platform-service/src/main/java/com/platform/service/business/impl/OutStoreFormActivitiServiceImpl.java

@@ -7,6 +7,7 @@ import com.platform.common.exception.BusinessException;
 import com.platform.common.model.UserInfo;
 import com.platform.common.util.IdGeneratorUtils;
 import com.platform.common.util.SecurityUtils;
+import com.platform.common.yongyou.response.OtherOutAddResponse;
 import com.platform.dao.entity.activiti.LocalAuditRecord;
 import com.platform.dao.entity.store.OutStoreForm;
 import com.platform.dao.enums.ActivitiFormStatusEnum;
@@ -20,6 +21,8 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+
 /**
  * @Description 工作流业务
  * @Author chenyuehu
@@ -112,29 +115,28 @@ public class OutStoreFormActivitiServiceImpl extends BaseFormCheckServiceAbstrac
     public String doFinish(ActAuditRequest actAuditRequest) {
         OutStoreForm outStoreForm = new OutStoreForm();
         outStoreForm.setId(actAuditRequest.getId());
+
+        // 发送用友通知
+        OtherOutAddResponse response = yongyouService.addOutForm(actAuditRequest.getId(), true);
+        if(response == null){
+            outStoreForm.setStatus(OutStoreStatusEnum.EXECUTING.getValue());
+        }else{
+            if(!response.getResult()){
+                outStoreForm.setStatus(OutStoreStatusEnum.PUSH_ERROR.getValue());
+                outStoreForm.setYyMessage(response.getMsg());
+            }else{
+                outStoreForm.setStatus(OutStoreStatusEnum.PUSH_OK.getValue());
+                outStoreForm.setYyMessage(response.getMsg());
+                outStoreForm.setYyId(response.getData());
+            }
+        }
+        outStoreForm.setUpdateTime(LocalDateTime.now());
         outStoreForm.setUpdateUserId(SecurityUtils.getUserInfo().getUserId());
         outStoreForm.setUpdateUserName(SecurityUtils.getUserInfo().getRealName());
-        outStoreForm.setStatus(OutStoreStatusEnum.EXECUTING.getValue());
         outStoreFormMapper.updateByPrimaryKeySelective(outStoreForm);
-        //yongyouService.addOutForm(actAuditRequest.getId());
-        // Thread.sleep(5000);// 5秒后执行
-        YongYouThread yongYouThread = new YongYouThread();
-        yongYouThread.setId(actAuditRequest.getId());
-        yongYouThread.start();
         return null;
     }
 
-    class YongYouThread extends Thread {
-        private String id;
-        public void setId(String id){
-            this.id = id;
-        }
-        @Override
-        public void run() {
-            yongyouService.addOutForm(id);
-        }
-    }
-
     /**
      * 终止审批业务
      * 清空:processInstanceId

+ 6 - 6
platform-service/src/main/java/com/platform/service/wechat/service/WeChatConnectService.java

@@ -41,12 +41,12 @@ public class WeChatConnectService {
    // private static final String APPID = "wx6e063fb37c1ba333";
     //   private static final String APPSECRET = "e74b6b4d7582ed12b141c62e7737af20";
     // 微信token,把这个配置到微信:消息推送平台Token(令牌), 乾元坤和科技的服务号
-    public static final String ACCESS_TOKEN = "wwwqykh2009com";
-    public static final String APPID = "wx38f46845be704faa";
-    public static final String APPSECRET = "1063daee3da88465eb0e1f7736ae6387";
-
-    //  private static final String APPID = DictCache.getLabelByValue(DictTypeEnum.WECHAT.getType(), CommonConstants.WECHAT_APP_ID);
-    //   private static final String APPSECRET = DictCache.getLabelByValue(DictTypeEnum.WECHAT.getType(), CommonConstants.WECHAT_APP_ID);
+    //public static final String ACCESS_TOKEN = "wwwqykh2009com";
+    //public static final String APPID = "wx38f46845be704faa";
+    //public static final String APPSECRET = "1063daee3da88465eb0e1f7736ae6387";
+    public static final String ACCESS_TOKEN = "wwwqykh2009com";// 思康服务号,在公众号设置的token
+    public static final String APPID = "wxe84a5ad20b7a72ce";// 公众号appid
+    public static final String APPSECRET = "42d09e728f6194e3120a68e053ad7da7";// 开发者密码
 
     // 获取access token的授权类型
     private static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";

+ 2 - 1
platform-service/src/main/java/com/platform/service/yongyou/YongyouService.java

@@ -2,6 +2,7 @@ package com.platform.service.yongyou;
 
 import com.alibaba.fastjson.JSONObject;
 import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.common.yongyou.response.OtherOutAddResponse;
 import com.platform.dao.dto.sqarepartmanage.SparePartInfoDTO;
 import com.platform.dao.dto.store.SparePickFormDTO;
 import com.platform.dao.dto.store.SpareRestoreFormDTO;
@@ -49,7 +50,7 @@ public interface YongyouService {
      * @param id 领用单id
      * @return
      */
-    void addOutForm(String id);
+    OtherOutAddResponse addOutForm(String id, boolean fromActivity);
     /**
      * 出库单(退库单)用友回调
      *

+ 30 - 23
platform-service/src/main/java/com/platform/service/yongyou/impl/YongyouServiceImpl.java

@@ -81,6 +81,7 @@ public class YongyouServiceImpl implements YongyouService {
 
     /**
      * 强制重新获取token
+     *
      * @return
      */
     private String geTokenForce() {
@@ -95,7 +96,7 @@ public class YongyouServiceImpl implements YongyouService {
         handler.setRequest(req);
         String responseStr = handler.handler();
         LoginResponse response = JSONObject.parseObject(responseStr, LoginResponse.class);
-        if(!response.getResult()){
+        if (!response.getResult()) {
             throw new BusinessException(response.getMsg() + "," + response.getData().getMsg());
         }
         Login login = response.getData();
@@ -109,6 +110,7 @@ public class YongyouServiceImpl implements YongyouService {
     private String getConn() {
         return RedisUtils.getString(Conn_key);
     }
+
     private String getCAccId() {
         return RedisUtils.getString(cAcc_ID_key);
     }
@@ -133,30 +135,30 @@ public class YongyouServiceImpl implements YongyouService {
         req.setPageSize(pageSize);
         StringBuffer whereStr = new StringBuffer(" 1=1 ");
         // 仓库编码搜索
-        if(StringUtils.isNotBlank(record.getStoreNo())){
+        if (StringUtils.isNotBlank(record.getStoreNo())) {
             whereStr.append(" and cWhCode like '%" + record.getStoreNo() + "%' ");
         }
         // 仓库名称搜索
-        if(StringUtils.isNotBlank(record.getStoreName())){
+        if (StringUtils.isNotBlank(record.getStoreName())) {
             whereStr.append(" and cWhName like '%" + record.getStoreName() + "%' ");
         }
         // 存货编码搜索
-        if(StringUtils.isNotBlank(record.getSpareNo())){
+        if (StringUtils.isNotBlank(record.getSpareNo())) {
             whereStr.append(" and cInvCode like '%" + record.getSpareNo() + "%' ");
         }
         // 存货名称搜索
-        if(StringUtils.isNotBlank(record.getSpareName())){
+        if (StringUtils.isNotBlank(record.getSpareName())) {
             whereStr.append(" and cInvName like '%" + record.getSpareName() + "%' ");
         }
         // 规格型号搜索
-        if(StringUtils.isNotBlank(record.getGgxh())){
+        if (StringUtils.isNotBlank(record.getGgxh())) {
             whereStr.append(" and cInvStd like '%" + record.getGgxh() + "%' ");
         }
         req.setStrWhere(whereStr.toString());
         handler.setRequest(req);
         String responseStr = handler.handler();
         GetCurrentStockResponse response = JSONObject.parseObject(responseStr, GetCurrentStockResponse.class);
-        if(!response.getResult()){
+        if (!response.getResult()) {
             throw new BusinessException(response.getMsg());
         }
         GetCurrentStockResponseData data = response.getData();
@@ -210,22 +212,22 @@ public class YongyouServiceImpl implements YongyouService {
         req.setPageSize(pageSize);
         StringBuffer ccode = new StringBuffer(" 1=1 ");
         // 存货编码搜索
-        if(StringUtils.isNotBlank(record.getNo())){
+        if (StringUtils.isNotBlank(record.getNo())) {
             ccode.append(" and cInvCode like '%" + record.getNo() + "%' ");
         }
         // 存货名称搜索
-        if(StringUtils.isNotBlank(record.getName())){
+        if (StringUtils.isNotBlank(record.getName())) {
             ccode.append(" and cInvName like '%" + record.getName() + "%' ");
         }
         // 规格型号搜索
-        if(StringUtils.isNotBlank(record.getGgxh())){
+        if (StringUtils.isNotBlank(record.getGgxh())) {
             ccode.append(" and cInvStd like '%" + record.getGgxh() + "%' ");
         }
         req.setCcode(ccode.toString());
         handler.setRequest(req);
         String responseStr = handler.handler();
         GetInventoryListResponse response = JSONObject.parseObject(responseStr, GetInventoryListResponse.class);
-        if(!response.getResult()){
+        if (!response.getResult()) {
             throw new BusinessException(response.getMsg());
         }
         GetInventoryListResponseData data = response.getData();
@@ -257,9 +259,10 @@ public class YongyouServiceImpl implements YongyouService {
      * 提交出库单到用友
      *
      * @param id 领用单id
+     * @param id fromActivity是否从审批流过来的,审批过来,返回用友处理结果,否则直接更新结果
      */
     @Override
-    public void addOutForm(String id) {
+    public OtherOutAddResponse addOutForm(String id, boolean fromActivity) {
         OutStoreFormVO outStoreFormVO = outStoreFormService.getDetail(id);
         OtherOutVouch otherOutVouch = new OtherOutVouch();
         OtherOutMain otherOutMain = new OtherOutMain();
@@ -283,9 +286,9 @@ public class YongyouServiceImpl implements YongyouService {
             OtherOutDetail detail = new OtherOutDetail();
             detail.setId(vo.getSpareId());
             detail.setCinvcode(vo.getNo());
-            if(vo.getIsOut()){
+            if (vo.getIsOut()) {
                 detail.setIquantity(vo.getNum());
-            }else{// 负数为退库
+            } else {// 负数为退库
                 detail.setIquantity(vo.getNum().negate());
             }
             // detail.setIunitcost(vo.getPrice());
@@ -306,14 +309,18 @@ public class YongyouServiceImpl implements YongyouService {
         handler.setRequest(req);
         String responseStr = handler.handler();
         OtherOutAddResponse response = JSONObject.parseObject(responseStr, OtherOutAddResponse.class);
-        if(!response.getResult()){
-            outStoreFormService.updateModelByIdYongyouError(outStoreFormVO.getId(), response.getMsg());
-            throw new BusinessException(response.getMsg());
+        if (fromActivity) {//
+            return response;
+        } else {
+            if (!response.getResult()) {
+                outStoreFormService.updateModelByIdYongyouError(outStoreFormVO.getId(), response.getMsg());
+                throw new BusinessException(response.getMsg());
+            }
+            String data = response.getData();
+            // 保存用友出库单数据
+            outStoreFormService.updateModelByIdYongyou(outStoreFormVO.getId(), data);
+            return response;
         }
-        String data = response.getData();
-
-        // 保存用友出库单数据
-        outStoreFormService.updateModelByIdYongyou(outStoreFormVO.getId(), data);
     }
 
     /**
@@ -327,8 +334,8 @@ public class YongyouServiceImpl implements YongyouService {
         String id = (String) jsonObject.get("id");
         Integer status = (Integer) jsonObject.get("status");
         String time = (String) jsonObject.get("time");
-        List<Map<String, String>> detailList =  jsonObject.getObject("detailList", List.class);
-        for (Map<String, String> next: detailList ) {
+        List<Map<String, String>> detailList = jsonObject.getObject("detailList", List.class);
+        for (Map<String, String> next : detailList) {
             // spareId = next.getString("spareId");
             String spareNum = next.get("spareNum");
             String detailId = next.get("detailId");