package com.ltkj.web.controller.system; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.hosp.domain.TjProject; import com.ltkj.hosp.domain.TjRules; import com.ltkj.hosp.service.ITjProjectService; import com.ltkj.hosp.service.ITjRulesService; import io.swagger.annotations.ApiParam; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.enums.BusinessType; import com.ltkj.hosp.domain.TjRuleAdvice; import com.ltkj.hosp.service.ITjRuleAdviceService; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.common.core.page.TableDataInfo; /** * 病种+意见Controller * * @author ltkj_赵佳豪&李格 * @date 2023-08-30 */ @RestController @RequestMapping("/hosp/ruleAdvice") public class TjRuleAdviceController extends BaseController { @Autowired private ITjRulesService tjRulesService; @Autowired private ITjRuleAdviceService tjRuleAdviceService; @Resource private ITjProjectService tjProjectService; /** * 查询病种+意见列表 */ //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:list')") @GetMapping("/list") public TableDataInfo list(TjRuleAdvice tjRuleAdvice) { startPage(); LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); if (tjRuleAdvice.getBzmc() != null) { wq.like(TjRuleAdvice::getBzmc, tjRuleAdvice.getBzmc()); } if (tjRuleAdvice.getJy() != null) { wq.like(TjRuleAdvice::getJy, tjRuleAdvice.getJy()); } if (tjRuleAdvice.getZjf() != null) { wq.like(TjRuleAdvice::getZjf, tjRuleAdvice.getZjf()); } List list = tjRuleAdviceService.list(wq); return getDataTable(list); } /** * 导出病种+意见列表 */ //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:export')") @Log(title = "病种+意见", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TjRuleAdvice tjRuleAdvice) { LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); if (tjRuleAdvice.getBzmc() != null) { wq.like(TjRuleAdvice::getBzmc, tjRuleAdvice.getBzmc()); } if (tjRuleAdvice.getJy() != null) { wq.like(TjRuleAdvice::getJy, tjRuleAdvice.getJy()); } if (tjRuleAdvice.getZjf() != null) { wq.like(TjRuleAdvice::getZjf, tjRuleAdvice.getZjf()); } List list = tjRuleAdviceService.list(wq); ExcelUtil util = new ExcelUtil(TjRuleAdvice.class); util.exportExcel(response, list, "病种+意见数据"); } /** * 获取病种+意见详细信息 */ //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:query')") @GetMapping(value = "/{gid}") public AjaxResult getInfo(@PathVariable("gid") String gid) { return success(tjRuleAdviceService.getById(gid)); } /** * 新增病种+意见 */ // @PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:add')") @Log(title = "病种+意见", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TjRuleAdvice tjRuleAdvice) { return toAjax(tjRuleAdviceService.save(tjRuleAdvice)); } /** * 修改病种+意见 */ //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:edit')") @Log(title = "病种+意见", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TjRuleAdvice tjRuleAdvice) { return toAjax(tjRuleAdviceService.saveOrUpdate(tjRuleAdvice)); } /** * 删除病种+意见 */ //@PreAuthorize("@ss.hasPermi('hosp:ruleAdvice:remove')") @Log(title = "病种+意见", businessType = BusinessType.DELETE) @DeleteMapping("/{gids}") public AjaxResult remove(@PathVariable String[] gids) { for (String gid : gids) { tjRuleAdviceService.removeById(gid); } return toAjax(true); } /** * 根据项目id查询病种意见列表 */ @GetMapping("/getByProId") public TableDataInfo getByProId(@RequestParam(required = false) String proId) { startPage(); List list2 = new ArrayList<>(); final TjProject byId = tjProjectService.getById(proId); if (byId.getProParentId() == 0) { LambdaQueryWrapper wqqq = new LambdaQueryWrapper<>(); wqqq.eq(TjProject::getProParentId, byId.getProId()); final List list = tjProjectService.list(wqqq); for (TjProject project : list) { LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); wq.eq(TjRules::getProId, project.getProId()); wq.orderByAsc(TjRules::getSort); List list11 = tjRulesService.list(wq); for (TjRules tjRules : list11) { LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); wq1.eq(TjRuleAdvice::getBz, tjRules.getAid()); List list1 = tjRuleAdviceService.list(wq1); list2.addAll(list1); } } } else { LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); if (proId != null) { wq.eq(TjRules::getProId, proId); } wq.orderByAsc(TjRules::getSort); List list = tjRulesService.list(wq); for (TjRules tjRules : list) { LambdaQueryWrapper wq1 = new LambdaQueryWrapper<>(); wq1.eq(TjRuleAdvice::getBz, tjRules.getAid()); List list1 = tjRuleAdviceService.list(wq1); list2.addAll(list1); } } return getDataTable(list2); } }