Преглед на файлове

Merge branch 'master' of http://111.75.220.136:10030/turborao/jyyy

Tyx преди 1 ден
родител
ревизия
b5ce4613b2

+ 11 - 4
code/jyyy/nckd-jimin-jyyy-bd/src/main/java/nckd/jimin/jyyy/bd/common/oauth/FanWeiUtils.java

@@ -31,6 +31,8 @@ public class FanWeiUtils {
             String param_code_url = mapentity.get("getcode");
             String param_token_url = mapentity.get("gettoken");
             String post_getspeaker_url = mapentity.get("getspeaker");
+            String param_secretkey = mapentity.get("secret_key");
+            String param_operator = mapentity.get("operator");
 
             if( StringUtils.isEmpty(param_corpid) || StringUtils.isEmpty(param_app_secret)
                     || StringUtils.isEmpty(param_code_url) || StringUtils.isEmpty(param_token_url)
@@ -92,8 +94,13 @@ public class FanWeiUtils {
                     speakerUrl.append(post_url);
                     speakerUrl.append("?access_token=");
                     speakerUrl.append(tokenString);
-                    String speakerJsonData = getSpeakerData();
-                    logger.info("请求SAP 接口:" + speakerUrl.toString() );
+                    speakerUrl.append("&secret_key=");
+                    speakerUrl.append(param_secretkey);
+
+                    String speakerJsonData = getSpeakerData(param_operator);
+                    logger.info("请求SAP 接口:" + speakerUrl.toString());
+                    logger.info("请求SAP data:" + speakerJsonData);
+
                     String result = KHttpClientUtils.postjson(speakerUrl.toString(), header, speakerJsonData);
                     logger.info("请求SAP Speaker Return:" + result);
                     return result;
@@ -107,7 +114,7 @@ public class FanWeiUtils {
         }
     }
 
-    public static String getSpeakerData()
+    public static String getSpeakerData(String operator)
     {
         // 构建 requestHead 对象
         JSONObject requestHead = new JSONObject();
@@ -120,7 +127,7 @@ public class FanWeiUtils {
 
         // 构建 header 对象
         JSONObject header = new JSONObject();
-        header.put("operator", "037267");
+        header.put("operator", operator);
 
         // 构建 datajson 对象
         JSONObject datajsonParent = new JSONObject();

+ 101 - 70
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/business/DiDiTripUserCusInvoke.java

@@ -3,6 +3,19 @@ package nckd.jimin.jyyy.fi.business;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 import kd.bos.dataentity.RefObject;
 import kd.bos.dataentity.entity.DynamicObject;
 import kd.bos.dataentity.entity.DynamicObjectCollection;
@@ -21,20 +34,19 @@ import kd.fi.er.business.trip.exception.TripSyncLogParam;
 import kd.fi.er.business.trip.model.TripSyncDataMappingModel;
 import kd.fi.er.business.trip.service.function.AbstractUserInvoke;
 import kd.fi.er.business.trip.supplier.Supplier;
-import kd.fi.er.business.trip.supplier.didi.invoke.DiDiTripUserInvoke;
 import kd.fi.er.business.trip.supplier.didi.systemexternal.DiDiOrgAndUserInvokeUtil;
 import kd.fi.er.business.trip.supplier.didi.systemexternal.DiDiServiceUtil;
-import kd.fi.er.business.trip.util.*;
+import kd.fi.er.business.trip.util.SyncUserTypeEnum;
+import kd.fi.er.business.trip.util.TripCommonUtil;
+import kd.fi.er.business.trip.util.TripSyncConfigUtil;
+import kd.fi.er.business.trip.util.TripSyncDataMappingUtil;
+import kd.fi.er.business.trip.util.UserHelper;
 import kd.fi.er.business.utils.ErCommonUtils;
 import kd.fi.er.business.utils.ErCostCenterUtil;
 import kd.fi.er.business.utils.TripUserGrantUtils;
 import kd.fi.er.common.ExternalConstants;
 import kd.hrmp.hrpi.business.infrastructure.utils.QFilterUtil;
 import org.apache.commons.lang3.StringUtils;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collector;
-import java.util.stream.Collectors;
 
 /**
  * 滴滴人员同步
@@ -120,7 +132,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
             String signKey = (String)supplierMap.get("reservedfield1");
             String access_token = DiDiServiceUtil.getCacheToken(new Date());
             if (access_token == null) {
-                this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,获取滴滴token为空,请检查配置!", "DiDiTripUserInvoke_1", "fi-er-business", new Object[0]));
+                this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,获取滴滴Token为空,请检查配置。", "DiDiTripUserInvoke_1", "fi-er-business", new Object[0]));
                 this.tripSyncLogParam.setStatus("B");
                 return null;
             } else {
@@ -139,7 +151,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
         } else {
             SyncUserTypeEnum userTypeEnum = UserHelper.getSyncType(map);
             if (pageIndex == 1 && userTypeEnum != SyncUserTypeEnum.SYNC_BY_USER) {
-                this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,全量更新,人员为空,请检查人员信息!", "DiDiTripUserInvoke_0", "fi-er-business", new Object[0]));
+                this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,全量更新,人员为空,请检查人员信息。", "DiDiTripUserInvoke_0", "fi-er-business", new Object[0]));
             }
 
             return null;
@@ -157,6 +169,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
         userDataJsonObject.put("realname", name);
         userDataJsonObject.put("employee_number", number);
 
+        //二开逻辑,增加base地
         String baseCity = getBaseCity(number.toString());
         userDataJsonObject.put("residentsname", baseCity);
 
@@ -190,6 +203,10 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
 
         JSONObject extJson = new JSONObject();
         extJson.put("deptId", dptId);
+
+        //二开逻辑,增加参数【客户部门CODE】
+        extJson.put("out_budget_id", dptId);
+
         if (null != companyId) {
             extJson.put("companyId", companyId);
         }
@@ -259,6 +276,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
             userDataJsonObject.put("realname", name);
             userDataJsonObject.put("employee_number", number);
 
+            //二开逻辑,增加base地
             String baseCity = getBaseCity(number.toString());
             userDataJsonObject.put("residentsname", baseCity);
 
@@ -294,48 +312,6 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
         delUserList.add(delUserObj);
     }
 
-    /**
-     * 获取base地
-     * @param employeeNumber
-     * @return
-     */
-    private String getBaseCity(Object employeeNumber){
-        String baseCity = "";
-
-        if (employeeNumber != null) {
-            QFilter statusFilter = QFilterUtil.getCurrentQf();
-            statusFilter.and(QFilterUtil.getDataStatusFilter());
-
-            QFilter qFilter = new QFilter("number", "=", employeeNumber);
-            qFilter.and(statusFilter);
-
-            DynamicObject hrPerson = BusinessDataServiceHelper.loadSingleFromCache("hrpi_person", "id", qFilter.toArray());
-            if (hrPerson == null) {
-                logger.info("根据员工number未获取到HR人员基本信息{}", employeeNumber);
-                return "";
-            }
-            if(hrPerson != null){
-                DynamicObject baseLocation = QueryServiceHelper.queryOne("hrpi_baselocation", "location.city.id", new QFilter[]{
-                        new QFilter("person", QCP.equals, hrPerson.getLong("id")),
-                        new QFilter("iscurrentversion", QCP.equals, Boolean.TRUE)
-                });
-
-                if(baseLocation != null){
-                    Long cityId = baseLocation.getLong("location.city.id");
-                    DynamicObject admind = QueryServiceHelper.queryOne("bd_admindivision", "name",
-                            new QFilter("id", QCP.equals, cityId).toArray());
-                    // 查询行政区划名称
-                    if(admind != null) {
-                        baseCity = admind.getString("name");
-                    }
-                }
-            }
-        } else {
-            logger.info("未获取到员工{}", employeeNumber);
-        }
-        return baseCity;
-    }
-
     private Map<String, JSONArray> getChangedUserMap(String changeTime, Integer pageIndex, Integer pageSize, Map<Object, Object> dataOrgMappingMap, Map<String, Object> map) {
         Date changeDate = TripCommonUtil.convertToDate(changeTime);
         List<Map<String, Object>> userChangeInfos = UserHelper.getUserInfosByTimeNew(pageIndex, pageSize, changeDate, map);
@@ -392,6 +368,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
                 }
             }
 
+            new ArrayList();
             JSONArray delUserList = new JSONArray();
             List<Map<String, Object>> delUserChangeInfos = (List)maxTimeUserChangeInfos.stream().filter((userChangeDO) -> {
                 return userChangeDO.get("number") != null && (null != userChangeDO.get("enable") && "0".equals(userChangeDO.get("enable").toString()) || null != userChangeDO.get("isforbidden") && "true".equals(userChangeDO.get("isforbidden").toString()));
@@ -440,7 +417,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
             return postUserMap;
         } else {
             if (pageIndex == 1) {
-                this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空!", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
+                this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空。", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
             }
 
             return null;
@@ -460,7 +437,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
                 String url = "";
                 switch (syncKey) {
                     case "add":
-                        url = (String) ExternalConstants.DIDIURLMAP.get("memberSingleKey");
+                        url = (String)ExternalConstants.DIDIURLMAP.get("memberSingleKey");
                         break;
                     case "edit":
                         url = (String)ExternalConstants.DIDIURLMAP.get("memberEditKey");
@@ -498,7 +475,7 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
                 code = "300";
             }
 
-            this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空!", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
+            this.tripSyncLogParam.setMessage(ResManager.loadKDString("商旅集成,差量更新,差量人员为空。", "DiDiTripUserInvoke_2", "fi-er-business", new Object[0]));
             return code;
         }
     }
@@ -514,34 +491,46 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
             switch (paramValue) {
                 case 0:
                 case 2:
-                    budgetCenterId = dataOrgMappingMap.get(dptId);
+                    budgetCenterId = dataOrgMappingMap.get(Long.parseLong(dptId.toString()));
                     break;
                 case 1:
-                    DynamicObject userInfo = BusinessDataServiceHelper.loadSingle("bos_user", "id,number,entryentity.dpt,entryentity.ispartjob,entryentity.id", new QFilter[]{new QFilter("id", "=", Long.parseLong(userId.toString()))});
-                    if (userInfo != null) {
-                        DynamicObjectCollection entryEntity = userInfo.getDynamicObjectCollection("entryentity");
-                        int size = entryEntity.size();
-
-                        for(int i = 0; i < size; ++i) {
-                            DynamicObject dynamicObject = (DynamicObject)entryEntity.get(i);
-                            boolean ispartjob = dynamicObject.getBoolean("ispartjob");
-                            if (!ispartjob) {
-                                Long id = ErCommonUtils.getPk(dynamicObject.get("dpt"));
-                                Long companyId = CoreBaseBillServiceHelper.initCompanyByDept(id);
-                                budgetCenterId = dataOrgMappingMap.get(companyId);
-                            }
-                        }
-                    }
+                    budgetCenterId = defaultDeal(dataOrgMappingMap, userId, budgetCenterId);
                     break;
                 case 3:
                     Long accountOrgId = CoreBaseBillServiceHelper.getAccountOrgId(Long.parseLong(dptId.toString()));
-                    budgetCenterId = dataOrgMappingMap.get(accountOrgId);
+                    if (accountOrgId == null) {
+                        defaultDeal(dataOrgMappingMap, userId, budgetCenterId);
+                    } else {
+                        budgetCenterId = dataOrgMappingMap.get(accountOrgId);
+                    }
             }
 
             userDataJsonObject.put("budget_center_id", budgetCenterId);
         }
     }
 
+    private static Object defaultDeal(Map<Object, Object> dataOrgMappingMap, Object userId, Object budgetCenterId) {
+        DynamicObject userInfo = BusinessDataServiceHelper.loadSingle("bos_user", "id,number,entryentity.dpt,entryentity.ispartjob,entryentity.id", new QFilter[]{new QFilter("id", "=", Long.parseLong(userId.toString()))});
+        if (userInfo == null) {
+            return budgetCenterId;
+        } else {
+            DynamicObjectCollection entryEntity = userInfo.getDynamicObjectCollection("entryentity");
+            int size = entryEntity.size();
+
+            for(int i = 0; i < size; ++i) {
+                DynamicObject dynamicObject = (DynamicObject)entryEntity.get(i);
+                boolean ispartjob = dynamicObject.getBoolean("ispartjob");
+                if (!ispartjob) {
+                    Long id = ErCommonUtils.getPk(dynamicObject.get("dpt"));
+                    Long companyId = CoreBaseBillServiceHelper.initCompanyByDept(id);
+                    budgetCenterId = dataOrgMappingMap.get(companyId);
+                }
+            }
+
+            return budgetCenterId;
+        }
+    }
+
     private Integer getUseCompanyMoney() {
         return TripSyncConfigUtil.getBoolean("dtrip_use_company_money") ? 1 : 0;
     }
@@ -591,5 +580,47 @@ public class DiDiTripUserCusInvoke extends AbstractUserInvoke<Set<JSONObject>> {
             }
         }
     }
