|
@@ -8,6 +8,7 @@ import com.imed.costaccount.enums.ErrorCodeEnum;
|
|
|
import com.imed.costaccount.model.User;
|
|
|
import com.imed.costaccount.model.dto.ResponsibilityEditDTO;
|
|
|
import com.imed.costaccount.model.dto.ResponsibilitySaveDTO;
|
|
|
+import com.imed.costaccount.model.vo.CenterDepartmentVO;
|
|
|
import com.imed.costaccount.model.vo.CostResponsibilityVO;
|
|
|
import com.imed.costaccount.utils.BeanUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -21,6 +22,7 @@ import com.imed.costaccount.service.ResponsibilityService;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
@@ -180,4 +182,44 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
this.remove(new LambdaQueryWrapper<Responsibility>().eq(Responsibility::getParentId, id));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取部门树列表
|
|
|
+ *
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<CenterDepartmentVO> getParentSon(User user) {
|
|
|
+ // 1. 获取所有的列表然后组装
|
|
|
+ List<Responsibility> parentList = this.list(
|
|
|
+ new LambdaQueryWrapper<Responsibility>()
|
|
|
+ .eq(Responsibility::getHospId, user.getHospId())
|
|
|
+ .eq(Responsibility::getParentId, 0)
|
|
|
+ );
|
|
|
+ if (CollUtil.isEmpty(parentList)) {
|
|
|
+ throw new CostException(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
|
+ }
|
|
|
+ List<Responsibility> sonList = this.list(
|
|
|
+ new LambdaQueryWrapper<Responsibility>()
|
|
|
+ .eq(Responsibility::getHospId, user.getHospId())
|
|
|
+ .ne(Responsibility::getParentId, 0)
|
|
|
+ );
|
|
|
+ List<CenterDepartmentVO> list = new ArrayList<>();
|
|
|
+ // 拷贝组合
|
|
|
+ for (Responsibility parent : parentList) {
|
|
|
+ CenterDepartmentVO centerDepartmentVO = new CenterDepartmentVO();
|
|
|
+ centerDepartmentVO.setResponsibilityId(parent.getId());
|
|
|
+ centerDepartmentVO.setResponsibilityName(parent.getResponsibilityName());
|
|
|
+ for (Responsibility son : sonList) {
|
|
|
+ CenterDepartmentVO sonVO = new CenterDepartmentVO();
|
|
|
+ if (parent.getId().equals(son.getParentId())) {
|
|
|
+ sonVO.setResponsibilityId(son.getId());
|
|
|
+ sonVO.setResponsibilityName(son.getResponsibilityName());
|
|
|
+ centerDepartmentVO.getChild().add(sonVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ list.add(centerDepartmentVO);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|