yaozhixue il y a 1 an
Parent
commit
ca143a31a0

+ 3 - 3
src/main/java/com/zfire/jiasm/syncdata/service/impl/BaseDownServiceImpl.java

@@ -213,7 +213,7 @@ public class BaseDownServiceImpl implements BaseDownService {
 
                 JSONArray jsonArray = (JSONArray) jsonResult.getData();
                 if (jsonArray != null) {
-                    log.info("下载了{}条数据",jsonArray.size());
+                    log.info("格力品牌用户属性信息下载了{}条数据",jsonArray.size());
 
                     if (bc.equals(InterFaceTypeEnum.GLPP_YHSX.getCode())){
                         glppyhsxxxqdService.extractedYHSX(jsonArray);
@@ -274,7 +274,7 @@ public class BaseDownServiceImpl implements BaseDownService {
                 JSONArray jsonArray = (JSONArray) jsonResult.getData();
 
                 if (jsonArray != null) {
-                    log.info("下载了{}条数据",jsonArray.size());
+                    log.info("格力品牌需求类别下载了{}条数据",jsonArray.size());
 
                     if (bc.equals(InterFaceTypeEnum.GELI_XQDL.getCode())){
                         glppXuQiuLeiBieService.extractedXQDL(brandRec,jsonArray);
@@ -318,7 +318,7 @@ public class BaseDownServiceImpl implements BaseDownService {
         if (jsonArray != null) {
             log.info("格力品牌安装销售类型下载了{}条数据",jsonArray.size());
 
-            log.info("格力品牌安装销售类型下载了{}", JSONObject.toJSONString(jsonArray));
+            // log.info("格力品牌安装销售类型下载了{}", JSONObject.toJSONString(jsonArray));
 
             try{
                 glppxslxDownloadService.extractedXSLX(jsonArray);

+ 6 - 5
src/main/java/com/zfire/jiasm/syncdata/service/impl/GLPPXSLXDownloadServiceImpl.java

@@ -58,20 +58,20 @@ public class GLPPXSLXDownloadServiceImpl implements GLPPXSLXDownloadService {
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAzAssignXslxDowload item : addRec){
-                if (!oldSysDictRecMap.containsKey(String.valueOf(item.getXslxid())) && !sxlxids.contains(item.getXslxid())){
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getXslxid())) || sxlxids.contains(item.getXslxid())){
+                    // 修改
+                    upXslx(updateSysDict, oldSysDictRecMap, item);
+                } else {
                     // 新增
                     addXslx(addSysDict, item);
                     sxlxids.add(item.getXslxid());
-                } else {
-                    // 修改
-                    upXslx(updateSysDict, oldSysDictRecMap, item);
                 }
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAzAssignXslxDowload item : updateRec){
-                if (oldSysDictRecMap.containsKey(String.valueOf(item.getXslxid()))){
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getXslxid())) || sxlxids.contains(item.getXslxid())){
                     // 修改
                     upXslx(updateSysDict, oldSysDictRecMap, item);
                 } else {
@@ -94,6 +94,7 @@ public class GLPPXSLXDownloadServiceImpl implements GLPPXSLXDownloadService {
             log.info("格力品牌安装销售类型本地字典信息表更新修改了{}条数据", updateSysDict.size());
             updateSysDict.clear();
         }
+        sxlxids.clear();
     }
 
     private void upXslx(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblAzAssignXslxDowload item) {

+ 244 - 157
src/main/java/com/zfire/jiasm/syncdata/service/impl/GLPPXuQiuLeiBieServiceImpl.java

@@ -71,9 +71,10 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
 
 
     private void extractedXQXLLocalRefAddOrUpdate(Brand brandRec, List<ItfTblAssignXqxlDowload> addRec, List<ItfTblAssignXqxlDowload> updateRec) {
-        Boolean flag = Boolean.FALSE;
+
         List<SysDictRef> addSysDictRef = new ArrayList<>();
         List<SysDictRef> updateSysDictRef = new ArrayList<>();
+        List<String> dictcodes = new ArrayList<>();
 
         // 提取字典对应关系
         List<SysDictRef> oldSysDictRefRec =  sysDictRefService.lambdaQuery()
@@ -84,47 +85,22 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignXqxlDowload item : addRec){
-                SysDictRef v = new SysDictRef();
-                v.setId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_SMALL_TYPE.getCode());
-                v.setDictCode(String.valueOf(item.getId()));
-                v.setDictValue(item.getLbmc());
-                v.setSortNum(Integer.valueOf(item.getPxdj()));
-                v.setBrandId(brandRec.getBrandId());
-                v.setRefDictCode(String.valueOf(item.getId()));
-                v.setRefDictName(item.getLbmc());
-                v.setCreateTime(new Date());
-                v.setCreateBy("system");
-                addSysDictRef.add(v);
+                if (oldSysDictRefRecMap.containsKey(item.getId()) || dictcodes.contains(item.getId())){
+                    upXqxlRef(updateSysDictRef, oldSysDictRefRecMap, item);
+                } else {
+                    addXqxlRef(brandRec, addSysDictRef, item);
+                    dictcodes.add(String.valueOf(item.getId()));
+                }
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignXqxlDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDictRef v = oldSysDictRefRecMap.get(String.valueOf(item.getId())).get(0);
-                if (!v.getDictValue().equals(item.getLbmc())){
-                    v.setDictValue(item.getLbmc());
-                    flag = Boolean.TRUE;
-                }
-                if (!v.getRefDictName().equals(item.getLbmc())){
-                    v.setRefDictName(item.getLbmc());
-                    flag = Boolean.TRUE;
-                }
-                if (!v.getSortNum().equals(Integer.valueOf(item.getPxdj()))){
-                    v.setSortNum(Integer.valueOf(item.getPxdj()));
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    v.setUpdateBy("system");
-                    v.setUpdateTime(new Date());
-                    if (item.getLastModifiedBy()!=null){
-                        v.setUpdateBy(item.getLastModifiedBy());
-                    }
-                    if (item.getLastModifiedDate()!=null){
-                        v.setUpdateTime(item.getLastModifiedDate());
-                    }
-                    updateSysDictRef.add(v);
+                if (oldSysDictRefRecMap.containsKey(item.getId()) || dictcodes.contains(item.getId())){
+                    upXqxlRef(updateSysDictRef, oldSysDictRefRecMap, item);
+                } else {
+                    addXqxlRef(brandRec, addSysDictRef, item);
+                    dictcodes.add(String.valueOf(item.getId()));
                 }
             }
         }
@@ -139,72 +115,83 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
             sysDictRefService.updateBatchById(updateSysDictRef);
             log.info("本地字典对应关系信息表更新修改了{}条数据", updateSysDictRef.size());
         }
+        dictcodes.clear();
+    }
+
+    private void upXqxlRef(List<SysDictRef> updateSysDictRef, Map<String, List<SysDictRef>> oldSysDictRefRecMap, ItfTblAssignXqxlDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDictRef v = oldSysDictRefRecMap.get(item.getId()).get(0);
+        if (!v.getDictValue().equals(item.getLbmc())){
+            v.setDictValue(item.getLbmc());
+            flag = Boolean.TRUE;
+        }
+        if (!v.getRefDictName().equals(item.getLbmc())){
+            v.setRefDictName(item.getLbmc());
+            flag = Boolean.TRUE;
+        }
+        if (!v.getSortNum().equals(Integer.valueOf(item.getPxdj()))){
+            v.setSortNum(Integer.valueOf(item.getPxdj()));
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            v.setUpdateBy("system");
+            v.setUpdateTime(new Date());
+            if (item.getLastModifiedBy()!=null){
+                v.setUpdateBy(item.getLastModifiedBy());
+            }
+            if (item.getLastModifiedDate()!=null){
+                v.setUpdateTime(item.getLastModifiedDate());
+            }
+            updateSysDictRef.add(v);
+        }
+    }
+
+    private void addXqxlRef(Brand brandRec, List<SysDictRef> addSysDictRef, ItfTblAssignXqxlDowload item) {
+        SysDictRef v = new SysDictRef();
+        v.setId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_SMALL_TYPE.getCode());
+        v.setDictCode(item.getId());
+        v.setDictValue(item.getLbmc());
+        v.setSortNum(Integer.valueOf(item.getPxdj()));
+        v.setBrandId(brandRec.getBrandId());
+        v.setRefDictCode((item.getId()));
+        v.setRefDictName(item.getLbmc());
+        v.setCreateTime(new Date());
+        v.setCreateBy("system");
+        addSysDictRef.add(v);
     }
 
     private void extractedLocalAddOrUPdate(List<ItfTblAssignXqxlDowload> addRec, List<ItfTblAssignXqxlDowload> updateRec) {
         List<SysDict> addSysDict = new ArrayList<>();
         List<SysDict> updateSysDict = new ArrayList<>();
+        List<String> dictcodes = new ArrayList<>();
 
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_DEMAND_SMALL_TYPE.getCode()).list();
         Map<String, List<SysDict>> oldSysDictRecMap = oldSysDictRec.stream().collect(Collectors.groupingBy(SysDict::getDictCode));
 
-        Boolean flag = Boolean.FALSE;
+
 
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignXqxlDowload item : addRec){
-                SysDict v = new SysDict();
-                v.setSysDictId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_SMALL_TYPE.getCode());
-                v.setDictCode(String.valueOf(item.getId()));
-                v.setDictValue(item.getLbmc());
-                v.setSortNum(Integer.valueOf(item.getPxdj()));
-                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                }
-                v.setParentDictCode(item.getDaleiid());
-                v.setParentDictType(DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode());
-                v.setCreateTime(new Date());
-                if (item.getCreatedDate() !=null){
-                    v.setCreateTime(item.getCreatedDate());
+                if (oldSysDictRecMap.containsKey(item.getId()) || dictcodes.contains(item.getId())){
+                    upXqxl(updateSysDict, oldSysDictRecMap, item);
+                } else {
+                    addXqxl(addSysDict, item);
+                    dictcodes.add(item.getId());
                 }
-                addSysDict.add(v);
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignXqxlDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDict v = oldSysDictRecMap.get(String.valueOf(item.getId())).get(0);
-                if (!v.getDictValue().equals(item.getLbmc())){
-                    v.setDictValue(item.getLbmc());
-                    flag = Boolean.TRUE;
-                }
-                // 修改的为有效
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                        flag = Boolean.TRUE;
-                    }
+                if (oldSysDictRecMap.containsKey(item.getId()) || dictcodes.contains(item.getId())){
+                    upXqxl(updateSysDict, oldSysDictRecMap, item);
                 } else {
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                        flag = Boolean.TRUE;
-                    }
-                }
-                if (!v.getSortNum().equals(Integer.valueOf(item.getPxdj()))){
-                    v.setSortNum(Integer.valueOf(item.getPxdj()));
-                    flag = Boolean.TRUE;
-                }
-                if (!v.getParentDictCode().equals(item.getDaleiid())){
-                    v.setParentDictCode(item.getDaleiid());
-                    flag = Boolean.TRUE;
-                }
-
-                if (flag){
-                    updateSysDict.add(v);
+                    addXqxl(addSysDict, item);
+                    dictcodes.add(item.getId());
                 }
             }
         }
