科室名称重复修改
This commit is contained in:
parent
d8a5b60d36
commit
2613872722
@ -105,7 +105,7 @@ public class DepartmentController extends BaseController {
|
||||
@Log(title = "科室信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody Department department) {
|
||||
return toAjax(departmentService.insertDepartment(department));
|
||||
return departmentService.insertDepartment(department);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +115,7 @@ public class DepartmentController extends BaseController {
|
||||
@Log(title = "科室信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody Department department) {
|
||||
return toAjax(departmentService.updateDepartment(department));
|
||||
return departmentService.updateDepartment(department);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -145,4 +145,12 @@ public interface DepartmentMapper {
|
||||
* @return 机构信息
|
||||
*/
|
||||
List<Department> selectDepartmentByParentId(Long[] id);
|
||||
|
||||
/**
|
||||
* 根据上级机构id和科室名称查询数量
|
||||
*
|
||||
* @param department 科室
|
||||
* @return int
|
||||
*/
|
||||
List<Department> selectDepartmentNameCount(Department department);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public interface IDepartmentService {
|
||||
* @param department 科室信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertDepartment(Department department);
|
||||
AjaxResult insertDepartment(Department department);
|
||||
|
||||
/**
|
||||
* 修改科室信息
|
||||
@ -60,7 +60,7 @@ public interface IDepartmentService {
|
||||
* @param department 科室信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDepartment(Department department);
|
||||
AjaxResult updateDepartment(Department department);
|
||||
|
||||
/**
|
||||
* 批量删除科室信息
|
||||
|
||||
@ -19,18 +19,19 @@ import com.xinelu.manage.vo.department.DepartmentBaseVo;
|
||||
import com.xinelu.manage.vo.department.DepartmentListVO;
|
||||
import com.xinelu.manage.vo.department.DepartmentVO;
|
||||
import com.xinelu.system.mapper.SysUserMapper;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 科室信息Service业务层处理
|
||||
@ -46,8 +47,8 @@ public class DepartmentServiceImpl implements IDepartmentService {
|
||||
private RegexUtil regexUtil;
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Resource
|
||||
private AgencyMapper agencyMapper;
|
||||
@Resource
|
||||
private AgencyMapper agencyMapper;
|
||||
@Resource
|
||||
private GenerateSystemCodeUtil generateSystemCodeUtil;
|
||||
|
||||
@ -111,14 +112,28 @@ public class DepartmentServiceImpl implements IDepartmentService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertDepartment(Department department) {
|
||||
public AjaxResult insertDepartment(Department department) {
|
||||
if (Objects.isNull(department.getParentDepartmentId())) {
|
||||
department.setParentDepartmentId(0L);
|
||||
}
|
||||
department.setCreateTime(LocalDateTime.now());
|
||||
department.setCreateBy(SecurityUtils.getUsername());
|
||||
//根据上级机构id查询
|
||||
List<Department> departmentList = departmentMapper.selectDepartmentNameCount(department);
|
||||
if (CollectionUtils.isNotEmpty(departmentList)) {
|
||||
//重名
|
||||
List<Department> departmentName = departmentList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getDepartmentName()) && department.getDepartmentName().equals(item.getDepartmentName())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(departmentName)) {
|
||||
return AjaxResult.error("该" + department.getHospitalAgencyName() + "下,已存在名称为" + department.getDepartmentName() + "的科室!");
|
||||
}
|
||||
//重编号
|
||||
List<Department> departmentCode = departmentList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getDepartmentCode()) && department.getDepartmentCode().equals(item.getDepartmentName())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(departmentCode)) {
|
||||
return AjaxResult.error("该" + department.getHospitalAgencyName() + "下,已存在科室编号为" + department.getDepartmentName() + "的科室!");
|
||||
}
|
||||
}
|
||||
//department.setDepartmentCode(Constants.DEPARTMENT_CODE + generateSystemCodeUtil.generateSystemCode(Constants.DEPARTMENT_CODE));
|
||||
return departmentMapper.insertDepartment(department);
|
||||
return AjaxResult.success(departmentMapper.insertDepartment(department));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,13 +143,28 @@ public class DepartmentServiceImpl implements IDepartmentService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDepartment(Department department) {
|
||||
public AjaxResult updateDepartment(Department department) {
|
||||
//上级科室是自己本身,取消上级科室
|
||||
if (Objects.nonNull(department) && Objects.nonNull(department.getId()) && Objects.nonNull(department.getParentDepartmentId()) && department.getId().equals(department.getParentDepartmentId())) {
|
||||
department.setParentDepartmentId(null);
|
||||
}
|
||||
//根据上级机构id查询
|
||||
List<Department> departmentList = departmentMapper.selectDepartmentNameCount(department);
|
||||
if (CollectionUtils.isNotEmpty(departmentList)) {
|
||||
//重名
|
||||
List<Department> departmentName = departmentList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getDepartmentName()) && department.getDepartmentName().equals(item.getDepartmentName()) && !department.getId().equals(item.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(departmentName)) {
|
||||
return AjaxResult.error("该" + department.getHospitalAgencyName() + "下,已存在名称为" + department.getDepartmentName() + "的科室!");
|
||||
}
|
||||
//重编号
|
||||
List<Department> departmentCode = departmentList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getDepartmentCode()) && department.getDepartmentCode().equals(item.getDepartmentName()) && !department.getId().equals(item.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(departmentCode)) {
|
||||
return AjaxResult.error("该" + department.getHospitalAgencyName() + "下,已存在科室编号为" + department.getDepartmentName() + "的科室!");
|
||||
}
|
||||
}
|
||||
department.setUpdateBy(SecurityUtils.getUsername());
|
||||
department.setUpdateTime(LocalDateTime.now());
|
||||
return departmentMapper.updateDepartmentById(department);
|
||||
return AjaxResult.success(departmentMapper.updateDepartmentById(department));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,9 +275,9 @@ public class DepartmentServiceImpl implements IDepartmentService {
|
||||
return AjaxResult.error("当前科室电话:" + department.getDepartmentPhone() + " 格式不正确,请重新录入!");
|
||||
}
|
||||
List<String> departmentName = importDataList.stream().filter(item -> StringUtils.isNotBlank(item.getDepartmentName())).map(Department::getDepartmentName).distinct().collect(Collectors.toList());
|
||||
//根据名称查询护理站基本信息
|
||||
//根据名称查询科室基本信息
|
||||
List<Department> allDepartment = departmentMapper.getAllDepartmentInfo(departmentName);
|
||||
//做差集,去除数据库中已经存在的护理站信息
|
||||
//做差集,去除数据库中已经存在的科室信息
|
||||
List<Department> subtractList = new ArrayList<>(CollectionUtils.subtract(importDataList, allDepartment));
|
||||
if (CollectionUtils.isEmpty(subtractList)) {
|
||||
return AjaxResult.success();
|
||||
@ -279,9 +309,9 @@ public class DepartmentServiceImpl implements IDepartmentService {
|
||||
@DataScope(agencyAlias = "d", deptAlias = "sp")
|
||||
@Override
|
||||
public DepartmentBaseVo selectListServicePackageNum(DepartmentDTO departmentDto) {
|
||||
Agency agency = agencyMapper.selectAgencyById(departmentDto.getHospitalAgencyId());
|
||||
List<DepartmentVO> departmentVOList = departmentMapper.selectListServicePackageNum(departmentDto);
|
||||
return DepartmentBaseVo.builder().hospitalAgencyName(ObjectUtils.isEmpty(agency) ? "" : agency.getAgencyName())
|
||||
.deptNumList(departmentVOList).build();
|
||||
Agency agency = agencyMapper.selectAgencyById(departmentDto.getHospitalAgencyId());
|
||||
List<DepartmentVO> departmentVOList = departmentMapper.selectListServicePackageNum(departmentDto);
|
||||
return DepartmentBaseVo.builder().hospitalAgencyName(ObjectUtils.isEmpty(agency) ? "" : agency.getAgencyName())
|
||||
.deptNumList(departmentVOList).build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,76 +496,76 @@
|
||||
update department
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="parentDepartmentId != null">parent_department_id =
|
||||
#{parentDepartmentId},
|
||||
#{parentDepartmentId},
|
||||
</if>
|
||||
<if test="hospitalAgencyId != null">hospital_agency_id =
|
||||
#{hospitalAgencyId},
|
||||
#{hospitalAgencyId},
|
||||
</if>
|
||||
<if test="hospitalAgencyName != null">hospital_agency_name =
|
||||
#{hospitalAgencyName},
|
||||
#{hospitalAgencyName},
|
||||
</if>
|
||||
<if test="departmentName != null">department_name =
|
||||
#{departmentName},
|
||||
#{departmentName},
|
||||
</if>
|
||||
<if test="departmentCode != null">department_code =
|
||||
#{departmentCode},
|
||||
#{departmentCode},
|
||||
</if>
|
||||
<if test="departmentType != null">department_type =
|
||||
#{departmentType},
|
||||
#{departmentType},
|
||||
</if>
|
||||
<if test="departmentAbbreviation != null">department_abbreviation =
|
||||
#{departmentAbbreviation},
|
||||
#{departmentAbbreviation},
|
||||
</if>
|
||||
<if test="departmentPersonId != null">department_person_id =
|
||||
#{departmentPersonId},
|
||||
#{departmentPersonId},
|
||||
</if>
|
||||
<if test="departmentPersonName != null">department_person_name =
|
||||
#{departmentPersonName},
|
||||
#{departmentPersonName},
|
||||
</if>
|
||||
<if test="nodeType != null">node_type =
|
||||
#{nodeType},
|
||||
#{nodeType},
|
||||
</if>
|
||||
<if test="provideServiceCategory != null">provide_service_category =
|
||||
#{provideServiceCategory},
|
||||
#{provideServiceCategory},
|
||||
</if>
|
||||
<if test="subdivisionCategoryId != null">subdivision_category_id =
|
||||
#{subdivisionCategoryId},
|
||||
#{subdivisionCategoryId},
|
||||
</if>
|
||||
<if test="subdivisionCategoryName != null">subdivision_category_name =
|
||||
#{subdivisionCategoryName},
|
||||
#{subdivisionCategoryName},
|
||||
</if>
|
||||
<if test="normDepartmentCompareId != null">norm_department_compare_id =
|
||||
#{normDepartmentCompareId},
|
||||
#{normDepartmentCompareId},
|
||||
</if>
|
||||
<if test="normDepartmentCompareName != null">norm_department_compare_name =
|
||||
#{normDepartmentCompareName},
|
||||
#{normDepartmentCompareName},
|
||||
</if>
|
||||
<if test="prepareBedsCount != null">prepare_beds_count =
|
||||
#{prepareBedsCount},
|
||||
#{prepareBedsCount},
|
||||
</if>
|
||||
<if test="departmentPhone != null">department_phone =
|
||||
#{departmentPhone},
|
||||
#{departmentPhone},
|
||||
</if>
|
||||
<if test="departmentMail != null">department_mail =
|
||||
#{departmentMail},
|
||||
#{departmentMail},
|
||||
</if>
|
||||
<if test="establishDate != null">establish_date =
|
||||
#{establishDate},
|
||||
#{establishDate},
|
||||
</if>
|
||||
<if test="revokeDate != null">revoke_date =
|
||||
#{revokeDate},
|
||||
#{revokeDate},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
#{updateTime},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
@ -624,4 +624,13 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectDepartmentNameCount" resultType="com.xinelu.manage.domain.department.Department" resultMap="DepartmentResult">
|
||||
<include refid="selectDepartmentVo"/>
|
||||
<where>
|
||||
<if test="hospitalAgencyId != null ">
|
||||
and hospital_agency_id =#{hospitalAgencyId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user