|
|
@@ -6,8 +6,11 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.domain.model.ErrorInfo;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.json.utils.JsonUtils;
|
|
|
+import org.dromara.hotel.api.domain.bo.RemoteTeamBo;
|
|
|
+import org.dromara.hotel.api.domain.vo.RemoteTeamVo;
|
|
|
import org.dromara.server.base.service.dept.SyncRemoteDeptService;
|
|
|
import org.dromara.server.base.service.dept.strategy.ISyncDeptStrategy;
|
|
|
import org.dromara.server.common.constant.DefaultConstants;
|
|
|
@@ -41,6 +44,7 @@ public class TrainClassStrategyImpl implements ISyncDeptStrategy {
|
|
|
@Override
|
|
|
public void syncDept(List<ResourceDept> deptList) {
|
|
|
List<String> syncMessage = new ArrayList<>();
|
|
|
+ List<String> syncTeamMessage = new ArrayList<>();
|
|
|
deptList.forEach(resourceDept -> {
|
|
|
R<Object> result = syncDept(resourceDept);
|
|
|
if (result.getCode() == R.SUCCESS) {
|
|
|
@@ -48,8 +52,17 @@ public class TrainClassStrategyImpl implements ISyncDeptStrategy {
|
|
|
} else {
|
|
|
syncMessage.add(MessageFormat.format("[同步培训班级失败]-[{0}]-[{1}]", JsonUtils.toJsonString(resourceDept), result.getMsg()));
|
|
|
}
|
|
|
+ // 增加了同时导入客房系统的团客信息
|
|
|
+ R<ErrorInfo> resultTeam = syncTeam(resourceDept);
|
|
|
+ if (R.isSuccess(resultTeam)) {
|
|
|
+ syncTeamMessage.add(MessageFormat.format("[同步客房团客成功]-[{0}]", JsonUtils.toJsonString(resourceDept)));
|
|
|
+ } else {
|
|
|
+ syncTeamMessage.add(
|
|
|
+ MessageFormat.format("[同步客房团客失败]-[{0}]-[{1}]", JsonUtils.toJsonString(resourceDept), resultTeam.getMsg()));
|
|
|
+ }
|
|
|
});
|
|
|
syncMessage.forEach(System.out::println);
|
|
|
+ syncTeamMessage.forEach(System.out::println);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -67,7 +80,7 @@ public class TrainClassStrategyImpl implements ISyncDeptStrategy {
|
|
|
}
|
|
|
String otherId = resourceDept.getDept_id();
|
|
|
RemoteDeptVo remoteDeptVo = syncRemoteDeptService.selectDeptByOtherId(otherId, tenantId);
|
|
|
- //将班级组装成入库的对模型
|
|
|
+ // 将班级组装成入库的对模型
|
|
|
R<RemoteDeptBo> result = setRemoteDeptBo(resourceDept, remoteDeptVo);
|
|
|
if (result.getCode() == R.SUCCESS) {
|
|
|
if (remoteDeptVo != null) {
|
|
|
@@ -90,27 +103,27 @@ public class TrainClassStrategyImpl implements ISyncDeptStrategy {
|
|
|
* @return 写库班级业务数据
|
|
|
*/
|
|
|
private R<RemoteDeptBo> setRemoteDeptBo(ResourceDept resourceDept, RemoteDeptVo remoteDeptVo) {
|
|
|
- //检查年份对应的部门,年份的父节点固定为127->校本部
|
|
|
+ // 检查年份对应的部门,年份的父节点固定为127->校本部
|
|
|
Long rootId = DefaultConstants.TRAIN_PARENT_DEPT_ID;
|
|
|
RemoteDeptVo yearDeptVo = doYearOrSemesterDept(resourceDept, rootId, 0);
|
|
|
if (yearDeptVo == null) {
|
|
|
- //处理年份对应的班级失败,直接返回失败
|
|
|
+ // 处理年份对应的班级失败,直接返回失败
|
|
|
return R.fail("创建年份对应部门失败");
|
|
|
}
|
|
|
- //检查学期对应的部门
|
|
|
+ // 检查学期对应的部门
|
|
|
RemoteDeptVo semesterDeptVo = doYearOrSemesterDept(resourceDept, yearDeptVo.getDeptId(), 1);
|
|
|
if (semesterDeptVo == null) {
|
|
|
- //处理学期对应的班级失败,直接返回失败
|
|
|
+ // 处理学期对应的班级失败,直接返回失败
|
|
|
return R.fail("创建学期对应部门失败");
|
|
|
}
|
|
|
|
|
|
- //处理班级对应的部门
|
|
|
+ // 处理班级对应的部门
|
|
|
String deptNum = resourceDept.getDept_num();
|
|
|
String tenantId = resourceDept.getTenantId();
|
|
|
RemoteDeptBo remoteDeptBo;
|
|
|
if (ObjUtil.isEmpty(remoteDeptVo)) {
|
|
|
remoteDeptBo = new RemoteDeptBo();
|
|
|
- //班级对应的部门默认类型为 05-班级
|
|
|
+ // 班级对应的部门默认类型为 05-班级
|
|
|
remoteDeptBo.setDeptType(DefaultConstants.CLASS_DEPT_TYPE);
|
|
|
} else {
|
|
|
remoteDeptBo = BeanUtil.copyProperties(remoteDeptVo, RemoteDeptBo.class);
|
|
|
@@ -146,13 +159,13 @@ public class TrainClassStrategyImpl implements ISyncDeptStrategy {
|
|
|
* @return 部门
|
|
|
*/
|
|
|
private RemoteDeptVo doYearOrSemesterDept(ResourceDept resourceDept, Long rootId, int flag) {
|
|
|
- String deptName = flag == 0 ? resourceDept.getYear().toString()+"年" : resourceDept.getSemester();
|
|
|
+ String deptName = flag == 0 ? resourceDept.getYear().toString() + "年" : resourceDept.getSemester();
|
|
|
|
|
|
RemoteDeptVo yearDeptVo = syncRemoteDeptService.selectDeptByParentIdAndName(rootId, deptName);
|
|
|
if (yearDeptVo != null) {
|
|
|
return yearDeptVo;
|
|
|
}
|
|
|
- //不存在对应的部门,需要增加
|
|
|
+ // 不存在对应的部门,需要增加
|
|
|
RemoteDeptBo remoteDeptBo = new RemoteDeptBo();
|
|
|
remoteDeptBo.setDeptName(deptName);
|
|
|
remoteDeptBo.setParentId(rootId);
|
|
|
@@ -166,4 +179,53 @@ public class TrainClassStrategyImpl implements ISyncDeptStrategy {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理单个班级,将班级转换成酒店系统的团客信息后入库
|
|
|
+ *
|
|
|
+ * @param resourceDept 班级数据
|
|
|
+ * @return 处理结果
|
|
|
+ */
|
|
|
+ private R<ErrorInfo> syncTeam(ResourceDept resourceDept) {
|
|
|
+ String otherId = resourceDept.getDept_id();
|
|
|
+ String tenantId = resourceDept.getTenantId();
|
|
|
+ R<RemoteTeamVo> result = syncRemoteDeptService.selectTeamByOtherId(otherId, tenantId);
|
|
|
+ RemoteTeamVo remoteTeamVo = result.getData();
|
|
|
+ R<RemoteTeamBo> getBo = setRemoteTeamBo(resourceDept, remoteTeamVo);
|
|
|
+ if (R.isSuccess(getBo)) {
|
|
|
+ if (R.isSuccess(result)) {
|
|
|
+ return syncRemoteDeptService.updateRemoteTeam(getBo.getData());
|
|
|
+ } else {
|
|
|
+ return syncRemoteDeptService.insertRemoteTeam(getBo.getData());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return R.fail(getBo.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组装写库的团客数据
|
|
|
+ *
|
|
|
+ * @param resourceDept 源数据
|
|
|
+ * @param remoteTeamVo 系统已有的团客数据
|
|
|
+ * @return 团客入库业务对象
|
|
|
+ */
|
|
|
+ private R<RemoteTeamBo> setRemoteTeamBo(ResourceDept resourceDept, RemoteTeamVo remoteTeamVo) {
|
|
|
+ RemoteTeamBo remoteTeamBo;
|
|
|
+ if (ObjUtil.isEmpty(remoteTeamVo)) {
|
|
|
+ remoteTeamBo = new RemoteTeamBo();
|
|
|
+ } else {
|
|
|
+ remoteTeamBo = BeanUtil.copyProperties(remoteTeamVo, RemoteTeamBo.class);
|
|
|
+ }
|
|
|
+ remoteTeamBo.setName(resourceDept.getDept_name());
|
|
|
+ remoteTeamBo.setStartTime(resourceDept.getBeginDate());
|
|
|
+ remoteTeamBo.setEndTime(resourceDept.getEndDate());
|
|
|
+ remoteTeamBo.setPlanQuantity(resourceDept.getPlanCount().longValue());
|
|
|
+ remoteTeamBo.setRemark("");
|
|
|
+ remoteTeamBo.setOtherId(resourceDept.getDept_id());
|
|
|
+ remoteTeamBo.setTenantId(resourceDept.getTenantId());
|
|
|
+
|
|
|
+ return R.ok(remoteTeamBo);
|
|
|
+ }
|
|
|
}
|