@@ -221,6 +208,61 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
             log.info("格力品牌需求小类本地字典信息表更新修改了{}条数据", updateSysDict.size());
             updateSysDict.clear();
         }
+        dictcodes.clear();
+    }
+
+    private void upXqxl(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblAssignXqxlDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDict v = oldSysDictRecMap.get(item.getId()).get(0);
+        if (!v.getDictValue().equals(item.getLbmc())){
+            v.setDictValue(item.getLbmc());
+            flag = Boolean.TRUE;
+        }
+        // 修改的为有效
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+                flag = Boolean.TRUE;
+            }
+        } else {
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+                flag = Boolean.TRUE;
+            }
+        }
+        if (!v.getSortNum().equals(Integer.valueOf(item.getPxdj()))){
+            v.setSortNum(Integer.valueOf(item.getPxdj()));
+            flag = Boolean.TRUE;
+        }
+        if (!v.getParentDictCode().equals(item.getDaleiid())){
+            v.setParentDictCode(item.getDaleiid());
+            flag = Boolean.TRUE;
+        }
+
+        if (flag){
+            updateSysDict.add(v);
+        }
+    }
+
+    private void addXqxl(List<SysDict> addSysDict, ItfTblAssignXqxlDowload item) {
+        SysDict v = new SysDict();
+        v.setSysDictId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_SMALL_TYPE.getCode());
+        v.setDictCode(item.getId());
+        v.setDictValue(item.getLbmc());
+        v.setSortNum(Integer.valueOf(item.getPxdj()));
+        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+        }
+        v.setParentDictCode(item.getDaleiid());
+        v.setParentDictType(DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode());
+        v.setCreateTime(new Date());
+        if (item.getCreatedDate() !=null){
+            v.setCreateTime(item.getCreatedDate());
+        }
+        addSysDict.add(v);
     }
 
     private void extractedXQXLAddOrUpdate(JSONArray jsonArray, List<ItfTblAssignXqxlDowload> addRec, List<ItfTblAssignXqxlDowload> updateRec) {
@@ -310,9 +352,9 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
     }
 
     private void extractedLocalRefAddOrUpdate(Brand brandRec, List<ItfTblAssignXxlbDowload> addRec, List<ItfTblAssignXxlbDowload> updateRec) {
-        Boolean flag = Boolean.FALSE;
         List<SysDictRef> addSysDictRef = new ArrayList<>();
         List<SysDictRef> updateSysDictRef = new ArrayList<>();
+        List<String> dictcodes = new ArrayList<>();
 
         // 提取字典对应关系
         List<SysDictRef> oldSysDictRefRec =  sysDictRefService.lambdaQuery()
@@ -323,47 +365,24 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignXxlbDowload item : addRec){
-                SysDictRef v = new SysDictRef();
-                v.setId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode());
-                v.setDictCode(String.valueOf(item.getLbid()));
-                v.setDictValue(item.getLbmc());
-                v.setSortNum(item.getPxdj());
-                v.setBrandId(brandRec.getBrandId());
-                v.setRefDictCode(String.valueOf(item.getLbid()));
-                v.setRefDictName(item.getLbmc());
-                v.setCreateTime(new Date());
-                v.setCreateBy("system");
-                addSysDictRef.add(v);
+                if (oldSysDictRefRecMap.containsKey(String.valueOf(item.getLbid())) ||
+                        dictcodes.contains(String.valueOf(item.getLbid()))){
+                    upXxlRef(updateSysDictRef, oldSysDictRefRecMap, item);
+                } else {
+                    addXxlbRef(brandRec, addSysDictRef, item);
+                    dictcodes.add(String.valueOf(item.getLbid()));
+                }
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignXxlbDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDictRef v = oldSysDictRefRecMap.get(String.valueOf(item.getLbid())).get(0);
-                if (!v.getDictValue().equals(item.getLbmc())){
-                    v.setDictValue(item.getLbmc());
-                    flag = Boolean.TRUE;
-                }
-                if (!v.getRefDictName().equals(item.getLbmc())){
-                    v.setRefDictName(item.getLbmc());
-                    flag = Boolean.TRUE;
-                }
-                if (v.getSortNum() != item.getPxdj()){
-                    v.setSortNum(item.getPxdj());
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    v.setUpdateBy("system");
-                    v.setUpdateTime(new Date());
-                    if (item.getLastModifiedBy()!=null){
-                        v.setUpdateBy(item.getLastModifiedBy());
-                    }
-                    if (item.getLastModifiedDate()!=null){
-                        v.setUpdateTime(item.getLastModifiedDate());
-                    }
-                    updateSysDictRef.add(v);
+                if (oldSysDictRefRecMap.containsKey(String.valueOf(item.getLbid())) ||
+                        dictcodes.contains(String.valueOf(item.getLbid()))){
+                    upXxlRef(updateSysDictRef, oldSysDictRefRecMap, item);
+                } else {
+                    addXxlbRef(brandRec, addSysDictRef, item);
+                    dictcodes.add(String.valueOf(item.getLbid()));
                 }
             }
         }
