瀏覽代碼

建行接口

sunhz 3 年之前
父節點
當前提交
b65115c331

+ 12 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/CcbConstants.java

@@ -0,0 +1,12 @@
+package com.ruoyi.common.constant;
+
+
+public class CcbConstants {
+
+    public static final String IN_URL = "https://in";
+
+    public static final String OUT_URL = "https://out";
+
+    public static final String SUCCESS = "Y";
+
+}

+ 11 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehousebillsitemsElabelMapper.java

@@ -51,4 +51,15 @@ public interface TWarehousebillsitemsElabelMapper {
      * 获取电子标签
      */
     List<String> getLabel(String billNo);
+
+    /**
+     * 获取电子标签
+     */
+    List<String> getLabelByTop(Long topId);
+
+    /**
+     * 获取电子标签
+     */
+    List<String> getLabelByPid(Long pid);
+
 }

+ 132 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.warehouseBusiness.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -15,6 +16,7 @@ import com.ruoyi.basicData.domain.*;
 import com.ruoyi.basicData.mapper.*;
 import com.ruoyi.basicData.service.impl.TWarehouseServiceImpl;
 import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.CcbConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysDictData;
@@ -67,6 +69,9 @@ import com.ruoyi.warehouseBusiness.excel.*;
 import com.ruoyi.warehouseBusiness.mapper.*;
 import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
 import lombok.AllArgsConstructor;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
@@ -4192,6 +4197,70 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         map.put("fDateChanged", tWarehouseBills.getfDateChanged());
         map.put("warehousebills", tWarehouseBills);
         map.put("warehousebillsitems", warehousebillsitemsList);
+
+        // 处理银行反馈
+        if (WarehouseTypeEnum.SJRK.getType().equals(billsType)) {
+            SysConfig feedbackConfig = sysConfigMapper.checkConfigKeyUnique("bank.feedback");
+            if (ObjectUtil.isNotNull(feedbackConfig) && "0".equals(feedbackConfig.getConfigValue())) {
+                // 出入库不同处理
+                TCorps corp = tCorpsMapper.selectTCorpsById(tWarehouseBills.getfCorpid());
+                if (ObjectUtil.isNull(corp)) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("请求银行反馈异常,未找到客户");
+                }
+
+                JSONObject json = new JSONObject();
+                json.put("userName", corp.getfCname());
+                json.put("uscc", corp.getUscc());
+                json.put("reqUser", corp.getfCname());
+
+                List<Map<String, Object>> stockList = tWhgenlegMapper.selectStockList(tWarehouseBills.getfBillno(), tWarehouseBills.getfCorpid());
+                if (CollectionUtil.isEmpty(stockList)) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("请求银行反馈异常,未找到库存");
+                }
+
+                JSONArray array = new JSONArray();
+                stockList.forEach(detail -> {
+                    detail.put("numberUnit", "件");
+                    detail.put("weightUnit", "千克");
+                    detail.put("cargoBelong", corp.getfCname());
+                    detail.put("inStorageNumber", detail.get("takeVoucher"));
+                    detail.put("remainNumber", detail.get("numberLeft"));
+                    detail.put("remainWeight", detail.get("weightLeft"));
+                    detail.put("electronicTags", warehousebillsitemsElabelMapper.getLabelByTop(tWarehouseBills.getfId()));
+
+                    JSONObject temp = new JSONObject();
+                    json.put("cargo", temp);
+                    json.put("result", "Y");
+                    array.add(temp);
+                });
+
+                json.put("cargoInResults", array);
+
+                OkHttpClient okHttpClient = new OkHttpClient();
+                Request request = new Request.Builder()
+                        .addHeader("content-type", "application/json")
+                        .url(CcbConstants.IN_URL)
+                        .post(RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json.toString()))
+                        .build();
+
+                String s;
+                try {
+                    s = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+                } catch (IOException e) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("请求银行反馈异常," + e.getMessage());
+                }
+
+                JSONObject result = JSON.parseObject(s);
+                if (!CcbConstants.SUCCESS.equals(result.getString("result"))) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("请求银行反馈失败," + result.getString("reason"));
+                }
+            }
+        }
+
         return AjaxResult.success("成功", map);
     }
 