+
+    /**
+     * 获取base地,二开方法
+     * @param employeeNumber
+     * @return
+     */
+    private String getBaseCity(Object employeeNumber){
+        String baseCity = "";
+
+        if (employeeNumber != null) {
+            QFilter statusFilter = QFilterUtil.getCurrentQf();
+            statusFilter.and(QFilterUtil.getDataStatusFilter());
+
+            QFilter qFilter = new QFilter("number", "=", employeeNumber);
+            qFilter.and(statusFilter);
+
+            DynamicObject hrPerson = BusinessDataServiceHelper.loadSingleFromCache("hrpi_person", "id", qFilter.toArray());
+            if (hrPerson == null) {
+                logger.info("根据员工number未获取到HR人员基本信息{}", employeeNumber);
+                return "";
+            }
+            if(hrPerson != null){
+                DynamicObject baseLocation = QueryServiceHelper.queryOne("hrpi_baselocation", "location.city.id", new QFilter[]{
+                        new QFilter("person", QCP.equals, hrPerson.getLong("id")),
+                        new QFilter("iscurrentversion", QCP.equals, Boolean.TRUE)
+                });
+
+                if(baseLocation != null){
+                    Long cityId = baseLocation.getLong("location.city.id");
+                    DynamicObject admind = QueryServiceHelper.queryOne("bd_admindivision", "name",
+                            new QFilter("id", QCP.equals, cityId).toArray());
+                    // 查询行政区划名称
+                    if(admind != null) {
+                        baseCity = admind.getString("name");
+                    }
+                }
+            }
+        } else {
+            logger.info("未获取到员工{}", employeeNumber);
+        }
+        return baseCity;
+    }
 }
 