@@ -380,65 +399,85 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
             log.info("本地字典对应关系信息表更新修改了{}条数据", updateSysDictRef.size());
             updateSysDictRef.clear();
         }
+        dictcodes.clear();
+    }
+
+    private void upXxlRef(List<SysDictRef> updateSysDictRef, Map<String, List<SysDictRef>> oldSysDictRefRecMap, ItfTblAssignXxlbDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDictRef v = oldSysDictRefRecMap.get(String.valueOf(item.getLbid())).get(0);
+        if (!v.getDictValue().equals(item.getLbmc())){
+            v.setDictValue(item.getLbmc());
+            flag = Boolean.TRUE;
+        }
+        if (!v.getRefDictName().equals(item.getLbmc())){
+            v.setRefDictName(item.getLbmc());
+            flag = Boolean.TRUE;
+        }
+        if (v.getSortNum() != item.getPxdj()){
+            v.setSortNum(item.getPxdj());
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            v.setUpdateBy("system");
+            v.setUpdateTime(new Date());
+            if (item.getLastModifiedBy()!=null){
+                v.setUpdateBy(item.getLastModifiedBy());
+            }
+            if (item.getLastModifiedDate()!=null){
+                v.setUpdateTime(item.getLastModifiedDate());
+            }
+            updateSysDictRef.add(v);
+        }
+    }
+
+    private void addXxlbRef(Brand brandRec, List<SysDictRef> addSysDictRef, ItfTblAssignXxlbDowload item) {
+        SysDictRef v = new SysDictRef();
+        v.setId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode());
+        v.setDictCode(String.valueOf(item.getLbid()));
+        v.setDictValue(item.getLbmc());
+        v.setSortNum(item.getPxdj());
+        v.setBrandId(brandRec.getBrandId());
+        v.setRefDictCode(String.valueOf(item.getLbid()));
+        v.setRefDictName(item.getLbmc());
+        v.setCreateTime(new Date());
+        v.setCreateBy("system");
+        addSysDictRef.add(v);
     }
 
     private void extractedLocalAddOrUpdate(List<ItfTblAssignXxlbDowload> addRec, List<ItfTblAssignXxlbDowload> updateRec) {
         List<SysDict> addSysDict = new ArrayList<>();
         List<SysDict> updateSysDict = new ArrayList<>();
+        List<String> dictcodes = new ArrayList<>();
 
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode()).list();
         Map<String, List<SysDict>> oldSysDictRecMap = oldSysDictRec.stream().collect(Collectors.groupingBy(SysDict::getDictCode));
 
