From 94ff24d6718760eee6b7932213aaf5e50ce72ad9 Mon Sep 17 00:00:00 2001 From: water_xu Date: Thu, 22 Aug 2024 18:51:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E4=B8=AD=E5=8F=B0=20-=20?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E4=BC=81=E4=B8=9A=E3=80=81=E7=BB=84=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=98=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/bus/CorpInfoController.java | 15 +- .../system/DepartmentController.java | 12 ++ .../datasource/core/CoreSyncCorpMapper.java | 42 ++++ .../datasource/core/CoreSyncDeptMapper.java | 42 ++++ .../datasource/core/CoreSyncUserMapper.java | 42 ++++ .../service/core/CoreSyncCorpService.java | 39 ++++ .../service/core/CoreSyncDeptService.java | 39 ++++ .../service/core/CoreSyncUserService.java | 39 ++++ .../core/impl/CoreSyncCorpServiceImpl.java | 38 ++++ .../core/impl/CoreSyncDeptServiceImpl.java | 38 ++++ .../core/impl/CoreSyncUserServiceImpl.java | 39 ++++ .../zcloud/syncData/SyncDataAdviceAspect.java | 32 ++- .../com/zcloud/syncData/SyncTypeEnum.java | 4 +- .../syncData/listener/SyncDataListener.java | 83 +++++++- .../datasource/core/CoreSyncCorpMapper.xml | 106 ++++++++++ .../datasource/core/CoreSyncDeptMapper.xml | 136 +++++++++++++ .../datasource/core/CoreSyncUserMapper.xml | 187 ++++++++++++++++++ 17 files changed, 923 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/zcloud/mapper/datasource/core/CoreSyncCorpMapper.java create mode 100644 src/main/java/com/zcloud/mapper/datasource/core/CoreSyncDeptMapper.java create mode 100644 src/main/java/com/zcloud/mapper/datasource/core/CoreSyncUserMapper.java create mode 100644 src/main/java/com/zcloud/service/core/CoreSyncCorpService.java create mode 100644 src/main/java/com/zcloud/service/core/CoreSyncDeptService.java create mode 100644 src/main/java/com/zcloud/service/core/CoreSyncUserService.java create mode 100644 src/main/java/com/zcloud/service/core/impl/CoreSyncCorpServiceImpl.java create mode 100644 src/main/java/com/zcloud/service/core/impl/CoreSyncDeptServiceImpl.java create mode 100644 src/main/java/com/zcloud/service/core/impl/CoreSyncUserServiceImpl.java create mode 100644 src/main/resources/mybatis/datasource/core/CoreSyncCorpMapper.xml create mode 100644 src/main/resources/mybatis/datasource/core/CoreSyncDeptMapper.xml create mode 100644 src/main/resources/mybatis/datasource/core/CoreSyncUserMapper.xml diff --git a/src/main/java/com/zcloud/controller/bus/CorpInfoController.java b/src/main/java/com/zcloud/controller/bus/CorpInfoController.java index 0a0a35e0..436b9d5b 100644 --- a/src/main/java/com/zcloud/controller/bus/CorpInfoController.java +++ b/src/main/java/com/zcloud/controller/bus/CorpInfoController.java @@ -9,6 +9,8 @@ import java.util.Map; import com.zcloud.service.bus.CorpInfoRelatedService; import com.zcloud.service.system.DictionariesService; +import com.zcloud.syncData.SyncPlatformAdvice; +import com.zcloud.syncData.SyncTypeEnum; import com.zcloud.util.*; import net.sf.json.JSONArray; import org.apache.commons.io.FileUtils; @@ -79,6 +81,7 @@ public class CorpInfoController extends BaseController { @RequiresPermissions("corpinfo:add") @ResponseBody @Transactional + @SyncPlatformAdvice(type = SyncTypeEnum.CORP, isInsert = true) public Object add() throws Exception{ Map map = new HashMap(); String errInfo = "success"; @@ -123,6 +126,8 @@ public class CorpInfoController extends BaseController { map.put("pd",pd); map.put("result", errInfo); + map.put("syncInfo", corpinfoService.findById(pd)); + map.put("code", "0"); return map; } @@ -133,13 +138,17 @@ public class CorpInfoController extends BaseController { @RequestMapping(value="/delete") @RequiresPermissions("corpinfo:del") @ResponseBody + @SyncPlatformAdvice(type = SyncTypeEnum.CORP, isUpdate = true) public Object delete() throws Exception{ - Map map = new HashMap(); + Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); corpinfoService.delete(pd); map.put("result", errInfo); //返回结果 + pd.put("ISDELETE", "1"); + map.put("syncInfo", pd); + map.put("code", "0"); return map; } @@ -150,6 +159,7 @@ public class CorpInfoController extends BaseController { @RequestMapping(value="/edit", headers = "content-type=multipart/form-data") @ResponseBody @Transactional + @SyncPlatformAdvice(type = SyncTypeEnum.CORP, isUpdate = true) public Object edit( @RequestParam(value="imgFiles",required=false) MultipartFile[] imgFiles, @RequestParam(value="fourFiles",required=false) MultipartFile[] fourFiles) throws Exception{ @@ -188,7 +198,8 @@ public class CorpInfoController extends BaseController { corpinfoService.editCorpUserNew(pdNew); corpinfoService.editCorpdeptNew(pdNew); - + map.put("syncInfo", corpinfoService.findById(pd)); + map.put("code", "0"); return map; } @RequestMapping(value="/editIsReceive") diff --git a/src/main/java/com/zcloud/controller/system/DepartmentController.java b/src/main/java/com/zcloud/controller/system/DepartmentController.java index 9cd23a10..73de9dba 100644 --- a/src/main/java/com/zcloud/controller/system/DepartmentController.java +++ b/src/main/java/com/zcloud/controller/system/DepartmentController.java @@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject; import com.zcloud.entity.system.User; import com.zcloud.service.system.PostService; import com.zcloud.service.system.SupervisionDepartmentService; +import com.zcloud.syncData.SyncPlatformAdvice; +import com.zcloud.syncData.SyncTypeEnum; import com.zcloud.util.DateUtil; import com.zcloud.util.ObjectExcelView; import net.sf.json.JSONArray; @@ -58,6 +60,7 @@ public class DepartmentController extends BaseController { @RequestMapping(value = "/add") @RequiresPermissions("department:add") @ResponseBody + @SyncPlatformAdvice(type = SyncTypeEnum.DEPARTMENT, isInsert = true) public Object add(Page page) throws Exception { Map map = new HashMap(); String errInfo = "success"; @@ -100,6 +103,8 @@ public class DepartmentController extends BaseController { } } map.put("result", errInfo); //返回结果 + map.put("syncInfo", departmentService.findById(pd)); + map.put("code", "0"); return map; } @@ -157,6 +162,7 @@ public class DepartmentController extends BaseController { @RequestMapping(value = "/delete") @RequiresPermissions("department:del") @ResponseBody + @SyncPlatformAdvice(type = SyncTypeEnum.DEPARTMENT, isUpdate = true) public Object delete(@RequestParam String DEPARTMENT_ID) throws Exception { Map map = new HashMap(); String errInfo = "success"; @@ -181,6 +187,9 @@ public class DepartmentController extends BaseController { } map.put("result", errInfo); //返回结果 + pd.put("ISDELETE", "1"); + map.put("syncInfo", pd); + map.put("code", "0"); return map; } @@ -193,6 +202,7 @@ public class DepartmentController extends BaseController { @RequestMapping(value = "/edit") @RequiresPermissions("department:edit") @ResponseBody + @SyncPlatformAdvice(type = SyncTypeEnum.DEPARTMENT, isUpdate = true) public Object edit() throws Exception { Map map = new HashMap(); String errInfo = "success"; @@ -244,6 +254,8 @@ public class DepartmentController extends BaseController { } } map.put("result", errInfo); //返回结果 + map.put("syncInfo", departmentService.findById(pd)); + map.put("code", "0"); return map; } diff --git a/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncCorpMapper.java b/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncCorpMapper.java new file mode 100644 index 00000000..303aa117 --- /dev/null +++ b/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncCorpMapper.java @@ -0,0 +1,42 @@ +package com.zcloud.mapper.datasource.core; + +import com.zcloud.entity.PageData; + +import java.util.List; + +/** + * 人员中台本地同步Mapper + */ +public interface CoreSyncCorpMapper { + + /**列表(全部) + * @param pd + * @throws Exception + */ + List listAll(PageData pd); + + /**删除 + * @param pd + * @throws Exception + */ + void delete(PageData pd); + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + +} diff --git a/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncDeptMapper.java b/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncDeptMapper.java new file mode 100644 index 00000000..d59802e7 --- /dev/null +++ b/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncDeptMapper.java @@ -0,0 +1,42 @@ +package com.zcloud.mapper.datasource.core; + +import com.zcloud.entity.PageData; + +import java.util.List; + +/** + * 人员中台本地同步Mapper + */ +public interface CoreSyncDeptMapper { + + /**列表(全部) + * @param pd + * @throws Exception + */ + List listAll(PageData pd); + + /**删除 + * @param pd + * @throws Exception + */ + void delete(PageData pd); + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + +} diff --git a/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncUserMapper.java b/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncUserMapper.java new file mode 100644 index 00000000..f578a596 --- /dev/null +++ b/src/main/java/com/zcloud/mapper/datasource/core/CoreSyncUserMapper.java @@ -0,0 +1,42 @@ +package com.zcloud.mapper.datasource.core; + +import com.zcloud.entity.PageData; + +import java.util.List; + +/** + * 人员中台本地同步Mapper + */ +public interface CoreSyncUserMapper { + + /**列表(全部) + * @param pd + * @throws Exception + */ + List listAll(PageData pd); + + /**删除 + * @param pd + * @throws Exception + */ + void delete(PageData pd); + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + +} diff --git a/src/main/java/com/zcloud/service/core/CoreSyncCorpService.java b/src/main/java/com/zcloud/service/core/CoreSyncCorpService.java new file mode 100644 index 00000000..b9ab4299 --- /dev/null +++ b/src/main/java/com/zcloud/service/core/CoreSyncCorpService.java @@ -0,0 +1,39 @@ +package com.zcloud.service.core; + +import com.zcloud.entity.PageData; + +import java.util.List; + +public interface CoreSyncCorpService { + + /**列表(全部) + * @param pd + * @throws Exception + */ + List listAll(PageData pd); + + /**删除 + * @param pd + * @throws Exception + */ + void delete(PageData pd); + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + +} diff --git a/src/main/java/com/zcloud/service/core/CoreSyncDeptService.java b/src/main/java/com/zcloud/service/core/CoreSyncDeptService.java new file mode 100644 index 00000000..61350cfc --- /dev/null +++ b/src/main/java/com/zcloud/service/core/CoreSyncDeptService.java @@ -0,0 +1,39 @@ +package com.zcloud.service.core; + +import com.zcloud.entity.PageData; + +import java.util.List; + +public interface CoreSyncDeptService { + + /**列表(全部) + * @param pd + * @throws Exception + */ + List listAll(PageData pd); + + /**删除 + * @param pd + * @throws Exception + */ + void delete(PageData pd); + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + +} diff --git a/src/main/java/com/zcloud/service/core/CoreSyncUserService.java b/src/main/java/com/zcloud/service/core/CoreSyncUserService.java new file mode 100644 index 00000000..6f27ec12 --- /dev/null +++ b/src/main/java/com/zcloud/service/core/CoreSyncUserService.java @@ -0,0 +1,39 @@ +package com.zcloud.service.core; + +import com.zcloud.entity.PageData; + +import java.util.List; + +public interface CoreSyncUserService { + + /**列表(全部) + * @param pd + * @throws Exception + */ + List listAll(PageData pd); + + /**删除 + * @param pd + * @throws Exception + */ + void delete(PageData pd); + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + +} diff --git a/src/main/java/com/zcloud/service/core/impl/CoreSyncCorpServiceImpl.java b/src/main/java/com/zcloud/service/core/impl/CoreSyncCorpServiceImpl.java new file mode 100644 index 00000000..17c72cc5 --- /dev/null +++ b/src/main/java/com/zcloud/service/core/impl/CoreSyncCorpServiceImpl.java @@ -0,0 +1,38 @@ +package com.zcloud.service.core.impl; + +import com.zcloud.entity.PageData; +import com.zcloud.mapper.datasource.core.CoreSyncCorpMapper; +import com.zcloud.service.core.CoreSyncCorpService; + +import javax.annotation.Resource; +import java.util.List; + +public class CoreSyncCorpServiceImpl implements CoreSyncCorpService { + + @Resource + private CoreSyncCorpMapper coreSyncCorpMapper; + @Override + public List listAll(PageData pd) { + return coreSyncCorpMapper.listAll(pd); + } + + @Override + public void delete(PageData pd) { + coreSyncCorpMapper.delete(pd); + } + + @Override + public void save(PageData pd) { + coreSyncCorpMapper.save(pd); + } + + @Override + public void edit(PageData pd) { + coreSyncCorpMapper.edit(pd); + } + + @Override + public PageData findById(PageData pd) { + return coreSyncCorpMapper.findById(pd); + } +} diff --git a/src/main/java/com/zcloud/service/core/impl/CoreSyncDeptServiceImpl.java b/src/main/java/com/zcloud/service/core/impl/CoreSyncDeptServiceImpl.java new file mode 100644 index 00000000..a99667be --- /dev/null +++ b/src/main/java/com/zcloud/service/core/impl/CoreSyncDeptServiceImpl.java @@ -0,0 +1,38 @@ +package com.zcloud.service.core.impl; + +import com.zcloud.entity.PageData; +import com.zcloud.service.core.CoreSyncDeptService; + +import javax.annotation.Resource; +import java.util.List; + +public class CoreSyncDeptServiceImpl implements CoreSyncDeptService { + + @Resource + private CoreSyncDeptService coreSyncDeptService; + + @Override + public List listAll(PageData pd) { + return coreSyncDeptService.listAll(pd); + } + + @Override + public void delete(PageData pd) { + coreSyncDeptService.delete(pd); + } + + @Override + public void save(PageData pd) { + coreSyncDeptService.save(pd); + } + + @Override + public void edit(PageData pd) { + coreSyncDeptService.edit(pd); + } + + @Override + public PageData findById(PageData pd) { + return coreSyncDeptService.findById(pd); + } +} diff --git a/src/main/java/com/zcloud/service/core/impl/CoreSyncUserServiceImpl.java b/src/main/java/com/zcloud/service/core/impl/CoreSyncUserServiceImpl.java new file mode 100644 index 00000000..f2893aaf --- /dev/null +++ b/src/main/java/com/zcloud/service/core/impl/CoreSyncUserServiceImpl.java @@ -0,0 +1,39 @@ +package com.zcloud.service.core.impl; + +import com.zcloud.entity.PageData; +import com.zcloud.mapper.datasource.core.CoreSyncUserMapper; +import com.zcloud.service.core.CoreSyncUserService; + +import javax.annotation.Resource; +import java.util.List; + +public class CoreSyncUserServiceImpl implements CoreSyncUserService { + + @Resource + private CoreSyncUserMapper coreSyncUserMapper; + + @Override + public List listAll(PageData pd) { + return coreSyncUserMapper.listAll(pd); + } + + @Override + public void delete(PageData pd) { + coreSyncUserMapper.delete(pd); + } + + @Override + public void save(PageData pd) { + coreSyncUserMapper.save(pd); + } + + @Override + public void edit(PageData pd) { + coreSyncUserMapper.edit(pd); + } + + @Override + public PageData findById(PageData pd) { + return coreSyncUserMapper.findById(pd); + } +} diff --git a/src/main/java/com/zcloud/syncData/SyncDataAdviceAspect.java b/src/main/java/com/zcloud/syncData/SyncDataAdviceAspect.java index c095afb0..2acaf8ab 100644 --- a/src/main/java/com/zcloud/syncData/SyncDataAdviceAspect.java +++ b/src/main/java/com/zcloud/syncData/SyncDataAdviceAspect.java @@ -75,18 +75,38 @@ public class SyncDataAdviceAspect { message.setTopic(sliceDataChangeTopic); // 判断同步类型 + /** + * 同步隐患 + */ if (syncPlatformAdvice.type().equals(SyncTypeEnum.HIDDEN)){ - // 同步隐患 } + /** + * 同步人员 + */ if (syncPlatformAdvice.type().equals(SyncTypeEnum.PERSONNEL)){ - // 同步人员 dockSendMessageService.sendMessage(message); } - if (syncPlatformAdvice.type().equals(SyncTypeEnum.SAFETY_ENVIRONMENTAL_CHECK)){ - // 同步安全环保检查 + /** + * 同步安全环保检查 + */ + if (syncPlatformAdvice.type().equals(SyncTypeEnum.SAFETY_ENVIRONMENTAL_CHECK)){ } + /** + * 同步重点工程 + */ + if (syncPlatformAdvice.type().equals(SyncTypeEnum.KEY_PROJECT)){ } + /** + * 同步企业 + */ + if (syncPlatformAdvice.type().equals(SyncTypeEnum.CORP)){ + // 1. 发信 + dockSendMessageService.sendMessage(message); } - if (syncPlatformAdvice.type().equals(SyncTypeEnum.KEY_PROJECT)){ - // 同步重点工程 + /** + * 同步部门 + */ + if (syncPlatformAdvice.type().equals(SyncTypeEnum.DEPARTMENT)){ + // 1. 发信 + dockSendMessageService.sendMessage(message); } diff --git a/src/main/java/com/zcloud/syncData/SyncTypeEnum.java b/src/main/java/com/zcloud/syncData/SyncTypeEnum.java index 34647a2b..ba94f885 100644 --- a/src/main/java/com/zcloud/syncData/SyncTypeEnum.java +++ b/src/main/java/com/zcloud/syncData/SyncTypeEnum.java @@ -9,7 +9,9 @@ public enum SyncTypeEnum { PERSONNEL("人员"), HIDDEN("隐患"), SAFETY_ENVIRONMENTAL_CHECK("安全环保检查"), - KEY_PROJECT("重点工程"); + KEY_PROJECT("重点工程"), + DEPARTMENT("部门"), + CORP("企业"); private final String description; diff --git a/src/main/java/com/zcloud/syncData/listener/SyncDataListener.java b/src/main/java/com/zcloud/syncData/listener/SyncDataListener.java index b44c127a..93c6b1b2 100644 --- a/src/main/java/com/zcloud/syncData/listener/SyncDataListener.java +++ b/src/main/java/com/zcloud/syncData/listener/SyncDataListener.java @@ -4,8 +4,13 @@ import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.zcloud.dto.TenCorpDto; import com.zcloud.entity.PageData; +import com.zcloud.mapper.datasource.bus.CorpInfoMapper; +import com.zcloud.mapper.datasource.core.CoreSyncCorpMapper; +import com.zcloud.mapper.datasource.core.CoreSyncDeptMapper; +import com.zcloud.mapper.datasource.core.CoreSyncUserMapper; import com.zcloud.mapper.datasource.mq.MqConsumptionErrorLogMapper; import com.zcloud.mapper.datasource.mq.MqConsumptionLogMapper; +import com.zcloud.mapper.datasource.system.DepartmentMapper; import com.zcloud.service.system.UsersService; import com.zcloud.service.xgf.XgfUserService; import com.zcloud.syncData.SyncTypeEnum; @@ -39,6 +44,22 @@ public class SyncDataListener implements RocketMQListener { @Autowired private XgfUserService xgfUserService; + @Autowired + private CorpInfoMapper corpinfoMapper; + + @Autowired + private DepartmentMapper departmentMapper; + + /* 本地中台同步 */ + @Autowired + private CoreSyncUserMapper coreSyncUserMapper; + + @Autowired + private CoreSyncCorpMapper coreSyncCorpMapper; + + @Autowired + private CoreSyncDeptMapper coreSyncDeptMapper; + @Autowired private static MqConsumptionErrorLogMapper mqConsumptionErrorLogMapper; @@ -84,8 +105,14 @@ public class SyncDataListener implements RocketMQListener { PageData localData = usersService.findById(syncInfo); if (localData != null && !localData.isEmpty()){ usersService.editUser(syncInfo); + } + + // 2024.8.9 按郭跃鹏提出:后期各公司从企业端分离后,需要其他公司的用户进行SQL联查,要求新增一张core_user的同步表,用于记录中台的所有用户数据 + PageData coreLocalData = coreSyncUserMapper.findById(syncInfo); + if (coreLocalData != null && !coreLocalData.isEmpty()){ + coreSyncUserMapper.edit(syncInfo); } else { - // 2024.8.9 按郭跃鹏提出:后期各公司从企业端分离后,需要其他公司的用户进行SQL联查,要求新增一张core_user的同步表,用于记录中台的所有用户数据 + coreSyncUserMapper.save(syncInfo); } } @@ -101,6 +128,60 @@ public class SyncDataListener implements RocketMQListener { if (SyncTypeEnum.KEY_PROJECT.getDescription().equals(tenCorpDto.getMark())){ } + // 部门 + if (SyncTypeEnum.DEPARTMENT.getDescription().equals(tenCorpDto.getMark())){ + System.out.println("department"); + String str = tenCorpDto.getData().getString("syncInfo"); + PageData syncInfo = JSONUtil.toBean(str, PageData.class); + PageData localData = departmentMapper.findById(syncInfo); + if (localData != null && !localData.isEmpty()){ + departmentMapper.edit(syncInfo); + } + + PageData coreLocalData = coreSyncDeptMapper.findById(syncInfo); + try { + if (!"1".equals(syncInfo.getString("ISDELETE"))) { + // 如果不是待删除的数据, 则进行排序字段的转换, 删除的数据只会传递ID和ISDELETE参数 + syncInfo.put("DEP_ORDER", Integer.parseInt(syncInfo.getString("DEP_ORDER"))); + } + }catch (Exception e){ + System.out.println("========================排序字段为空 : " + syncInfo.getString("DEP_ORDER") + " ========================"); + } + if (coreLocalData != null && !coreLocalData.isEmpty()){ + syncInfo.put("ISDELETE", syncInfo.getString("ISDELETE") == null ? "0" : syncInfo.getString("ISDELETE")); + coreSyncDeptMapper.edit(syncInfo); + } else { + syncInfo.put("ISDELETE", "0"); + coreSyncDeptMapper.save(syncInfo); + } + } + // 企业 + if (SyncTypeEnum.CORP.getDescription().equals(tenCorpDto.getMark())){ + System.out.println("corp"); + String str = tenCorpDto.getData().getString("syncInfo"); + PageData syncInfo = JSONUtil.toBean(str, PageData.class); + PageData localData = corpinfoMapper.findById(syncInfo); + if (localData != null && !localData.isEmpty()){ + corpinfoMapper.edit(syncInfo); + } + + PageData coreLocalData = coreSyncCorpMapper.findById(syncInfo); + try { + if (!"1".equals(syncInfo.getString("ISDELETE"))) { + // 如果不是待删除的数据, 则进行排序字段的转换, 删除的数据只会传递ID和ISDELETE参数 + syncInfo.put("COR_ORDER", Integer.parseInt(syncInfo.getString("COR_ORDER"))); + } + }catch (Exception e){ + System.out.println("========================排序字段为空 : " + syncInfo.getString("COR_ORDER") + " ========================"); + } + if (coreLocalData != null && !coreLocalData.isEmpty()){ + syncInfo.put("ISDELETE", syncInfo.getString("ISDELETE") == null ? "0" : syncInfo.getString("ISDELETE")); + coreSyncCorpMapper.edit(syncInfo); + } else { + syncInfo.put("ISDELETE", "0"); + coreSyncCorpMapper.save(syncInfo); + } + } mqConsumptionLogMapper.save(productionPD); mqConsumptionLogMapper.save(pd); diff --git a/src/main/resources/mybatis/datasource/core/CoreSyncCorpMapper.xml b/src/main/resources/mybatis/datasource/core/CoreSyncCorpMapper.xml new file mode 100644 index 00000000..fc4938b3 --- /dev/null +++ b/src/main/resources/mybatis/datasource/core/CoreSyncCorpMapper.xml @@ -0,0 +1,106 @@ + + + + + + + CORE_SYNC_CORPINFO + + + + + f.CORPINFO_ID , + f.CORP_NAME , + f.COR_ORDER , + f.ISDELETE, + f.CORP_FLAG + + + + + CORPINFO_ID , + CORP_NAME , + COR_ORDER , + ISDELETE, + CORP_FLAG + + + + + #{CORPINFO_ID} , + #{CORP_NAME} , + #{COR_ORDER} , + #{ISDELETE}, + #{CORP_FLAG} + + + + + insert into + + ( + + ) values ( + + ) + + + + + + + update + + + + CORP_NAME = #{CORP_NAME}, + + + COR_ORDER = #{COR_ORDER}, + + + ISDELETE = #{ISDELETE}, + + + CORP_FLAG = #{CORP_FLAG} + + + where + CORPINFO_ID = #{CORPINFO_ID} + + + + update + + set ISDELETE = '1' + where + CORPINFO_ID = #{CORPINFO_ID} + + + + diff --git a/src/main/resources/mybatis/datasource/core/CoreSyncDeptMapper.xml b/src/main/resources/mybatis/datasource/core/CoreSyncDeptMapper.xml new file mode 100644 index 00000000..3ce3e90f --- /dev/null +++ b/src/main/resources/mybatis/datasource/core/CoreSyncDeptMapper.xml @@ -0,0 +1,136 @@ + + + + + + + CORE_SYNC_DEPARTMENT + + + + + f.DEPARTMENT_ID , + f.NAME , + f.PARENT_ID , + f.CORPINFO_ID , + f.CORP_NAME , + f.DEP_ORDER , + f.DEPT_FLAG , + f.ISDELETE + + + + + DEPARTMENT_ID , + NAME , + PARENT_ID , + CORPINFO_ID , + CORP_NAME , + DEP_ORDER , + DEPT_FLAG , + ISDELETE + + + + + #{DEPARTMENT_ID} , + #{NAME} , + #{PARENT_ID} , + #{CORPINFO_ID} , + #{CORP_NAME} , + #{DEP_ORDER} , + #{DEPT_FLAG} , + #{ISDELETE} + + + + + insert into + + ( + + ) values ( + + ) + + + + + + + update + + + + NAME = #{NAME}, + + + PARENT_ID = #{PARENT_ID}, + + + CORPINFO_ID = #{CORPINFO_ID}, + + + CORP_NAME = #{CORP_NAME}, + + + DEP_ORDER = #{DEP_ORDER}, + + + DEPT_FLAG = #{DEPT_FLAG}, + + + ISDELETE = #{ISDELETE} + + + where + DEPARTMENT_ID = #{DEPARTMENT_ID} + + + + update + + set ISDELETE = '1' + where + DEPARTMENT_ID = #{DEPARTMENT_ID} + + + + diff --git a/src/main/resources/mybatis/datasource/core/CoreSyncUserMapper.xml b/src/main/resources/mybatis/datasource/core/CoreSyncUserMapper.xml new file mode 100644 index 00000000..269d5d46 --- /dev/null +++ b/src/main/resources/mybatis/datasource/core/CoreSyncUserMapper.xml @@ -0,0 +1,187 @@ + + + + + + + CORE_SYNC_USER + + + + + f.USER_ID , + f.USERNAME , + f.NAME , + f.PHONE , + f.CORPINFO_ID , + f.CORPINFO_NAME , + f.DEPARTMENT_ID , + f.DEPARTMENT_NAME , + f.POST_ID , + f.POST_NAME , + f.ROLE_ID , + f.ROLE_NAME , + f.USER_TYPE , + f.ISDELETE + + + + + USER_ID , + USERNAME , + NAME , + PHONE , + CORPINFO_ID , + CORPINFO_NAME , + DEPARTMENT_ID , + DEPARTMENT_NAME , + POST_ID , + POST_NAME , + ROLE_ID , + ROLE_NAME , + USER_TYPE , + ISDELETE + + + + + #{USER_ID} , + #{USERNAME} , + #{NAME} , + #{PHONE} , + #{CORPINFO_ID} , + #{CORPINFO_NAME} , + #{DEPARTMENT_ID} , + #{DEPARTMENT_NAME} , + #{POST_ID} , + #{POST_NAME} , + #{ROLE_ID} , + #{ROLE_NAME} , + #{USER_TYPE} , + #{ISDELETE} + + + + + insert into + + ( + + ) values ( + + ) + + + + + + + update + + + + USER_ID = #{USER_ID}, + + + USERNAME = #{USERNAME}, + + + NAME = #{NAME}, + + + PHONE = #{PHONE}, + + + CORPINFO_ID = #{CORPINFO_ID}, + + + CORPINFO_NAME = #{CORPINFO_NAME}, + + + DEPARTMENT_ID = #{DEPARTMENT_ID}, + + + DEPARTMENT_NAME = #{DEPARTMENT_NAME}, + + + POST_ID = #{POST_ID}, + + + POST_NAME = #{POST_NAME}, + + + ROLE_ID = #{ROLE_ID}, + + + ROLE_NAME = #{ROLE_NAME}, + + + USER_TYPE = #{USER_TYPE}, + + + ISDELETE = #{ISDELETE} + + + where + USER_ID = #{USER_ID} + + + + update + + set ISDELETE = '1' + where + USER_ID = #{USER_ID} + + + +