|
|
|
@ -17,6 +17,7 @@ import com.glxp.api.dao.inout.IoCodeRelMapper;
|
|
|
|
|
import com.glxp.api.dao.purchase.*;
|
|
|
|
|
import com.glxp.api.dao.thrsys.ThrBusTypeOriginDao;
|
|
|
|
|
import com.glxp.api.dto.RelaySyncDto;
|
|
|
|
|
import com.glxp.api.entity.auth.*;
|
|
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
|
|
import com.glxp.api.entity.inout.*;
|
|
|
|
|
import com.glxp.api.entity.purchase.*;
|
|
|
|
@ -27,7 +28,9 @@ import com.glxp.api.entity.system.SyncDataSetEntity;
|
|
|
|
|
import com.glxp.api.entity.thrsys.ThrBusTypeOriginEntity;
|
|
|
|
|
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.*;
|
|
|
|
@ -41,7 +44,6 @@ import org.apache.ibatis.session.ExecutorType;
|
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
|
import org.apache.ibatis.session.TransactionIsolationLevel;
|
|
|
|
|
import org.springframework.aop.framework.AopContext;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -210,7 +212,7 @@ public class HeartService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void chooseData(SyncDataSetEntity info, Date syncTime, BasicExportTypeEnum exportType) {
|
|
|
|
|
public void pushData(SyncDataSetEntity info, Date syncTime, BasicExportTypeEnum exportType) {
|
|
|
|
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
String taskId = CustomUtil.getId();
|
|
|
|
@ -230,6 +232,11 @@ public class HeartService {
|
|
|
|
|
uploadData(exportType, taskId, x -> x.getDocumentTypeData(info, taskId, now, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case USER_DATA:
|
|
|
|
|
if (needExec(info.getDepartment(), info.getWarehouseDict(), info.getUserData())) {
|
|
|
|
|
uploadData(exportType, taskId, x -> x.getUserData(info, taskId, now, syncTime));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case COUNTRY_DI_DATA:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -537,6 +544,151 @@ public class HeartService {
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final DeptService deptService;
|
|
|
|
|
private final DeptUserService deptUserService;
|
|
|
|
|
private final InvWarehouseService warehouseService;
|
|
|
|
|
private final WarehouseUserService warehouseUserService;
|
|
|
|
|
private final WarehouseBussinessTypeService warehouseBussinessTypeService;
|
|
|
|
|
private final InvSpaceService invSpaceService;
|
|
|
|
|
private final AuthAdminService adminService;
|
|
|
|
|
private final InvBusUserService invBusUserService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取单据类型数据
|
|
|
|
|
*
|
|
|
|
|
* @param info 同步设置
|
|
|
|
|
* @param now 当前时间
|
|
|
|
|
* @param syncTime 同步时间 -- 传入时不操作exportTime表
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public SpsSyncDataResponse getUserData(SyncDataSetEntity info, String taskId, Date now, Date syncTime) {
|
|
|
|
|
SpsSyncDataResponse dataResponse = null;
|
|
|
|
|
Map<String, Object> syncTimeMap = new WeakHashMap<>(3);
|
|
|
|
|
syncTimeMap.put("isNew", true);
|
|
|
|
|
syncTimeMap.put("oldDate", syncTime);
|
|
|
|
|
|
|
|
|
|
//确认有开启部门信息同步
|
|
|
|
|
if (needExec(info.getDepartment())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.DEPARTMENT);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<DeptEntity> deptEntityList = deptService.list(Wrappers.lambdaQuery(DeptEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), DeptEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), DeptEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(deptEntityList)) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
dataResponse.setDeptEntityList(deptEntityList);
|
|
|
|
|
}
|
|
|
|
|
List<DeptUserEntity> deptUserEntityList = deptUserService.list(Wrappers.lambdaQuery(DeptUserEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), DeptUserEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), DeptUserEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(deptUserEntityList)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setDeptUserEntities(deptUserEntityList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//确认有开启仓库字典同步
|
|
|
|
|
if (needExec(info.getWarehouseDict())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.WAREHOUSE_DICT);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<InvWarehouseEntity> warehouseEntityList = warehouseService.list(Wrappers.lambdaQuery(InvWarehouseEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), InvWarehouseEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), InvWarehouseEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(warehouseEntityList)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setInvWarehouseEntities(warehouseEntityList);
|
|
|
|
|
}
|
|
|
|
|
List<WarehouseUserEntity> warehouseUserEntities = warehouseUserService.list(Wrappers.lambdaQuery(WarehouseUserEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), WarehouseUserEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), WarehouseUserEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(warehouseUserEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setWarehouseUserEntities(warehouseUserEntities);
|
|
|
|
|
}
|
|
|
|
|
List<WarehouseBussinessTypeEntity> warehouseBussinessTypeEntities = warehouseBussinessTypeService.list(Wrappers.lambdaQuery(WarehouseBussinessTypeEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), WarehouseBussinessTypeEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), WarehouseBussinessTypeEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(warehouseBussinessTypeEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setWarehouseBussinessTypeEntities(warehouseBussinessTypeEntities);
|
|
|
|
|
}
|
|
|
|
|
List<InvSpace> invSpaceList = invSpaceService.list(Wrappers.lambdaQuery(InvSpace.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), InvSpace::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), InvSpace::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(invSpaceList)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setInvSpaces(invSpaceList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//确认有开启用户信息同步
|
|
|
|
|
if (needExec(info.getUserData())) {
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
if (syncTime == null) {
|
|
|
|
|
map = basicExportStatusTimeInfo(now, BasicExportStatusTimeEnum.USER_DATA);
|
|
|
|
|
} else {
|
|
|
|
|
map = syncTimeMap;
|
|
|
|
|
}
|
|
|
|
|
List<AuthAdmin> adminList = adminService.list(Wrappers.lambdaQuery(AuthAdmin.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), AuthAdmin::getLastModifyTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), AuthAdmin::getLastModifyTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(adminList)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setAuthAdminList(adminList);
|
|
|
|
|
}
|
|
|
|
|
List<InvBusUserEntity> busUserEntities = invBusUserService.list(Wrappers.lambdaQuery(InvBusUserEntity.class)
|
|
|
|
|
.le((boolean) map.get("isNew"), InvBusUserEntity::getUpdateTime, now)
|
|
|
|
|
.between(!(boolean) map.get("isNew"), InvBusUserEntity::getUpdateTime
|
|
|
|
|
, map.get("oldDate"), now)
|
|
|
|
|
);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(busUserEntities)) {
|
|
|
|
|
if (dataResponse == null) {
|
|
|
|
|
dataResponse = new SpsSyncDataResponse();
|
|
|
|
|
}
|
|
|
|
|
dataResponse.setInvBusUserEntities(busUserEntities);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataResponse != null) {
|
|
|
|
|
dataResponse.setTaskId(taskId);
|
|
|
|
|
}
|
|
|
|
|
return dataResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断是否需要执行 由内向外
|
|
|
|
|
*
|
|
|
|
|