Forráskód Böngészése

1.4.7版本健康指导标签分组功能代码

liuwenbin 7 éve
szülő
commit
36ecbc50b4

+ 86 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/template/DoctorGuidanceTempLabel.java

@ -0,0 +1,86 @@
package com.yihu.wlyy.entity.template;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/5/17.
 */
@Entity
@Table(name = "wlyy_doctor_guidance_temp_label")
public class DoctorGuidanceTempLabel extends IdEntity {
    private String code;//业务编码
    private String name;//标签名称
    private Date createTime;// 创建时间
    private String doctorCode;//创建人code
    private Integer del;//作废标识1、正常 ,0、作废
    private Integer teamId;//医生团队Id
    @Column(name = "code", length = 50)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name", length = 100)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "doctor_code", length = 50)
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    @Column(name = "del", length = 2)
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "team_id", length = 11)
    public Integer getTeamId() {
        return teamId;
    }
    public void setTeamId(Integer teamId) {
        this.teamId = teamId;
    }
    public DoctorGuidanceTempLabel(String name) {
        this.name = name;
    }
    public DoctorGuidanceTempLabel() {
    }
}

+ 33 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorGuidanceTempLabelDao.java

@ -0,0 +1,33 @@
package com.yihu.wlyy.repository.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTempLabel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by 刘文彬 on 2018/5/18.
 */
public interface DoctorGuidanceTempLabelDao extends PagingAndSortingRepository<DoctorGuidanceTempLabel, Long> {
    @Query("select t from DoctorGuidanceTempLabel t where t.teamId = ?1 and t.del=1")
    Page<DoctorGuidanceTempLabel> findByTeamId(Integer teamId, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTempLabel t where t.code = ?1 and t.del=1 ")
    DoctorGuidanceTempLabel findByCodeWithDel(String code);
    @Query("select t from DoctorGuidanceTempLabel t where t.code = ?1 ")
    DoctorGuidanceTempLabel findByCode(String code);
    @Modifying
    @Query(value = "update DoctorGuidanceTempLabel p set p.del=?1 where p.code=?2 ")
    int updateDel(int del,String code);
    @Modifying
    @Query(value = "update DoctorGuidanceTempLabel p set p.name=?1 where p.code=?2 ")
    int updateName(String name,String code);
}

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorTeamGuidanceTemplateDao.java

@ -71,4 +71,13 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
            " AND b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 ")
    List<DoctorTeamGuidanceTemplate> getListByTile(int teamId, String title, Pageable pageRequest);
    // 根据模板文章标题模糊搜索团队指导模板(不分页)
    @Query("SELECT b FROM DoctorTeamGuidanceTemplate b WHERE   " +
            " b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 ")
    List<DoctorTeamGuidanceTemplate> getListByTile(int teamId, String title);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 and t.labelCode= ?2")
    List<DoctorTeamGuidanceTemplate> findGuidanceByTeamIdAndLabelCode(int teamId,String labelCode, Pageable request);
}

+ 72 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempLableService.java

@ -0,0 +1,72 @@
package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.template.DoctorGuidanceTempLabel;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempLabelDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/5/18.
 */
@Service
public class DoctorGuidanceTempLableService extends BaseService {
    @Autowired
    private DoctorGuidanceTempLabelDao doctorGuidanceTempLableDao;
    /**
     * 保存
     * @param doctorCode
     * @param name
     */
    @Transactional
    public DoctorGuidanceTempLabel save(String doctorCode, String name, Integer teamId)throws Exception{
        DoctorGuidanceTempLabel one = new DoctorGuidanceTempLabel();
        one.setCode(getCode());
        one.setCreateTime(new Date());
        one.setDoctorCode(doctorCode);
        one.setName(name);
        one.setTeamId(teamId);
        one.setDel(1);
        return doctorGuidanceTempLableDao.save(one);
    }
    public List<DoctorGuidanceTempLabel> findByDoctorCode(Integer teamId, int pageSize, int pageNo) throws Exception{
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        pageNo=pageNo-1;
        PageRequest pageRequest = new PageRequest(pageNo, pageSize,sort);
        Page<DoctorGuidanceTempLabel> page =  doctorGuidanceTempLableDao.findByTeamId(teamId,pageRequest);
        List<DoctorGuidanceTempLabel> newList = new ArrayList<>();
        newList.add(0,new DoctorGuidanceTempLabel("未分组"));
        newList.addAll(page.getContent());
        return newList;
    }
    @Transactional
    public boolean delete(String code) throws Exception{
        int temp = doctorGuidanceTempLableDao.updateDel(0,code);
        if(temp>0){
            return true;
        }
        return false;
    }
    @Transactional
    public boolean updateName(String code,String name) throws Exception{
        int temp = doctorGuidanceTempLableDao.updateName(name,code);
        if(temp>0){
            return true;
        }
        return false;
    }
}