-        Boolean flag = Boolean.FALSE;
+
 
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignXxlbDowload item : addRec){
-                SysDict v = new SysDict();
-                v.setSysDictId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode());
-                v.setDictCode(String.valueOf(item.getLbid()));
-                v.setDictValue(item.getLbmc());
-                v.setSortNum(item.getPxdj());
-                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                }
-                v.setCreateTime(new Date());
-                if (item.getCreatedDate() !=null){
-                    v.setCreateTime(item.getCreatedDate());
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getLbid())) ||
+                        dictcodes.contains(String.valueOf(item.getLbid()))){
+                    addXxlb(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getLbid()));
+                } else {
+                    upXxlb(updateSysDict, oldSysDictRecMap, item);
                 }
-                addSysDict.add(v);
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignXxlbDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDict v = oldSysDictRecMap.get(String.valueOf(item.getLbid())).get(0);
-                if (!v.getDictValue().equals(item.getLbmc())){
-                    v.setDictValue(item.getLbmc());
-                    flag = Boolean.TRUE;
-                }
-                // 修改的为有效
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                        flag = Boolean.TRUE;
-                    }
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getLbid())) ||
+                        dictcodes.contains(String.valueOf(item.getLbid()))){
+                    addXxlb(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getLbid()));
                 } else {
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                        flag = Boolean.TRUE;
-                    }
-                }
-                if (v.getSortNum() != item.getPxdj()){
-                    v.setSortNum(item.getPxdj());
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    updateSysDict.add(v);
+                    upXxlb(updateSysDict, oldSysDictRecMap, item);
                 }
             }
         }
