浏览代码

Merge branch 'dev' of wangzhinan/patient-co-management into dev

liuwenbin 7 年之前
父节点
当前提交
cdb7e0280d

+ 15 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -128,8 +128,8 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query(" select a from Message a where a.type=?2 and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findUnReadByReceiverAndType(String receiver,Integer type);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type in (16,20,22,23) order by a.czrq desc")
    List<Message> getSpecialistApply(String receiver,Integer read,String over);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (16,20,22,23) order by a.czrq desc")
    List<Message> getSpecialistApply(String receiver,String over);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransfer(String receiver);
@ -143,10 +143,10 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransferReadAndOver(String receiver,Integer read,String over);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type in (16,20,22,23) order by a.czrq desc")
    List<Message> getSpecialistUntreated(String receiver,Integer read,String over,Pageable pageable);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (16,20,22,23) order by a.czrq desc")
    List<Message> getSpecialistUntreated(String receiver,String over,Pageable pageable);
    @Query("select a from Message a where  a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (16,19,20,21,22,23) order by a.czrq desc")
    @Query("select a from Message a where  a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (19,21) order by a.czrq desc")
    List<Message> getSpecialistMessages(String receiver,String over,Pageable pageable);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type in (17) order by a.czrq desc")
@ -155,6 +155,15 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select a from Message a where a.code = ?1")
    Message findByCode(String code);
    @Query("select a from Message a where a.read = 1 and a.over = 0 and a.receiver = ?1 and a.state = 1 and a.type in (19,20,21,22,23) order by a.czrq desc")
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type in (19,21) order by a.czrq desc")
    List<Message> getSpecialistUnRead(String receiver);
    @Query("update Message a set a.read=0,a.over = '0' where a.id = ?1")
    @Modifying
    int setSpecialistById(Long id);
    @Query("update Message a set a.read = 0 where a.id = ?1")
    @Modifying
    int setSpecialistReadById(Long id);
}

+ 63 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -18,6 +18,7 @@ import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
@ -46,6 +47,8 @@ import java.util.*;
@Transactional(rollbackOn = Exception.class)
public class MessageService extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(MessageService.class);
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
@ -67,6 +70,11 @@ public class MessageService extends BaseService {
    @Value("${im.im_list_get}")
    private String im_list_get;
    @Value("${specialist.url}")
    private String specialistUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * IM消息数量
     */
@ -621,8 +629,16 @@ public class MessageService extends BaseService {
        }
        buffer.deleteCharAt(buffer.length()-1);
        buffer.append(")");
        String sql = " update wlyy_message a set a.has_read = 0,a.over = '0' where a.receiver = '"+doctor+"' and "+buffer;
        int i = jdbcTemplate.update(sql);
        int i = 0;
        if (types.contains(19)&&types.contains(21)){
            String sql = " update wlyy_message a set a.has_read = 0,a.over = '0' where a.receiver = '"+doctor+"' and "+buffer;
            i = jdbcTemplate.update(sql);
        }else {
            String sql1 = " update wlyy_message a set a.has_read = 0,a.over = '0' where a.receiver = '"+doctor+"' and type = 20";
            i=jdbcTemplate.update(sql1);
            String sql2 = "update wlyy_message a set a.has_read = 0 where a.receiver = '"+doctor+"' and type IN (22,23)";
            i=jdbcTemplate.update(sql2);
        }
        return Integer.toString(i);
    }
@ -865,14 +881,14 @@ public class MessageService extends BaseService {
    public JSONObject selectUntreated(String doctor){
        //专科医生签约平台
        List<Message> specialist = messageDao.getSpecialistApply(doctor,1,"1");
        List<Message> specialist = messageDao.getSpecialistApply(doctor,"1");
        JSONObject specialistJson = new JSONObject();
        if (specialist != null && specialist.size() != 0){
            specialistJson.put("amount", specialist.size());
            JSONObject specialistObject = new JSONObject();
            specialistObject.put("title", specialist.get(0).getTitle());
            specialistObject.put("type", specialist.get(0).getType());
            specialistObject.put("msg", "您有"+specialist.size()+"个居民申请共管服务");
            specialistObject.put("msg", "您有"+specialist.size()+"个消息待处理,请查收");
            specialistObject.put("msgTime", DateUtil.dateToStrLong(specialist.get(0).getCreateTime()));
            specialistObject.put("relationCode",specialist.get(0).getRelationCode());
            specialistJson.put("specialist",specialistObject);
@ -919,7 +935,7 @@ public class MessageService extends BaseService {
    public List<Message> getFamilySign(String receiver,Integer page, Integer size) throws Exception{
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "read","over","createTime");
        Sort sort = new Sort(Direction.DESC, "createTime");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, size, sort);
        return messageDao.selectFamilySign(receiver,pageRequest);
@ -938,11 +954,11 @@ public class MessageService extends BaseService {
    public List<Message> getSpecialistUnTreated(Message message, Integer page, Integer size) throws Exception{
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "read","over","createTime");
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, size, sort);
        return messageDao.getSpecialistUntreated(message.getReceiver(),message.getRead(),message.getOver(),pageRequest);
        return messageDao.getSpecialistUntreated(message.getReceiver(),message.getOver(),pageRequest);
    }
    /**
@ -984,6 +1000,45 @@ public class MessageService extends BaseService {
    }
    /**
     * 设置待办消息已处理
     *
     * @param id
     * @param type
     */
    public int setSpecialistOver(Long id,Integer type){
        if (type == 22 || type==23){
            int result = 0;
            Message message = messageDao.findOne(id);
            String response = null;
            String url =specialistUrl + "svr-specialist/selectByIds";
            Map<String,String> params = new HashMap<>();
            params.put("ids",message.getRelationCode());
            try {
                response = httpClientUtil.httpPost(url,params);
               com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(response);
               if (object.getInteger("status") == 200){
                   JSONArray array = object.getJSONArray("obj");
                   Integer count = 0;
                   for (int i =0;i<array.size();i++){
                       if (array.getJSONObject(i).getInteger("status") == 1){
                           count = count+1;
                       }
                   }
                   if (count == array.size()){
                       result = messageDao.setSpecialistById(id);
                   }else {
                       result = messageDao.setSpecialistReadById(id);
                   }
               }
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.getMessage());
            }
            return result;
        }else {
           return messageDao.setSpecialistById(id);
        }
    }
}

