From d183f6f3f4dd871721e9bd3f30a4e8c71b4a9f1b Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期五, 26 四月 2024 18:01:18 +0800 Subject: [PATCH] zjh 2024/04/26-1 --- ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java | 11 ++- ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjUserAdviceServiceImpl.java | 8 ++ ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java | 111 ++++++++++++++++++++++++++++--------- ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjUserAdviceMapper.java | 6 ++ ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjUserAdviceService.java | 2 5 files changed, 108 insertions(+), 30 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java index 8ee6169..374b807 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjAdviceController.java @@ -1,10 +1,7 @@ package com.ltkj.web.controller.system; import java.nio.channels.NonReadableChannelException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -14,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ltkj.common.annotation.Excel; import com.ltkj.common.utils.poi.ExcelUtil; +import com.ltkj.framework.config.UserHoder; import com.ltkj.hosp.domain.TjAdvice; import com.ltkj.hosp.domain.TjAdviceKjbq; import com.ltkj.hosp.domain.TjProject; @@ -57,6 +55,7 @@ @PostMapping("/addTjAdviceKjbq") @ApiOperation(value = "鏂板浣撴寤鸿蹇嵎鏍囩鎺ュ彛") public AjaxResult addTjAdviceKjbq(@RequestBody TjAdviceKjbq adviceKjbq) { + return AjaxResult.success(kjbqService.save(adviceKjbq)); } @@ -74,7 +73,7 @@ @PostMapping("/updateQybzTjAdviceKjbqById") @ApiOperation(value = "淇敼浣撴寤鸿蹇嵎鏍囩鍚敤鐘舵�佹帴鍙�") - public AjaxResult updateQybzTjAdviceKjbqById(@RequestParam int qybz,@RequestParam Long id) { + public AjaxResult updateQybzTjAdviceKjbqById(@RequestParam int qybz, @RequestParam Long id) { TjAdviceKjbq kjbq = kjbqService.getById(id); kjbq.setQyzt(String.valueOf(qybz)); return AjaxResult.success(kjbqService.updateById(kjbq)); @@ -82,22 +81,22 @@ @GetMapping("/getTjAdviceKjbqByFl") @ApiOperation(value = "鏍规嵁鏍囩鍒嗙被鏌ヨ浣撴寤鸿蹇嵎鏍囩鎺ュ彛") - public AjaxResult getTjAdviceKjbqByFl(@RequestParam(required = false)@ApiParam(value = "鐢ㄦ埛id 浼犲綋鍓嶇櫥褰曚汉 瓒呯鐧诲綍鏃朵笉浼� 涓簄ull") String userId, - @RequestParam(required = false)@ApiParam(value = "鍚敤鐘舵�� 0鍚敤 1鍋滅敤") Integer qyzt, + public AjaxResult getTjAdviceKjbqByFl(@RequestParam(required = false) @ApiParam(value = "鐢ㄦ埛id 浼犲綋鍓嶇櫥褰曚汉 瓒呯鐧诲綍鏃朵笉浼� 涓簄ull") String userId, + @RequestParam(required = false) @ApiParam(value = "鍚敤鐘舵�� 0鍚敤 1鍋滅敤") Integer qyzt, @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer page, @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize) { LambdaQueryWrapper<TjAdviceKjbq> wq = new LambdaQueryWrapper<>(); - Page<TjAdviceKjbq> page1=new Page<>(page,pageSize); + Page<TjAdviceKjbq> page1 = new Page<>(page, pageSize); if (null != userId && !userId.equals("")) { wq.eq(TjAdviceKjbq::getUserId, userId); } if (null != qyzt) { - wq.eq(TjAdviceKjbq::getQyzt,qyzt); + wq.eq(TjAdviceKjbq::getQyzt, qyzt); } Page<TjAdviceKjbq> kjbqPage = kjbqService.page(page1, wq); - if(null !=kjbqPage.getRecords() && kjbqPage.getRecords().size()>0){ + if (null != kjbqPage.getRecords() && kjbqPage.getRecords().size() > 0) { for (TjAdviceKjbq record : kjbqPage.getRecords()) { - if(null !=record.getUserId()){ + if (null != record.getUserId()) { record.setUserName(userService.getById(record.getUserId()).getNickName()); } @@ -109,46 +108,84 @@ @GetMapping("/getKjTjAdviceKjbqBySex") @ApiOperation(value = "鏍规嵁浣撴浜烘�у埆鍜屾槸鍚︿负鎬绘鏌ヨ浣撴寤鸿鎺ュ彛") - public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam String sex, @RequestParam @ApiParam(value = "0甯歌鍖荤敓 1鎬绘") String isZj, + public AjaxResult getKjTjAdviceKjbqBySex(@RequestParam String sex, @RequestParam @ApiParam(value = "1甯歌鍖荤敓 0鎬绘") String isZj, @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); + Page<TjAdvice> page1 = new Page<>(page, pageSize); + wq.eq(TjAdvice::getAdSex, sex).or().isNull(TjAdvice::getAdSex); wq.eq(TjAdvice::getIsZj, isZj); Page<TjAdvice> kjbqPage = tjAdviceService.page(page1, wq); return AjaxResult.success(kjbqPage); } - - @GetMapping("/getCyTjAdviceKjbqBySex") @ApiOperation(value = "鏍规嵁褰撳墠鐧诲綍浜篿d鑾峰彇甯哥敤寤鸿") - public AjaxResult getCyTjAdviceKjbqBySex(@RequestParam String sex,@RequestParam @ApiParam(value = "鐢ㄦ埛id 浼犲綋鍓嶇櫥褰曚汉") Long userId, + public AjaxResult getCyTjAdviceKjbqBySex(@RequestParam 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); + 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); + LambdaQueryWrapper<TjUserAdvice> wq0 = new LambdaQueryWrapper<>(); + wq0.eq(TjUserAdvice::getUserId, userId); List<TjUserAdvice> list = userAdviceService.list(wq0); - if(null !=list && list.size()>0){ + if (null != list && list.size() > 0) { List<Long> longs = list.stream().map(TjUserAdvice::getAdviceId).collect(Collectors.toList()); - wq.in(TjAdvice::getId, longs); - Page<TjAdvice> kjbqPage = tjAdviceService.page(page1, wq); + wq.in(TjAdvice::getId,longs); + wq.last("and (ad_sex=1 OR ad_sex=2)"); + Page<TjAdvice> kjbqPage = tjAdviceService.page(page1,wq); return AjaxResult.success(kjbqPage); } - } return AjaxResult.success("璇ョ敤鎴锋殏鏃舵病鏈夊父鐢ㄥ缓璁�!"); } + @GetMapping("/addCyTjAdviceByUserId") + @ApiOperation(value = "娣诲姞褰撳墠鐧诲綍浜哄父鐢ㄥ缓璁帴鍙�") + public AjaxResult addCyTjAdviceByUserId(@RequestParam @ApiParam(value = "鎵�閫夊缓璁富閿甶d鏁扮粍") List<Long> adviceIds) { + String userId = UserHoder.getLoginUser().getUserId(); + if (null != adviceIds && adviceIds.size() > 0) { + for (Long id : adviceIds) { + TjUserAdvice tjUserAdvice = userAdviceService.getTjUserAdviceByUserId(Long.valueOf(userId), id); + if (null == tjUserAdvice) { + TjUserAdvice userAdvice = new TjUserAdvice(); + userAdvice.setAdviceId(id); + userAdvice.setUserId(Long.valueOf(userId)); + userAdviceService.save(userAdvice); + } + } + return AjaxResult.success("娣诲姞鎴愬姛!"); + } + return AjaxResult.success("璇烽�夋嫨鎮ㄨ娣诲姞鐨勫缓璁�!"); + } + @PostMapping("/addCyTjAdvice") + @ApiOperation(value = "娣诲姞甯哥敤寤鸿鎺ュ彛") + public AjaxResult addCyTjAdvice(@RequestBody TjAdvice adviceId) { + String userId = UserHoder.getLoginUser().getUserId(); + if (null != adviceId) { + if (tjAdviceService.save(adviceId)) { + TjUserAdvice tjUserAdvice = userAdviceService.getTjUserAdviceByUserId(Long.valueOf(userId),adviceId.getId()); + if (null == tjUserAdvice) { + TjUserAdvice userAdvice = new TjUserAdvice(); + userAdvice.setAdviceId(adviceId.getId()); + userAdvice.setUserId(Long.valueOf(userId)); + userAdviceService.save(userAdvice); + } + } + return AjaxResult.success("鎿嶄綔鎴愬姛!"); + } + return AjaxResult.success("璇烽�夋嫨鎮ㄨ娣诲姞鐨勫缓璁�!"); + } + + + +// ================/**/================================================================================================================================== /** * 鏌ヨadvice鍒楄〃 */ @@ -175,6 +212,11 @@ if (null != adviceList.getRecords() && adviceList.getRecords().size() > 0) { for (TjAdvice record : adviceList.getRecords()) { record.setProName(project.getProName()); + String kjbq = record.getKjbq(); + if(null !=kjbq && !kjbq.equals("")){ + String[] split = kjbq.split(","); + record.setKjbqz(Arrays.asList(split)); + } } list.addAll(adviceList.getRecords()); } @@ -192,6 +234,11 @@ TjProject tjProject = tjProjectService.getById(advice.getProId()); if (null != tjProject) { advice.setProName(tjProject.getProName()); + } + String kjbq = advice.getKjbq(); + if(null !=kjbq && !kjbq.equals("")){ + String[] split = kjbq.split(","); + advice.setKjbqz(Arrays.asList(split)); } } } @@ -217,8 +264,17 @@ */ // @PreAuthorize("@ss.hasPermi('advice:advice:query')") @GetMapping(value = "/{id}") + @ApiOperation(value = "鏍规嵁涓婚敭id鑾峰彇advice璇︾粏淇℃伅") public AjaxResult getInfo(@PathVariable("id") Long id) { - return AjaxResult.success(tjAdviceService.selectTjAdviceById(id)); + TjAdvice advice = tjAdviceService.getById(id); + if(null !=advice){ + String kjbq = advice.getKjbq(); + if(null !=kjbq && !kjbq.equals("")){ + String[] split = kjbq.split(","); + advice.setKjbqz(Arrays.asList(split)); + } + } + return AjaxResult.success(advice); } /** @@ -227,8 +283,9 @@ // @PreAuthorize("@ss.hasPermi('advice:advice:add')") @Log(title = "advice", businessType = BusinessType.INSERT) @PostMapping + @ApiOperation(value = "鏂板浣撴寤鸿鎺ュ彛") public AjaxResult add(@RequestBody TjAdvice tjAdvice) { - return AjaxResult.success(tjAdviceService.insertTjAdvice(tjAdvice)); + return AjaxResult.success(tjAdviceService.save(tjAdvice)); } /** diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java index 9527065..c3f832e 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjAdvice.java @@ -16,6 +16,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.util.List; + /** * advice瀵硅薄 tj_advice * @@ -69,16 +71,19 @@ private String adSex; @Excel(name = "鏄惁鎬绘") - @ApiModelProperty(value = "鏄惁鎬绘 0甯歌 1鎬绘") + @ApiModelProperty(value = "鏄惁鎬绘 1甯歌 0鎬绘") private String isZj; - - @TableField(exist = false) @ApiModelProperty(value = "椤圭洰鍚嶅瓧") private String proName; + @Excel(name = "蹇嵎鏍囩") + @TableField(exist = false) + @ApiModelProperty(value = "蹇嵎鏍囩") + private List<String> kjbqz; + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjUserAdviceMapper.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjUserAdviceMapper.java index bb0d47e..838df60 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjUserAdviceMapper.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjUserAdviceMapper.java @@ -3,7 +3,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ltkj.hosp.domain.TjUserAdvice; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; @Mapper public interface TjUserAdviceMapper extends BaseMapper<TjUserAdvice> { + + + @Select("select * from tj_user_advice a where a.user_id=#{userId} and a.advice_id=#{adviceId}") + TjUserAdvice getTjUserAdviceByUserId(@Param("userId") Long userId,@Param("adviceId") Long adviceId); } diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjUserAdviceService.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjUserAdviceService.java index 1716bb3..6be4c4f 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjUserAdviceService.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/TjUserAdviceService.java @@ -4,4 +4,6 @@ import com.ltkj.hosp.domain.TjUserAdvice; public interface TjUserAdviceService extends IService<TjUserAdvice> { + + TjUserAdvice getTjUserAdviceByUserId(Long userId,Long adviceId); } diff --git a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjUserAdviceServiceImpl.java b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjUserAdviceServiceImpl.java index e6c552a..97079bb 100644 --- a/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjUserAdviceServiceImpl.java +++ b/ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjUserAdviceServiceImpl.java @@ -6,6 +6,14 @@ import com.ltkj.hosp.service.TjUserAdviceService; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + @Service public class TjUserAdviceServiceImpl extends ServiceImpl<TjUserAdviceMapper,TjUserAdvice> implements TjUserAdviceService { + @Resource + private TjUserAdviceMapper mapper; + @Override + public TjUserAdvice getTjUserAdviceByUserId(Long userId, Long adviceId) { + return mapper.getTjUserAdviceByUserId(userId,adviceId); + } } -- Gitblit v1.8.0