@@ -453,6 +492,54 @@ public class GLPPXuQiuLeiBieServiceImpl implements GLPPXuQiuLeiBieService {
             sysDictService.updateBatchById(updateSysDict);
             log.info("格力品牌需求大类本地字典信息表更新修改了{}条数据", updateSysDict.size());
         }
+        dictcodes.clear();
+    }
+
+    private void upXxlb(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblAssignXxlbDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDict v = oldSysDictRecMap.get(String.valueOf(item.getLbid())).get(0);
+        if (!v.getDictValue().equals(item.getLbmc())){
+            v.setDictValue(item.getLbmc());
+            flag = Boolean.TRUE;
+        }
+        // 修改的为有效
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+                flag = Boolean.TRUE;
+            }
+        } else {
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+                flag = Boolean.TRUE;
+            }
+        }
+        if (v.getSortNum() != item.getPxdj()){
+            v.setSortNum(item.getPxdj());
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            updateSysDict.add(v);
+        }
+    }
+
+    private void addXxlb(List<SysDict> addSysDict, ItfTblAssignXxlbDowload item) {
+        SysDict v = new SysDict();
+        v.setSysDictId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_DEMAND_TYPE.getCode());
+        v.setDictCode(String.valueOf(item.getLbid()));
+        v.setDictValue(item.getLbmc());
+        v.setSortNum(item.getPxdj());
+        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+        }
+        v.setCreateTime(new Date());
+        if (item.getCreatedDate() !=null){
+            v.setCreateTime(item.getCreatedDate());
+        }
+        addSysDict.add(v);
     }
 
     private void extractedXQLBAddOrUpdate(JSONArray jsonArray, List<ItfTblAssignXxlbDowload> addRec, List<ItfTblAssignXxlbDowload> updateRec) {

+ 228 - 138
src/main/java/com/zfire/jiasm/syncdata/service/impl/GLPPYHSXXXQDServiceImpl.java

@@ -97,7 +97,8 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
     private void extractedLocalYHDJAddOrUpdate(List<ItfTblYhsxViprankDowload> addRec, List<ItfTblYhsxViprankDowload> updateRec) {
         List<SysDict> addSysDict = new ArrayList<>();
         List<SysDict> updateSysDict = new ArrayList<>();
-        Boolean flag = Boolean.FALSE;
+        List<String> dictcodes = new ArrayList<>();
+
 
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_USER_LEVEL.getCode()).list();
@@ -107,35 +108,24 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblYhsxViprankDowload item : addRec){
-                SysDict v = new SysDict();
-                v.setSysDictId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_USER_LEVEL.getCode());
-                v.setDictCode(String.valueOf(item.getVipid()));
-                v.setDictValue(item.getVipmc());
-                v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                v.setSortNum(item.getPxdj());
-                v.setCreateTime(new Date());
-                if (item.getCjdt() !=null){
-                    v.setCreateTime(item.getCjdt());
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getVipid())) ||
+                        dictcodes.contains(String.valueOf(item.getVipid()))){
+                    upYhsxVip(updateSysDict, oldSysDictRecMap, item);
+                } else {
+                    addYhsxWip(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getVipid()));
                 }
-                addSysDict.add(v);
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblYhsxViprankDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDict v = oldSysDictRecMap.get(String.valueOf(item.getVipid())).get(0);
-                if (!v.getDictValue().equals(item.getVipmc())){
-                    v.setDictValue(item.getVipmc());
-                    flag = Boolean.TRUE;
-                }
-                if (v.getSortNum() != item.getPxdj()){
-                    v.setSortNum(item.getPxdj());
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    updateSysDict.add(v);
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getVipid())) ||
+                        dictcodes.contains(String.valueOf(item.getVipid()))){
+                    upYhsxVip(updateSysDict, oldSysDictRecMap, item);
+                } else {
+                    addYhsxWip(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getVipid()));
                 }
             }
         }