@@ -4450,6 +4519,69 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("库存明细更新失败");
             }
+
+            // 处理银行反馈
+            if (WarehouseTypeEnum.SJCK.getType().equals(billsType)) {
+                SysConfig feedbackConfig = sysConfigMapper.checkConfigKeyUnique("bank.feedback");
+                if (ObjectUtil.isNotNull(feedbackConfig) && "0".equals(feedbackConfig.getConfigValue())) {
+                    // 出入库不同处理
+                    TCorps corp = tCorpsMapper.selectTCorpsById(tWhgenle.getfCorpid());
+                    if (ObjectUtil.isNull(corp)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("请求银行反馈异常,未找到客户");
+                    }
+
+                    JSONObject json = new JSONObject();
+                    json.put("userName", corp.getfCname());
+                    json.put("uscc", corp.getUscc());
+                    json.put("reqUser", corp.getfCname());
+
+                    List<Map<String, Object>> stockList = tWhgenlegMapper.selectStockList(tWhgenle.getfOriginalbillno(), tWhgenle.getfCorpid());
+                    if (CollectionUtil.isEmpty(stockList)) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("请求银行反馈异常,未找到库存");
+                    }
+
+                    JSONArray array = new JSONArray();
+                    stockList.forEach(detail -> {
+                        detail.put("numberUnit", "件");
+                        detail.put("weightUnit", "千克");
+                        detail.put("cargoBelong", corp.getfCname());
+                        detail.put("inStorageNumber", detail.get("takeVoucher"));
+                        detail.put("remainNumber", detail.get("numberLeft"));
+                        detail.put("remainWeight", detail.get("weightLeft"));
+                        detail.put("electronicTags", warehousebillsitemsElabelMapper.getLabelByPid(wbItem.getfId()));
+
+                        JSONObject temp = new JSONObject();
+                        json.put("cargo", temp);
+                        json.put("result", "Y");
+                        array.add(temp);
+                    });
+
+                    json.put("cargoInResults", array);
+
+                    OkHttpClient okHttpClient = new OkHttpClient();
+                    Request request = new Request.Builder()
+                            .addHeader("content-type", "application/json")
+                            .url(CcbConstants.OUT_URL)
+                            .post(RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json.toString()))
+                            .build();
+
+                    String s;
+                    try {
+                        s = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+                    } catch (IOException e) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("请求银行反馈异常," + e.getMessage());
+                    }
+
+                    JSONObject result = JSON.parseObject(s);
+                    if (!CcbConstants.SUCCESS.equals(result.getString("result"))) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("请求银行反馈失败," + result.getString("reason"));
+                    }
+                }
+            }
         }
         //  箱型数据
         if (StringUtils.isNotNull(tCntr) && !"[]".equals(tCntr)) {

+ 1 - 1
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -1385,7 +1385,7 @@
         </where>
     </select>
 
-    <select id="selectStockList" parameterType="TWhgenleg" resultType="Map">
+    <select id="selectStockList" resultType="Map">
         select
                t3.dict_label as cargoType,
                t2.f_no as cargoNo,

+ 14 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsElabelMapper.xml

@@ -163,4 +163,18 @@
             left join t_whgenleg t2 on t2.f_id = t1.f_pid
         where t2.f_originalbillno = #{billNo} and t1.f_type = 3 and t1.f_status = 0
     </select>
+
+    <select id="getLabelByTop" parameterType="string" resultType="string">
+        select t1.f_content
+        from t_warehousebillsitems_elabel t1
+                 left join t_warehousebills t2 on t2.f_id = t1.f_g_pid
+        where t1.f_g_pid = #{topId}
+    </select>
+
+    <select id="getLabelByPid" parameterType="string" resultType="string">
+        select t1.f_content
+        from t_warehousebillsitems_elabel t1
+                 left join t_warehousebillsitems t2 on t2.f_id = t1.f_pid
+        where t1.f_pid = #{pid}
+    </select>
 </mapper>