+ 1 - 1
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/PayApplyBillSRMEditPlugin.java

@@ -19,7 +19,7 @@ import java.util.Map;
 
 /**
  * 对公报销单(nckd_er_publicreimbur_ext)、预付单
- * 由srm系统产生的单据,退回srm操作
+ * 由srm系统产生的单据,联查SRM
  * @author wanghaiwu_kd
  * @date 2025/05/15
  */

+ 80 - 0
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/PayApplyBillSRMListPlugin.java

@@ -0,0 +1,80 @@
+package nckd.jimin.jyyy.fi.plugin.form;
+
+import com.alibaba.druid.util.StringUtils;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.entity.datamodel.ListSelectedRow;
+import kd.bos.form.IClientViewProxy;
+import kd.bos.form.events.BeforeDoOperationEventArgs;
+import kd.bos.form.operate.AbstractOperate;
+import kd.bos.list.ListShowParameter;
+import kd.bos.list.plugin.AbstractListPlugin;
+import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.QueryServiceHelper;
+import nckd.jimin.jyyy.fi.plugin.operate.SRMHelperUtils;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * 对公报销单(nckd_er_publicreimbur_ext)、预付单
+ * 由srm系统产生的单据,退回srm操作
+ * @author wanghaiwu_kd
+ * @date 2025/05/15
+ */
+public class PayApplyBillSRMListPlugin extends AbstractListPlugin {
+
+    @Override
+    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
+        super.beforeDoOperation(args);
+        Object source = args.getSource();
+        String opKey = ((AbstractOperate)source).getOperateKey();
+
+        Set<Long> selectedDatas = (Set)args.getListSelectedData().stream().map((data) -> {
+            return (Long)data.getPrimaryKeyValue();
+        }).collect(Collectors.toSet());
+
+        if(StringUtils.equals("nckd_ssosrm", opKey)){
+            if (selectedDatas.size() > 1 || selectedDatas.size() == 0) {
+                this.getView().showTipNotification(ResManager.loadKDString("仅支持选择单条记录联查", "TripReqBillList_7", "fi-er-formplugin", new Object[0]));
+                args.setCancel(true);
+                return;
+            } else {
+                if (selectedDatas.size() == 1) {
+                    ListSelectedRow row = args.getListSelectedData().get(0);
+                    String entityName = ((ListShowParameter)this.getView().getFormShowParameter()).getBillFormId();
+                    DynamicObject objcetInfo = QueryServiceHelper.queryOne(entityName, "nckd_srmurl", new QFilter[]{new QFilter("id", "=", row.getPrimaryKeyValue())});
+                    if (StringUtils.isEmpty(objcetInfo.getString("nckd_srmurl"))) {
+                        this.getView().showTipNotification(ResManager.loadKDString("不是SRM生成的单据,不能单点到SRM系统", "TripReqBillList_11", "fi-er-formplugin", new Object[0]));
+                        args.setCancel(true);
+                        return;
+                    } else {
+                        openSRMSSOLink(objcetInfo.getString("nckd_srmurl"));
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 单点登录到srm系统
+     */
+    public void openSRMSSOLink(String ssourl){
+        Map<String, String> returnMap = SRMHelperUtils.buildSSOUrl(ssourl);
+
+        if(returnMap != null){
+            if("0".equals(returnMap.get("code"))) {
+                ssourl = returnMap.get("msg");
+                IClientViewProxy proxy = this.getView().getService(IClientViewProxy.class);
+                Map<String, String> mpUrl = new HashMap();
+                mpUrl.put("url", ssourl);
+                proxy.addAction("openUrl", mpUrl);
+            } else {
+                this.getView().showTipNotification(returnMap.get("msg"));
+            }
+        } else {
+            this.getView().showTipNotification("获取单点url失败");
+        }
+    }
+}