+ 72 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.specialist;/**
 * Created by nature of king on 2018/8/28.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
@ -13,6 +14,7 @@ import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -110,6 +112,76 @@ public class SpecialistEvaluateSevice extends BaseService {
    }
    /**
     * 医生获取评分
     *
     * @param doctor
     * @return
     */
    public JSONObject selectByDoctor(String doctor){
        String response = null;
        String url =/*"http://localhost:10051/"*/specialistUrl + "svr-specialist/selectByDoctor";
        Map<String,String> params = new HashMap<>();
        params.put("doctor",doctor);
        try {
            response = httpClientUtil.httpPost(url,params);
            JSONObject object = JSONObject.parseObject(response);
            if (object.getInteger("status")==200){
                JSONObject jsonObject4 = object.getJSONObject("obj");
                JSONObject jsonObject = jsonObject4.getJSONObject("4");
                JSONObject jsonObject1 = jsonObject4.getJSONObject("5");
                JSONObject jsonObject2 = jsonObject4.getJSONObject("6");
                JSONObject jsonObject3 = jsonObject4.getJSONObject("7");
                JSONArray array = jsonObject.getJSONArray("evaluate");
                JSONArray array1 = jsonObject1.getJSONArray("evaluate");
                JSONArray array2 = jsonObject2.getJSONArray("evaluate");
                JSONArray array3 = jsonObject3.getJSONArray("evaluate");
                //全部
                for (int i=0;i<array.size();i++){
                    JSONObject object1 = array.getJSONObject(i);
                    String patient = object1.getJSONArray("patient").getString(0);
                    Patient patient1 = patientDao.findByCode(patient);
                    Integer age = IdCardUtil.getAgeForIdcard(patient1.getIdcard());
                    object1.put("patient1",patient1);
                    object1.put("age",age);
                }
                //好评
                for (int i=0;i<array1.size();i++){
                    JSONObject object1 = array1.getJSONObject(i);
                    String patient = object1.getJSONArray("patient").getString(0);
                    Patient patient1 = patientDao.findByCode(patient);
                    Integer age = IdCardUtil.getAgeForIdcard(patient1.getIdcard());
                    object1.put("patient1",patient1);
                    object1.put("age",age);
                }
                //中评
                for (int i=0;i<array2.size();i++){
                    JSONObject object1 = array2.getJSONObject(i);
                    String patient = object1.getJSONArray("patient").getString(0);
                    Patient patient1 = patientDao.findByCode(patient);
                    Integer age = IdCardUtil.getAgeForIdcard(patient1.getIdcard());
                    object1.put("patient1",patient1);
                    object1.put("age",age);
                }
                //差评
                for (int i=0;i<array3.size();i++){
                    JSONObject object1 = array3.getJSONObject(i);
                    String patient = object1.getJSONArray("patient").getString(0);
                    Patient patient1 = patientDao.findByCode(patient);
                    Integer age = IdCardUtil.getAgeForIdcard(patient1.getIdcard());
                    object1.put("patient1",patient1);
                    object1.put("age",age);
                }
            }
            return object;
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * 发送消息 type:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成 23 服务进展提醒-待完成
     */

+ 26 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -730,4 +730,30 @@ public class DoctorMessageController extends BaseController {
        }
    }
    /**
     * 设置待办消息已处理
     *
     * @param id
     * @param type
     * @return
     */
    @RequestMapping(value = "setSpecialistOver",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("设置待办消息已处理" )
    public String setSpecialistOver(@ApiParam(name = "id",value = "消息id")
                                 @RequestParam(value = "id")Long id,
                                    @ApiParam(name = "type",value = "消息类型")
                                    @RequestParam(value = "type")Integer type) {
        try {
            return write(200, "获取消息总数成功!", "data", messageService.setSpecialistOver(id,type));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 42 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistEvaluate1Controller.java

@ -0,0 +1,42 @@
package com.yihu.wlyy.web.doctor.specialist;/**
 * Created by nature of king on 2018/9/14.
 */
import com.yihu.wlyy.service.specialist.SpecialistEvaluateSevice;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author wangzhinan
 * @create 2018-09-14 0:09
 * @desc 医生评价
 **/
@RestController
@RequestMapping(value = "/doctor/specialist/evaluate", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生-医生评价")
public class SpecialistEvaluate1Controller extends BaseController {
    @Autowired
    private SpecialistEvaluateSevice specialistEvaluateSevice;
    /**
     * 医生获取评分
     * @return
     */
    @RequestMapping(value = "/selectByDoctor",method = RequestMethod.POST)
    @ApiOperation("医生获取评分")
    public String selectByDoctor(){
        try {
            return write(200,"获取成功","data",specialistEvaluateSevice.selectByDoctor(getUID()));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/SpecialistEvaluateController.java

@ -85,4 +85,5 @@ public class SpecialistEvaluateController extends WeixinBaseController {
            return error(-1,e.getMessage());
        }
    }
}