|
@@ -9,6 +9,7 @@ import com.imed.costaccount.model.User;
|
|
import com.imed.costaccount.model.dto.ResponsibilityEditDTO;
|
|
import com.imed.costaccount.model.dto.ResponsibilityEditDTO;
|
|
import com.imed.costaccount.model.dto.ResponsibilitySaveDTO;
|
|
import com.imed.costaccount.model.dto.ResponsibilitySaveDTO;
|
|
import com.imed.costaccount.model.vo.CenterDepartmentVO;
|
|
import com.imed.costaccount.model.vo.CenterDepartmentVO;
|
|
|
|
+import com.imed.costaccount.model.vo.CommonVO;
|
|
import com.imed.costaccount.model.vo.CostResponsibilityVO;
|
|
import com.imed.costaccount.model.vo.CostResponsibilityVO;
|
|
import com.imed.costaccount.utils.BeanUtil;
|
|
import com.imed.costaccount.utils.BeanUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -22,10 +23,7 @@ import com.imed.costaccount.service.ResponsibilityService;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -35,8 +33,9 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
|
|
|
/**
|
|
/**
|
|
* 责任中心列表不分页
|
|
* 责任中心列表不分页
|
|
- * @return
|
|
|
|
|
|
+ *
|
|
* @param user
|
|
* @param user
|
|
|
|
+ * @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<CostResponsibilityVO> getList(User user) {
|
|
public List<CostResponsibilityVO> getList(User user) {
|
|
@@ -46,7 +45,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
.eq(Responsibility::getHospId, user.getHospId())
|
|
.eq(Responsibility::getHospId, user.getHospId())
|
|
);
|
|
);
|
|
if (CollUtil.isEmpty(list)) {
|
|
if (CollUtil.isEmpty(list)) {
|
|
- throw new CostException(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
|
|
|
|
+ return Collections.emptyList();
|
|
}
|
|
}
|
|
// 拷贝组合
|
|
// 拷贝组合
|
|
List<CostResponsibilityVO> costResponsibilityVOS = BeanUtil.convertList(list, CostResponsibilityVO.class);
|
|
List<CostResponsibilityVO> costResponsibilityVOS = BeanUtil.convertList(list, CostResponsibilityVO.class);
|
|
@@ -65,11 +64,12 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增责任中心
|
|
* 新增责任中心
|
|
|
|
+ *
|
|
* @param responsibilitySaveDTO {@link ResponsibilitySaveDTO }
|
|
* @param responsibilitySaveDTO {@link ResponsibilitySaveDTO }
|
|
* @param user
|
|
* @param user
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void addResponsibilityCenter(ResponsibilitySaveDTO responsibilitySaveDTO, User user) {
|
|
public void addResponsibilityCenter(ResponsibilitySaveDTO responsibilitySaveDTO, User user) {
|
|
// 如果是一级分类parentId为0
|
|
// 如果是一级分类parentId为0
|
|
Integer id = responsibilitySaveDTO.getId();
|
|
Integer id = responsibilitySaveDTO.getId();
|
|
@@ -87,8 +87,9 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
}
|
|
}
|
|
|
|
|
|
Responsibility center = BeanUtil.convertObj(responsibilitySaveDTO, Responsibility.class);
|
|
Responsibility center = BeanUtil.convertObj(responsibilitySaveDTO, Responsibility.class);
|
|
- center.setCreateTime(new Date().getTime()).setId(null).setParentId(id);
|
|
|
|
|
|
+ center.setCreateTime(new Date().getTime()).setId(null).setParentId(id).setHospId(user.getHospId());
|
|
if (id == 0) {
|
|
if (id == 0) {
|
|
|
|
+ center.setResponsibilityLevel(1);
|
|
center.setShareLevel(0);
|
|
center.setShareLevel(0);
|
|
center.setShareName("");
|
|
center.setShareName("");
|
|
}
|
|
}
|
|
@@ -98,11 +99,12 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
|
|
|
/**
|
|
/**
|
|
* 编辑责任中心
|
|
* 编辑责任中心
|
|
|
|
+ *
|
|
* @param responsibilityEditDTO {@link ResponsibilityEditDTO}
|
|
* @param responsibilityEditDTO {@link ResponsibilityEditDTO}
|
|
* @param user
|
|
* @param user
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void editResponsibility(ResponsibilityEditDTO responsibilityEditDTO, User user) {
|
|
public void editResponsibility(ResponsibilityEditDTO responsibilityEditDTO, User user) {
|
|
Integer id = responsibilityEditDTO.getId();
|
|
Integer id = responsibilityEditDTO.getId();
|
|
Responsibility center = this.getById(id);
|
|
Responsibility center = this.getById(id);
|
|
@@ -111,19 +113,20 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
}
|
|
}
|
|
// 如果修改父节点节点(只有两层的情况)
|
|
// 如果修改父节点节点(只有两层的情况)
|
|
if (center.getResponsibilityLevel() == 1) {
|
|
if (center.getResponsibilityLevel() == 1) {
|
|
- this.updateParent(responsibilityEditDTO,center);
|
|
|
|
|
|
+ this.updateParent(responsibilityEditDTO, center);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.updateCurrent(responsibilityEditDTO,center);
|
|
|
|
|
|
+ this.updateCurrent(responsibilityEditDTO, center);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修的是父节点
|
|
* 修的是父节点
|
|
|
|
+ *
|
|
* @param dto
|
|
* @param dto
|
|
* @param responsibility
|
|
* @param responsibility
|
|
*/
|
|
*/
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void updateParent(ResponsibilityEditDTO dto, Responsibility responsibility) {
|
|
public void updateParent(ResponsibilityEditDTO dto, Responsibility responsibility) {
|
|
// 删除原有的父节点数据
|
|
// 删除原有的父节点数据
|
|
Integer id = dto.getId();
|
|
Integer id = dto.getId();
|
|
@@ -141,10 +144,11 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改当前的节点
|
|
* 修改当前的节点
|
|
|
|
+ *
|
|
* @param responsibility
|
|
* @param responsibility
|
|
* @param dto
|
|
* @param dto
|
|
*/
|
|
*/
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void updateCurrent(ResponsibilityEditDTO dto, Responsibility responsibility) {
|
|
public void updateCurrent(ResponsibilityEditDTO dto, Responsibility responsibility) {
|
|
// 删除原有的父节点数据
|
|
// 删除原有的父节点数据
|
|
Integer id = dto.getId();
|
|
Integer id = dto.getId();
|
|
@@ -162,7 +166,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
* @param id
|
|
* @param id
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void deleteCenter(Integer id) {
|
|
public void deleteCenter(Integer id) {
|
|
Responsibility center = this.getById(id);
|
|
Responsibility center = this.getById(id);
|
|
if (Objects.isNull(center)) {
|
|
if (Objects.isNull(center)) {
|
|
@@ -171,16 +175,17 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
Integer parentId = center.getParentId();
|
|
Integer parentId = center.getParentId();
|
|
if (parentId == 0) {
|
|
if (parentId == 0) {
|
|
this.deleteAllSonCenter(id);
|
|
this.deleteAllSonCenter(id);
|
|
- return ;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
this.removeById(id);
|
|
this.removeById(id);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除父节点以及所有子节点责任中心
|
|
* 删除父节点以及所有子节点责任中心
|
|
|
|
+ *
|
|
* @param id
|
|
* @param id
|
|
*/
|
|
*/
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void deleteAllSonCenter(Integer id) {
|
|
public void deleteAllSonCenter(Integer id) {
|
|
this.removeById(id);
|
|
this.removeById(id);
|
|
this.remove(new LambdaQueryWrapper<Responsibility>().eq(Responsibility::getParentId, id));
|
|
this.remove(new LambdaQueryWrapper<Responsibility>().eq(Responsibility::getParentId, id));
|
|
@@ -226,4 +231,19 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
|
|
}
|
|
}
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<CommonVO> getParentList(User user) {
|
|
|
|
+ List<Responsibility> list = this.list(
|
|
|
|
+ new LambdaQueryWrapper<Responsibility>().select(Responsibility::getId, Responsibility::getResponsibilityName)
|
|
|
|
+ .eq(Responsibility::getHospId, user.getHospId())
|
|
|
|
+ );
|
|
|
|
+ return list.stream().map(i -> {
|
|
|
|
+ CommonVO commonVO = new CommonVO();
|
|
|
|
+ commonVO.setId(i.getId());
|
|
|
|
+ commonVO.setName(i.getResponsibilityName());
|
|
|
|
+ return commonVO;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }
|
|
}
|
|
}
|