|
@@ -3,13 +3,24 @@ package com.ym.mec.biz.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.ym.mec.biz.dal.entity.Organization;
|
|
|
|
+import com.ym.mec.biz.dal.enums.EDegreeStatus;
|
|
|
|
+import com.ym.mec.biz.service.OrganizationService;
|
|
|
|
+import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import com.ym.mec.biz.dal.entity.Degree;
|
|
import com.ym.mec.biz.dal.entity.Degree;
|
|
import com.ym.mec.biz.dal.wrapper.DegreeWrapper;
|
|
import com.ym.mec.biz.dal.wrapper.DegreeWrapper;
|
|
import com.ym.mec.biz.dal.mapper.DegreeMapper;
|
|
import com.ym.mec.biz.dal.mapper.DegreeMapper;
|
|
import com.ym.mec.biz.service.DegreeService;
|
|
import com.ym.mec.biz.service.DegreeService;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
+
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 考级信息
|
|
* 考级信息
|
|
@@ -19,6 +30,9 @@ import com.ym.mec.biz.service.DegreeService;
|
|
@Service
|
|
@Service
|
|
public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> implements DegreeService {
|
|
public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> implements DegreeService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private OrganizationService organizationService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询详情
|
|
* 查询详情
|
|
* @param id 详情ID
|
|
* @param id 详情ID
|
|
@@ -37,9 +51,44 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
|
|
* @return IPage<Degree>
|
|
* @return IPage<Degree>
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public IPage<Degree> selectPage(IPage<Degree> page, DegreeWrapper.DegreeQuery query) {
|
|
|
|
-
|
|
|
|
- return page.setRecords(baseMapper.selectPage(page, query));
|
|
|
|
|
|
+ public IPage<DegreeWrapper.Degree> selectPage(IPage<Degree> page, DegreeWrapper.DegreeQuery query) {
|
|
|
|
+
|
|
|
|
+ Integer tenantId = TenantContextHolder.getTenantId();
|
|
|
|
+ query.setTenantId(tenantId);
|
|
|
|
+
|
|
|
|
+ IPage<Degree> degreeIPage = page.setRecords(baseMapper.selectPage(page, query));
|
|
|
|
+ List<Degree> records = degreeIPage.getRecords();
|
|
|
|
+ IPage<DegreeWrapper.Degree> result = degreeIPage.convert(o -> new DegreeWrapper.Degree());
|
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ // 设置分部信息
|
|
|
|
+ List<DegreeWrapper.Degree> degrees = JSON.parseArray(JSON.toJSONString(records), DegreeWrapper.Degree.class);
|
|
|
|
+
|
|
|
|
+ // 所有的分部id
|
|
|
|
+ List<Integer> organIds = degrees.stream()
|
|
|
|
+ .flatMap(o -> Arrays.stream(o.getOrganIds().split(",")))
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .map(Integer::valueOf)
|
|
|
|
+ .distinct()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<Organization> organs = organizationService.findOrgans(organIds, tenantId);
|
|
|
|
+
|
|
|
|
+ degrees.forEach(o -> {
|
|
|
|
+ List<String> organNames = Arrays.stream(o.getOrganIds().split(","))
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .map(Integer::valueOf)
|
|
|
|
+ .distinct()
|
|
|
|
+ .flatMap(organId -> organs.stream()
|
|
|
|
+ .filter(organ -> organ.getId().equals(organId))
|
|
|
|
+ .map(Organization::getName)
|
|
|
|
+ ).collect(Collectors.toList());
|
|
|
|
+ o.setOrganNames(organNames);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return result.setRecords(degrees);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,19 +97,40 @@ public class DegreeServiceImpl extends ServiceImpl<DegreeMapper, Degree> impleme
|
|
* @return Boolean
|
|
* @return Boolean
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Boolean add(DegreeWrapper.Degree degree) {
|
|
|
|
|
|
+ public Boolean add(DegreeWrapper.Degree degree) {
|
|
|
|
+
|
|
|
|
+ Integer tenantId = TenantContextHolder.getTenantId();
|
|
|
|
+ degree.setTenantId(tenantId);
|
|
|
|
+ updateDegreeStatus(degree);
|
|
|
|
+
|
|
|
|
|
|
return this.save(JSON.parseObject(degree.jsonString(), Degree.class));
|
|
return this.save(JSON.parseObject(degree.jsonString(), Degree.class));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 根据时间设置状态
|
|
|
|
+ * @param degree DegreeWrapper.Degree
|
|
|
|
+ */
|
|
|
|
+ private void updateDegreeStatus(DegreeWrapper.Degree degree) {
|
|
|
|
+ if (degree.getStartTime().compareTo(new Date()) > 0) {
|
|
|
|
+ degree.setStatus(EDegreeStatus.NOT_START);
|
|
|
|
+ } else if (degree.getStartTime().compareTo(new Date()) <= 0 && degree.getEndTime().compareTo(new Date()) >= 0) {
|
|
|
|
+ degree.setStatus(EDegreeStatus.START);
|
|
|
|
+ } else {
|
|
|
|
+ degree.setStatus(EDegreeStatus.END);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 更新
|
|
* 更新
|
|
* @param degree DegreeWrapper.Degree
|
|
* @param degree DegreeWrapper.Degree
|
|
* @return Boolean
|
|
* @return Boolean
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean update(DegreeWrapper.Degree degree){
|
|
public Boolean update(DegreeWrapper.Degree degree){
|
|
|
|
+ updateDegreeStatus(degree);
|
|
|
|
|
|
return this.updateById(JSON.parseObject(degree.jsonString(), Degree.class));
|
|
return this.updateById(JSON.parseObject(degree.jsonString(), Degree.class));
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|