Commit fc30f692 by 刘鑫

Merge remote-tracking branch 'origin/develop' into develop

2 parents b5244bc8 c047e1a7
......@@ -187,11 +187,14 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
LocalDate beginDate = DateUtils.localDateFromStr(beginTime);
LocalDate endDate = DateUtils.localDateFromStr(repeatEndDate);
LocalDate current = beginDate;
// 保留固定基准开始时间,后续日历根据此日期推算
final String finalBeginTime = beginTime;
final String finalEndTime = endTime;
while (!current.isAfter(endDate)) {
// 开始时间,结束时间平移
int days = Period.between(beginDate, current).getDays();
beginTime = DateUtils.formatDateTime(DateUtils.localDateTimeFromStr(beginTime).plusDays(days));
endTime = DateUtils.formatDateTime(DateUtils.localDateTimeFromStr(endTime).plusDays(days));
long days = beginDate.until(current, ChronoUnit.DAYS);
beginTime = DateUtils.formatDateTime(DateUtils.localDateTimeFromStr(finalBeginTime).plusDays(days));
endTime = DateUtils.formatDateTime(DateUtils.localDateTimeFromStr(finalEndTime).plusDays(days));
addOneEngineerPlan(userId, engineerCode, type, beginTime, endTime, remark);
current = getNextDate(current, repeatType);
}
......@@ -406,7 +409,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
return mapping.get(type);
}
private String newPlanId(){
private String newPlanId() {
String idStr = IdUtil.getSnowflake().nextIdStr();
return idStr.substring(idStr.length() - 10);
}
......
......@@ -13,6 +13,7 @@ import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -43,12 +44,26 @@ public class OrganizationServiceImpl implements OrganizationService {
@Override
public Result<?> getOrganizationTree(String levelType, String levelValue) {
// 如果传递了精确的id,只返回对应的tree内容;如果没有传递,返回所有tree内容
List<OrganizationTreeDTO.Result> rs = new ArrayList<>();
if (StringUtils.isBlank(levelType) && StringUtils.isBlank(levelValue)) {
rs.add(getOrganizationTreeByOrgId(levelType, levelValue));
} else {
for (String value : levelValue.split(",")) {
rs.add(getOrganizationTreeByOrgId(levelType, value));
}
}
return Result.success(rs);
}
public OrganizationTreeDTO.Result getOrganizationTreeByOrgId(String levelType, String levelValue) {
// 如果传递了精确的id,只返回对应的tree内容;如果没有传递,返回所有tree内容
OrganizationTreeDTO.Result rs = new OrganizationTreeDTO.Result();
rs.setLevelType(levelType).setLevelValue(levelValue);
if ("group".equals(levelType)) {
OrgGroupEntity orgGroupEntity = orgGroupDao.getByGroupId(levelValue);
if (orgGroupEntity == null) {
return Result.failed("groupId对应的信息不存在");
return null;
}
List<?> groups = new ArrayList<>(Collections.singletonList(groupEntity2Dto(orgGroupEntity)));
OrgBranchEntity orgBranchEntity = orgBranchDao.getByBranchId(orgGroupEntity.getBranchId());
......@@ -59,7 +74,7 @@ public class OrganizationServiceImpl implements OrganizationService {
} else if ("branch".equals(levelType)) {
OrgBranchEntity orgBranchEntity = orgBranchDao.getByBranchId(levelValue);
if (orgBranchEntity == null) {
return Result.failed("分站信息不存在");
return null;
}
OrgClusterEntity orgClusterEntity = orgClusterDao.getByClusterId(orgBranchEntity.getClusterId());
List<?> groups = getChildByBranch(levelValue);
......@@ -69,7 +84,7 @@ public class OrganizationServiceImpl implements OrganizationService {
} else if ("cluster".equals(levelType)) {
OrgClusterEntity orgClusterEntity = orgClusterDao.getByClusterId(levelValue);
if (orgClusterEntity == null) {
return Result.failed("大区信息不存在");
return null;
}
List<?> branchs = getChildByCluster(levelValue);
List<?> clusters = new ArrayList<>(Collections.singletonList(clusterEntity2Dto(orgClusterEntity).setChildren(branchs)));
......@@ -77,7 +92,7 @@ public class OrganizationServiceImpl implements OrganizationService {
} else {
rs.setClusters(getTreeByRoot());
}
return Result.success(rs);
return rs;
}
@Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!