diff --git a/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java b/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java index 9e66a71bc..95a9a2694 100644 --- a/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java +++ b/src/main/java/com/glxp/api/constant/BasicExportStatusTimeEnum.java @@ -56,7 +56,7 @@ public enum BasicExportStatusTimeEnum { /** * 部门数据 */ - DEPARTMENT("department","部门数据"), + DEPT_DATA("dept_data","部门数据"), /** * 仓库数据 @@ -67,6 +67,26 @@ public enum BasicExportStatusTimeEnum { * 用户数据 */ USER_DATA("user_data","用户数据"), + + /** + * 第三方部门信息 + */ + THR_DEPT("thr_dept","第三方部门信息"), + + /** + * 第三方仓库信息 + */ + THR_WAREHOUSE("thr_warehouse","第三方仓库信息"), + + /** + * 第三方产品信息 + */ + THR_PRODUCTS("thr_products","第三方产品信息"), + + /** + * 第三方往来单位信息 + */ + THR_CORP("thr_corp","第三方往来单位信息"), ; @EnumValue private String key; diff --git a/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java b/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java index 2d3b97deb..03fc55503 100644 --- a/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java +++ b/src/main/java/com/glxp/api/constant/BasicExportTypeEnum.java @@ -31,6 +31,11 @@ public enum BasicExportTypeEnum { * 用户数据 */ USER_DATA("user_data", "用户数据"), + + /** + * 第三方数据 + */ + THIRD_DATA("third_data", "第三方数据"), ; private String key; diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrCorpDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrCorpDao.java index 250ea6cf1..7e535a3b5 100644 --- a/src/main/java/com/glxp/api/dao/thrsys/ThrCorpDao.java +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrCorpDao.java @@ -1,6 +1,7 @@ package com.glxp.api.dao.thrsys; +import com.glxp.api.dao.BaseMapperPlus; import com.glxp.api.entity.thrsys.ThrCorpEntity; import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; import com.glxp.api.req.thrsys.FilterThrCorpRequest; @@ -14,7 +15,7 @@ import java.util.Date; import java.util.List; @Mapper -public interface ThrCorpDao { +public interface ThrCorpDao extends BaseMapperPlus { List filterThrCorps(FilterThrCorpRequest filterThrCorpRequest); diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrDeptDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrDeptDao.java index e2eabe7e7..5a1df27ed 100644 --- a/src/main/java/com/glxp/api/dao/thrsys/ThrDeptDao.java +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrDeptDao.java @@ -1,5 +1,6 @@ package com.glxp.api.dao.thrsys; +import com.glxp.api.dao.BaseMapperPlus; import com.glxp.api.entity.thrsys.ThrDeptEntity; import com.glxp.api.req.thrsys.FilterThrDeptRequest; import org.apache.ibatis.annotations.Mapper; @@ -9,7 +10,7 @@ import java.util.Date; import java.util.List; @Mapper -public interface ThrDeptDao { +public interface ThrDeptDao extends BaseMapperPlus { List filterThrInvWarehouse(FilterThrDeptRequest filterThrDeptRequest); diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrInvWarehouseDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrInvWarehouseDao.java index 69c1ef3e9..1ab2bdd9a 100644 --- a/src/main/java/com/glxp/api/dao/thrsys/ThrInvWarehouseDao.java +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrInvWarehouseDao.java @@ -1,5 +1,6 @@ package com.glxp.api.dao.thrsys; +import com.glxp.api.dao.BaseMapperPlus; import com.glxp.api.entity.thrsys.ThrInvWarehouseEntity; import com.glxp.api.req.thrsys.FilterThrSubInvWarehouseRequest; import com.glxp.api.res.thrsys.ThrInvWarehouseResponse; @@ -10,7 +11,7 @@ import java.util.Date; import java.util.List; @Mapper -public interface ThrInvWarehouseDao { +public interface ThrInvWarehouseDao extends BaseMapperPlus { List filterThrInvWarehouse(FilterThrSubInvWarehouseRequest filterThrSubInvWarehouseRequest); diff --git a/src/main/java/com/glxp/api/dao/thrsys/ThrProductsDao.java b/src/main/java/com/glxp/api/dao/thrsys/ThrProductsDao.java index b7939422a..c8daaf63f 100644 --- a/src/main/java/com/glxp/api/dao/thrsys/ThrProductsDao.java +++ b/src/main/java/com/glxp/api/dao/thrsys/ThrProductsDao.java @@ -1,5 +1,6 @@ package com.glxp.api.dao.thrsys; +import com.glxp.api.dao.BaseMapperPlus; import com.glxp.api.entity.thrsys.ThrProductsEntity; import com.glxp.api.req.thrsys.FilterThrProductsRequest; import com.glxp.api.res.thrsys.ThrProductsResponse; @@ -16,7 +17,7 @@ import java.util.List; * @author ${author} * @since 2023-01-10 */ -public interface ThrProductsDao { +public interface ThrProductsDao extends BaseMapperPlus { List filterThrProducts(FilterThrProductsRequest filterThrProductsRequest); @@ -44,5 +45,5 @@ public interface ThrProductsDao { */ ThrProductsEntity selectByCodeAndThird(@Param("code") String code, @Param("thirdSysFk") String thirdSysFk); - boolean updateById(ThrProductsEntity thrProductsEntity); + boolean updateEntityById(ThrProductsEntity thrProductsEntity); } diff --git a/src/main/java/com/glxp/api/res/sync/SpsSyncThrDataResponse.java b/src/main/java/com/glxp/api/res/sync/SpsSyncThrDataResponse.java index 670d9eab5..f46767816 100644 --- a/src/main/java/com/glxp/api/res/sync/SpsSyncThrDataResponse.java +++ b/src/main/java/com/glxp/api/res/sync/SpsSyncThrDataResponse.java @@ -3,6 +3,7 @@ package com.glxp.api.res.sync; import com.glxp.api.entity.thrsys.ThrCorpEntity; import com.glxp.api.entity.thrsys.ThrDeptEntity; import com.glxp.api.entity.thrsys.ThrInvWarehouseEntity; +import com.glxp.api.entity.thrsys.ThrProductsEntity; import lombok.Data; import java.util.List; @@ -23,6 +24,11 @@ public class SpsSyncThrDataResponse extends BaseSyncResponse { */ private List invWarehouseEntities; + /** + * 第三方产品信息 + */ + private List productsEntityList; + /** * 往来单位信息 */ diff --git a/src/main/java/com/glxp/api/service/sync/HeartService.java b/src/main/java/com/glxp/api/service/sync/HeartService.java index 0be2e20c5..d3f3b0721 100644 --- a/src/main/java/com/glxp/api/service/sync/HeartService.java +++ b/src/main/java/com/glxp/api/service/sync/HeartService.java @@ -25,16 +25,15 @@ import com.glxp.api.entity.sync.BasicDownloadStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusEntity; import com.glxp.api.entity.sync.BasicExportStatusTimeEntity; import com.glxp.api.entity.system.SyncDataSetEntity; -import com.glxp.api.entity.thrsys.ThrBusTypeOriginEntity; +import com.glxp.api.entity.thrsys.*; import com.glxp.api.http.sync.SpGetHttpClient; import com.glxp.api.req.sync.SpsSyncDataRequest; -import com.glxp.api.res.auth.InvSpaceResponse; import com.glxp.api.res.sync.*; import com.glxp.api.service.auth.*; import com.glxp.api.service.basic.IBasicBusTypeChangeService; import com.glxp.api.service.basic.IBasicBussinessTypeService; import com.glxp.api.service.inout.*; -import com.glxp.api.service.thrsys.IThrBusTypeOriginService; +import com.glxp.api.service.thrsys.*; import com.glxp.api.util.CustomUtil; import com.glxp.api.util.DateUtil; import com.glxp.api.util.RedisUtil; @@ -237,6 +236,11 @@ public class HeartService { uploadData(exportType, taskId, x -> x.getUserData(info, taskId, now, syncTime)); } break; + case THIRD_DATA: + if (needExec(info.getBasicThirdDept(), info.getBasicThirdInv(), info.getBasicThirdProducts(),info.getBasicThirdCorp())) { + uploadData(exportType, taskId, x -> x.getThirdData(info, taskId, now, syncTime)); + } + break; case COUNTRY_DI_DATA: } } @@ -571,7 +575,7 @@ public class HeartService { if (needExec(info.getDepartment())) { Map map; if (syncTime == null) { - map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEPARTMENT); + map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEPT_DATA); } else { map = syncTimeMap; } @@ -689,6 +693,113 @@ public class HeartService { return dataResponse; } + private final ThrDeptService thrDeptService; + private final ThrInvWarehouseService thrInvWarehouseService; + private final ThrProductsService thrProductsService; + private final ThrCorpService thrCorpService; + + /** + * 获取第三方模块数据 + * + * @param info 同步设置 + * @param now 当前时间 + * @param syncTime 同步时间 -- 传入时不操作exportTime表 + * @return + */ + private SpsSyncThrDataResponse getThirdData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) { + SpsSyncThrDataResponse dataResponse = null; + Map syncTimeMap = new WeakHashMap<>(3); + syncTimeMap.put("isNew", true); + syncTimeMap.put("oldDate", syncTime); + + //确认有开启第三方部门信息同步 + if (needExec(info.getBasicThirdDept())) { + Map map; + if (syncTime == null) { + map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.THR_DEPT); + } else { + map = syncTimeMap; + } + List deptEntityList = thrDeptService.list(Wrappers.lambdaQuery(ThrDeptEntity.class) + .le((boolean) map.get("isNew"), ThrDeptEntity::getUpdateTime, now) + .between(!(boolean) map.get("isNew"), ThrDeptEntity::getUpdateTime + , map.get("oldDate"), now) + ); + if (CollectionUtil.isNotEmpty(deptEntityList)) { + dataResponse = new SpsSyncThrDataResponse(); + dataResponse.setDeptEntities(deptEntityList); + } + } + + //确认有开启第三方仓库信息同步 + if(needExec(info.getBasicThirdInv())){ + Map map; + if (syncTime == null) { + map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.THR_WAREHOUSE); + } else { + map = syncTimeMap; + } + List warehouseEntityList = thrInvWarehouseService.list(Wrappers.lambdaQuery(ThrInvWarehouseEntity.class) + .le((boolean) map.get("isNew"), ThrInvWarehouseEntity::getUpdateTime, now) + .between(!(boolean) map.get("isNew"), ThrInvWarehouseEntity::getUpdateTime + , map.get("oldDate"), now) + ); + if (CollectionUtil.isNotEmpty(warehouseEntityList)) { + if (dataResponse == null) { + dataResponse = new SpsSyncThrDataResponse(); + } + dataResponse.setInvWarehouseEntities(warehouseEntityList); + } + } + + //确认有开启仓库字典同步 + if (needExec(info.getBasicThirdProducts())) { + Map map; + if (syncTime == null) { + map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.THR_PRODUCTS); + } else { + map = syncTimeMap; + } + List productsEntityList = thrProductsService.list(Wrappers.lambdaQuery(ThrProductsEntity.class) + .le((boolean) map.get("isNew"), ThrProductsEntity::getUpdateTime, now) + .between(!(boolean) map.get("isNew"), ThrProductsEntity::getUpdateTime + , map.get("oldDate"), now) + ); + if (CollectionUtil.isNotEmpty(productsEntityList)) { + if (dataResponse == null) { + dataResponse = new SpsSyncThrDataResponse(); + } + dataResponse.setProductsEntityList(productsEntityList); + } + } + + //确认有开启第三方往来单位信息同步 + if (needExec(info.getBasicThirdCorp())) { + Map map; + if (syncTime == null) { + map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.THR_CORP); + } else { + map = syncTimeMap; + } + List corpEntities = thrCorpService.list(Wrappers.lambdaQuery(ThrCorpEntity.class) + .le((boolean) map.get("isNew"), ThrCorpEntity::getUpdateTime, now) + .between(!(boolean) map.get("isNew"), ThrCorpEntity::getUpdateTime + , map.get("oldDate"), now) + ); + if (CollectionUtil.isNotEmpty(corpEntities)) { + if (dataResponse == null) { + dataResponse = new SpsSyncThrDataResponse(); + } + dataResponse.setCorpEntities(corpEntities); + } + } + + if (dataResponse != null) { + dataResponse.setTaskId(taskId); + } + return dataResponse; + } + /** * 判断是否需要执行 由内向外 * diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrCorpService.java b/src/main/java/com/glxp/api/service/thrsys/ThrCorpService.java index e262c470e..c6ff97012 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThrCorpService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThrCorpService.java @@ -1,6 +1,7 @@ package com.glxp.api.service.thrsys; +import com.baomidou.mybatisplus.extension.service.IService; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.entity.thrsys.ThrCorpEntity; import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; @@ -11,7 +12,7 @@ import com.glxp.api.res.thrsys.ThrUnitMaintainResponse; import java.util.Date; import java.util.List; -public interface ThrCorpService { +public interface ThrCorpService extends IService { List filterThrCorps(FilterThrCorpRequest filterThrCorpRequest); diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrDeptService.java b/src/main/java/com/glxp/api/service/thrsys/ThrDeptService.java index 99abbb784..e9e415d3a 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThrDeptService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThrDeptService.java @@ -1,6 +1,7 @@ package com.glxp.api.service.thrsys; +import com.baomidou.mybatisplus.extension.service.IService; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.entity.thrsys.ThrDeptEntity; import com.glxp.api.req.thrsys.FilterThrDeptRequest; @@ -8,7 +9,7 @@ import com.glxp.api.req.thrsys.FilterThrDeptRequest; import java.util.Date; import java.util.List; -public interface ThrDeptService { +public interface ThrDeptService extends IService { ThrDeptEntity findDefault(Boolean advaceType, Boolean isDefault); diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrInvWarehouseService.java b/src/main/java/com/glxp/api/service/thrsys/ThrInvWarehouseService.java index 562990fa3..d815d6fdf 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThrInvWarehouseService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThrInvWarehouseService.java @@ -1,6 +1,7 @@ package com.glxp.api.service.thrsys; +import com.baomidou.mybatisplus.extension.service.IService; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.entity.thrsys.ThrInvWarehouseEntity; import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; @@ -10,7 +11,7 @@ import com.glxp.api.res.thrsys.ThrInvWarehouseResponse; import java.util.Date; import java.util.List; -public interface ThrInvWarehouseService { +public interface ThrInvWarehouseService extends IService { ThrInvWarehouseEntity selectById(String id); diff --git a/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java b/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java index 2d15691f3..593052c2d 100644 --- a/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java +++ b/src/main/java/com/glxp/api/service/thrsys/ThrProductsService.java @@ -1,6 +1,7 @@ package com.glxp.api.service.thrsys; +import com.baomidou.mybatisplus.extension.service.IService; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.entity.thrsys.ThrProductsEntity; import com.glxp.api.entity.thrsys.ThrSystemDetailEntity; @@ -20,7 +21,7 @@ import java.util.List; * @author ${author} * @since 2023-01-10 */ -public interface ThrProductsService { +public interface ThrProductsService extends IService { ThrProductsEntity selectByCode(String code); diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java index fc2a50a41..00f65773b 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrCorpServiceImpl.java @@ -1,6 +1,7 @@ package com.glxp.api.service.thrsys.impl; import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -24,7 +25,7 @@ import java.util.List; @Service @Transactional(rollbackFor = Exception.class) -public class ThrCorpServiceImpl implements ThrCorpService { +public class ThrCorpServiceImpl extends ServiceImpl implements ThrCorpService { @Resource private ThrCorpDao thrCorpDao; diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrDeptServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrDeptServiceImpl.java index ae916967e..f79172bd0 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrDeptServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrDeptServiceImpl.java @@ -2,6 +2,7 @@ package com.glxp.api.service.thrsys.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -26,7 +27,7 @@ import java.util.List; @Service @Transactional(rollbackFor = Exception.class) -public class ThrDeptServiceImpl implements ThrDeptService { +public class ThrDeptServiceImpl extends ServiceImpl implements ThrDeptService { @Resource private ThrDeptDao thrDeptDao; diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java index 29a84e44f..24970bcb4 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrInvWarehouseServiceImpl.java @@ -3,6 +3,7 @@ package com.glxp.api.service.thrsys.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -28,7 +29,7 @@ import java.util.List; @Slf4j @Service @Transactional(rollbackFor = Exception.class) -public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService { +public class ThrInvWarehouseServiceImpl extends ServiceImpl implements ThrInvWarehouseService { @Resource private ThrInvWarehouseDao thrInvWarehouseDao; diff --git a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java index 7f70976bc..7156d9de9 100644 --- a/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java +++ b/src/main/java/com/glxp/api/service/thrsys/impl/ThrProductsServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.pagehelper.PageHelper; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; @@ -41,7 +42,7 @@ import java.util.List; @Slf4j @Service @Transactional(rollbackFor = Exception.class) -public class ThrProductsServiceImpl implements ThrProductsService { +public class ThrProductsServiceImpl extends ServiceImpl implements ThrProductsService { @Resource private ThrProductsDao thrProductsDao; @@ -188,7 +189,7 @@ public class ThrProductsServiceImpl implements ThrProductsService { boolean isChange = verifyDataChange(thrProductsEntity, item); if (isChange) { thrProductsEntity.setUpdateTime(new Date()); - thrProductsDao.updateById(thrProductsEntity); + thrProductsDao.updateEntityById(thrProductsEntity); } } }); diff --git a/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml b/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml index 18452a296..dd44c14f5 100644 --- a/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml +++ b/src/main/resources/mybatis/mapper/thrsys/ThrProductsDao.xml @@ -279,7 +279,7 @@ - + update thr_products code = #{code,jdbcType=VARCHAR},