@@ -152,6 +142,39 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
             log.info("格力品牌用户等级本地字典信息表更新修改了{}条数据", updateSysDict.size());
             updateSysDict.clear();
         }
+        dictcodes.clear();
+    }
+
+    private void upYhsxVip(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblYhsxViprankDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDict v = oldSysDictRecMap.get(String.valueOf(item.getVipid())).get(0);
+        if (!v.getDictValue().equals(item.getVipmc())){
+            v.setDictValue(item.getVipmc());
+            flag = Boolean.TRUE;
+        }
+        if (v.getSortNum() != item.getPxdj()){
+            v.setSortNum(item.getPxdj());
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            updateSysDict.add(v);
+        }
+    }
+
+    private void addYhsxWip(List<SysDict> addSysDict, ItfTblYhsxViprankDowload item) {
+        SysDict v = new SysDict();
+        v.setSysDictId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_USER_LEVEL.getCode());
+        v.setDictCode(String.valueOf(item.getVipid()));
+        v.setDictValue(item.getVipmc());
+        v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+        v.setSortNum(item.getPxdj());
+        v.setCreateTime(new Date());
+        if (item.getCjdt() !=null){
+            v.setCreateTime(item.getCjdt());
+        }
+        addSysDict.add(v);
     }
 
     private void extractedYHDJAddOrUpdate(JSONArray jsonArray, List<ItfTblYhsxViprankDowload> addRec, List<ItfTblYhsxViprankDowload> updateRec) {
@@ -218,7 +241,7 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
     private void extractedLocalXXLYAddOrUpdate(List<ItfTblAssignXxlyDowload> addRec, List<ItfTblAssignXxlyDowload> updateRec) {
         List<SysDict> addSysDict = new ArrayList<>();
         List<SysDict> updateSysDict = new ArrayList<>();
-        Boolean flag = Boolean.FALSE;
+        List<String> dictcodes = new ArrayList<>();
 
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_XXQD_SOURCE.getCode()).list();
@@ -228,50 +251,24 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignXxlyDowload item : addRec){
-                SysDict v = new SysDict();
-                v.setSysDictId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_XXQD_SOURCE.getCode());
-                v.setDictCode(String.valueOf(item.getLyid()));
-                v.setDictValue(item.getLymc());
-                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                }
-                v.setSortNum(item.getPxdj());
-                v.setCreateTime(new Date());
-                if (item.getCjdt() !=null){
-                    v.setCreateTime(item.getCjdt());
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getLyid())) ||
+                        dictcodes.contains(String.valueOf(item.getLyid()))){
+                    upXxly(updateSysDict, oldSysDictRecMap, item);
+                } else {
+                    addXxly(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getLyid()));
                 }
-                addSysDict.add(v);
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignXxlyDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDict v = oldSysDictRecMap.get(String.valueOf(item.getLyid())).get(0);
-                if (!v.getDictValue().equals(item.getLymc())){
-                    v.setDictValue(item.getLymc());
-                    flag = Boolean.TRUE;
-                }
-                // 修改的为有效
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                        flag = Boolean.TRUE;
-                    }
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getLyid())) ||
+                        dictcodes.contains(String.valueOf(item.getLyid()))){
+                    upXxly(updateSysDict, oldSysDictRecMap, item);
                 } else {
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                        flag = Boolean.TRUE;
-                    }
-                }
-                if (v.getSortNum() != item.getPxdj()){
-                    v.setSortNum(item.getPxdj());
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    updateSysDict.add(v);
+                    addXxly(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getLyid()));
                 }
             }
         }
@@ -288,6 +285,54 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
             log.info("格力品牌用户属性本地字典信息表更新修改了{}条数据", updateSysDict.size());
             updateSysDict.clear();
         }
