|
@@ -7,13 +7,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.imed.costaccount.common.exception.CostException;
|
|
import com.imed.costaccount.common.exception.CostException;
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
|
|
+import com.imed.costaccount.constants.NumberConstant;
|
|
import com.imed.costaccount.mapper.HospitalMapper;
|
|
import com.imed.costaccount.mapper.HospitalMapper;
|
|
import com.imed.costaccount.model.Hospital;
|
|
import com.imed.costaccount.model.Hospital;
|
|
import com.imed.costaccount.model.dto.HospitalDto;
|
|
import com.imed.costaccount.model.dto.HospitalDto;
|
|
import com.imed.costaccount.model.dto.HospitalSaveDto;
|
|
import com.imed.costaccount.model.dto.HospitalSaveDto;
|
|
import com.imed.costaccount.model.vo.CommonVO;
|
|
import com.imed.costaccount.model.vo.CommonVO;
|
|
import com.imed.costaccount.model.vo.HospitalAllVO;
|
|
import com.imed.costaccount.model.vo.HospitalAllVO;
|
|
-import com.imed.costaccount.model.vo.HosptailVO;
|
|
|
|
|
|
+import com.imed.costaccount.model.vo.HospitalVO;
|
|
import com.imed.costaccount.service.HospitalService;
|
|
import com.imed.costaccount.service.HospitalService;
|
|
import com.imed.costaccount.utils.BeanUtil;
|
|
import com.imed.costaccount.utils.BeanUtil;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -46,9 +47,17 @@ public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> i
|
|
// .eq(!StringUtils.isEmpty(hospId), Hospital::getId, hospId)
|
|
// .eq(!StringUtils.isEmpty(hospId), Hospital::getId, hospId)
|
|
.like(!StringUtils.isEmpty(name), Hospital::getName, name));
|
|
.like(!StringUtils.isEmpty(name), Hospital::getName, name));
|
|
List<Hospital> records = pages.getRecords();
|
|
List<Hospital> records = pages.getRecords();
|
|
- List<HosptailVO> hosptailVOList = BeanUtil.convertList(records, HosptailVO.class);
|
|
|
|
|
|
+ List<HospitalVO> hospitalVOList = BeanUtil.convertList(records, HospitalVO.class);
|
|
|
|
+
|
|
|
|
+ hospitalVOList.forEach(i->{
|
|
|
|
+ if (NumberConstant.ZERO.equals(i.getIsHospital())){
|
|
|
|
+ i.setParentId(null);
|
|
|
|
+ i.setParentName(null);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
PageUtils pageUtils = new PageUtils(pages);
|
|
PageUtils pageUtils = new PageUtils(pages);
|
|
- pageUtils.setList(hosptailVOList);
|
|
|
|
|
|
+ pageUtils.setList(hospitalVOList);
|
|
return pageUtils;
|
|
return pageUtils;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -61,6 +70,7 @@ public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> i
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void saveHosptail(HospitalSaveDto hospitalSaveDto) {
|
|
public void saveHosptail(HospitalSaveDto hospitalSaveDto) {
|
|
String sign = hospitalSaveDto.getSign();
|
|
String sign = hospitalSaveDto.getSign();
|
|
|
|
+ // 检验此时保存的是医院还是院区
|
|
checkParam(hospitalSaveDto, sign);
|
|
checkParam(hospitalSaveDto, sign);
|
|
Hospital hospital = BeanUtil.convertObj(hospitalSaveDto, Hospital.class);
|
|
Hospital hospital = BeanUtil.convertObj(hospitalSaveDto, Hospital.class);
|
|
hospital.setCreateTime(System.currentTimeMillis());
|
|
hospital.setCreateTime(System.currentTimeMillis());
|
|
@@ -70,11 +80,12 @@ public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> i
|
|
// 校验参数
|
|
// 校验参数
|
|
private void checkParam(HospitalSaveDto hospitalSaveDto, String sign) {
|
|
private void checkParam(HospitalSaveDto hospitalSaveDto, String sign) {
|
|
Integer isHospital = hospitalSaveDto.getIsHospital();
|
|
Integer isHospital = hospitalSaveDto.getIsHospital();
|
|
|
|
+ // 新增医院
|
|
if (isHospital == 0) {
|
|
if (isHospital == 0) {
|
|
if (StringUtils.isEmpty(sign)) {
|
|
if (StringUtils.isEmpty(sign)) {
|
|
throw new CostException(500, "新增医院请选择医院标识");
|
|
throw new CostException(500, "新增医院请选择医院标识");
|
|
}
|
|
}
|
|
- Hospital bySign = this.getBySign(sign);
|
|
|
|
|
|
+ Hospital bySign = this.getBySignHospital(sign);
|
|
if (Objects.nonNull(bySign)) {
|
|
if (Objects.nonNull(bySign)) {
|
|
throw new CostException(500, "当前医院标识已存在,请重新生成");
|
|
throw new CostException(500, "当前医院标识已存在,请重新生成");
|
|
}
|
|
}
|
|
@@ -87,6 +98,17 @@ public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Hospital getBySignHospital(String hospSign) {
|
|
|
|
+ Hospital one = this.getOne(
|
|
|
|
+ new LambdaQueryWrapper<Hospital>()
|
|
|
|
+ .select(Hospital::getId, Hospital::getName)
|
|
|
|
+ .eq(Hospital::getIsHospital, 0)
|
|
|
|
+ .eq(Hospital::getSign, hospSign)
|
|
|
|
+ .last("limit 1")
|
|
|
|
+ );
|
|
|
|
+ return one;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 修改医院信息
|
|
* 修改医院信息
|
|
*
|
|
*
|
|
@@ -115,7 +137,8 @@ public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> i
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<HospitalAllVO> getAll() {
|
|
public List<HospitalAllVO> getAll() {
|
|
- List<Hospital> hospitals = baseMapper.selectList(null);
|
|
|
|
|
|
+ List<Hospital> hospitals = baseMapper.selectList(new QueryWrapper<Hospital>().lambda()
|
|
|
|
+ .eq(Hospital::getIsHospital,NumberConstant.ONE));
|
|
List<HospitalAllVO> hospitalAllVOList = BeanUtil.convertList(hospitals, HospitalAllVO.class);
|
|
List<HospitalAllVO> hospitalAllVOList = BeanUtil.convertList(hospitals, HospitalAllVO.class);
|
|
return hospitalAllVOList;
|
|
return hospitalAllVOList;
|
|
}
|
|
}
|