+ 36 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorTeamGuidanceService.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.entity.template.DoctorGuidanceTempLabel;
import com.yihu.wlyy.entity.template.DoctorTeamGuidanceDetail;
import com.yihu.wlyy.entity.template.DoctorTeamGuidanceTemplate;
import com.yihu.wlyy.logs.BusinessLogs;
@ -12,13 +13,13 @@ import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempLabelDao;
import com.yihu.wlyy.repository.template.DoctorTeamGuidanceDetailDao;
import com.yihu.wlyy.repository.template.DoctorTeamGuidanceTemplateDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.util.CommonUtil;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -57,6 +58,8 @@ public class DoctorTeamGuidanceService extends BaseService {
    DoctorGuidanceTempDao guidanceTempDao;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private DoctorGuidanceTempLabelDao doctorGuidanceTempLableDao;
    /**
     * 新增团队指导模板
@ -66,7 +69,7 @@ public class DoctorTeamGuidanceService extends BaseService {
     * @param content
     * @param images
     */
    public String saveTeamGuidance(String doctor, String title, JSONArray teams, String content, String images) throws Exception {
    public String saveTeamGuidance(String doctor, String title, JSONArray teams, String content, String images,String labelCode) throws Exception {
        String templateCode = getCode();
        Date nowDate = new Date();
        String image = "";
@ -75,7 +78,12 @@ public class DoctorTeamGuidanceService extends BaseService {
            image = CommonUtil.copyTempImage(images);
            System.out.println("images =====>" + image);
        }
        //指导标签
        DoctorGuidanceTempLabel doctorGuidanceTempLable =  doctorGuidanceTempLableDao.findByCode(labelCode);
        String labelName = "未分组";
        if(doctorGuidanceTempLable!=null){
            labelName = doctorGuidanceTempLable.getName();
        }
        for (Object team : teams) {
            JSONObject teamJson = new JSONObject(team.toString());
            int teamId = teamJson.getInt("teamId");
@ -93,7 +101,8 @@ public class DoctorTeamGuidanceService extends BaseService {
                doctorTeamGuidanceTemplate.setTitle(title);
                doctorTeamGuidanceTemplate.setTeamTemplateCode(templateCode);
                doctorTeamGuidanceTemplate.setUseTimes(0);
                doctorTeamGuidanceTemplate.setLabelCode(labelCode);
                doctorTeamGuidanceTemplate.setLabelName(labelName);
                doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
            } else {
                throw new Exception(teamName + ":团队标题重复!");
@ -468,4 +477,27 @@ public class DoctorTeamGuidanceService extends BaseService {
        return imagePath;
    }
    public List<DoctorTeamGuidanceTemplate> getGuidanceByTeamIdAndLabelCode( Integer teamId,String labelCode, int pageNo, int pageSize) throws Exception {
        Sort sort = new Sort(Sort.Direction.DESC, "useTimes","createTime");
        pageNo = pageNo -1;
        PageRequest request = new PageRequest(pageNo, pageSize, sort);
        List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.findGuidanceByTeamIdAndLabelCode(teamId,labelCode,request);
        return list;
    }
    public Map<String,List<DoctorTeamGuidanceTemplate>> getTeamGuidanceListByLabelWithFilter(Integer teamId ,String filter) throws Exception {
        List<DoctorTeamGuidanceTemplate>  listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(teamId,"%"+filter+"%");
        Map<String,List<DoctorTeamGuidanceTemplate>> map= new HashMap<>();
        for(DoctorTeamGuidanceTemplate one:listGuidances){
            if(map.containsKey(one.getLabelName()!=null?one.getLabelName():"未分组")){
                List<DoctorTeamGuidanceTemplate> temp = map.get(one.getLabelName()!=null?one.getLabelName():"未分组");
                temp.add(one);
            }else{
                map.put(one.getLabelName()!=null?one.getLabelName():"未分组",new ArrayList<>(Arrays.asList(one)));
            }
        }
        return map;
    }
}

+ 8 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java

@ -44,14 +44,14 @@ public class BaseController {
     */
    public String getUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("uid");
//            return "xh1D2017031502222";// wjw00000001000e6badcfa163e424589/wjw00000001000e6badcfa163e424525
//            String userAgent = request.getHeader("userAgent");
//            if (StringUtils.isEmpty(userAgent)) {
//                userAgent = request.getHeader("User-Agent");
//            }
//            JSONObject json = new JSONObject(userAgent);
//            return json.getString("uid");
            return "test00000000005";// wjw00000001000e6badcfa163e424589/wjw00000001000e6badcfa163e424525
        } catch (Exception e) {
            return null;
        }

+ 107 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempLabelController.java

@ -0,0 +1,107 @@
package com.yihu.wlyy.web.doctor.template;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.template.DoctorGuidanceTempLabel;
import com.yihu.wlyy.service.template.DoctorGuidanceTempLableService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/5/18.
 */
@RestController
@RequestMapping(value = "/doctor/guidance_temp/lable")
@Api(description = "医生健康指导模板标签")
public class DoctorGuidanceTempLabelController extends BaseController {
    @Autowired
    private DoctorGuidanceTempLableService doctorGuidanceTempLableService;
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加指导模板标签")
    @ObserverRequired
    public String save(@ApiParam(name = "name", value = "标签名称", required = true)
                        @RequestParam(value = "name", required = true) String name,
                        @ApiParam(name = "teamId", value = "医生团队id", required = true)
                        @RequestParam(value = "teamId", required = true) Integer teamId){
        try{
            DoctorGuidanceTempLabel doctorGuidanceTempLable = doctorGuidanceTempLableService.save(getUID(),name,teamId);
            if(doctorGuidanceTempLable!=null){
                return write(200,"保存标签成功!","data",doctorGuidanceTempLable);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"保存标签失败!");
        }
        return error(-1,"保存标签失败!");
    }
    @RequestMapping(value = "/findAllList", method = RequestMethod.GET)
    @ApiOperation(value = "根据团队id获取标签")
    @ObserverRequired
    public String findAllList(@ApiParam(name = "pageSize", value = "每页总数", required = true)
                                  @RequestParam(value = "pageSize", required = true,defaultValue = "10") int pageSize,
                              @ApiParam(name = "pageNo", value = "当前页", required = true)
                              @RequestParam(value = "pageNo", required = true,defaultValue = "1") int pageNo,
                              @ApiParam(name = "teamId", value = "医生团队id", required = true)
                                  @RequestParam(value = "teamId", required = true) Integer teamId){
        try{
            List<DoctorGuidanceTempLabel> list = doctorGuidanceTempLableService.findByDoctorCode(teamId, pageSize, pageNo);
            if (list == null || list.size() < 1) {
                return write(200, "查询成功!");
            } else {
                return write(200, "查询成功!", "data", list);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "/deleteLabel", method = RequestMethod.POST)
    @ApiOperation(value = "删除健康指导模板标签")
    @ObserverRequired
    public String deleteLabel(@ApiParam(name = "code", value = "标签code", required = true)
                              @RequestParam(value = "code", required = true) String code){
        try {
            boolean b = doctorGuidanceTempLableService.delete(code);
            if(b){
                return success("删除成功!");
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"删除成功!");
        }
        return error(-1,"删除成功!");
    }
    @RequestMapping(value = "/updateLabel", method = RequestMethod.POST)
    @ApiOperation(value = "修改健康指导模板标签")
    @ObserverRequired
    public String updateLabel(@ApiParam(name = "code", value = "标签code", required = true)
                              @RequestParam(value = "code", required = true) String code,
                              @ApiParam(name = "name", value = "标签名称", required = true)
                              @RequestParam(value = "name", required = true) String name){
        try {
            boolean b = doctorGuidanceTempLableService.updateName(code,name);
            if(b){
                return success("修改成功!");
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"修改失败!");
        }
        return error(-1,"修改失败!");
    }
}

+ 46 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorTeamGuidanceController.java

@ -122,13 +122,15 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
            @ApiParam(value = "模板内容")
            @RequestParam String content,
            @ApiParam(value = "图片路径")
            @RequestParam(required = false) String images
            @RequestParam(required = false) String images,
            @ApiParam(value = "指导标签")
            @RequestParam(required = false) String labelCode
    ) {
        try {
//            前端参数校验
            String doctor = getUID();
            JSONArray teams = new JSONArray(teamInfo);
            String guidanceCode = doctorTeamGuidanceService.saveTeamGuidance(doctor, title, teams, content, images);
            String guidanceCode = doctorTeamGuidanceService.saveTeamGuidance(doctor, title, teams, content, images,labelCode);
            return write(200, "保存团队模板成功!","guidanceCode",guidanceCode);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
@ -251,4 +253,46 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
        }
    }
    /**
     * 根据医生所属的单个团队获取团队模板标签列表
     *
     * @param teamId
     * @return
     */
    @RequestMapping(value = "/getTeamGuidanceLabelList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据单个团队标签获取团队模板列表")
    public String getTeamGuidanceListByLabel(
            @RequestParam(required = true)
            @ApiParam(value = "团队ID") Integer teamId,
            @RequestParam(required = true)
            @ApiParam(value = "团队模板标签code") String labelCode,
            @RequestParam(value = "pageNo", required = true,defaultValue = "1") int pageNo,
            @RequestParam(value = "pageSize", required = true,defaultValue = "10") int pageSize) {
        try {
            List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceService.getGuidanceByTeamIdAndLabelCode(teamId,labelCode, pageNo , pageSize);
            return write(200, "获取团队模板列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "/getTeamGuidanceListByLabelWithFilter", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据单个团队标签过滤条件获取团队模板列表")
    public String getTeamGuidanceListByLabelWithFilter(@RequestParam(value = "teamId",required = true)
                                                        @ApiParam(value = "团队ID") Integer teamId,
                                                       @RequestParam(value = "filter",required = true)
                                                       @ApiParam(value = "过滤条件") String filter){
        try{
            Map<String,List<DoctorTeamGuidanceTemplate>> map = doctorTeamGuidanceService.getTeamGuidanceListByLabelWithFilter(teamId ,filter);
            return write(200, "查询成功!","data",map);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}