diff --git a/src/main/java/com/peanut/modules/common/controller/MedicalRecordsController.java b/src/main/java/com/peanut/modules/common/controller/MedicalRecordsController.java index b378773d..7a586a6d 100644 --- a/src/main/java/com/peanut/modules/common/controller/MedicalRecordsController.java +++ b/src/main/java/com/peanut/modules/common/controller/MedicalRecordsController.java @@ -1,7 +1,8 @@ package com.peanut.modules.common.controller; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.R; import com.peanut.common.utils.ShiroUtils; @@ -11,6 +12,7 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataSet; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.tool.ToolCallbackProvider; import org.springframework.beans.factory.annotation.Autowired; @@ -18,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; @Slf4j @RestController("commonMedicalRecords") @@ -32,9 +31,11 @@ public class MedicalRecordsController { @Autowired private MedicalRecordsService medicalRecordsService; @Autowired - private MedicalRecordsLabelService medicalRecordsLabelService; + private DeptLabelService deptLabelService; @Autowired - private MedicalRecordsToLabelService medicalRecordsToLabelService; + private MedicalRecordsToDeptLabelService medicalRecordsToDeptLabelService; + @Autowired + private MedicalRecordsCheckUserService medicalRecordsCheckUserService; @Autowired private TaihuTalentService taihuTalentService; @Autowired @@ -52,16 +53,16 @@ public class MedicalRecordsController { public R getMedicalRecordsLabelList(){ return R.ok().put("Medicals", medicalRecordsLabels(0)); } - private List medicalRecordsLabels(int id){ - List medicalRecordsLabelList = medicalRecordsLabelService.list(new LambdaQueryWrapper() - .eq(MedicalRecordsLabel::getPid, id)); - for (MedicalRecordsLabel m : medicalRecordsLabelList){ + private List medicalRecordsLabels(int id){ + List deptLabelList = deptLabelService.list(new LambdaQueryWrapper() + .eq(DeptLabel::getPid, id)); + for (DeptLabel m : deptLabelList){ if(m.getIsLast()!=1){ - List so = this.medicalRecordsLabels(m.getId()); + List so = this.medicalRecordsLabels(m.getId()); m.setChildren(so); } } - return medicalRecordsLabelList; + return deptLabelList; } public MedicalRecordsController(ChatClient.Builder chatClientBuilder, ToolCallbackProvider tools) { @@ -163,11 +164,11 @@ public class MedicalRecordsController { MedicalRecords mr = medicalRecordsService.getOne(new MPJLambdaWrapper() .disableLogicDel() .eq(MedicalRecords::getId,parmas.get("id").toString())); - MedicalRecordsToLabel toLabel = medicalRecordsToLabelService.getOne(new LambdaQueryWrapper() - .eq(MedicalRecordsToLabel::getRecordId,mr.getId())); + MedicalRecordsToDeptLabel toLabel = medicalRecordsToDeptLabelService.getOne(new LambdaQueryWrapper() + .eq(MedicalRecordsToDeptLabel::getRecordId,mr.getId())); if (toLabel!=null){ mr.setLabelId(toLabel.getLabelId()); - MedicalRecordsLabel label = medicalRecordsLabelService.getById(toLabel.getLabelId()); + DeptLabel label = deptLabelService.getById(toLabel.getLabelId()); if (label!=null){ mr.setLabelTitle(label.getTitle()); } @@ -204,15 +205,17 @@ public class MedicalRecordsController { +medicalRecords.getPhysicaExamination()+medicalRecords.getDiagnosis()+medicalRecords.getTreatmentPlan()); medicalRecordsService.saveOrUpdate(medicalRecords); //绑定标签 - MedicalRecordsToLabel toLabel = medicalRecordsToLabelService.getOne(new LambdaQueryWrapper() - .eq(MedicalRecordsToLabel::getLabelId, medicalRecords.getLabelId()) - .eq(MedicalRecordsToLabel::getRecordId,medicalRecords.getId())); - if (toLabel==null){ - toLabel = new MedicalRecordsToLabel(); + if (medicalRecords.getLabelId()!=null&&medicalRecords.getLabelId()!=0){ + MedicalRecordsToDeptLabel toLabel = medicalRecordsToDeptLabelService.getOne(new LambdaQueryWrapper() + .eq(MedicalRecordsToDeptLabel::getLabelId, medicalRecords.getLabelId()) + .eq(MedicalRecordsToDeptLabel::getRecordId,medicalRecords.getId())); + if (toLabel==null){ + toLabel = new MedicalRecordsToDeptLabel(); + } + toLabel.setRecordId(medicalRecords.getId()); + toLabel.setLabelId(medicalRecords.getLabelId()); + medicalRecordsToDeptLabelService.saveOrUpdate(toLabel); } - toLabel.setRecordId(medicalRecords.getId()); - toLabel.setLabelId(medicalRecords.getLabelId()); - medicalRecordsToLabelService.saveOrUpdate(toLabel); return R.ok().put("medicalRecords",medicalRecords); } @@ -226,9 +229,15 @@ public class MedicalRecordsController { //医案列表 @RequestMapping(value = "/medicalRecordsList") public R medicalRecordsList(@RequestBody Map parmas) { - List medicalRecordsList = medicalRecordsService.list(new LambdaQueryWrapper() - .eq(MedicalRecords::getUserId,ShiroUtils.getUId()) - .eq(MedicalRecords::getState,parmas.get("state"))); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(MedicalRecords::getUserId,ShiroUtils.getUId()); + if (parmas.get("state").toString().contains(",")){ + wrapper.and(t->t.eq(MedicalRecords::getState,parmas.get("state").toString().split(",")[0]) + .or().eq(MedicalRecords::getState,parmas.get("state").toString().split(",")[1])); + }else { + wrapper.in(MedicalRecords::getState,parmas.get("state")); + } + List medicalRecordsList = medicalRecordsService.list(wrapper); return R.ok().put("medicalRecordsList",medicalRecordsList); } @@ -251,10 +260,93 @@ public class MedicalRecordsController { article.setTitle(medicalRecords.getTitle()); article.setContent(medicalRecords.getData()); article.setImg(medicalRecords.getImg()); + article.setCome(1); taihuTalentArticleService.save(article); medicalRecords.setArticleFlag(1); medicalRecordsService.updateById(medicalRecords); return R.ok(); } + + + //能否审批 + @RequestMapping("/canCheck") + public R canCheck(){ + boolean flag = false; + long c = medicalRecordsCheckUserService.count(new LambdaQueryWrapper() + .eq(MedicalRecordsCheckUser::getUserId,ShiroUtils.getUId())); + if (c>0){ + flag = true; + } + return R.ok().put("flag",flag); + } + //审批列表 + @RequestMapping("/getMedicalRecordsCheckList") + public R getMedicalRecordsCheckList(@RequestBody Map parmas){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.rightJoin(MedicalRecordsToDeptLabel.class, MedicalRecordsToDeptLabel::getRecordId,MedicalRecords::getId); + wrapper.rightJoin(MedicalRecordsCheckUser.class,MedicalRecordsCheckUser::getLabelId,MedicalRecordsToDeptLabel::getLabelId); + wrapper.selectAll(MedicalRecords.class); + wrapper.eq(MedicalRecordsCheckUser::getUserId,ShiroUtils.getUId()); + wrapper.eq(MedicalRecords::getState,3); + if (parmas.containsKey("flag")&&parmas.get("flag")!=null){ + if ("0".equals(parmas.get("flag").toString())){ + wrapper.notLike(MedicalRecords::getStateInfo,"\""+ShiroUtils.getUId()+"\""); + }else if ("1".equals(parmas.get("flag").toString())){ + wrapper.like(MedicalRecords::getStateInfo,"\""+ShiroUtils.getUId()+"\""); + } + } + List list = medicalRecordsService.list(wrapper); + return R.ok().put("list",list); + } + //审批医案 + @RequestMapping("/medicalRecordsCheck") + public R medicalRecordsCheck(@RequestBody Map parmas){ + String stateInfo = ""; + String state = parmas.get("state").toString(); + String id = parmas.get("id").toString(); + MedicalRecords medicalRecords = medicalRecordsService.getById(id); + Map userIdAndState = new HashMap<>(); + if (StringUtils.isNotEmpty(medicalRecords.getStateInfo())){ + boolean flag = true;//判断是否评价过 + userIdAndState = JSON.parseObject(medicalRecords.getStateInfo()); + for (Map.Entry key : userIdAndState.entrySet()) { + if (key.equals(ShiroUtils.getUId().toString())){ + flag = false; + key.setValue(state); + } + } + if (flag) { + userIdAndState.put(""+ShiroUtils.getUId(),state); + } + }else { + userIdAndState.put(""+ShiroUtils.getUId(),state); + } + stateInfo = JSON.toJSONString(userIdAndState); + medicalRecords.setStateInfo(stateInfo); + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(MedicalRecords::getId,id); + wrapper.set(MedicalRecords::getStateInfo,stateInfo); + wrapper.set(MedicalRecords::getInfoCount,userIdAndState.size()); + int same = 0; + for (Map.Entry key : userIdAndState.entrySet()) { + if (userIdAndState.size()==2&&key.getValue().equals(state)){ + same++; + } + } + if (same==2){ + if ("A".equals(state)){ + wrapper.set(MedicalRecords::getState,6); + wrapper.set(MedicalRecords::getTrain,1); + }else if ("B".equals(state)){ + wrapper.set(MedicalRecords::getState,5); + }else { + wrapper.set(MedicalRecords::getState,4); + } + } + medicalRecordsService.update(wrapper); + return R.ok(); + } + + } diff --git a/src/main/java/com/peanut/modules/common/dao/DeptLabelDao.java b/src/main/java/com/peanut/modules/common/dao/DeptLabelDao.java new file mode 100644 index 00000000..5e33571b --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/DeptLabelDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.DeptLabel; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface DeptLabelDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/MedicalRecordsCheckUserDao.java b/src/main/java/com/peanut/modules/common/dao/MedicalRecordsCheckUserDao.java new file mode 100644 index 00000000..b456cf42 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/MedicalRecordsCheckUserDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.MedicalRecordsCheckUser; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface MedicalRecordsCheckUserDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/MedicalRecordsLabelDao.java b/src/main/java/com/peanut/modules/common/dao/MedicalRecordsLabelDao.java deleted file mode 100644 index 0909bf89..00000000 --- a/src/main/java/com/peanut/modules/common/dao/MedicalRecordsLabelDao.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.peanut.modules.common.dao; - -import com.github.yulichang.base.MPJBaseMapper; -import com.peanut.modules.common.entity.MedicalRecordsLabel; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface MedicalRecordsLabelDao extends MPJBaseMapper { -} diff --git a/src/main/java/com/peanut/modules/common/dao/MedicalRecordsToDeptLabelDao.java b/src/main/java/com/peanut/modules/common/dao/MedicalRecordsToDeptLabelDao.java new file mode 100644 index 00000000..afd259a4 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/MedicalRecordsToDeptLabelDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.MedicalRecordsToDeptLabel; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface MedicalRecordsToDeptLabelDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/MedicalRecordsToLabelDao.java b/src/main/java/com/peanut/modules/common/dao/MedicalRecordsToLabelDao.java deleted file mode 100644 index 0b2b7ced..00000000 --- a/src/main/java/com/peanut/modules/common/dao/MedicalRecordsToLabelDao.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.peanut.modules.common.dao; - -import com.github.yulichang.base.MPJBaseMapper; -import com.peanut.modules.common.entity.MedicalRecordsToLabel; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface MedicalRecordsToLabelDao extends MPJBaseMapper { -} diff --git a/src/main/java/com/peanut/modules/common/entity/MedicalRecordsLabel.java b/src/main/java/com/peanut/modules/common/entity/DeptLabel.java similarity index 86% rename from src/main/java/com/peanut/modules/common/entity/MedicalRecordsLabel.java rename to src/main/java/com/peanut/modules/common/entity/DeptLabel.java index c56a380e..ff4b4b08 100644 --- a/src/main/java/com/peanut/modules/common/entity/MedicalRecordsLabel.java +++ b/src/main/java/com/peanut/modules/common/entity/DeptLabel.java @@ -9,8 +9,8 @@ import java.util.Date; import java.util.List; @Data -@TableName("medical_records_label") -public class MedicalRecordsLabel { +@TableName("dept_label") +public class DeptLabel { private static final long serialVersionUID = 1L; @TableId @@ -30,7 +30,7 @@ public class MedicalRecordsLabel { private Integer delFlag; @TableField(exist = false) - private List children; + private List children; @TableField(exist = false) private List medicalRecordsList; } diff --git a/src/main/java/com/peanut/modules/common/entity/MedicalRecords.java b/src/main/java/com/peanut/modules/common/entity/MedicalRecords.java index 722365ff..22e3eec0 100644 --- a/src/main/java/com/peanut/modules/common/entity/MedicalRecords.java +++ b/src/main/java/com/peanut/modules/common/entity/MedicalRecords.java @@ -23,8 +23,12 @@ public class MedicalRecords { private Integer articleFlag; //标题 private String title; - //0暂存1提交审核2审核拒绝3审核成功 + //0暂存1提交审核2审核拒绝3审核成功4C 5B 6A private Integer state; + //二审详情 + private String stateInfo; + //二审次数 + private Integer infoCount; //是否加入ai训练库0否1是 private Integer train; //未加入训练库原因 diff --git a/src/main/java/com/peanut/modules/common/entity/MedicalRecordsCheckUser.java b/src/main/java/com/peanut/modules/common/entity/MedicalRecordsCheckUser.java new file mode 100644 index 00000000..59eeac0f --- /dev/null +++ b/src/main/java/com/peanut/modules/common/entity/MedicalRecordsCheckUser.java @@ -0,0 +1,21 @@ +package com.peanut.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("medical_records_check_user") +public class MedicalRecordsCheckUser { + private static final long serialVersionUID = 1L; + + @TableId + private Integer id; + //科室id + private Integer labelId; + //用户id + private Integer userId; + @TableLogic + private Integer delFlag; +} diff --git a/src/main/java/com/peanut/modules/common/entity/MedicalRecordsToLabel.java b/src/main/java/com/peanut/modules/common/entity/MedicalRecordsToDeptLabel.java similarity index 86% rename from src/main/java/com/peanut/modules/common/entity/MedicalRecordsToLabel.java rename to src/main/java/com/peanut/modules/common/entity/MedicalRecordsToDeptLabel.java index 0f5aa1d7..6d88f7c3 100644 --- a/src/main/java/com/peanut/modules/common/entity/MedicalRecordsToLabel.java +++ b/src/main/java/com/peanut/modules/common/entity/MedicalRecordsToDeptLabel.java @@ -8,8 +8,8 @@ import lombok.Data; import java.util.Date; @Data -@TableName("medical_records_to_label") -public class MedicalRecordsToLabel { +@TableName("medical_records_to_dept_label") +public class MedicalRecordsToDeptLabel { private static final long serialVersionUID = 1L; @TableId diff --git a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java index 4717bedd..35f870fa 100644 --- a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java +++ b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; import java.util.Date; +import java.util.List; @Data @TableName("taihu_talent_article") @@ -26,6 +27,10 @@ public class TaihuTalentArticle implements Serializable { private Integer readCount; //转发数 private Integer forwardCount; + //0文章1医案转 + private Integer come; + //0下架1显示 + private Integer showFlag; private Date createTime; @TableLogic private Integer delFlag; @@ -36,6 +41,8 @@ public class TaihuTalentArticle implements Serializable { @TableField(exist = false) private Integer likeCount; @TableField(exist = false) + private List likeList; + @TableField(exist = false) private Integer likeFlag; @TableField(exist = false) private TaihuTalent taihuTalent; diff --git a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java index 4f78ba99..447350e2 100644 --- a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java +++ b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java @@ -29,4 +29,6 @@ public class TaihuTalentArticleComment implements Serializable { private Integer delFlag; @TableField(exist = false) private List children; + @TableField(exist = false) + private MyUserEntity user; } diff --git a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java index acaa1df2..57f05adf 100644 --- a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java +++ b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java @@ -1,5 +1,6 @@ package com.peanut.modules.common.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableName; @@ -17,4 +18,6 @@ public class TaihuTalentArticleLike implements Serializable { private Integer userId; @TableLogic private Integer delFlag; + @TableField(exist = false) + private MyUserEntity user; } diff --git a/src/main/java/com/peanut/modules/common/service/DeptLabelService.java b/src/main/java/com/peanut/modules/common/service/DeptLabelService.java new file mode 100644 index 00000000..11c7c15f --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/DeptLabelService.java @@ -0,0 +1,7 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.DeptLabel; + +public interface DeptLabelService extends IService { +} diff --git a/src/main/java/com/peanut/modules/common/service/MedicalRecordsCheckUserService.java b/src/main/java/com/peanut/modules/common/service/MedicalRecordsCheckUserService.java new file mode 100644 index 00000000..88ccc57c --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/MedicalRecordsCheckUserService.java @@ -0,0 +1,7 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.MedicalRecordsCheckUser; + +public interface MedicalRecordsCheckUserService extends IService { +} diff --git a/src/main/java/com/peanut/modules/common/service/MedicalRecordsLabelService.java b/src/main/java/com/peanut/modules/common/service/MedicalRecordsLabelService.java deleted file mode 100644 index 9b16e9ec..00000000 --- a/src/main/java/com/peanut/modules/common/service/MedicalRecordsLabelService.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.peanut.modules.common.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.peanut.modules.common.entity.MedicalRecordsLabel; - -public interface MedicalRecordsLabelService extends IService { -} diff --git a/src/main/java/com/peanut/modules/common/service/MedicalRecordsToDeptLabelService.java b/src/main/java/com/peanut/modules/common/service/MedicalRecordsToDeptLabelService.java new file mode 100644 index 00000000..6aa14db7 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/MedicalRecordsToDeptLabelService.java @@ -0,0 +1,7 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.MedicalRecordsToDeptLabel; + +public interface MedicalRecordsToDeptLabelService extends IService { +} diff --git a/src/main/java/com/peanut/modules/common/service/MedicalRecordsToLabelService.java b/src/main/java/com/peanut/modules/common/service/MedicalRecordsToLabelService.java deleted file mode 100644 index 3d81682d..00000000 --- a/src/main/java/com/peanut/modules/common/service/MedicalRecordsToLabelService.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.peanut.modules.common.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.peanut.modules.common.entity.MedicalRecordsToLabel; - -public interface MedicalRecordsToLabelService extends IService { -} diff --git a/src/main/java/com/peanut/modules/common/service/impl/DeptLabelServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/DeptLabelServiceImpl.java new file mode 100644 index 00000000..d3bd7189 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/DeptLabelServiceImpl.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.DeptLabelDao; +import com.peanut.modules.common.entity.DeptLabel; +import com.peanut.modules.common.service.DeptLabelService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonMedicalRecordsLabelService") +public class DeptLabelServiceImpl extends ServiceImpl implements DeptLabelService { +} diff --git a/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsCheckUserServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsCheckUserServiceImpl.java new file mode 100644 index 00000000..8e27efd9 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsCheckUserServiceImpl.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.MedicalRecordsCheckUserDao; +import com.peanut.modules.common.entity.MedicalRecordsCheckUser; +import com.peanut.modules.common.service.MedicalRecordsCheckUserService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonMedicalRecordsCheckUserService") +public class MedicalRecordsCheckUserServiceImpl extends ServiceImpl implements MedicalRecordsCheckUserService { +} diff --git a/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsLabelServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsLabelServiceImpl.java deleted file mode 100644 index 764fcfa1..00000000 --- a/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsLabelServiceImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.peanut.modules.common.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.peanut.modules.common.dao.MedicalRecordsLabelDao; -import com.peanut.modules.common.entity.MedicalRecordsLabel; -import com.peanut.modules.common.service.MedicalRecordsLabelService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -@Slf4j -@Service("commonMedicalRecordsLabelService") -public class MedicalRecordsLabelServiceImpl extends ServiceImpl implements MedicalRecordsLabelService { -} diff --git a/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsToDeptLabelServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsToDeptLabelServiceImpl.java new file mode 100644 index 00000000..8b8b232d --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsToDeptLabelServiceImpl.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.MedicalRecordsToDeptLabelDao; +import com.peanut.modules.common.entity.MedicalRecordsToDeptLabel; +import com.peanut.modules.common.service.MedicalRecordsToDeptLabelService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonMedicalRecordsToLabelService") +public class MedicalRecordsToDeptLabelServiceImpl extends ServiceImpl implements MedicalRecordsToDeptLabelService { +} diff --git a/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsToLabelServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsToLabelServiceImpl.java deleted file mode 100644 index 1a00ba33..00000000 --- a/src/main/java/com/peanut/modules/common/service/impl/MedicalRecordsToLabelServiceImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.peanut.modules.common.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.peanut.modules.common.dao.MedicalRecordsToLabelDao; -import com.peanut.modules.common.entity.MedicalRecordsToLabel; -import com.peanut.modules.common.service.MedicalRecordsToLabelService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -@Slf4j -@Service("commonMedicalRecordsToLabelService") -public class MedicalRecordsToLabelServiceImpl extends ServiceImpl implements MedicalRecordsToLabelService { -} diff --git a/src/main/java/com/peanut/modules/master/controller/MedicalRecordsController.java b/src/main/java/com/peanut/modules/master/controller/MedicalRecordsController.java index 1f0af3b0..02788746 100644 --- a/src/main/java/com/peanut/modules/master/controller/MedicalRecordsController.java +++ b/src/main/java/com/peanut/modules/master/controller/MedicalRecordsController.java @@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.R; import com.peanut.modules.common.entity.*; -import com.peanut.modules.common.service.MedicalRecordsLabelService; -import com.peanut.modules.common.service.MedicalRecordsService; -import com.peanut.modules.common.service.MedicalRecordsToLabelService; +import com.peanut.modules.common.service.*; import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.master.service.MyUserService; import lombok.extern.slf4j.Slf4j; @@ -28,34 +26,48 @@ public class MedicalRecordsController { @Autowired private MedicalRecordsService medicalRecordsService; @Autowired - private MedicalRecordsLabelService medicalRecordsLabelService; + private TaihuTalentService talentService; @Autowired - private MedicalRecordsToLabelService toLabelService; + private DeptLabelService deptLabelService; + @Autowired + private MedicalRecordsToDeptLabelService toLabelService; + @Autowired + private MedicalRecordsCheckUserService medicalRecordsCheckUserService; @Autowired private MyUserService userService; - //获取医案待审核、拒绝列表 + //获取医案待审核、拒绝、审核不同结果列表 @RequestMapping("/getMedicalRecordsListCheck") public R getMedicalRecordsListCheck(@RequestBody Map params){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); - if ("3".equals(params.get("state"))){ - wrapper.leftJoin(MedicalRecordsToLabel.class,MedicalRecordsToLabel::getRecordId,MedicalRecords::getId); - wrapper.leftJoin(MedicalRecordsLabel.class,MedicalRecordsLabel::getId,MedicalRecordsToLabel::getLabelId); - wrapper.selectAs(MedicalRecordsLabel::getTitle,"labelTitle"); - } - if ("0".equals(params.get("state"))){ - wrapper.eq(MedicalRecords::getUserId,"1"); + if (params.containsKey("infoCount")&¶ms.get("infoCount")!=null&&StringUtils.isNotEmpty(params.get("infoCount").toString())&& + "2".equals(params.get("infoCount").toString())&&"3".equals(params.get("state").toString())){ + wrapper.leftJoin(MedicalRecordsToDeptLabel.class, MedicalRecordsToDeptLabel::getRecordId,MedicalRecords::getId); + wrapper.leftJoin(DeptLabel.class, DeptLabel::getId, MedicalRecordsToDeptLabel::getLabelId); + wrapper.selectAs(DeptLabel::getTitle,"labelTitle"); + wrapper.eq(MedicalRecords::getInfoCount,2); + }else { + if ("3".equals(params.get("state").toString())){ + wrapper.leftJoin(MedicalRecordsToDeptLabel.class, MedicalRecordsToDeptLabel::getRecordId,MedicalRecords::getId); + wrapper.leftJoin(DeptLabel.class, DeptLabel::getId, MedicalRecordsToDeptLabel::getLabelId); + wrapper.selectAs(DeptLabel::getTitle,"labelTitle"); + wrapper.lt(MedicalRecords::getInfoCount,2); + } + if ("0".equals(params.get("state").toString())){ + wrapper.eq(MedicalRecords::getUserId,"1"); + } } wrapper.selectAll(MedicalRecords.class); wrapper.eq(MedicalRecords::getState,params.get("state")); + wrapper.orderByAsc(MedicalRecords::getCreateTime); Page page = medicalRecordsService.page(new Page<>( Long.parseLong(params.get("current").toString()),Long.parseLong(params.get("limit").toString())),wrapper); for (MedicalRecords mr:page.getRecords()){ mr.setUser(userService.getById(mr.getUserId())); - MedicalRecordsToLabel toLabel = toLabelService.getOne(new LambdaQueryWrapper() - .eq(MedicalRecordsToLabel::getRecordId,mr.getId())); + MedicalRecordsToDeptLabel toLabel = toLabelService.getOne(new LambdaQueryWrapper() + .eq(MedicalRecordsToDeptLabel::getRecordId,mr.getId())); if (toLabel!=null){ - MedicalRecordsLabel label = medicalRecordsLabelService.getById(toLabel.getLabelId()); + DeptLabel label = deptLabelService.getById(toLabel.getLabelId()); mr.setLabelId(label.getId()); mr.setLabelTitle(label.getTitle()); } @@ -67,11 +79,11 @@ public class MedicalRecordsController { @RequestMapping("/getMedicalRecordsList") public R getMedicalRecordsList(@RequestBody Map params){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); - wrapper.rightJoin(MedicalRecordsToLabel.class,MedicalRecordsToLabel::getRecordId,MedicalRecords::getId); + wrapper.rightJoin(MedicalRecordsToDeptLabel.class, MedicalRecordsToDeptLabel::getRecordId,MedicalRecords::getId); wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,MedicalRecords::getUserId); wrapper.selectAll(MedicalRecords.class); - wrapper.eq(MedicalRecordsToLabel::getLabelId,params.get("labelId")); - wrapper.eq(MedicalRecords::getState,3); + wrapper.eq(MedicalRecordsToDeptLabel::getLabelId,params.get("labelId")); + wrapper.gt(MedicalRecords::getState,4); wrapper.like(StringUtils.isNotBlank(params.get("tel").toString()),MyUserEntity::getTel,params.get("tel")); wrapper.eq(StringUtils.isNotBlank(params.get("train").toString()),MedicalRecords::getTrain,params.get("train")); wrapper.like(StringUtils.isNotBlank(params.get("title").toString()),MedicalRecords::getTitle,params.get("title")); @@ -88,7 +100,7 @@ public class MedicalRecordsController { public R addMedicalRecords(@RequestBody MedicalRecords medicalRecords){ medicalRecords.setState(3); medicalRecordsService.save(medicalRecords); - MedicalRecordsToLabel toLabel = new MedicalRecordsToLabel(); + MedicalRecordsToDeptLabel toLabel = new MedicalRecordsToDeptLabel(); toLabel.setLabelId(medicalRecords.getLabelId()); toLabel.setRecordId(medicalRecords.getId()); toLabelService.save(toLabel); @@ -98,13 +110,13 @@ public class MedicalRecordsController { @RequestMapping("/editMedicalRecords") @Transactional public R editMedicalRecords(@RequestBody MedicalRecords medicalRecords){ - MedicalRecordsToLabel toLabel = toLabelService.getOne(new LambdaQueryWrapper() - .eq(MedicalRecordsToLabel::getRecordId,medicalRecords.getId())); + MedicalRecordsToDeptLabel toLabel = toLabelService.getOne(new LambdaQueryWrapper() + .eq(MedicalRecordsToDeptLabel::getRecordId,medicalRecords.getId())); if (toLabel!=null){ toLabel.setLabelId(medicalRecords.getLabelId()); toLabelService.updateById(toLabel); }else { - toLabel = new MedicalRecordsToLabel(); + toLabel = new MedicalRecordsToDeptLabel(); toLabel.setRecordId(medicalRecords.getId()); toLabel.setLabelId(medicalRecords.getLabelId()); toLabelService.save(toLabel); @@ -119,43 +131,69 @@ public class MedicalRecordsController { return R.ok(); } + //医案审核员列表 + @RequestMapping("/getMedicalRecordsCheckUserListByLabelId") + public R getMedicalRecordsCheckUserListByLabelId(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.rightJoin(MedicalRecordsCheckUser.class, MedicalRecordsCheckUser::getUserId,MyUserEntity::getId); + wrapper.selectAll(MyUserEntity.class); + wrapper.eq(MedicalRecordsCheckUser::getLabelId,params.get("labelId")); + Page page = userService.page(new Page<>( + Long.parseLong(params.get("current").toString()),Long.parseLong(params.get("limit").toString())),wrapper); + return R.ok().put("page",page); + } + + @RequestMapping("/addMedicalRecordsCheckUser") + public R addMedicalRecordsCheckUser(@RequestBody MedicalRecordsCheckUser checkUser){ + medicalRecordsCheckUserService.save(checkUser); + return R.ok().put("MedicalRecordsCheckUser", checkUser); + } + + @RequestMapping("/delMedicalRecordsCheckUser") + public R delMedicalRecordsCheckUser(@RequestBody MedicalRecordsCheckUser checkUser){ + medicalRecordsCheckUserService.remove(new LambdaQueryWrapper() + .eq(MedicalRecordsCheckUser::getUserId,checkUser.getUserId()) + .eq(MedicalRecordsCheckUser::getLabelId,checkUser.getLabelId())); + return R.ok(); + } + //科室标签 @RequestMapping("/getMedicalRecordsLabelList") public R getMedicalRecordsLabelList(){ return R.ok().put("Medicals", medicalRecordsLabels(0)); } - private List medicalRecordsLabels(int id){ - List medicalRecordsLabelList = medicalRecordsLabelService.list(new LambdaQueryWrapper() - .eq(MedicalRecordsLabel::getPid, id)); - for (MedicalRecordsLabel m : medicalRecordsLabelList){ + private List medicalRecordsLabels(int id){ + List deptLabelList = deptLabelService.list(new LambdaQueryWrapper() + .eq(DeptLabel::getPid, id)); + for (DeptLabel m : deptLabelList){ if(m.getIsLast()!=1){ - List so = this.medicalRecordsLabels(m.getId()); + List so = this.medicalRecordsLabels(m.getId()); m.setChildren(so); } } - return medicalRecordsLabelList; + return deptLabelList; } @RequestMapping("/addMedicalRecordsLabel") - public R addMedicalRecordsLabel(@RequestBody MedicalRecordsLabel medicalRecordsLabel){ - medicalRecordsLabelService.save(medicalRecordsLabel); - return R.ok().put("medicalRecordsLabel", medicalRecordsLabel); + public R addMedicalRecordsLabel(@RequestBody DeptLabel deptLabel){ + deptLabelService.save(deptLabel); + return R.ok().put("medicalRecordsLabel", deptLabel); } @RequestMapping("/delMedicalRecordsLabel") public R delMedicalRecordsLabel(@RequestBody ParamTo param){ //查看下一级是否存在 - long count = medicalRecordsLabelService.count(new LambdaQueryWrapper() - .eq(MedicalRecordsLabel::getPid, param.getId())); + long count = deptLabelService.count(new LambdaQueryWrapper() + .eq(DeptLabel::getPid, param.getId())); if(count>0){ return R.error(501,"删除失败,请先删除子项目后再尝试"); } //查看绑定关系是否存在 - List toLabels = toLabelService.list(new LambdaQueryWrapper() - .eq(MedicalRecordsToLabel::getLabelId, param.getId())); - for (MedicalRecordsToLabel toLabel:toLabels){ + List toLabels = toLabelService.list(new LambdaQueryWrapper() + .eq(MedicalRecordsToDeptLabel::getLabelId, param.getId())); + for (MedicalRecordsToDeptLabel toLabel:toLabels){ MedicalRecords c = medicalRecordsService.getById(toLabel.getRecordId()); if (c!=null){ return R.error(502,"删除失败,请先解绑医案与标签的绑定关系"); @@ -163,29 +201,55 @@ public class MedicalRecordsController { toLabelService.removeById(toLabel.getId()); } } - medicalRecordsLabelService.removeById(param.getId()); + //查看绑定关系是否存在 + long taihuTalents = talentService.count(new LambdaQueryWrapper() + .eq(TaihuTalent::getDeptLabelId, param.getId())); + if (taihuTalents>0){ + return R.error(502,"删除失败,请先解绑太湖英才与标签的绑定关系"); + } + //查看绑定关系是否存在 + long checkUsers = medicalRecordsCheckUserService.count(new LambdaQueryWrapper() + .eq(MedicalRecordsCheckUser::getLabelId, param.getId())); + if (checkUsers>0){ + return R.error(502,"删除失败,请先解绑医案审核员与标签的绑定关系"); + } + deptLabelService.removeById(param.getId()); return R.ok(); } @RequestMapping("/editMedicalRecordsLabel") - public R editMedicalRecordsLabel(@RequestBody MedicalRecordsLabel medicalRecordsLabel){ - MedicalRecordsLabel old = medicalRecordsLabelService.getById(medicalRecordsLabel.getId()); - if(old.getIsLast()==0&& medicalRecordsLabel.getIsLast()==1){ - MedicalRecordsLabel one = medicalRecordsLabelService.getOne(new LambdaQueryWrapper() - .eq(MedicalRecordsLabel::getPid, medicalRecordsLabel.getId())); + public R editMedicalRecordsLabel(@RequestBody DeptLabel deptLabel){ + DeptLabel old = deptLabelService.getById(deptLabel.getId()); + if(old.getIsLast()==0&& deptLabel.getIsLast()==1){ + DeptLabel one = deptLabelService.getOne(new LambdaQueryWrapper() + .eq(DeptLabel::getPid, deptLabel.getId())); if(one!=null){ return R.error(501,"更新失败,请先清空此项的下级标签,才能将此标签变成终极标签"); } } - if(old.getIsLast()==1&& medicalRecordsLabel.getIsLast()==0){ - long c = toLabelService.count(new LambdaQueryWrapper() - .eq(MedicalRecordsToLabel::getLabelId, medicalRecordsLabel.getId())); + if(old.getIsLast()==1&& deptLabel.getIsLast()==0){ + long c = toLabelService.count(new LambdaQueryWrapper() + .eq(MedicalRecordsToDeptLabel::getLabelId, deptLabel.getId())); if(c>0){ return R.error(502,"更新失败,请先把此项与医案的关联关系清空后才可把此标签变成普通标签"); } } - medicalRecordsLabelService.updateById(medicalRecordsLabel); - return R.ok().put("medicalRecordsLabel", medicalRecordsLabel); + if(old.getIsLast()==0&& deptLabel.getIsLast()==1){ + long c = talentService.count(new LambdaQueryWrapper() + .eq(TaihuTalent::getDeptLabelId, deptLabel.getId())); + if(c>0){ + return R.error(502,"更新失败,请先把此项与太湖英才的关联关系清空后才可把此标签变成普通标签"); + } + } + if(old.getIsLast()==0&& deptLabel.getIsLast()==1){ + long checkUsers = medicalRecordsCheckUserService.count(new LambdaQueryWrapper() + .eq(MedicalRecordsCheckUser::getLabelId, deptLabel.getId())); + if (checkUsers>0){ + return R.error(502,"删除失败,请先解绑医案审核员与标签的绑定关系"); + } + } + deptLabelService.updateById(deptLabel); + return R.ok().put("medicalRecordsLabel", deptLabel); } diff --git a/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java b/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java index 50904349..2dcb91e4 100644 --- a/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java +++ b/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java @@ -6,12 +6,14 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.peanut.common.utils.R; import com.peanut.common.utils.ShiroUtils; import com.peanut.modules.common.entity.*; +import com.peanut.modules.common.service.MyUserService; import com.peanut.modules.common.service.TaihuTalentArticleCommentService; import com.peanut.modules.common.service.TaihuTalentArticleService; import com.peanut.modules.common.service.TaihuTalentService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -29,6 +31,8 @@ public class TaihuTalentArticleController { private TaihuTalentService taihuTalentService; @Autowired private TaihuTalentArticleCommentService taihuTalentArticleCommentService; + @Autowired + private MyUserService userService; //太湖英才文章列表 @RequestMapping("/getArticleList") @@ -57,10 +61,20 @@ public class TaihuTalentArticleController { return R.ok(); } + //编辑文章 + @RequestMapping("/editArticle") + public R editArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ + taihuTalentArticleService.updateById(taihuTalentArticle); + return R.ok(); + } + //删除文章 @RequestMapping("/delArticle") + @Transactional public R delArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ taihuTalentArticleService.removeById(taihuTalentArticle); + taihuTalentArticleCommentService.remove(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,taihuTalentArticle.getId())); return R.ok(); } @@ -70,7 +84,7 @@ public class TaihuTalentArticleController { MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,TaihuTalentArticleComment::getUserId); wrapper.selectAll(TaihuTalentArticleComment.class); - wrapper.like(TaihuTalentArticleComment::getContent,params.get("conten")); + wrapper.like(TaihuTalentArticleComment::getContent,params.get("content")); if (StringUtils.isNotEmpty(params.get("userInfo").toString())) { wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo")) .or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo"))); @@ -78,6 +92,9 @@ public class TaihuTalentArticleController { wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); Page page = taihuTalentArticleCommentService.page(new Page<>(Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper); + for (TaihuTalentArticleComment comment : page.getRecords()) { + comment.setUser(userService.getById(comment.getUserId())); + } return R.ok().put("page",page); } diff --git a/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java b/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java index 650ebd9b..ff81ecc6 100644 --- a/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java +++ b/src/main/java/com/peanut/modules/master/controller/TaihuTalentController.java @@ -7,9 +7,8 @@ import com.peanut.common.utils.R; import com.peanut.modules.common.entity.*; import com.peanut.modules.common.service.CourseToTaihumedService; import com.peanut.modules.common.service.CourseToTalentService; -import com.peanut.modules.common.service.MedicalRecordsLabelService; +import com.peanut.modules.common.service.DeptLabelService; import com.peanut.modules.common.service.TaihuTalentService; -import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.master.service.CourseService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -21,7 +20,6 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Slf4j @RestController("masterTaihuTalent") @@ -37,7 +35,7 @@ public class TaihuTalentController { @Autowired private CourseToTaihumedService courseToTaihumedService; @Autowired - private MedicalRecordsLabelService medicalRecordsLabelService; + private DeptLabelService deptLabelService; //太湖英才课程列表 @@ -109,9 +107,9 @@ public class TaihuTalentController { @RequestMapping("/getTaihuTalents") public R getTaihuTalents(@RequestBody Map params){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); - wrapper.leftJoin(MedicalRecordsLabel.class,MedicalRecordsLabel::getId,TaihuTalent::getDeptLabelId); + wrapper.leftJoin(DeptLabel.class, DeptLabel::getId,TaihuTalent::getDeptLabelId); wrapper.selectAll(TaihuTalent.class); - wrapper.selectAs(MedicalRecordsLabel::getTitle,TaihuTalent::getDepartment); + wrapper.selectAs(DeptLabel::getTitle,TaihuTalent::getDepartment); wrapper.like(StringUtils.isNotEmpty(params.get("name").toString()),TaihuTalent::getName,params.get("name")); wrapper.like(StringUtils.isNotEmpty(params.get("region").toString()),TaihuTalent::getRegion,params.get("region")); wrapper.orderByDesc(TaihuTalent::getCreateTime); @@ -123,6 +121,10 @@ public class TaihuTalentController { //新增太湖英才 @RequestMapping("/addTaihuTalent") public R addTaihuTalent(@RequestBody TaihuTalent taihuTalent){ + if (taihuTalentService.count(new LambdaQueryWrapper() + .eq(TaihuTalent::getUserId,taihuTalent.getUserId()))>0){ + return R.error("已绑定过"); + } taihuTalentService.save(taihuTalent); return R.ok(); } @@ -148,7 +150,7 @@ public class TaihuTalentController { @RequestMapping("/taihuTalentInfo") public R taihuTalentInfo(@RequestBody Map params){ TaihuTalent taihuTalent = taihuTalentService.getById(params.get("id").toString()); - taihuTalent.setDepartment(medicalRecordsLabelService.getById(taihuTalent.getDeptLabelId()).getTitle()); + taihuTalent.setDepartment(deptLabelService.getById(taihuTalent.getDeptLabelId()).getTitle()); return R.ok().put("taihuTalent",taihuTalent); } diff --git a/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java b/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java index 9513a2c4..74f494e5 100644 --- a/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java +++ b/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java @@ -1,6 +1,8 @@ package com.peanut.modules.taihumed.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.peanut.common.utils.R; import com.peanut.common.utils.ShiroUtils; @@ -10,14 +12,12 @@ import com.peanut.modules.sys.entity.SysSensitiveWords; import com.peanut.modules.sys.service.SysSensitiveWordsService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; @Slf4j @RestController("commonTaihuTalentArticle") @@ -34,11 +34,16 @@ public class TaihuTalentArticleController { private TaihuTalentArticleLikeService taihuTalentArticleLikeService; @Autowired private SysSensitiveWordsService sysSensitiveWordsService; + @Autowired + private MyUserService userService; + @Autowired + private MedicalRecordsService medicalRecordsService; //太湖英才文章列表 @RequestMapping("/getArticleList") public R getArticleList(@RequestBody Map params){ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaihuTalentArticle::getShowFlag,1); wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); Page page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper); @@ -49,6 +54,12 @@ public class TaihuTalentArticleController { .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() .eq(TaihuTalentArticleLike::getArticleId,article.getId()))); + List likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId())); + for (TaihuTalentArticleLike like: likeList) { + like.setUser(userService.getById(like.getUserId())); + } + article.setLikeList(likeList); article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() .eq(TaihuTalentArticleLike::getArticleId,article.getId()) .eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId()))); @@ -64,9 +75,14 @@ public class TaihuTalentArticleController { .eq(TaihuTalent::getUserId, article.getUserId()))); article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper() .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); - article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() - .eq(TaihuTalentArticleLike::getArticleId,article.getId()))); - article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + List likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId())); + for (TaihuTalentArticleLike like: likeList) { + like.setUser(userService.getById(like.getUserId())); + } + article.setLikeList(likeList); + article.setLikeCount(likeList.size()); + article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() .eq(TaihuTalentArticleLike::getArticleId,article.getId()) .eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId()))); List comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() @@ -74,10 +90,15 @@ public class TaihuTalentArticleController { .eq(TaihuTalentArticleComment::getPid,0) .orderByDesc(TaihuTalentArticleComment::getCreateTime)); for (TaihuTalentArticleComment comment : comments) { - comment.setChildren(taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + List childrenList = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() .eq(TaihuTalentArticleComment::getArticleId,article.getId()) - .ne(TaihuTalentArticleComment::getPid,0) - .orderByAsc(TaihuTalentArticleComment::getCreateTime))); + .eq(TaihuTalentArticleComment::getPid,comment.getId()) + .orderByAsc(TaihuTalentArticleComment::getCreateTime)); + for (TaihuTalentArticleComment cc : childrenList) { + cc.setUser(userService.getById(cc.getUserId())); + } + comment.setChildren(childrenList); + comment.setUser(userService.getById(comment.getUserId())); } if (!Objects.equals(article.getUserId(), ShiroUtils.getUId())){ article.setReadCount(article.getReadCount()+1); @@ -86,12 +107,63 @@ public class TaihuTalentArticleController { return R.ok().put("article",article).put("comments",comments); } + //太湖英才文章点赞和评论数量 + @RequestMapping("/getArticleLikeAndComment") + public R getArticleLikeAndComment(@RequestBody Map params){ + TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString()); + article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); + List likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId())); + for (TaihuTalentArticleLike like: likeList) { + like.setUser(userService.getById(like.getUserId())); + } + article.setLikeList(likeList); + article.setLikeCount(likeList.size()); + article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId()) + .eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId()))); + List comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()) + .eq(TaihuTalentArticleComment::getPid,0) + .orderByDesc(TaihuTalentArticleComment::getCreateTime)); + for (TaihuTalentArticleComment comment : comments) { + List childrenList = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()) + .eq(TaihuTalentArticleComment::getPid,comment.getId()) + .orderByAsc(TaihuTalentArticleComment::getCreateTime)); + for (TaihuTalentArticleComment cc : childrenList) { + cc.setUser(userService.getById(cc.getUserId())); + } + comment.setChildren(childrenList); + comment.setUser(userService.getById(comment.getUserId())); + } + return R.ok().put("article",article).put("comments",comments); + } + + //增加阅读数 + @RequestMapping("/addReadCount") + public R addReadCount(@RequestBody Map params){ + TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString()); + if (article!=null){ + article.setReadCount(article.getReadCount()+1); + taihuTalentArticleService.updateById(article); + } + return R.ok(); + } + //太湖英才文章点赞或取消 @RequestMapping("/addOrCancelArticleLike") + @Transactional public R addOrCancelArticleLike(@RequestBody Map params){ TaihuTalentArticleLike like = taihuTalentArticleLikeService.getOne(new LambdaQueryWrapper() .eq(TaihuTalentArticleLike::getArticleId,params.get("articleId").toString()) .eq(TaihuTalentArticleLike::getUserId,ShiroUtils.getUId())); + TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString()); + if (article!=null){ + article.setReadCount(article.getReadCount()+1); + taihuTalentArticleService.updateById(article); + } if (like != null) { taihuTalentArticleLikeService.removeById(like); }else { @@ -105,7 +177,13 @@ public class TaihuTalentArticleController { //新增文章评论 @RequestMapping("/addArticleComment") + @Transactional public R addArticleComment(@RequestBody TaihuTalentArticleComment comment){ + TaihuTalentArticle article = taihuTalentArticleService.getById(comment.getArticleId()); + if (article!=null){ + article.setReadCount(article.getReadCount()+1); + taihuTalentArticleService.updateById(article); + } R result = new R(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.last(" where instr(\""+comment.getContent()+"\",word)>0"); @@ -121,34 +199,38 @@ public class TaihuTalentArticleController { } result.put("tip","您的评论含有敏感词:"+str+",请重新输入。"); }else { + comment.setUserId(ShiroUtils.getUId()); taihuTalentArticleCommentService.save(comment); result.put("tip","评论成功!"); } - return result; } //评论提醒 @RequestMapping("/getCommentRemind") - public R getCommentRemind(@RequestBody Map params){ - List list = new ArrayList<>(); + public R getCommentRemind(){ + Set set = new HashSet<>(); List userComments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() .eq(TaihuTalentArticleComment::getUserId,ShiroUtils.getUId()) - .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString())); + .eq(TaihuTalentArticleComment::getReadFlag,0)); for (TaihuTalentArticleComment comment : userComments) { - if(comment.getPid().equals(0)){ - list.addAll(taihuTalentArticleCommentService.list(new LambdaQueryWrapper() - .eq(TaihuTalentArticleComment::getPid,comment.getId()) - .eq(TaihuTalentArticleComment::getReadFlag,0) - .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString()))); - }else { - list.addAll(taihuTalentArticleCommentService.list(new LambdaQueryWrapper() - .eq(TaihuTalentArticleComment::getPid,comment.getPid()) - .eq(TaihuTalentArticleComment::getReadFlag,0) - .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString()))); + TaihuTalentArticle article = taihuTalentArticleService.getById(comment.getArticleId()); + if (article!=null){ + set.add(article); } } - return R.ok().put("list",list); + return R.ok().put("set",set); + } + + //评论提醒 + @RequestMapping("/setReadFlag") + public R setReadFlag(@RequestBody Map params){ + taihuTalentArticleCommentService.update(new LambdaUpdateWrapper() + .eq(TaihuTalentArticleComment::getUserId,ShiroUtils.getUId()) + .eq(TaihuTalentArticleComment::getReadFlag,0) + .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString()) + .set(TaihuTalentArticleComment::getReadFlag,1)); + return R.ok(); } //我的文章列表 @@ -156,17 +238,103 @@ public class TaihuTalentArticleController { public R myArticleList(@RequestBody Map params){ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TaihuTalentArticle::getUserId,ShiroUtils.getUId()); + wrapper.eq(TaihuTalentArticle::getShowFlag,params.get("showFlag").toString()); wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); Page page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper); + for (TaihuTalentArticle article : page.getRecords()) { + article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); + List likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId())); + for (TaihuTalentArticleLike like: likeList) { + like.setUser(userService.getById(like.getUserId())); + } + article.setLikeList(likeList); + article.setLikeCount(likeList.size()); + article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId()) + .eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId()))); + List comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()) + .eq(TaihuTalentArticleComment::getPid,0) + .orderByDesc(TaihuTalentArticleComment::getCreateTime)); + for (TaihuTalentArticleComment comment : comments) { + List childrenList = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()) + .eq(TaihuTalentArticleComment::getPid,comment.getId()) + .orderByAsc(TaihuTalentArticleComment::getCreateTime)); + for (TaihuTalentArticleComment cc : childrenList) { + cc.setUser(userService.getById(cc.getUserId())); + } + comment.setChildren(childrenList); + comment.setUser(userService.getById(comment.getUserId())); + } + } return R.ok().put("page",page); } + //当前用户是否能新增文章 + @RequestMapping("/getArticleRoleByUser") + public R getArticleRoleByUser(){ + return R.ok().put("roleFlag", taihuTalentService.count(new LambdaQueryWrapper() + .eq(TaihuTalent::getUserId,ShiroUtils.getUId()))); + } + //新增文章 @RequestMapping("/addArticle") public R addArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ - taihuTalentArticle.setUserId(ShiroUtils.getUId()); - taihuTalentArticleService.save(taihuTalentArticle); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.last(" where instr(\""+taihuTalentArticle.getTitle()+"\",word)>0"); + List list = sysSensitiveWordsService.list(wrapper); + if (list.size() > 0){ + String str = ""; + for (SysSensitiveWords words:list) { + if ("".equals(str)){ + str = words.getWord(); + }else { + str = str + "、" + words.getWord(); + } + } + return R.error("您的标题含有敏感词:"+str+",请重新输入。"); + }else { + LambdaQueryWrapper cwrapper = new LambdaQueryWrapper<>(); + cwrapper.last(" where instr(\""+taihuTalentArticle.getContent()+"\",word)>0"); + List clist = sysSensitiveWordsService.list(cwrapper); + if (clist.size() > 0){ + String str = ""; + for (SysSensitiveWords words:clist) { + if ("".equals(str)){ + str = words.getWord(); + }else { + str = str + "、" + words.getWord(); + } + } + return R.error("您的内容含有敏感词:"+str+",请重新输入。"); + }else { + taihuTalentArticle.setUserId(ShiroUtils.getUId()); + taihuTalentArticleService.save(taihuTalentArticle); + return R.ok(); + } + } + } + + //删除文章 + @RequestMapping("/delArticle") + @Transactional + public R delArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ + taihuTalentArticle = taihuTalentArticleService.getById(taihuTalentArticle.getId()); + if (taihuTalentArticle.getCome()==1){ + medicalRecordsService.update(new LambdaUpdateWrapper() + .eq(MedicalRecords::getUserId,taihuTalentArticle.getUserId()) + .eq(MedicalRecords::getTitle,taihuTalentArticle.getTitle()) + .set(MedicalRecords::getArticleFlag,0)); + } + taihuTalentArticleCommentService.remove(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,taihuTalentArticle.getId())); + taihuTalentArticleLikeService.remove(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,taihuTalentArticle.getId())); + taihuTalentArticleService.removeById(taihuTalentArticle); return R.ok(); } diff --git a/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentController.java b/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentController.java index e9f9886a..06221be5 100644 --- a/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentController.java +++ b/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentController.java @@ -31,15 +31,15 @@ public class TaihuTalentController { @Autowired private MedicalRecordsService medicalRecordsService; @Autowired - private MedicalRecordsLabelService medicalRecordsLabelService; + private DeptLabelService deptLabelService; //太湖英才列表 @RequestMapping("/getTaihuTalents") public R getTaihuTalents(@RequestBody Map params){ MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); - wrapper.leftJoin(MedicalRecordsLabel.class,MedicalRecordsLabel::getId,TaihuTalent::getDeptLabelId); + wrapper.leftJoin(DeptLabel.class, DeptLabel::getId,TaihuTalent::getDeptLabelId); wrapper.selectAll(TaihuTalent.class); - wrapper.selectAs(MedicalRecordsLabel::getTitle,TaihuTalent::getDepartment); + wrapper.selectAs(DeptLabel::getTitle,TaihuTalent::getDepartment); wrapper.like(StringUtils.isNotEmpty(params.get("name").toString()),TaihuTalent::getName,params.get("name")); wrapper.eq(StringUtils.isNotEmpty(params.get("deptLabelId").toString()),TaihuTalent::getDeptLabelId,params.get("deptLabelId")); wrapper.like(StringUtils.isNotEmpty(params.get("region").toString()),TaihuTalent::getRegion,params.get("region")); @@ -68,7 +68,7 @@ public class TaihuTalentController { @RequestMapping("/taihuTalentInfo") public R taihuTalentInfo(@RequestBody Map params){ TaihuTalent taihuTalent = taihuTalentService.getById(params.get("id").toString()); - taihuTalent.setDepartment(medicalRecordsLabelService.getById(taihuTalent.getDeptLabelId()).getTitle()); + taihuTalent.setDepartment(deptLabelService.getById(taihuTalent.getDeptLabelId()).getTitle()); List labels = userCertificateLabelService.list(new LambdaQueryWrapper() .eq(UserCertificateLabel::getPid,0)); List filterLabels = new ArrayList<>(); @@ -115,7 +115,7 @@ public class TaihuTalentController { List courseList = courseService.list(wrapper); //精彩医案 List medicalRecords = medicalRecordsService.list(new LambdaQueryWrapper() - .eq(MedicalRecords::getState,3) + .ge(MedicalRecords::getState,5) .eq(MedicalRecords::getShowFlag,1) .eq(MedicalRecords::getUserId,taihuTalent.getUserId()) .orderByDesc(MedicalRecords::getTrain));