+        dictcodes.clear();
+    }
+
+    private void upXxly(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblAssignXxlyDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDict v = oldSysDictRecMap.get(String.valueOf(item.getLyid())).get(0);
+        if (!v.getDictValue().equals(item.getLymc())){
+            v.setDictValue(item.getLymc());
+            flag = Boolean.TRUE;
+        }
+        // 修改的为有效
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+                flag = Boolean.TRUE;
+            }
+        } else {
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+                flag = Boolean.TRUE;
+            }
+        }
+        if (v.getSortNum() != item.getPxdj()){
+            v.setSortNum(item.getPxdj());
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            updateSysDict.add(v);
+        }
+    }
+
+    private void addXxly(List<SysDict> addSysDict, ItfTblAssignXxlyDowload item) {
+        SysDict v = new SysDict();
+        v.setSysDictId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_XXQD_SOURCE.getCode());
+        v.setDictCode(String.valueOf(item.getLyid()));
+        v.setDictValue(item.getLymc());
+        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+        }
+        v.setSortNum(item.getPxdj());
+        v.setCreateTime(new Date());
+        if (item.getCjdt() !=null){
+            v.setCreateTime(item.getCjdt());
+        }
+        addSysDict.add(v);
     }
 
     private void extractedXXLYAddOrUpdate(JSONArray jsonArray, List<ItfTblAssignXxlyDowload> addRec, List<ItfTblAssignXxlyDowload> updateRec) {
@@ -374,7 +419,8 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
     private void extractedLocalXXQDAddOrUpdate(List<ItfTblAssignXxqdDowload> addRec, List<ItfTblAssignXxqdDowload> updateRec) {
         List<SysDict> addSysDict = new ArrayList<>();
         List<SysDict> updateSysDict = new ArrayList<>();
-        Boolean flag = Boolean.FALSE;
+        List<String> dictcodes = new ArrayList<>();
+
 
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_XXQD_CHANNEL.getCode()).list();
@@ -383,50 +429,24 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignXxqdDowload item : addRec){
-                SysDict v = new SysDict();
-                v.setSysDictId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_XXQD_CHANNEL.getCode());
-                v.setDictCode(String.valueOf(item.getQdid()));
-                v.setDictValue(item.getQdmc());
-                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                }
-                v.setSortNum(item.getPxdj());
-                v.setCreateTime(new Date());
-                if (item.getCjdt() !=null){
-                    v.setCreateTime(item.getCjdt());
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getQdid())) ||
+                        dictcodes.contains(String.valueOf(item.getQdid()))){
+                    upXxqd(updateSysDict, oldSysDictRecMap, item);
+                } else {
+                    addXxqd(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getQdid()));
                 }
-                addSysDict.add(v);
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignXxqdDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDict v = oldSysDictRecMap.get(String.valueOf(item.getQdid())).get(0);
-                if (!v.getDictValue().equals(item.getQdmc())){
-                    v.setDictValue(item.getQdmc());
-                    flag = Boolean.TRUE;
-                }
-                // 修改的为有效
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                        flag = Boolean.TRUE;
-                    }
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getQdid())) ||
+                        dictcodes.contains(String.valueOf(item.getQdid()))){
+                    upXxqd(updateSysDict, oldSysDictRecMap, item);
                 } else {
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                        flag = Boolean.TRUE;
-                    }
-                }
-                if (v.getSortNum() != item.getPxdj()){
-                    v.setSortNum(item.getPxdj());
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    updateSysDict.add(v);
+                    addXxqd(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getQdid()));
                 }
             }
         }
@@ -443,6 +463,54 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
             log.info("格力品牌用户属性本地字典信息表更新修改了{}条数据", updateSysDict.size());
             updateSysDict.clear();
         }
+        dictcodes.clear();
+    }
+
+    private void upXxqd(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblAssignXxqdDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDict v = oldSysDictRecMap.get(String.valueOf(item.getQdid())).get(0);
+        if (!v.getDictValue().equals(item.getQdmc())){
+            v.setDictValue(item.getQdmc());
+            flag = Boolean.TRUE;
+        }
+        // 修改的为有效
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+                flag = Boolean.TRUE;
+            }
+        } else {
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+                flag = Boolean.TRUE;
+            }
+        }
+        if (v.getSortNum() != item.getPxdj()){
+            v.setSortNum(item.getPxdj());
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            updateSysDict.add(v);
+        }
+    }
+
+    private void addXxqd(List<SysDict> addSysDict, ItfTblAssignXxqdDowload item) {
+        SysDict v = new SysDict();
+        v.setSysDictId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_XXQD_CHANNEL.getCode());
+        v.setDictCode(String.valueOf(item.getQdid()));
+        v.setDictValue(item.getQdmc());
+        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+        }
+        v.setSortNum(item.getPxdj());
+        v.setCreateTime(new Date());
+        if (item.getCjdt() !=null){
+            v.setCreateTime(item.getCjdt());
+        }
+        addSysDict.add(v);
     }
 
     private void extractedXXQDAddOrUpdate(JSONArray jsonArray, List<ItfTblAssignXxqdDowload> addRec, List<ItfTblAssignXxqdDowload> updateRec) {
@@ -530,60 +598,34 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
     private void extractedLocalYHSXAddOrUpdate(List<ItfTblAssignYhsxWxDowload> addRec, List<ItfTblAssignYhsxWxDowload> updateRec) {
         List<SysDict> addSysDict = new ArrayList<>();
         List<SysDict> updateSysDict = new ArrayList<>();
+        List<String> dictcodes = new ArrayList<>();
 
         // 提取大类字典数据  sysDictService
         List<SysDict> oldSysDictRec =  sysDictService.lambdaQuery().eq(SysDict::getDictType, DictTypeEnum.DICT_TYPE_USER_ATTR.getCode()).list();
         Map<String, List<SysDict>> oldSysDictRecMap = oldSysDictRec.stream().collect(Collectors.groupingBy(SysDict::getDictCode));
 
-        Boolean flag = Boolean.FALSE;
 
         // 获取新增的
         if (addRec.size()>0){
             for (ItfTblAssignYhsxWxDowload item : addRec){
-                SysDict v = new SysDict();
-                v.setSysDictId(UUID.randomUUID().toString());
-                v.setDictType(DictTypeEnum.DICT_TYPE_USER_ATTR.getCode());
-                v.setDictCode(String.valueOf(item.getYhsxid()));
-                v.setDictValue(item.getYhsxmc());
-                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                }
-                v.setSortNum(item.getPxdj());
-                v.setCreateTime(new Date());
-                if (item.getCjdt() !=null){
-                    v.setCreateTime(item.getCjdt());
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getYhsxid())) ||
+                        dictcodes.contains(String.valueOf(item.getYhsxid()))){
+                    upYhsxWx(updateSysDict, oldSysDictRecMap, item);
+                } else {
+                    addYhsxWx(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getYhsxid()));
                 }
