yaozhixue 2 years ago
parent
commit
56c73e0632

+ 6 - 0
src/main/java/com/zfire/jiasm/syncdata/plus/entity/BrandWebsit.java

@@ -36,6 +36,12 @@ public class BrandWebsit extends Model<BrandWebsit> {
     @ApiModelProperty(value = "品牌方网点的主键id")
     private String brandPkId;
 
+    @ApiModelProperty(value = "公司id")
+    private Integer belongCompanyId;
+
+    @ApiModelProperty(value = "所属销售公司")
+    private String belongCompany;
+
     @ApiModelProperty(value = "网点类型 S=售后网点  X=销售网点")
     private String type;
 

+ 35 - 9
src/main/java/com/zfire/jiasm/syncdata/task/GLPPGFWebsitTask.java

@@ -1,5 +1,6 @@
 package com.zfire.jiasm.syncdata.task;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -7,14 +8,8 @@ import com.zfire.jiasm.syncdata.constant.BrandWebsitStatEnum;
 import com.zfire.jiasm.syncdata.constant.DictTypeEnum;
 import com.zfire.jiasm.syncdata.constant.InterFaceTypeEnum;
 import com.zfire.jiasm.syncdata.data.Token;
-import com.zfire.jiasm.syncdata.plus.entity.Brand;
-import com.zfire.jiasm.syncdata.plus.entity.BrandWebsit;
-import com.zfire.jiasm.syncdata.plus.entity.ItfTblXinWangdianDownload;
-import com.zfire.jiasm.syncdata.plus.entity.SysDict;
-import com.zfire.jiasm.syncdata.plus.service.BrandService;
-import com.zfire.jiasm.syncdata.plus.service.BrandWebsitService;
-import com.zfire.jiasm.syncdata.plus.service.ItfTblXinWangdianDownloadService;
-import com.zfire.jiasm.syncdata.plus.service.SysDictService;
+import com.zfire.jiasm.syncdata.plus.entity.*;
+import com.zfire.jiasm.syncdata.plus.service.*;
 import com.zfire.jiasm.syncdata.utils.HttpUtil;
 import com.zfire.jiasm.syncdata.utils.JSONResult;
 import com.zfire.jiasm.syncdata.utils.TokenCenter;
@@ -51,6 +46,8 @@ public class GLPPGFWebsitTask {
     BrandWebsitService brandWebsitService;
     @Resource
     SysDictService sysDictService;
+    @Resource
+    BelongcompanyService belongcompanyService;
 
 
 
@@ -288,11 +285,23 @@ public class GLPPGFWebsitTask {
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_MAIN_TYPE.getCode()).list();
 
+        // 取门户对应关系
+        List<Belongcompany> bcs =   belongcompanyService.lambdaQuery()
+                .select(Belongcompany::getId,Belongcompany::getBelongCompanySale,Belongcompany::getBelongCompanyProfession).list();
+        Map<String, List<Belongcompany>> bMap = bcs.stream().collect(Collectors.groupingBy(Belongcompany::getBelongCompanySale));
+        Map<String, List<Belongcompany>> bcMap = bcs.stream().collect(Collectors.groupingBy(Belongcompany::getBelongCompanyProfession));
+        bMap.forEach((k, v) -> bcMap.merge(k, v, (v1, v2) -> v2));
+        List<String> bcsaList = new ArrayList<>();
+        List<String> bcsList = new ArrayList<>();
+        bcsaList = bcs.stream().map(Belongcompany::getBelongCompanySale).collect(Collectors.toList());
+        bcsList = bcs.stream().map(Belongcompany::getBelongCompanyProfession).collect(Collectors.toList());
+        bcsList.addAll(bcsaList);
+
+
         for (SysDict item :oldSysDictRec){
             oldSysDictRecMap.put(item.getDictCode(),item.getDictValue());
         }
 
-
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblXinWangdianDownload item : addRec){
@@ -303,6 +312,12 @@ public class GLPPGFWebsitTask {
                 if (InterFaceTypeEnum.SH_WEBSIT_TYPE.getCode().equals("S")){
                     v.setFwlm("家电售后");
                 }
+                if (BeanUtil.isNotEmpty(item.getSsxsgs())){
+                    if (bcsList.contains(item.getSsxsgs())){
+                        v.setBelongCompanyId(bcMap.get(item.getSsxsgs()).get(0).getId());
+                    }
+                    v.setBelongCompany(item.getSsxsgs());
+                }
 
                 v.setBrandWebsitId(UUID.randomUUID().toString());
                 v.setBrandPkId(item.getPkGuid());
@@ -342,6 +357,17 @@ public class GLPPGFWebsitTask {
                 flag = Boolean.FALSE;
                 BrandWebsit old = oldWebsitRecMap.get(item.getPkGuid()).get(0);
 
+                if (item.getSsxsgs() != null ){
+                    if (!old.getBelongCompany().equals(item.getSsxsgs())){
+                        old.setBelongCompanyId(0);
+                        if (bcsList.contains(item.getSsxsgs())){
+                            old.setBelongCompanyId(bcMap.get(item.getSsxsgs()).get(0).getId());
+                        }
+                        old.setBelongCompany(item.getSsxsgs());
+                        flag = Boolean.TRUE;
+                    }
+                }
+
                 if (!old.getSysWebsitNumber().equals(item.getXtwdbh())){
                     old.setSysWebsitNumber(item.getXtwdbh());
                     flag = Boolean.TRUE;