package cn.besteam.modules.system.controller; import cn.besteam.common.api.vo.Result; import cn.besteam.common.aspect.annotation.AutoLog; import cn.besteam.common.aspect.annotation.LogApi; import cn.besteam.common.aspect.annotation.OpenApi; import cn.besteam.common.dto.IdDTO; import cn.besteam.modules.system.biz.SysDepartmentBiz; import cn.besteam.modules.system.dto.ImportDTO; import cn.besteam.modules.system.dto.SysDepartmentDTO; import cn.besteam.modules.system.entity.SysDepartment; import cn.besteam.modules.system.service.ISysDepartmentService; import cn.besteam.modules.system.vo.*; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; /** * @Title: Controller * @Description: 组织架构表 * @author: besteam * @date: 2020-04-17 * @version: V1.0 */ @RestController @RequestMapping("/system/sysDepartment") @Slf4j @Api(description = "组织架构表") public class SysDepartmentController { @Autowired private SysDepartmentBiz sysDepartmentBiz; @Autowired private ISysDepartmentService sysDepartmentService; /** * 获取组织架构表数据列表-分页 * * @param pageNo * @param pageSize * @param keyword * @return */ @GetMapping(value = "/list") @ApiOperation(value = "获取组织架构表数据列表", notes = "获取所有组织架构表数据列表-分页", produces = "application/json") public Result> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, String keyword) { return Result.ok(sysDepartmentBiz.queryPageList(pageNo, pageSize, keyword)); } /** * 获取组织架构 * * @param keyword * @return */ @GetMapping(value = "/listRegion") @ApiOperation(value = "获取组织架构表数据列表", notes = "获取所有组织架构表数据列表-分页", produces = "application/json") public Result> listRegion(String keyword) { return Result.ok(sysDepartmentBiz.listRegion(keyword)); } /** * 获取组织架构 * * @param parentId * @return */ @GetMapping(value = "/listRegionChildren") @ApiOperation(value = "获取组织架构表数据列表", notes = "获取所有组织架构表数据列表-分页", produces = "application/json") public Result> listRegionChildren(@RequestParam Integer parentId) { return Result.ok(sysDepartmentBiz.listRegionChildren(parentId)); } /** * 获取组织架构树形列表 * * @return */ @GetMapping(value = "/sysDepartmentTreeList") @ApiOperation(value = "获取组织架构树形列表", notes = "获取组织架构树形列表", produces = "application/json") public Result sysDepartmentTreeList() { return Result.ok(sysDepartmentBiz.sysDepartmentTreeList()); } /** * 获取组织架构树形列表 * * @return */ @GetMapping(value = "/getMyDepartmentTreeList") @ApiOperation(value = "获取组织架构树形列表", notes = "获取组织架构树形列表", produces = "application/json") public Result getMyDepartmentTreeList() { return Result.ok(sysDepartmentBiz.getMyDepartmentTreeList(null)); // Object ob = sysDepartmentBiz.getCache(3); // return Result.ok((List)ob); } /** * 添加 * * @param sysDepartment * @return */ @PostMapping(value = "/add") @AutoLog(value = "添加组织架构表") @ApiOperation(value = "添加组织架构表", notes = "添加组织架构表", produces = "application/json") public Result add(@RequestBody SysDepartment sysDepartment) { sysDepartmentBiz.save(sysDepartment); return Result.ok("添加成功!"); } /** * 编辑 * * @param sysDepartment * @return */ @PostMapping(value = "/edit") @AutoLog(value = "编辑组织架构表") @ApiOperation(value = "编辑组织架构表", notes = "编辑组织架构表", produces = "application/json") public Result edit(@RequestBody SysDepartment sysDepartment) { sysDepartmentBiz.edit(sysDepartment); return Result.ok("修改成功!"); } /** * 录屏开关 * * @param sysDepartment * @return */ @PostMapping(value = "/editSwitch") @AutoLog(value = "医院录屏开关") @ApiOperation(value = "医院录屏开关", notes = "医院录屏开关", produces = "application/json") public Result editSwitch(@RequestBody SysDepartment sysDepartment) { sysDepartmentBiz.editSwitch(sysDepartment); return Result.ok("修改成功!"); } /** * 通过id删除 * * @param dto * @return */ @PostMapping(value = "/delete") @AutoLog(value = "删除组织架构表") @ApiOperation(value = "删除组织架构表", notes = "删除组织架构表", produces = "application/json") public Result delete(@Validated @RequestBody IdDTO dto) { sysDepartmentBiz.delete(dto.getId()); return Result.ok("已删除!"); } /** * 获取我的医院列表 * * @return */ @GetMapping(value = "/getMyHospitalList") @ApiOperation(value = "获取我的医院列表", notes = "获取我的医院列表", produces = "application/json") public Result getMyHospitalList() { return Result.ok(sysDepartmentBiz.getMyHospitalList()); } /** * 获取我的医院列表--级联 * * @return */ @GetMapping(value = "/getMyHospitalCascadeList") @ApiOperation(value = "获取我的医院列表--级联", notes = "获取我的医院列表--级联", produces = "application/json") public Result getMyHospitalCascadeList() { return Result.ok(sysDepartmentBiz.getMyHospitalCascadeList(null)); // Object ob = sysDepartmentBiz.getCache(2); // return Result.ok((List)ob); } /** * 获取我的医院列表--级联到科室列表 * * @return */ @GetMapping(value = "/getMyHospitalAndOfficeCascadeList") @ApiOperation(value = "获取我的医院以及科室列表--级联", notes = "获取我的医院以及科室列表--级联", produces = "application/json") public Result getMyHospitalAndOfficeCascadeList() { return Result.ok(sysDepartmentBiz.getMyHospitalAndOfficeCascadeListV2(null)); // Object ob = sysDepartmentBiz.getCache(1); // return Result.ok((List)ob); } /** * 获取我的科室列表 * * @return */ @GetMapping(value = "/getMyOfficeList") @ApiOperation(value = "获取我的科室列表", notes = "获取我的科室列表", produces = "application/json") public Result getMyOfficeList() { return Result.ok(sysDepartmentBiz.getMyOfficeList()); } /** * 获取我的科室列表--级联 * * @return */ @GetMapping(value = "/getMyOfficeCascadeList") @ApiOperation(value = "获取我的科室列表--级联", notes = "获取我的科室列表--级联", produces = "application/json") public Result getMyOfficeCascadeList(Integer parentId) { return Result.ok(sysDepartmentBiz.getMyOfficeCascadeList(parentId)); } /** * 获取我的科室列表--级联 * * @return */ @GetMapping(value = "/getMyOfficeCascadeListV2") @ApiOperation(value = "获取我的科室列表--级联", notes = "获取我的科室列表--级联", produces = "application/json") public Result getMyOfficeCascadeListV2(Integer parentId, @RequestParam(required = false, defaultValue = "false") Boolean onlyOffice) { return Result.ok(sysDepartmentBiz.getMyOfficeCascadeListV2(parentId, onlyOffice)); } @PostMapping(value = "/importDepartment") @ApiOperation(value = "组织架构导入", notes = "组织架构导入") public Result importDepartment(@Validated ImportDTO dto) throws IOException { return Result.ok(sysDepartmentService.importDepartment(dto)); } @GetMapping(value = "/downloadImportTemplate") @ApiOperation(value = "下载导入模板", notes = "下载导入模板") public void downloadImportTemplate(HttpServletResponse response) throws IOException { sysDepartmentService.downloadImportTemplate(response); } @GetMapping(value = "/getMyWarehouseOfficeList") @ApiOperation(value = "获取我的暂存间列表", notes = "获取我的暂存间列表", produces = "application/json") @LogApi(value = "获取我的暂存间列表") public Result getMyWarehouseOfficeList(Integer officeId) { return Result.ok(sysDepartmentBiz.getMyWarehouseOfficeList(officeId)); } //报表用 @GetMapping(value = "/getTwoAreaCascadeList") @ApiOperation(value = "获取前两级区域列表", notes = "获取前两级区域列表", produces = "application/json") public Result getTwoAreaCascadeList() { return Result.ok(sysDepartmentBiz.getTwoAreaCascadeList()); } @GetMapping(value = "/getThreeAreaCascadeList") @ApiOperation(value = "获取前三级区域列表", notes = "获取前三级区域列表", produces = "application/json") public Result getThreeAreaCascadeList() { return Result.ok(sysDepartmentBiz.getThreeAreaCascadeList()); } @GetMapping(value = "/getRegionHospitalCascadeList") @ApiOperation(value = "根据区域获取医院列表", notes = "根据区域获取医院列表", produces = "application/json") public Result getRegionHospitalCascadeList(@RequestParam Integer departmentId) { return Result.ok(sysDepartmentBiz.getRegionHospitalCascadeList(departmentId)); } @OpenApi @PostMapping(value = "reCalculateTreeCode") public Result reCalculateTreeCode() { SysDepartment root = sysDepartmentService.getById(-1); sysDepartmentBiz.reCalculateChildrenTreeCode(root); return Result.ok(true); } @GetMapping(value = "/hospitalConfigurationList") @ApiOperation(value = "获取医院配置列表(全选开关/手选开关/签名开关/环保交接开关/出库称重开关/出库打印开关/芯片箱包开关)", notes = "获取医院配置列表(全选开关/手选开关/签名开关/环保交接开关/出库称重开关/出库打印开关)", produces = "application/json") public Result> list(SysDepartmentVO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { IPage pageList = sysDepartmentService.queryDepartmentPageList(pageNo, pageSize, dto); return Result.ok(pageList); } /** * 批量编辑医院配置(全选开关/手选开关/签名开关/环保交接开关/出库称重开关/出库打印开关) * * @param * @return */ @PostMapping(value = "/batchEditHospitalConfiguration") @AutoLog(value = "批量编辑医院配置(全选开关/手选开关/签名开关/环保交接开关/出库称重开关/出库打印开关/蓝牙称重开关/蓝牙打印开关)") @ApiOperation(value = "批量编辑医院配置(全选开关/手选开关//环保交接开关/出库称重开关/出库打印开关/蓝牙称重开关/蓝牙打印开关)", notes = "批量编辑医院配置(全选开关/手选开关/签名开关/环保交接开关/出库称重开关/出库打印开关/蓝牙称重开关/蓝牙打印开关)", produces = "application/json") public Result batchEditHospitalConfiguration(@RequestBody EditHospitalConfigurationBatchVo vo) { sysDepartmentBiz.batchEdit(vo.getIds(),vo.getSelectSwitch(),vo.getCheckallSwitch(),vo.getSignatureSwitch(), vo.getEnvironmentalHandoverSwitch(), vo.getOutboundWeighingSwitch(), vo.getOutboundPrintingSwitch(),vo.getBluetoothPrintSwitch(),vo.getBluetoothWeighSwitch(),vo.getChipBoxSwitch()); return Result.ok("修改成功!"); } /** * 批量编辑医院配置(全选开关/手选开关/签名开关) * * @param * @return */ @PostMapping(value = "/editHospitalConfiguration") @AutoLog(value = "编辑医院配置(1全选开关/2手选开关/3签名开关/4环保交接开关/5出库称重开关/6出库打印开关/7蓝牙称重开关/8蓝牙打印开关;1启用/0关闭)/9芯片箱包开关") @ApiOperation(value = "编辑医院配置(1全选开关/2手选开关/3签名开关/4环保交接开关/5出库称重开关/6出库打印开关;1启用/0关闭)", notes = "编辑医院配置(1全选开关/2手选开关/3签名开关/4环保交接开关/5出库称重开关/6出库打印开关/7蓝牙称重开关/8蓝牙打印开关;1启用/0关闭)/9芯片箱包开关)", produces = "application/json") public Result editHospitalConfiguration(@RequestBody EditHospitalConfigurationVo vo) { sysDepartmentBiz.editHospitalConfiguration(vo.getId(),vo.getType(),vo.getState()); return Result.ok("修改成功!"); } /** * 获取收集小程序授权列表 * @param vo * @return */ @PostMapping(value = "/getCollectAppletAuthorization") @AutoLog(value = "获取收集小程序授权列表") @ApiOperation(value = "获取收集小程序授权列表", notes = "获取收集小程序授权列表", produces = "application/json") public Result> getCollectAppletAuthorization(@RequestBody CollectAppletAuthorizationVO vo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize){ return Result.ok(sysDepartmentBiz.getCollectAppletAuthorization(vo, pageNo, pageSize)); } /** * 导出收集小程序授权列表 * @param vo * @param response */ @GetMapping(value = "/exportCollectAppletAuthorization") @AutoLog(value = "导出收集小程序授权列表") @ApiOperation(value = "导出收集小程序授权列表", notes = "导出收集小程序授权列表", produces = "application/json") public void exportCollectAppletAuthorization(CollectAppletAuthorizationVO vo, HttpServletResponse response){ try { sysDepartmentBiz.exportCollectAppletAuthorization(vo, response); }catch (Exception e){ e.printStackTrace(); } } /** * 批量编辑收集小程序授权状态 * @param request * @return */ @RequestMapping(value = "/batchEditCollectAppletAuthorization", method = {RequestMethod.POST}) @AutoLog(value = "批量编辑收集小程序授权状态") @ApiOperation(value = "批量编辑收集小程序授权状态", notes = "批量编辑收集小程序授权状态", produces = "application/json") public Result batchEditCollectAppletAuthorization(@RequestBody EditCollectAppletAuthorizationVO vo, HttpServletRequest request){ sysDepartmentBiz.batchEditCollectAppletAuthorization(vo.getIds(), vo.getStatus(), request); return Result.ok("成功"); } /** * 获取月报短信授权列表 * @param vo * @return */ @PostMapping(value = "/getMonthlySmsAuthorization") @AutoLog(value = "获取月报短信授权列表") @ApiOperation(value = "获取月报短信授权列表", notes = "获取月报短信授权列表", produces = "application/json") public Result> getMonthlySmsAuthorization(@RequestBody MonthlySmsAuthorizationVO vo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize){ return Result.ok(sysDepartmentBiz.getMonthlySmsAuthorization(vo, pageNo, pageSize)); } /** * 导出月报短信授权列表 * @param vo * @param response */ @GetMapping(value = "/exportMonthlySmsAuthorization") @AutoLog(value = "导出月报短信授权列表") @ApiOperation(value = "导出月报短信授权列表", notes = "导出月报短信授权列表", produces = "application/json") public void exportMonthlySmsAuthorization(MonthlySmsAuthorizationVO vo, HttpServletResponse response){ try { sysDepartmentBiz.exportMonthlySmsAuthorization(vo, response); }catch (Exception e){ e.printStackTrace(); } } /** * 批量编辑月报短信授权状态 * @param request * @return */ @RequestMapping(value = "/batchEditMonthlySmsAuthorization", method = {RequestMethod.POST}) @AutoLog(value = "批量编辑月报短信授权状态") @ApiOperation(value = "批量编辑月报短信授权状态", notes = "批量编辑月报短信授权状态", produces = "application/json") public Result batchEditMonthlySmsAuthorization(@RequestBody EditCollectAppletAuthorizationVO vo, HttpServletRequest request){ sysDepartmentBiz.batchEditMonthlySmsAuthorization(vo.getIds(), vo.getStatus(), request); return Result.ok("成功"); } @PostMapping(value = "/updateCache") @ApiOperation(value = "手动更新缓存", notes = "手动更新缓存") public Result updateCache() throws IOException { sysDepartmentService.joinCache() ; return Result.ok("操作成功!"); } }