-                addSysDict.add(v);
             }
         }
         // 获取修改的
         if (updateRec.size()>0){
             for (ItfTblAssignYhsxWxDowload item : updateRec){
-                flag = Boolean.FALSE;
-                SysDict v = oldSysDictRecMap.get(String.valueOf(item.getYhsxid())).get(0);
-                if (!v.getDictValue().equals(item.getYhsxmc())){
-                    v.setDictValue(item.getYhsxmc());
-                    flag = Boolean.TRUE;
-                }
-                // 修改的为有效
-                if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
-                        flag = Boolean.TRUE;
-                    }
+                if (oldSysDictRecMap.containsKey(String.valueOf(item.getYhsxid())) ||
+                        dictcodes.contains(String.valueOf(item.getYhsxid()))){
+                    upYhsxWx(updateSysDict, oldSysDictRecMap, item);
                 } else {
-                    if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
-                        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
-                        flag = Boolean.TRUE;
-                    }
-                }
-                if (v.getSortNum() != item.getPxdj()){
-                    v.setSortNum(item.getPxdj());
-                    flag = Boolean.TRUE;
-                }
-                if (flag){
-                    updateSysDict.add(v);
+                    addYhsxWx(addSysDict, item);
+                    dictcodes.add(String.valueOf(item.getYhsxid()));
                 }
             }
         }
@@ -600,6 +642,54 @@ public class GLPPYHSXXXQDServiceImpl implements GLPPYHSXXXQDService {
             log.info("格力品牌用户属性本地字典信息表更新修改了{}条数据", updateSysDict.size());
             updateSysDict.clear();
         }
+        dictcodes.clear();
+    }
+
+    private void upYhsxWx(List<SysDict> updateSysDict, Map<String, List<SysDict>> oldSysDictRecMap, ItfTblAssignYhsxWxDowload item) {
+        Boolean flag = Boolean.FALSE;
+        flag = Boolean.FALSE;
+        SysDict v = oldSysDictRecMap.get(String.valueOf(item.getYhsxid())).get(0);
+        if (!v.getDictValue().equals(item.getYhsxmc())){
+            v.setDictValue(item.getYhsxmc());
+            flag = Boolean.TRUE;
+        }
+        // 修改的为有效
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_OFF.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+                flag = Boolean.TRUE;
+            }
+        } else {
+            if (v.getStatus().equals(DictTypeEnum.DICT_TYPE_ON.getCode())){
+                v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+                flag = Boolean.TRUE;
+            }
+        }
+        if (v.getSortNum() != item.getPxdj()){
+            v.setSortNum(item.getPxdj());
+            flag = Boolean.TRUE;
+        }
+        if (flag){
+            updateSysDict.add(v);
+        }
+    }
+
+    private void addYhsxWx(List<SysDict> addSysDict, ItfTblAssignYhsxWxDowload item) {
+        SysDict v = new SysDict();
+        v.setSysDictId(UUID.randomUUID().toString());
+        v.setDictType(DictTypeEnum.DICT_TYPE_USER_ATTR.getCode());
+        v.setDictCode(String.valueOf(item.getYhsxid()));
+        v.setDictValue(item.getYhsxmc());
+        v.setStatus(DictTypeEnum.DICT_TYPE_OFF.getCode());
+        if (item.getFlag().equals(DictTypeEnum.DICT_TYPE_FLAG_ON.getCode())){
+            v.setStatus(DictTypeEnum.DICT_TYPE_ON.getCode());
+        }
+        v.setSortNum(item.getPxdj());
+        v.setCreateTime(new Date());
+        if (item.getCjdt() !=null){
+            v.setCreateTime(item.getCjdt());
+        }
+        addSysDict.add(v);
     }
 
     private void extractedYHSXAddOrUpdate(JSONArray jsonArray, List<ItfTblAssignYhsxWxDowload> addRec, List<ItfTblAssignYhsxWxDowload> updateRec) {