mitao
2024-12-09 eb2ac2a40f92359739701c6f060607a474010de0
单位管理
14个文件已修改
10个文件已添加
1414 ■■■■■ 已修改文件
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwDisposalUnitController.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwMedicalInstitutionController.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwRegulatoryUnitController.java 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwCheckoutRecordItem.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwDisposalRecordItem.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwMicroEquipmentRecordItem.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwTransitRoute.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwTransitRouteCar.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwTransitRoutePoints.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/MwWarningConfigItem.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartment.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/dto/DisposalUnitDTO.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/dto/MedicalInstitutionDTO.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/dto/RegulatoryUnitDTO.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/query/DepartmentQuery.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/DisposalUnitVO.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/MedicalInstitutionVO.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/RegulatoryUnitVO.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/mapper/SysDepartmentMapper.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java 428 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwDisposalUnitController.java
New file
@@ -0,0 +1,96 @@
package com.sinata.web.controller.backend;
import com.sinata.common.core.domain.R;
import com.sinata.common.entity.PageDTO;
import com.sinata.system.domain.dto.DisposalUnitDTO;
import com.sinata.system.domain.query.DepartmentQuery;
import com.sinata.system.domain.vo.DisposalUnitVO;
import com.sinata.system.service.SysDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Validated
@RestController
@RequestMapping("/backend/disposal")
@RequiredArgsConstructor
@Api(tags = "处置单位管理相关接口")
public class MwDisposalUnitController {
    private final SysDepartmentService sysDepartmentService;
    /**
     * 处置单位分页列表
     *
     * @param query
     * @return
     */
    @PostMapping("/page")
    @ApiOperation("处置单位分页列表")
    public R<PageDTO<DisposalUnitVO>> pageList(@RequestBody DepartmentQuery query) {
        return R.ok(sysDepartmentService.pageDisposalUnitList(query));
    }
    /**
     * 新增处置单位
     *
     * @param dto
     */
    @PostMapping("/add")
    @ApiOperation("新增处置单位")
    public R<?> add(@Valid @RequestBody DisposalUnitDTO dto) {
        sysDepartmentService.addDisposalUnit(dto);
        return R.ok();
    }
    /**
     * 编辑处置单位
     *
     * @param dto
     * @return
     */
    @PostMapping("/edit")
    @ApiOperation("编辑处置单位")
    public R<?> edit(@Valid @RequestBody DisposalUnitDTO dto) {
        sysDepartmentService.editDisposalUnit(dto);
        return R.ok();
    }
    /**
     * 处置单位详情
     *
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    @ApiOperation("处置单位详情")
    public R<DisposalUnitVO> detail(@ApiParam(name = "id", value = "处置单位id", required = true) @PathVariable("id") Long id) {
        return R.ok(sysDepartmentService.getDisposalUnitDetailById(id));
    }
    /**
     * 删除处置单位
     *
     * @param id
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除处置单位")
    public R<?> delete(@ApiParam(name = "id", value = "处置单位id", required = true) @PathVariable("id") Long id) {
        sysDepartmentService.deleteDisposalUnit(id);
        return R.ok();
    }
}
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwMedicalInstitutionController.java
New file
@@ -0,0 +1,110 @@
package com.sinata.web.controller.backend;
import com.sinata.common.core.domain.R;
import com.sinata.common.entity.PageDTO;
import com.sinata.system.domain.dto.MedicalInstitutionDTO;
import com.sinata.system.domain.query.DepartmentQuery;
import com.sinata.system.domain.vo.DisposalUnitVO;
import com.sinata.system.domain.vo.MedicalInstitutionVO;
import com.sinata.system.service.SysDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Validated
@RestController
@RequestMapping("/backend/medical")
@RequiredArgsConstructor
@Api(tags = "医疗机构管理相关接口")
public class MwMedicalInstitutionController {
    private final SysDepartmentService sysDepartmentService;
    /**
     * 医疗机构分页列表
     *
     * @param query
     * @return
     */
    @PostMapping("/page")
    @ApiOperation("医疗机构分页列表")
    public R<PageDTO<MedicalInstitutionVO>> pageList(@RequestBody DepartmentQuery query) {
        return R.ok(sysDepartmentService.pageMedicalList(query));
    }
    /**
     * 新增医疗机构
     *
     * @param dto
     */
    @PostMapping("/add")
    @ApiOperation("新增医疗机构")
    public R<?> add(@Valid @RequestBody MedicalInstitutionDTO dto) {
        sysDepartmentService.addMedical(dto);
        return R.ok();
    }
    /**
     * 根据父级区域id查询处置单位列表
     *
     * @param id
     * @return
     */
    @GetMapping("/getDisposalList/{id}")
    @ApiOperation("根据父级区域id查询处置单位列表")
    public R<List<DisposalUnitVO>> getDisposalUnitList(@ApiParam(name = "id", value = "父级区域id") @PathVariable("id") Long id) {
        return R.ok(sysDepartmentService.getDisposalUnitListByParentId(id));
    }
    /**
     * 编辑医疗机构
     *
     * @param dto
     * @return
     */
    @PostMapping("/edit")
    @ApiOperation("编辑医疗机构")
    public R<?> edit(@Valid @RequestBody MedicalInstitutionDTO dto) {
        sysDepartmentService.editMedical(dto);
        return R.ok();
    }
    /**
     * 医疗机构详情
     *
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    @ApiOperation("医疗机构详情")
    public R<MedicalInstitutionVO> detail(@ApiParam(name = "id", value = "医疗机构id", required = true) @PathVariable("id") Long id) {
        return R.ok(sysDepartmentService.getMedicalDetailById(id));
    }
    /**
     * 删除医疗机构
     *
     * @param id
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除医疗机构")
    public R<?> delete(@ApiParam(name = "id", value = "医疗机构id", required = true) @PathVariable("id") Long id) {
        sysDepartmentService.deleteMedical(id);
        return R.ok();
    }
}
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/MwRegulatoryUnitController.java
New file
@@ -0,0 +1,97 @@
package com.sinata.web.controller.backend;
import com.sinata.common.core.domain.R;
import com.sinata.common.entity.PageDTO;
import com.sinata.system.domain.dto.RegulatoryUnitDTO;
import com.sinata.system.domain.query.DepartmentQuery;
import com.sinata.system.domain.vo.RegulatoryUnitVO;
import com.sinata.system.service.SysDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Validated
@RestController
@RequestMapping("/backend/regulatory")
@RequiredArgsConstructor
@Api(tags = "监管单位管理相关接口")
public class MwRegulatoryUnitController {
    private final SysDepartmentService sysDepartmentService;
    /**
     * 监管单位分页列表
     *
     * @param query
     * @return
     */
    @PostMapping("/page")
    @ApiOperation("监管单位分页列表")
    public R<PageDTO<RegulatoryUnitVO>> pageList(@RequestBody DepartmentQuery query) {
        return R.ok(sysDepartmentService.pageRegulatoryUnitList(query));
    }
    /**
     * 新增监管单位
     *
     * @param dto
     */
    @PostMapping("/add")
    @ApiOperation("新增监管单位")
    public R<?> add(@Valid @RequestBody RegulatoryUnitDTO dto) {
        sysDepartmentService.addRegulatoryUnit(dto);
        return R.ok();
    }
    /**
     * 编辑监管单位
     *
     * @param dto
     * @return
     */
    @PostMapping("/edit")
    @ApiOperation("编辑监管单位")
    public R<?> edit(@Valid @RequestBody RegulatoryUnitDTO dto) {
        sysDepartmentService.editRegulatoryUnit(dto);
        return R.ok();
    }
    /**
     * 监管单位详情
     *
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    @ApiOperation("监管单位详情")
    public R<RegulatoryUnitVO> detail(@ApiParam(name = "id", value = "监管单位id", required = true) @PathVariable("id") Long id) {
        return R.ok(sysDepartmentService.getRegulatoryUnitDetailById(id));
    }
    /**
     * 删除监管单位
     *
     * @param id
     */
    @DeleteMapping("/{id}")
    @ApiOperation("删除监管单位")
    public R<?> delete(@ApiParam(name = "id", value = "监管单位id", required = true) @PathVariable("id") Long id) {
        sysDepartmentService.deleteRegulatoryUnit(id);
        return R.ok();
    }
}
medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java
@@ -22,6 +22,7 @@
import com.sinata.system.service.ISysRoleService;
import com.sinata.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.ArrayUtils;
@@ -47,7 +48,7 @@
 * 
 * @author ruoyi
 */
