zjh
1 天以前 cdd1ef49773e49dd91d19f9d02c82fb70e9f658c
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java
@@ -12,6 +12,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ltkj.common.annotation.Excel;
import com.ltkj.common.core.domain.entity.SysDept;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.common.utils.StringUtils;
import com.ltkj.common.utils.poi.ExcelUtil;
import com.ltkj.framework.config.UserHoder;
@@ -115,7 +116,7 @@
    @GetMapping("/getKjTjAdviceKjbqBySex")
    @ApiOperation(value = "根据体检人性别和是否为总检查询体检建议接口")
    public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam String sex, @RequestParam @ApiParam(value = "1常规医生 0总检") String isZj,
    public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam @ApiParam(value = "1常规医生 0总检") String isZj,
                                             @RequestParam(required = false) @ApiParam(value ="建议内容") String jynr,
                                             @RequestParam(required = false) @ApiParam(value ="建议标题") String jybt,
                                             @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
@@ -132,14 +133,13 @@
    }
    @GetMapping("/getCyTjAdviceKjbqBySex")
/*    @GetMapping("/getCyTjAdviceKjbqBySex")
    @ApiOperation(value = "根据当前登录人id获取常用建议")
    public AjaxResult getCyTjAdviceKjbqBySex(@RequestParam(required = false) String sex, @RequestParam @ApiParam(value = "用户id 传当前登录人") Long userId,
                                             @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                             @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize) {
        LambdaQueryWrapper<TjAdvice> wq = new LambdaQueryWrapper<>();
        Page<TjAdvice> page1 = new Page<>(page, pageSize);
//        wq.eq(TjAdvice::getAdSex,sex).or().eq(TjAdvice::getAdSex,"2");
        if (null != userId) {
            LambdaQueryWrapper<TjUserAdvice> wq0 = new LambdaQueryWrapper<>();
            wq0.eq(TjUserAdvice::getUserId, userId);
@@ -150,6 +150,46 @@
                Page<TjAdvice> kjbqPage = tjAdviceService.page(page1,wq);
                return AjaxResult.success(kjbqPage);
            }
        }
        return AjaxResult.success("该用户暂时没有常用建议!");
    }*/
    @GetMapping("/getCyTjAdviceKjbqBySex")
    @ApiOperation(value = "根据当前登录人id获取常用建议")
    public AjaxResult getCyTjAdviceKjbqBySex( @RequestParam @ApiParam(value = "用户id 传当前登录人") Long userId,
                                             @ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer page,
                                             @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                             @RequestParam(required = false) String nr) {
        LambdaQueryWrapper<TjUserAdvice> wq0 = new LambdaQueryWrapper<>();
        if(!SecurityUtils.isAdmin(userId))
            wq0.eq(TjUserAdvice::getUserId, userId);
        List<TjUserAdvice> list = userAdviceService.list(wq0);
        List<TjAdvice> kjbqPage = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("total", 0);
        map.put("records", null);
        if (null != list && !list.isEmpty()) {
            for (TjUserAdvice advice : list) {
                TjAdvice advice1 = tjAdviceService.getById(advice.getAdviceId());
                if(null != advice1){
                    advice1.setUserName(userService.getById(advice.getUserId()).getNickName());
                    kjbqPage.add(advice1);
                }
            }
            List<TjAdvice> adviceList =null;
            if(StringUtil.isNotBlank( nr)){
                adviceList = kjbqPage.stream().filter(kjbq -> StringUtil.isNotBlank(kjbq.getTitle()) && kjbq.getTitle().contains(nr)).collect(Collectors.toList());
                List<TjAdvice> tjAdviceList = adviceList.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                map.put("total", adviceList.size());
                map.put("records", tjAdviceList);
            }else {
                adviceList = kjbqPage.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                map.put("total", kjbqPage.size());
                map.put("records", adviceList);
            }
            return AjaxResult.success(map);
        }
        return AjaxResult.success("该用户暂时没有常用建议!");
    }
@@ -364,4 +404,18 @@
    public AjaxResult remove(@PathVariable Long[] ids) {
        return AjaxResult.success(tjAdviceService.deleteTjAdviceByIds(ids));
    }
    @DeleteMapping("/delCyremove")
    @ApiOperation(value = "删除用户常用建议接口")
    public AjaxResult delCyremove(@RequestParam List<String> ids) {
        String userId = UserHoder.getLoginUser().getUserId();
        LambdaQueryWrapper<TjUserAdvice> wq=new LambdaQueryWrapper<>();
        wq.in(TjUserAdvice::getAdviceId,ids);
        wq.eq(TjUserAdvice::getUserId,userId);
        if (userAdviceService.remove(wq)) {
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
}