@Api(tags = {"管理后台-用户管理"})
@Api(tags = {"用户管理"})
@Validated
@RestController
@RequestMapping("/backend/system/user")
@@ -117,9 +118,7 @@
    /**
     * 批量修改账号状态
     *
     * @param userIds
     * @param status
     * @param dto
     * @return
     */
    @ApiOperation("批量修改账号状态")
@@ -137,6 +136,7 @@
     */
    @ApiOperation("批量删除")
    @PostMapping("/delBatch")
    @ApiImplicitParam(name = "userIds", value = "用户id列表", required = true, allowMultiple = true)
    public R<?> delBatch(@RequestBody List<Long> userIds) {
        userService.delBatch(userIds);
        return R.ok();
medicalWaste-system/src/main/java/com/sinata/system/domain/MwCheckoutRecordItem.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,7 @@
@Setter
@TableName("MW_CHECKOUT_RECORD_ITEM")
@ApiModel(value = "MwCheckoutRecordItem对象", description = "暂存间出库记录项")
public class MwCheckoutRecordItem extends BaseModel {
    private static final long serialVersionUID = 1L;
public class MwCheckoutRecordItem {
    @ApiModelProperty("医废出库入库关联表")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/MwDisposalRecordItem.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,7 @@
@Setter
@TableName("MW_DISPOSAL_RECORD_ITEM")
@ApiModel(value = "MwDisposalRecordItem对象", description = "处置接收记录项")
public class MwDisposalRecordItem extends BaseModel {
    private static final long serialVersionUID = 1L;
public class MwDisposalRecordItem {
    @ApiModelProperty("处置接收记录项id")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/MwMicroEquipmentRecordItem.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,7 @@
@Setter
@TableName("MW_MICRO_EQUIPMENT_RECORD_ITEM")
@ApiModel(value = "MwMicroEquipmentRecordItem对象", description = "设备使用记录项")
public class MwMicroEquipmentRecordItem extends BaseModel {
    private static final long serialVersionUID = 1L;
public class MwMicroEquipmentRecordItem {
    @ApiModelProperty("设备使用记录项")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/MwTransitRoute.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,7 @@
@Setter
@TableName("MW_TRANSIT_ROUTE")
@ApiModel(value = "MwTransitRoute对象", description = "转运线路")
public class MwTransitRoute extends BaseModel {
    private static final long serialVersionUID = 1L;
public class MwTransitRoute {
    @ApiModelProperty("转运线路id")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/MwTransitRouteCar.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,7 @@
@Setter
@TableName("MW_TRANSIT_ROUTE_CAR")
@ApiModel(value = "MwTransitRouteCar对象", description = "转运线路车辆关系")
public class MwTransitRouteCar extends BaseModel {
    private static final long serialVersionUID = 1L;
public class MwTransitRouteCar {
    @ApiModelProperty("转运线路车辆关系id")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/MwTransitRoutePoints.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,8 @@
@Setter
@TableName("MW_TRANSIT_ROUTE_POINTS")
@ApiModel(value = "MwTransitRoutePoints对象", description = "转运线路途经点")
public class MwTransitRoutePoints extends BaseModel {
public class MwTransitRoutePoints {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty("转运线路途经点id")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/MwWarningConfigItem.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -22,9 +21,7 @@
@Setter
@TableName("MW_WARNING_CONFIG_ITEM")
@ApiModel(value = "MwWarningConfigItem对象", description = "预警配置项")
public class MwWarningConfigItem extends BaseModel {
    private static final long serialVersionUID = 1L;
public class MwWarningConfigItem {
    @ApiModelProperty("预警配置项id")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartment.java
@@ -82,5 +82,8 @@
    @TableField("UNIFIED_SOCIAL_CREDIT_CODE")
    private String unifiedSocialCreditCode;
    @ApiModelProperty("区域")
    @TableField("REGION")
    private String region;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sinata.common.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
@@ -24,9 +23,7 @@
@Setter
@TableName("SYS_DEPARTMENT_INFO")
@ApiModel(value = "SysDepartmentInfo对象", description = "单位信息")
public class SysDepartmentInfo extends BaseModel {
    private static final long serialVersionUID = 1L;
public class SysDepartmentInfo {
    @ApiModelProperty("主键id")
    @TableId(value = "ID", type = IdType.AUTO)
medicalWaste-system/src/main/java/com/sinata/system/domain/dto/DisposalUnitDTO.java
New file
@@ -0,0 +1,34 @@
package com.sinata.system.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("处置单位数据传输对象")
public class DisposalUnitDTO extends RegulatoryUnitDTO {
    @ApiModelProperty("许可证图片")
    private String disposalLicenseImage;
    @ApiModelProperty("日处理能力(kg)")
    private BigDecimal dailyDisposalQuantity;
    @ApiModelProperty("年处理能力(kg)")
    private BigDecimal yearlyDisposalQuantity;
    @ApiModelProperty("主要技术")
    private String mainTechnology;
    @ApiModelProperty("医废最大存储量")
    private BigDecimal maximumStorageCapacity;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/dto/MedicalInstitutionDTO.java
New file
@@ -0,0 +1,37 @@
package com.sinata.system.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("医疗机构数据传输对象")
public class MedicalInstitutionDTO extends RegulatoryUnitDTO {
    @ApiModelProperty("机构级别(数据字典id)")
    private Long institutionLevel;
    @ApiModelProperty("机构性质(数据字典id)")
    private Long institutionType;
    @ApiModelProperty("每日产废范围起")
    private BigDecimal dailyMinWasteQuantity;
    @ApiModelProperty("每日产废范围止")
    private BigDecimal dailyMaxWasteQuantity;
    @ApiModelProperty("每月产废范围起")
    private BigDecimal monthlyMinWasteQuantity;
    @ApiModelProperty("每月产废范围止")
    private BigDecimal monthlyMaxWasteQuantity;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/dto/RegulatoryUnitDTO.java
New file
@@ -0,0 +1,53 @@
package com.sinata.system.domain.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@ApiModel("监管单位数据传输对象")
public class RegulatoryUnitDTO {
    @ApiModelProperty(value = "id", notes = "新增不传,编辑必传")
    private Long id;
    @ApiModelProperty("所属区域id")
    @NotNull(message = "所属区域id不能为空")
    private Long parentId;
    @ApiModelProperty("单位名称")
    @NotBlank(message = "单位名称不能为空")
    @Length(max = 20, message = "单位名称长度不能超过20个字符")
    private String departmentName;
    @ApiModelProperty("统一社会信用代码")
    private String unifiedSocialCreditCode;
    @ApiModelProperty("单位地址")
    private String address;
    @ApiModelProperty("经度")
    private Double longitude;
    @ApiModelProperty("纬度")
    private Double latitude;
    @ApiModelProperty("联系人")
    private String contactPerson;
    @ApiModelProperty("联系电话")
    private String contactPhone;
    @ApiModelProperty("备注")
    private String remark;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/query/DepartmentQuery.java
New file
@@ -0,0 +1,32 @@
package com.sinata.system.domain.query;
import com.sinata.common.entity.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("单位查询数据传输对象")
public class DepartmentQuery extends BasePage {
    private static final long serialVersionUID = 3842694251110119850L;
    @ApiModelProperty("所属区域id")
    private Long departmentId;
    @ApiModelProperty("单位名称")
    private String departmentName;
    @ApiModelProperty("联系人")
    private String contactPerson;
    @ApiModelProperty("联系电话")
    private String contactPhone;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/DisposalUnitVO.java
New file
@@ -0,0 +1,39 @@
package com.sinata.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("处置单位视图对象")
public class DisposalUnitVO extends RegulatoryUnitVO {
    @ApiModelProperty("法人代表")
    private String legalPerson;
    @ApiModelProperty("医疗废物处置许可证号")
    private String disposalLicenseNumber;
    @ApiModelProperty("许可证图片")
    private String disposalLicenseImage;
    @ApiModelProperty("日处理能力(kg)")
    private BigDecimal dailyDisposalQuantity;
    @ApiModelProperty("年处理能力(kg)")
    private BigDecimal yearlyDisposalQuantity;
    @ApiModelProperty("主要技术")
    private String mainTechnology;
    @ApiModelProperty("医废最大存储量")
    private BigDecimal maximumStorageCapacity;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/MedicalInstitutionVO.java
New file
@@ -0,0 +1,47 @@
package com.sinata.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("医疗机构视图对象")
public class MedicalInstitutionVO extends RegulatoryUnitVO {
    @ApiModelProperty("机构级别(数据字典id)")
    private Long institutionLevel;
    @ApiModelProperty("机构级别")
    private String institutionLevelStr;
    @ApiModelProperty("机构性质(数据字典id)")
    private Long institutionType;
    @ApiModelProperty("机构性质")
    private String institutionTypeStr;
    @ApiModelProperty("每日产废范围起")
    private BigDecimal dailyMinWasteQuantity;
    @ApiModelProperty("每日产废范围止")
    private BigDecimal dailyMaxWasteQuantity;
    @ApiModelProperty("每月产废范围起")
    private BigDecimal monthlyMinWasteQuantity;
    @ApiModelProperty("每月产废范围止")
    private BigDecimal monthlyMaxWasteQuantity;
    @ApiModelProperty("处置单位列表")
    private List<DisposalUnitVO> disposalUnitList;
}
medicalWaste-system/src/main/java/com/sinata/system/domain/vo/RegulatoryUnitVO.java
New file
@@ -0,0 +1,49 @@
package com.sinata.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
 * @author mitao
 * @date 2024/12/9
 */
@Data
@ApiModel("监管单位视图对象")
public class RegulatoryUnitVO {
    @ApiModelProperty("id")
    private Long id;
    @ApiModelProperty("所属区域id")
    private Long parentId;
    @ApiModelProperty("所属区域")
    private String region;
    @ApiModelProperty("单位名称")
    private String departmentName;
    @ApiModelProperty("联系人")
    private String contactPerson;
    @ApiModelProperty("联系电话")
    private String contactPhone;
    @ApiModelProperty("统一社会信用代码")
    private String unifiedSocialCreditCode;
    @ApiModelProperty("经度")
    private Double longitude;
    @ApiModelProperty("纬度")
    private Double latitude;
    @ApiModelProperty("备注")
    private String remark;
    @ApiModelProperty(value = "添加时间")
    private Date createTime;
}
medicalWaste-system/src/main/java/com/sinata/system/mapper/SysDepartmentMapper.java
@@ -1,9 +1,14 @@
package com.sinata.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sinata.system.domain.SysDepartment;
import com.sinata.system.domain.vo.DisposalUnitVO;
import com.sinata.system.domain.vo.MedicalInstitutionVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <p>
@@ -16,10 +21,57 @@
@Mapper
public interface SysDepartmentMapper extends BaseMapper<SysDepartment> {
    /**
     * 根据类型查询用户区域列表
     * 查询用户区域列表
     * @param userId
     * @param type
     * @return
     */
    SysDepartment getDepartmentByUserId(@Param("userId") Long userId);
    /**
     * 根据类型查询机构列表
     *
     * @param medicalInstitutionVOPage
     * @param departmentName
     * @param contactPerson
     * @param contactPhone
     * @param treeCode
     * @return
     */
    Page<MedicalInstitutionVO> pageMedicalList(Page<MedicalInstitutionVO> medicalInstitutionVOPage, @Param("departmentId") Long departmentId, @Param("departmentName") String departmentName, @Param("contactPerson") String contactPerson, @Param("contactPhone") String contactPhone, @Param("treeCode") String treeCode);
    /**
     * 查询医疗机构详情
     *
     * @param id
     * @return
     */
    MedicalInstitutionVO getMedicalDetailById(Long id);
    /**
     * 根据treeCode查询处置单位列表
     *
     * @param treeCode
     * @return
     */
    List<DisposalUnitVO> getDisposalUnitListByTreeCode(String treeCode);
    /**
     * 处置单位分页列表
     *
     * @param page
     * @param departmentName
     * @param contactPerson
     * @param contactPhone
     * @param treeCode
     * @return
     */
    Page<DisposalUnitVO> pageRegulatoryUnitList(Page<DisposalUnitVO> page, @Param("departmentId") Long departmentId, @Param("departmentName") String departmentName, @Param("contactPerson") String contactPerson, @Param("contactPhone") String contactPhone, @Param("treeCode") String treeCode);
    /**
     * 处置单位详情
     *
     * @param id
     * @return
     */
    DisposalUnitVO getDisposalUnitDetailById(@Param("id") Long id);
}
medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java
@@ -1,8 +1,16 @@
package com.sinata.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sinata.common.entity.PageDTO;
import com.sinata.system.domain.SysDepartment;
import com.sinata.system.domain.dto.DisposalUnitDTO;
import com.sinata.system.domain.dto.MedicalInstitutionDTO;
import com.sinata.system.domain.dto.RegulatoryUnitDTO;
import com.sinata.system.domain.dto.SysDepartmentDTO;
import com.sinata.system.domain.query.DepartmentQuery;
import com.sinata.system.domain.vo.DisposalUnitVO;
import com.sinata.system.domain.vo.MedicalInstitutionVO;
import com.sinata.system.domain.vo.RegulatoryUnitVO;
import com.sinata.system.domain.vo.SysDepartmentVO;
import java.util.List;
@@ -85,4 +93,125 @@
     * @param id
     */
    void deleteRegion(Long id);
    /**
     * 医疗机构分页列表
     *
     * @param query
     * @return
     */
    PageDTO<MedicalInstitutionVO> pageMedicalList(DepartmentQuery query);
    /**
     * 新增医疗机构
     *
     * @param dto
     */
    void addMedical(MedicalInstitutionDTO dto);
    /**
     * 编辑医疗机构
     *
     * @param dto
     * @return
     */
    void editMedical(MedicalInstitutionDTO dto);
    /**
     * 医疗机构详情
     *
     * @param id
     * @return
     */
    MedicalInstitutionVO getMedicalDetailById(Long id);
    /**
     * 根据父级区域id查询处置单位列表
     *
     * @param id
     * @return
     */
    List<DisposalUnitVO> getDisposalUnitListByParentId(Long id);
    /**
     * 删除医疗机构
     *
     * @param id
     */
    void deleteMedical(Long id);
    /**
     * 处置单位分页列表
     *
     * @param query
     * @return
     */
    PageDTO<DisposalUnitVO> pageDisposalUnitList(DepartmentQuery query);
    /**
     * 新增处置单位
     *
     * @param dto
     */
    void addDisposalUnit(DisposalUnitDTO dto);
    /**
     * 编辑医疗机构
     *
     * @param dto
     * @return
     */
    void editDisposalUnit(DisposalUnitDTO dto);
    /**
     * 处置单位详情
     *
     * @param id
     * @return
     */
    DisposalUnitVO getDisposalUnitDetailById(Long id);
    /**
     * 删除处置单位
     *
     * @param id
     */
    void deleteDisposalUnit(Long id);
    /**
     * 监管单位分页列表
     *
     * @param query
     * @return
     */
    PageDTO<RegulatoryUnitVO> pageRegulatoryUnitList(DepartmentQuery query);
    /**
     * 新增监管单位
     *
     * @param dto
     */
    void addRegulatoryUnit(RegulatoryUnitDTO dto);
    /**
     * 编辑监管单位
     *
     * @param dto
     */
    void editRegulatoryUnit(RegulatoryUnitDTO dto);
    /**
     * 监管单位详情
     *
     * @param id
     * @return
     */
    RegulatoryUnitVO getRegulatoryUnitDetailById(Long id);
    /**
     * 删除监管单位
     *
     * @param id
     */
    void deleteRegulatoryUnit(Long id);
}
medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java
@@ -1,25 +1,37 @@
package com.sinata.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sinata.common.constant.CacheConstants;
import com.sinata.common.entity.PageDTO;
import com.sinata.common.exception.ServiceException;
import com.sinata.common.utils.BeanUtils;
import com.sinata.common.utils.CollUtils;
import com.sinata.common.utils.SecurityUtils;
import com.sinata.common.utils.StringUtils;
import com.sinata.system.domain.SysDepartment;
import com.sinata.system.domain.SysDepartmentInfo;
import com.sinata.system.domain.SysUserDepartment;
import com.sinata.system.domain.dto.DisposalUnitDTO;
import com.sinata.system.domain.dto.MedicalInstitutionDTO;
import com.sinata.system.domain.dto.RegulatoryUnitDTO;
import com.sinata.system.domain.dto.SysDepartmentDTO;
import com.sinata.system.domain.query.DepartmentQuery;
import com.sinata.system.domain.vo.DisposalUnitVO;
import com.sinata.system.domain.vo.MedicalInstitutionVO;
import com.sinata.system.domain.vo.RegulatoryUnitVO;
import com.sinata.system.domain.vo.SysDepartmentVO;
import com.sinata.system.enums.DepartmentEnum;
import com.sinata.system.mapper.SysDepartmentMapper;
import com.sinata.system.service.SysDepartmentInfoService;
import com.sinata.system.service.SysDepartmentService;
import com.sinata.system.service.SysUserDepartmentService;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,6 +56,7 @@
public class SysDepartmentServiceImpl extends ServiceImpl<SysDepartmentMapper, SysDepartment> implements SysDepartmentService {
    private final SysUserDepartmentService sysUserDepartmentService;
    private final RedisTemplate<Object, Object> redisTemplate;
    private final SysDepartmentInfoService sysDepartmentInfoService;
    /**
     * 获取区域树
     * @return
@@ -340,4 +353,419 @@
        }
        removeById(id);
    }
    /**
     * 医疗机构分页列表
     *
     * @param query
     * @return
     */
    @Override
    public PageDTO<MedicalInstitutionVO> pageMedicalList(DepartmentQuery query) {
        String treeCode = "";
        if (Objects.isNull(query.getDepartmentId())) {
            SysDepartment myDepartment = getMyDepartment();
            if (Objects.nonNull(myDepartment)) {
                treeCode = myDepartment.getTreeCode();
            }
        }
        Page<MedicalInstitutionVO> page = baseMapper.pageMedicalList(new Page<>(query.getPageCurr(), query.getPageSize()), query.getDepartmentId(), query.getDepartmentName(), query.getContactPerson(), query.getContactPhone(), treeCode);
        return PageDTO.of(page);
    }
    /**
     * 新增医疗机构
     *
     * @param dto
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addMedical(MedicalInstitutionDTO dto) {
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            throw new ServiceException("无操作权限");
        }
        SysDepartment parent = this.getById(dto.getParentId());
        if (Objects.isNull(parent)) {
            throw new ServiceException("找不到对应父级组织");
        }
        if (!parent.getTreeCode().startsWith(currentDepartment.getTreeCode())) {
            throw new ServiceException("无操作权限");
        }
        Long count = this.lambdaQuery().eq(SysDepartment::getDepartmentName, dto.getDepartmentName())
                .eq(SysDepartment::getOrgType, DepartmentEnum.MEDICAL_INSTITUTION.getCode())
                .count();
        if (count > 0) {
            throw new ServiceException("医疗机构已存在");
        }
        SysDepartment department = BeanUtils.copyBean(dto, SysDepartment.class);
        department.setTreeCode(getTreeCode(parent.getId()));
        department.setOrgCode(getOrgCode(parent.getId(), DepartmentEnum.MEDICAL_INSTITUTION.getCode()));
        department.setOrgType(DepartmentEnum.MEDICAL_INSTITUTION.getCode());
        //查询父级完整区域
        String region = getRegionName(parent);
        department.setRegion(region);
        save(department);
        SysDepartmentInfo sysDepartmentInfo = BeanUtils.copyBean(dto, SysDepartmentInfo.class);
        sysDepartmentInfo.setDepartmentId(department.getId());
        sysDepartmentInfoService.save(sysDepartmentInfo);
    }
    @Override
    public List<DisposalUnitVO> getDisposalUnitListByParentId(Long id) {
        List<DisposalUnitVO> disposalUnitList = null;
        SysDepartment parent = getById(id);
        if (Objects.nonNull(parent)) {
            //查询处置单位
            disposalUnitList = baseMapper.getDisposalUnitListByTreeCode(parent.getTreeCode());
        }
        return disposalUnitList;
    }
    /**
     * 获取完成区域
     *
     * @param department
     * @return
     */
    private String getRegionName(SysDepartment department) {
        String region = department.getDepartmentName();
        SysDepartment sysDepartment = this.lambdaQuery().eq(SysDepartment::getId, department.getParentId()).ne(SysDepartment::getId, -1).one();
        if (Objects.nonNull(sysDepartment)) {
            region = getRegionName(sysDepartment) + region;
        }
        return region;
    }
    /**
     * 编辑医疗机构
     *
     * @param dto
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void editMedical(MedicalInstitutionDTO dto) {
        if (Objects.isNull(dto.getId())) {
            throw new ServiceException("id不能为空");
        }
        SysDepartment sysDepartment = getById(dto.getId());
        if (Objects.isNull(sysDepartment)) {
            throw new ServiceException("医疗机构不存在");
        }
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            throw new ServiceException("无操作权限");
        }
        SysDepartment parent = this.getById(dto.getParentId());
        if (Objects.isNull(parent)) {
            throw new ServiceException("找不到对应父级组织");
        }
        if (!parent.getTreeCode().startsWith(currentDepartment.getTreeCode())) {
            throw new ServiceException("无操作权限");
        }
        Long count = this.lambdaQuery().eq(SysDepartment::getDepartmentName, dto.getDepartmentName())
                .eq(SysDepartment::getOrgType, DepartmentEnum.MEDICAL_INSTITUTION.getCode()).ne(SysDepartment::getId, dto.getId())
                .count();
        if (count > 0) {
            throw new ServiceException("机构已存在");
        }
        SysDepartment department = BeanUtils.copyBean(dto, SysDepartment.class);
        if (!department.getParentId().equals(sysDepartment.getParentId())) {
            department.setTreeCode(getTreeCode(parent.getId()));
            //查询父级完整区域
            String region = getRegionName(parent);
            department.setRegion(region);
        }
        updateById(department);
        sysDepartmentInfoService.lambdaUpdate().eq(SysDepartmentInfo::getDepartmentId, sysDepartment.getId()).remove();
        SysDepartmentInfo sysDepartmentInfo = BeanUtils.copyBean(dto, SysDepartmentInfo.class);
        sysDepartmentInfo.setDepartmentId(department.getId());
        sysDepartmentInfo.setId(null);
        sysDepartmentInfoService.save(sysDepartmentInfo);
    }
    /**
     * 医疗机构详情
     *
     * @param id
     * @return
     */
    @Override
    public MedicalInstitutionVO getMedicalDetailById(Long id) {
        MedicalInstitutionVO vo = baseMapper.getMedicalDetailById(id);
        List<DisposalUnitVO> disposalUnitList = getDisposalUnitListByParentId(vo.getParentId());
        vo.setDisposalUnitList(disposalUnitList);
        return vo;
    }
    /**
     * 删除医疗机构
     *
     * @param id
     */
    @Override
    public void deleteMedical(Long id) {
        Long count = sysUserDepartmentService.lambdaQuery().eq(SysUserDepartment::getDepartmentId, id).count();
        if (count > 0) {
            throw new ServiceException("该医疗机构已存在用户,无法删除");
        }
        removeById(id);
    }
    /**
     * 处置单位分页列表
     *
     * @param query
     * @return
     */
    @Override
    public PageDTO<DisposalUnitVO> pageDisposalUnitList(DepartmentQuery query) {
        String treeCode = "";
        if (Objects.isNull(query.getDepartmentId())) {
            SysDepartment myDepartment = getMyDepartment();
            if (Objects.nonNull(myDepartment)) {
                treeCode = myDepartment.getTreeCode();
            }
        }
        Page<DisposalUnitVO> page = baseMapper.pageRegulatoryUnitList(new Page<>(query.getPageCurr(), query.getPageSize()), query.getDepartmentId(), query.getDepartmentName(), query.getContactPerson(), query.getContactPhone(), treeCode);
        return PageDTO.of(page);
    }
    /**
     * 新增处置单位
     *
     * @param dto
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addDisposalUnit(DisposalUnitDTO dto) {
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            throw new ServiceException("无操作权限");
        }
        SysDepartment parent = this.getById(dto.getParentId());
        if (Objects.isNull(parent)) {
            throw new ServiceException("找不到对应父级组织");
        }
        if (!parent.getTreeCode().startsWith(currentDepartment.getTreeCode())) {
            throw new ServiceException("无操作权限");
        }
        Long count = this.lambdaQuery().eq(SysDepartment::getDepartmentName, dto.getDepartmentName())
                .eq(SysDepartment::getOrgType, DepartmentEnum.DISPOSAL_UNIT.getCode())
                .count();
        if (count > 0) {
            throw new ServiceException("处置单位已存在");
        }
        SysDepartment department = BeanUtils.copyBean(dto, SysDepartment.class);
        department.setTreeCode(getTreeCode(parent.getId()));
        department.setOrgCode(getOrgCode(parent.getId(), DepartmentEnum.DISPOSAL_UNIT.getCode()));
        department.setOrgType(DepartmentEnum.DISPOSAL_UNIT.getCode());
        //查询父级完整区域
        String region = getRegionName(parent);
        department.setRegion(region);
        save(department);
        SysDepartmentInfo sysDepartmentInfo = BeanUtils.copyBean(dto, SysDepartmentInfo.class);
        sysDepartmentInfo.setDepartmentId(department.getId());
        sysDepartmentInfoService.save(sysDepartmentInfo);
    }
    /**
     * 编辑处置单位
     *
     * @param dto
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void editDisposalUnit(DisposalUnitDTO dto) {
        if (Objects.isNull(dto.getId())) {
            throw new ServiceException("id不能为空");
        }
        SysDepartment sysDepartment = getById(dto.getId());
        if (Objects.isNull(sysDepartment)) {
            throw new ServiceException("处置单位不存在");
        }
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            throw new ServiceException("无操作权限");
        }
        SysDepartment parent = this.getById(dto.getParentId());
        if (Objects.isNull(parent)) {
            throw new ServiceException("找不到对应父级组织");
        }
        if (!parent.getTreeCode().startsWith(currentDepartment.getTreeCode())) {
            throw new ServiceException("无操作权限");
        }
        Long count = this.lambdaQuery().eq(SysDepartment::getDepartmentName, dto.getDepartmentName())
                .eq(SysDepartment::getOrgType, DepartmentEnum.DISPOSAL_UNIT.getCode()).ne(SysDepartment::getId, dto.getId())
                .count();
        if (count > 0) {
            throw new ServiceException("处置单位已存在");
        }
        SysDepartment department = BeanUtils.copyBean(dto, SysDepartment.class);
        if (!department.getParentId().equals(sysDepartment.getParentId())) {
            department.setTreeCode(getTreeCode(parent.getId()));
            //查询父级完整区域
            String region = getRegionName(parent);
            department.setRegion(region);
        }
        updateById(department);
        sysDepartmentInfoService.lambdaUpdate().eq(SysDepartmentInfo::getDepartmentId, sysDepartment.getId()).remove();
        SysDepartmentInfo sysDepartmentInfo = BeanUtils.copyBean(dto, SysDepartmentInfo.class);
        sysDepartmentInfo.setId(null);
        sysDepartmentInfo.setDepartmentId(department.getId());
        sysDepartmentInfoService.save(sysDepartmentInfo);
    }
    /**
     * 处置单位详情
     *
     * @param id
     * @return
     */
    @Override
    public DisposalUnitVO getDisposalUnitDetailById(Long id) {
        return baseMapper.getDisposalUnitDetailById(id);
    }
    @Override
    public void deleteDisposalUnit(Long id) {
        Long count = sysUserDepartmentService.lambdaQuery().eq(SysUserDepartment::getDepartmentId, id).count();
        if (count > 0) {
            throw new ServiceException("该处置单位构已存在用户,无法删除");
        }
        removeById(id);
    }
    /**
     * 监管单位分页列表
     *
     * @param query
     * @return
     */
    @Override
    public PageDTO<RegulatoryUnitVO> pageRegulatoryUnitList(DepartmentQuery query) {
        String treeCode = "";
        if (Objects.isNull(query.getDepartmentId())) {
            SysDepartment myDepartment = getMyDepartment();
            if (Objects.nonNull(myDepartment)) {
                treeCode = myDepartment.getTreeCode();
            }
        }
        Page<SysDepartment> page = this.lambdaQuery().eq(Objects.nonNull(query.getDepartmentId()), SysDepartment::getParentId, query.getDepartmentId())
                .likeRight(StringUtils.isNotBlank(treeCode), SysDepartment::getTreeCode, treeCode)
                .like(StringUtils.isNotEmpty(query.getDepartmentName()), SysDepartment::getDepartmentName, query.getDepartmentName())
                .like(StringUtils.isNotBlank(query.getContactPerson()), SysDepartment::getContactPerson, query.getContactPerson())
                .like(StringUtils.isNotBlank(query.getContactPhone()), SysDepartment::getContactPhone, query.getContactPhone())
                .page(new Page<>(query.getPageCurr(), query.getPageSize()));
        return PageDTO.of(page, RegulatoryUnitVO.class);
    }
    /**
     * 新增监管单位
     *
     * @param dto
     */
    @Override
    public void addRegulatoryUnit(RegulatoryUnitDTO dto) {
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            throw new ServiceException("无操作权限");
        }
        SysDepartment parent = this.getById(dto.getParentId());
        if (Objects.isNull(parent)) {
            throw new ServiceException("找不到对应父级组织");
        }
        if (!parent.getTreeCode().startsWith(currentDepartment.getTreeCode())) {
            throw new ServiceException("无操作权限");
        }
        Long count = this.lambdaQuery().eq(SysDepartment::getDepartmentName, dto.getDepartmentName())
                .eq(SysDepartment::getOrgType, DepartmentEnum.REGULATORY_UNIT.getCode())
                .count();
        if (count > 0) {
            throw new ServiceException("监管单位已存在");
        }
        SysDepartment department = BeanUtils.copyBean(dto, SysDepartment.class);
        department.setTreeCode(getTreeCode(parent.getId()));
        department.setOrgCode(getOrgCode(parent.getId(), DepartmentEnum.REGULATORY_UNIT.getCode()));
        department.setOrgType(DepartmentEnum.REGULATORY_UNIT.getCode());
        //查询父级完整区域
        String region = getRegionName(parent);
        department.setRegion(region);
        save(department);
    }
    /**
     * 编辑监管单位
     *
     * @param dto
     * @return
     */
    @Override
    public void editRegulatoryUnit(RegulatoryUnitDTO dto) {
        if (Objects.isNull(dto.getId())) {
            throw new ServiceException("id不能为空");
        }
        SysDepartment sysDepartment = getById(dto.getId());
        if (Objects.isNull(sysDepartment)) {
            throw new ServiceException("监管单位不存在");
        }
        SysDepartment currentDepartment = getMyDepartment();
        if (Objects.isNull(currentDepartment)) {
            throw new ServiceException("无操作权限");
        }
        SysDepartment parent = this.getById(dto.getParentId());
        if (Objects.isNull(parent)) {
            throw new ServiceException("找不到对应父级组织");
        }
        if (!parent.getTreeCode().startsWith(currentDepartment.getTreeCode())) {
            throw new ServiceException("无操作权限");
        }
        Long count = this.lambdaQuery().eq(SysDepartment::getDepartmentName, dto.getDepartmentName())
                .eq(SysDepartment::getOrgType, DepartmentEnum.REGULATORY_UNIT.getCode()).ne(SysDepartment::getId, dto.getId())
                .count();
        if (count > 0) {
            throw new ServiceException("监管单位已存在");
        }
        SysDepartment department = BeanUtils.copyBean(dto, SysDepartment.class);
        if (!department.getParentId().equals(sysDepartment.getParentId())) {
            department.setTreeCode(getTreeCode(parent.getId()));
            //查询父级完整区域
            String region = getRegionName(parent);
            department.setRegion(region);
        }
        updateById(department);
    }
    /**
     * 监管单位详情
     *
     * @param id
     * @return
     */
    @Override
    public RegulatoryUnitVO getRegulatoryUnitDetailById(Long id) {
        SysDepartment department = this.lambdaQuery().eq(SysDepartment::getId, id).eq(SysDepartment::getOrgType, DepartmentEnum.REGULATORY_UNIT.getCode()).one();
        if (Objects.nonNull(department)) {
            return BeanUtils.copyBean(department, RegulatoryUnitVO.class);
        }
        return null;
    }
    /**
     * 删除监管单位
     *
     * @param id
     */
    @Override
    public void deleteRegulatoryUnit(Long id) {
        Long count = sysUserDepartmentService.lambdaQuery().eq(SysUserDepartment::getDepartmentId, id).count();
        if (count > 0) {
            throw new ServiceException("该监管单位构已存在用户,无法删除");
        }
        removeById(id);
    }
}
medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml
@@ -41,5 +41,160 @@
        </where>
        LIMIT 1
    </select>
    <select id="pageMedicalList" resultType="com.sinata.system.domain.vo.MedicalInstitutionVO">
        SELECT sd.*,
        sdi.DEPARTMENT_ID,
        sdi.INSTITUTION_LEVEL,
        sdi.INSTITUTION_TYPE,
        sdi.DAILY_MIN_WASTE_QUANTITY,
        sdi.DAILY_MAX_WASTE_QUANTITY,
        sdi.MONTHLY_MIN_WASTE_QUANTITY,
        sdi.MONTHLY_MAX_WASTE_QUANTITY,
        sdi.DISPOSAL_LICENSE_NUMBER,
        sdi.DISPOSAL_LICENSE_IMAGE,
        sdi.DAILY_DISPOSAL_QUANTITY,
        sdi.YEARLY_DISPOSAL_QUANTITY,
        sdi.MAIN_TECHNOLOGY,
        sdi.MAXIMUM_STORAGE_CAPACITY,
        sdd.DICT_LABEL AS INSTITUTION_LEVEL_STR,sdd2.DICT_LABEL AS INSTITUTION_TYPE_STR
        FROM SYS_DEPARTMENT sd
        LEFT JOIN SYS_DEPARTMENT_INFO sdi
        ON sd.id = sdi.DEPARTMENT_ID
        LEFT JOIN SYS_DICT_DATA sdd
        ON sdi.INSTITUTION_LEVEL = sdd.DICT_CODE
        LEFT JOIN SYS_DICT_DATA sdd2
        ON sdi.INSTITUTION_TYPE = sdd2.DICT_CODE
        <where>
            sd.ORG_TYPE = 2
            <if test="departmentId != null">
                AND sd.PARENT_ID = #{departmentId}
            </if>
            <if test="departmentName != null and departmentName != ''">
                AND sd.DEPARTMENT_NAME LIKE CONCAT('%', #{departmentName}, '%')
            </if>
            <if test="contactPerson != null and contactPerson != ''">
                AND sd.CONTACT_PERSON LIKE CONCAT('%', #{contactPerson}, '%')
            </if>
            <if test="contactPhone != null and contactPhone != ''">
                AND sd.CONTACT_PHONE LIKE CONCAT('%', #{contactPhone}, '%')
            </if>
            <if test="treeCode != null and treeCode != ''">
                AND sd.TREE_CODE LIKE CONCAT(#{treeCode}, '%')
            </if>
        </where>
        ORDER BY sd.CREATE_TIME DESC
    </select>
    <select id="getMedicalDetailById" resultType="com.sinata.system.domain.vo.MedicalInstitutionVO"
            parameterType="java.lang.Long">
        SELECT sd.*,
        sdi.DEPARTMENT_ID,
        sdi.INSTITUTION_LEVEL,
        sdi.INSTITUTION_TYPE,
        sdi.DAILY_MIN_WASTE_QUANTITY,
        sdi.DAILY_MAX_WASTE_QUANTITY,
        sdi.MONTHLY_MIN_WASTE_QUANTITY,
        sdi.MONTHLY_MAX_WASTE_QUANTITY,
        sdi.DISPOSAL_LICENSE_NUMBER,
        sdi.DISPOSAL_LICENSE_IMAGE,
        sdi.DAILY_DISPOSAL_QUANTITY,
        sdi.YEARLY_DISPOSAL_QUANTITY,
        sdi.MAIN_TECHNOLOGY,
        sdi.MAXIMUM_STORAGE_CAPACITY,
        sdd.DICT_LABEL AS INSTITUTION_LEVEL_STR,sdd2.DICT_LABEL AS INSTITUTION_TYPE_STR
        FROM SYS_DEPARTMENT sd
        LEFT JOIN SYS_DEPARTMENT_INFO sdi
        ON sd.id = sdi.DEPARTMENT_ID
        LEFT JOIN SYS_DICT_DATA sdd
        ON sdi.INSTITUTION_LEVEL = sdd.DICT_CODE
        LEFT JOIN SYS_DICT_DATA sdd2
        ON sdi.INSTITUTION_TYPE = sdd2.DICT_CODE
        <where>
            sd.ORG_TYPE = 2 AND sd.id = #{id}
        </where>
    </select>
    <select id="getDisposalUnitListByTreeCode" resultType="com.sinata.system.domain.vo.DisposalUnitVO"
            parameterType="java.lang.String">
        SELECT sd.*,
        sdi.DEPARTMENT_ID,
        sdi.INSTITUTION_LEVEL,
        sdi.INSTITUTION_TYPE,
        sdi.DAILY_MIN_WASTE_QUANTITY,
        sdi.DAILY_MAX_WASTE_QUANTITY,
        sdi.MONTHLY_MIN_WASTE_QUANTITY,
        sdi.MONTHLY_MAX_WASTE_QUANTITY,
        sdi.DISPOSAL_LICENSE_NUMBER,
        sdi.DISPOSAL_LICENSE_IMAGE,
        sdi.DAILY_DISPOSAL_QUANTITY,
        sdi.YEARLY_DISPOSAL_QUANTITY,
        sdi.MAIN_TECHNOLOGY,
        sdi.MAXIMUM_STORAGE_CAPACITY
        FROM SYS_DEPARTMENT sd
        LEFT JOIN SYS_DEPARTMENT_INFO sdi
        ON sd.id = sdi.DEPARTMENT_ID
        <where>
            sd.ORG_TYPE = 3 AND sd.TREE_CODE LIKE CONCAT(#{treeCode}, '%')
        </where>
    </select>
    <select id="pageRegulatoryUnitList" resultType="com.sinata.system.domain.vo.DisposalUnitVO">
        SELECT sd.*,
        sdi.DEPARTMENT_ID,
        sdi.INSTITUTION_LEVEL,
        sdi.INSTITUTION_TYPE,
        sdi.DAILY_MIN_WASTE_QUANTITY,
        sdi.DAILY_MAX_WASTE_QUANTITY,
        sdi.MONTHLY_MIN_WASTE_QUANTITY,
        sdi.MONTHLY_MAX_WASTE_QUANTITY,
        sdi.DISPOSAL_LICENSE_NUMBER,
        sdi.DISPOSAL_LICENSE_IMAGE,
        sdi.DAILY_DISPOSAL_QUANTITY,
        sdi.YEARLY_DISPOSAL_QUANTITY,
        sdi.MAIN_TECHNOLOGY,
        sdi.MAXIMUM_STORAGE_CAPACITY
        FROM SYS_DEPARTMENT sd
        LEFT JOIN SYS_DEPARTMENT_INFO sdi
        ON sd.id = sdi.DEPARTMENT_ID
        <where>
            sd.ORG_TYPE = 3
            <if test="departmentId != null">
                AND sd.PARENT_ID = #{departmentId}
            </if>
            <if test="departmentName != null and departmentName != ''">
                AND sd.DEPARTMENT_NAME LIKE CONCAT('%', #{departmentName}, '%')
            </if>
            <if test="contactPerson != null and contactPerson != ''">
                AND sd.CONTACT_PERSON LIKE CONCAT('%', #{contactPerson}, '%')
            </if>
            <if test="contactPhone != null and contactPhone != ''">
                AND sd.CONTACT_PHONE LIKE CONCAT('%', #{contactPhone}, '%')
            </if>
            <if test="treeCode != null and treeCode != ''">
                AND sd.TREE_CODE LIKE CONCAT(#{treeCode}, '%')
            </if>
        </where>
    </select>
    <select id="getDisposalUnitDetailById" resultType="com.sinata.system.domain.vo.DisposalUnitVO"
            parameterType="java.lang.Long">
        SELECT sd.*,
        sdi.DEPARTMENT_ID,
        sdi.INSTITUTION_LEVEL,
        sdi.INSTITUTION_TYPE,
        sdi.DAILY_MIN_WASTE_QUANTITY,
        sdi.DAILY_MAX_WASTE_QUANTITY,
        sdi.MONTHLY_MIN_WASTE_QUANTITY,
        sdi.MONTHLY_MAX_WASTE_QUANTITY,
        sdi.DISPOSAL_LICENSE_NUMBER,
        sdi.DISPOSAL_LICENSE_IMAGE,
        sdi.DAILY_DISPOSAL_QUANTITY,
        sdi.YEARLY_DISPOSAL_QUANTITY,
        sdi.MAIN_TECHNOLOGY,
        sdi.MAXIMUM_STORAGE_CAPACITY
        FROM SYS_DEPARTMENT sd
        LEFT JOIN SYS_DEPARTMENT_INFO sdi
        ON sd.id = sdi.DEPARTMENT_ID
        <where>
            sd.id = #{id}
        </where>
    </select>
</mapper>