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

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

zhanghaoyu 7 éve
szülő
commit
01c04e60e0
21 módosított fájl, 603 hozzáadás és 178 törlés
  1. 27 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/specialist/HospitalServiceItemDO.java
  2. 2 3
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/ServiceItemService.java
  3. 13 12
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/SpecialistHospitalItemService.java
  4. 5 1
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java
  5. 15 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/DateUtil.java
  6. 2 1
      patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml
  7. 18 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  8. 80 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  9. 8 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  10. 77 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java
  11. 127 35
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/rehabilitation/RehabilitationManageService.java
  12. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  13. 1 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/messages/ImMessageController.java
  14. 77 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  15. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  16. 34 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  17. 42 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistEvaluate1Controller.java
  18. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/SpecialistEvaluateController.java
  19. 2 2
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  20. 2 2
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt
  21. 51 78
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

+ 27 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/specialist/HospitalServiceItemDO.java

@ -41,6 +41,12 @@ public class HospitalServiceItemDO extends IdEntityWithOperation implements Seri
    @Column(name = "expense")
    private Integer expense;//价格
    @Transient
    private String title;//标题
    @Transient
    private String content;//内容
    @Transient
    private Integer flag;//标识(1:社区,2、医院,3、社区、医院)
@ -50,6 +56,9 @@ public class HospitalServiceItemDO extends IdEntityWithOperation implements Seri
    @Transient
    private SpecialistServiceItemDO specialistServiceItemDO;
    public HospitalServiceItemDO() {
    }
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
@ -139,4 +148,22 @@ public class HospitalServiceItemDO extends IdEntityWithOperation implements Seri
    public void setImediate(Integer imediate) {
        this.imediate = imediate;
    }
    @Transient
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Transient
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
}

+ 2 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/ServiceItemService.java

@ -192,11 +192,10 @@ public class ServiceItemService extends BaseService {
                String value = sheet.getCell(index-1, finalRow).getContents().trim();
                excelData.transform(value);
            });
            JSONObject object = JSONObject.parseObject(itemDO.toString());
            array.add(object);
            array.add(itemDO);
        }
        String response = null;
        String url =getBaseUrl() + "importData1";
        String url =/*"http://localhost:10051/svr-specialist/"*/getBaseUrl() + "importData1";
        Map<String,String> params = new HashMap<>();
        params.put("serviceItems",array.toJSONString());
        try {

+ 13 - 12
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/SpecialistHospitalItemService.java

@ -190,14 +190,15 @@ public class SpecialistHospitalItemService extends BaseService {
        JSONArray array = new  JSONArray();
        for (int row = 1; row < rows; row++) {  //索引从0开始,第一行为标题
            HospitalServiceItemDO hospitalServiceItemDO = new HospitalServiceItemDO();
            Map<Integer, ExcelData> mapping = mapping(hospitalServiceItemDO);
            Map<Integer, ExcelData> mapping = mapping1(hospitalServiceItemDO);
            int finalRow = row;
            mapping.forEach((index, excelData) -> {
                String value = sheet.getCell(index, finalRow).getContents().trim();
                String value = sheet.getCell(index-1, finalRow).getContents().trim();
                excelData.transform(value);
            });
            JSONObject object = JSONObject.parseObject(hospitalServiceItemDO.toString());
            array.add(object);
            Hospital hospital = hospitalDao.findByName(hospitalServiceItemDO.getHospitalName());
            hospitalServiceItemDO.setHospital(hospital.getCode());
            array.add(hospitalServiceItemDO);
        }
        String response = null;
        String url =getBaseUrl() + "importData2";
@ -219,33 +220,33 @@ public class SpecialistHospitalItemService extends BaseService {
     * @param hospitalServiceItemDO
     * @return
     */
    private Map<Integer, ExcelData> mapping(HospitalServiceItemDO hospitalServiceItemDO) {
    private Map<Integer, ExcelData> mapping1(HospitalServiceItemDO hospitalServiceItemDO) {
        Map<Integer, ExcelData> dataMap = new HashMap<>();
        //医院名称
        dataMap.put(1, new ExcelData() {
            @Override
            public void transform(String data) {
                hospitalServiceItemDO.setHospital(hospitalServiceItemDO.getHospital());
                hospitalServiceItemDO.setHospitalName(data);
            }
        });
        //医院名称
        //服务项目标题
        dataMap.put(2, new ExcelData() {
            @Override
            public void transform(String data) {
                hospitalServiceItemDO.setHospitalName(hospitalServiceItemDO.getHospitalName());
                hospitalServiceItemDO.setTitle(data);
            }
        });
        //服务项目id
        //服务项目内容
        dataMap.put(3, new ExcelData() {
            @Override
            public void transform(String data) {
                hospitalServiceItemDO.setServiceItemId(hospitalServiceItemDO.getServiceItemId());
                hospitalServiceItemDO.setContent(data);
            }
        });
        //服务项目名称
        dataMap.put(4, new ExcelData() {
            @Override
            public void transform(String data) {
                hospitalServiceItemDO.setServiceItemName(hospitalServiceItemDO.getServiceItemName());
                hospitalServiceItemDO.setExpense(Integer.parseInt(data));
            }
        });
        hospitalServiceItemDO.setSaasId("dev");

+ 5 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java

@ -116,6 +116,11 @@ public class MysqlToEsQuotaJob implements Job {
        } else {
            endTime = endTime + " 17:00:00";
        }
        if("2".equals(incrementInterval)){
            endTime =  DateUtil.getSundayOfThisDate(DateUtil.strToDateLong(endTime));
        }else if("3".equals(incrementInterval)){
            endTime=  DateUtil.getLastDayOfMonth((DateUtil.strToDateLong(endTime)));
        }
        //初始化统计年份
        this.year = getNowYearByDate(endTime);
        //初始化开始时间
@ -132,7 +137,6 @@ public class MysqlToEsQuotaJob implements Job {
            }
        }
        this.quotaDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
        this.wlyyJobCongId = map.getString("jobConfig");
        this.quartzJobConfig = quartzJobConfigDao.findById(wlyyJobCongId);

+ 15 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/DateUtil.java

@ -753,6 +753,21 @@ public class DateUtil {
        c.add(Calendar.DATE, -day_of_week + 7);
        return df2.format(c.getTime());
    }
	/**
	 * 得到本周周日
	 *
	 * @return yyyy-MM-dd
	 */
	public static Date getSundayOfThisDateToDate(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 7);
		return c.getTime();
	}
	/**
	 * 获取当月第一天
	 * @return

+ 2 - 1
patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml

@ -87,9 +87,10 @@ images:
  sign_path: /usr/local/apache-tomcat-8.0.36/webapps/wlyy/images/familycontract.png
sign:
  check_upload: http://172.19.103.88:8011/wlyy_service
  zysoft: http://59.61.92.90:8072/wlyy_sign
quartz:
  name: schedulerFactoryBean_test

+ 18 - 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.read = 1 and 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,18 @@ 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("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type in (19,20,21,22,23) order by a.czrq desc")
    List<Message> getSpecialistUnRead2(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);
}

+ 80 - 11
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消息数量
     */
@ -103,7 +111,7 @@ public class MessageService extends BaseService {
    /**
     * 查询医生未读消息和最后消息
     */
    public JSONObject findDoctorAllMessage(String doctor,Integer type) throws Exception {
    public JSONObject findDoctorAllMessage(String doctor,Integer type,Integer flag) throws Exception {
        // 签约未读消息总数
        int sign = messageDao.amountUnreadByReceiver(doctor);
        JSONObject signJson = new JSONObject();
@ -244,8 +252,17 @@ public class MessageService extends BaseService {
            familyMesJson.put("amount", 0);
        }
        //专科1、全科2
        //专科消息
        List<Message> specialistList = messageDao.getSpecialistUnRead(doctor);
        List<Message> specialistList = new ArrayList<>();
        if (flag!=null){
            if (flag == 1){
                specialistList = messageDao.getSpecialistUnRead(doctor);
            }else if (flag == 2){
                specialistList = messageDao.getSpecialistUnRead2(doctor);
            }
        }
        JSONObject specialistMesJson = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        if (specialistList != null && specialistList.size() > 0) {
@ -613,7 +630,7 @@ public class MessageService extends BaseService {
     *
     * @param doctor
     */
    public String setMessageReaded(String doctor,List<Integer> types) {
    public String setMessageReaded(String doctor,List<Integer> types,Integer flag) {
        StringBuffer buffer = new StringBuffer();
        buffer.append("type in (");
        for (int i = 0;i<types.size();i++){
@ -621,8 +638,21 @@ 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 (flag == 1){
            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 if (flag == 2){
            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 +895,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 +949,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 +968,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 +1014,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);
        }
    }
}

+ 8 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -5452,7 +5452,7 @@ public class StatisticsESService {
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer");
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血压%' " + areaCondition;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=1 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(mondayTime,DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "1");
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "1");
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "hemopiezometer");
@ -5467,7 +5467,7 @@ public class StatisticsESService {
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer");
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血糖%' " + areaCondition;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=2 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(mondayTime,DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "2");
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "2");
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "glucometer");
@ -5483,7 +5483,7 @@ public class StatisticsESService {
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_88, SaveModel.timeLevel_DDL);
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 " + areaCondition;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1  and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(mondayTime,DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_97, SaveModel.timeLevel_DDL);
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
@ -5634,7 +5634,7 @@ public class StatisticsESService {
                        obj.put("code", one.get("doctorCode"));
                        obj.put("name", one.get("doctorName"));
                        obj.put("amount", one.get("amount"));
                        obj = deviceRateList(obj,hos);
                        obj = deviceRateList(obj,hos,String.valueOf(obj.get("doctorCode")));
                        if("other".equals(one.get("doctorCode")+"")){
                            amount += Integer.valueOf(obj.get("amount")+"");
                            allNum += Integer.valueOf(obj.get("allNum")+"");
@ -5766,13 +5766,14 @@ public class StatisticsESService {
    }
    //按绑定的医生列表展示绑定的设备列表
    public Map<String, Object> deviceRateList(Map<String, Object> reMap,Hospital hos){
    public Map<String, Object> deviceRateList(Map<String, Object> reMap,Hospital hos,String doctor){
//        String sql = " select count(1) as amount from wlyy.wlyy_patient_device p JOIN wlyy.wlyy_doctor r on p.doctor is not null and  p.doctor =r.code  LEFT JOIN device.wlyy_devices d on p.device_sn=d.device_code where  p.doctor is not null and d.grant_org_code ='" + hos.getCode() + "' and p.doctor='"+reMap.get("code")+"'";
        String temp = "other".equals(reMap.get("code"))? " and p.doctor is null ":" and p.doctor='"+reMap.get("code")+"' ";
        String sql = " select count(1) as amount " +
       /* String sql = " select count(1) as amount " +
                " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p left join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                " where d.is_binding in (1,2) and p.category_code in('1','2') and d.grant_org_code ='" + hos.getCode() + "' "+temp+") a " +
                " GROUP BY a.doctor,a.name";
                " GROUP BY a.doctor,a.name";*/
       String sql ="SELECT count(1) as amount from device.wlyy_devices wd LEFT JOIN dm_device dd ON wd.device_model=dd.model where grant_doctor ='"+doctor+"' AND dd.category_code IN('1','2')";
//        Map<String, Object> map = jdbcTemplate.queryForMap(sql);
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        Map<String,Object> map = result.get(0);

+ 77 - 1
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 服务进展提醒-待完成
     */
@ -133,7 +205,11 @@ public class SpecialistEvaluateSevice extends BaseService {
                message.setOver("1");//未处理
                message.setType(20);
                message.setTitle("康复计划-待办工作提醒");
                message.setContent("您的"+patient.getName()+"签约居民"+num+"天后计划到"+(hospital!=null?hospital.getName():"")+"复诊,请查看");
                if(num==0){
                    message.setContent("您的"+patient.getName()+"签约居民今天计划到"+(hospital!=null?hospital.getName():"")+"复诊,请查看");
                }else{
                    message.setContent("您的"+patient.getName()+"签约居民"+num+"天后计划到"+(hospital!=null?hospital.getName():"")+"复诊,请查看");
                }
            }else if (message.getType() == 21){
                message.setOver("0");//未处理
                message.setType(21);

+ 127 - 35
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/rehabilitation/RehabilitationManageService.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.specialist.rehabilitation;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
@ -14,6 +15,8 @@ import com.yihu.wlyy.service.specialist.SpecialistEvaluateSevice;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.QrcodeUtil;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -28,7 +31,10 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -41,6 +47,14 @@ import java.util.Map;
public class RehabilitationManageService extends BaseService {
    @Value("${specialist.url}")
    private String specialistUrl;
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Value("${wechat.appId}")
    private String appId;
    @Value("${neiwang.enable}")
    private Boolean isneiwang;  //如果不是内网项目要转到到内网wlyy在上传
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
@ -59,6 +73,10 @@ public class RehabilitationManageService extends BaseService {
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
    protected HttpServletRequest request;
    @Autowired
    private com.yihu.wlyy.util.CommonUtil CommonUtil;
    /************************************************************* start ************************************************************************/
    private String findRehabilitationPlanList = "/svr-specialist/findRehabilitationPlanList";//康复管理-康复计划列表
@ -323,7 +341,7 @@ public class RehabilitationManageService extends BaseService {
     * @throws Exception
     */
    public JSONObject patientRehabilitationDetail(String patientCode) throws Exception{
        Map<String, Object> param = new HashedMap();
        List<SignFamily> list = signFamilyDao.findByPatientAndExpensesStatusAndStatus(patientCode,"1",1);
        String healthDoctor = null;
        String healthDoctorName =null;
@ -333,6 +351,8 @@ public class RehabilitationManageService extends BaseService {
        Integer age = null;
        String sex = null;
        String signHospitalName = null;
        JSONObject json = null;
        Patient patient = patientDao.findByCode(patientCode);
        if(list.size()>0){
            SignFamily signFamily = list.get(0);
            healthDoctor = signFamily.getDoctorHealth();
@ -340,38 +360,56 @@ public class RehabilitationManageService extends BaseService {
            generalDoctor = signFamily.getDoctor();
            generalDoctorName = signFamily.getDoctorName();
            patientName = signFamily.getName();
            age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());
            sex = IdCardUtil.getSexForIdcard_new(signFamily.getIdcard());
            signHospitalName = signFamily.getHospitalName();
        }
        param.put("patientCode", patientCode);
        param.put("healthDoctor", healthDoctor);
        param.put("healthDoctorName", healthDoctorName);
        param.put("generalDoctor", generalDoctor);
        param.put("generalDoctorName", generalDoctorName);
        HttpResponse response = HttpUtils.doGet(specialistUrl + patientRehabilitationDetail, param);
        JSONObject result = new JSONObject(response.getContent());
        if(result.getInt("status")==200){
            JSONObject json = result.getJSONObject("obj").getJSONObject("patientInfo");
            json.put("patientName",patientName);
            json.put("age",age);
            json.put("sex",sex);
            json.put("healthyCondition","康复期");
            json.put("signHospitalName",signHospitalName);
            Patient patient = patientDao.findByCode(patientCode);
            json.put("photo",patient.getPhoto());
            json.put("mobile",patient.getMobile());
            JSONArray jsonArray = result.getJSONObject("obj").getJSONArray("serviceDoctorList");
            String doctorCode ="";
            Doctor doctor = null;
            for(int i=0;i<jsonArray.length();i++){
                doctorCode = jsonArray.getJSONObject(i).get("doctorCode")+"";
                doctor = doctorDao.findByCode(doctorCode);
                jsonArray.getJSONObject(i).put("doctorPhoto",doctor!=null?doctor.getPhoto():"");
            Map<String, Object> param = new HashedMap();
            param.put("patientCode", patientCode);
            param.put("healthDoctor", healthDoctor);
            param.put("healthDoctorName", healthDoctorName);
            param.put("generalDoctor", generalDoctor);
            param.put("generalDoctorName", generalDoctorName);
            HttpResponse response = HttpUtils.doGet(specialistUrl + patientRehabilitationDetail, param);
            JSONObject result = new JSONObject(response.getContent());
            if(result.getInt("status")==200){
                json = result.getJSONObject("obj").getJSONObject("patientInfo");
                json.put("patientName",patientName);
                String healthyConditionSql =" select  label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+patientCode+"' and label_type=8";
                List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
                String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
                String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
                json.put("healthyCondition",healthyCondition);
                json.put("healthyConditionType",healthyConditionType);
                json.put("signHospitalName",signHospitalName);
                age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
                sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
                json.put("patientCode", patientCode);
                json.put("patientName", patient.getName());
                json.put("age",age);
                json.put("sex",sex);
                json.put("photo",patient.getPhoto());
                json.put("mobile",patient.getMobile());
                JSONArray jsonArray = result.getJSONObject("obj").getJSONArray("serviceDoctorList");
                String doctorCode ="";
                Doctor doctor = null;
                for(int i=0;i<jsonArray.length();i++){
                    doctorCode = jsonArray.getJSONObject(i).get("doctorCode")+"";
                    doctor = doctorDao.findByCode(doctorCode);
                    jsonArray.getJSONObject(i).put("doctorPhoto",doctor!=null?doctor.getPhoto():"");
                }
                return result.getJSONObject("obj").put("patientInfo",json);
            }
            return result.getJSONObject("obj").put("patientInfo",json);
            throw new Exception("请求微服务失败!");
        }else{
            json = new JSONObject();
        }
        throw new Exception("请求微服务失败!");
        age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
        sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
        json.put("patientCode", patientCode);
        json.put("patientName", patient.getName());
        json.put("age",age);
        json.put("sex",sex);
        json.put("photo",patient.getPhoto());
        json.put("mobile",patient.getMobile());
        return new JSONObject().put("patientInfo",json) ;
    }
    /**
@ -399,8 +437,46 @@ public class RehabilitationManageService extends BaseService {
    public String createServiceQrCode(String planDetailId,String doctorCode) throws Exception{
        Map<String, Object> param = new HashedMap();
        String fileUrl = "";
        String sql ="SELECT service_qr_code FROM wlyy_specialist.wlyy_rehabilitation_plan_detail where id='"+planDetailId+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null && list.size()>0){
            fileUrl = String.valueOf(list.get(0).get("service_qr_code"));
        }
        if (StringUtils.isEmpty(fileUrl)){
            //生成二维码图片
            String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wechat_base_url+"/wx/html/kfgl/html/confirm-service.html"+"?paramStr="+planDetailId+","+doctorCode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
            InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
            if (isneiwang) {
                // 圖片列表
                List<String> tempPaths = new ArrayList<String>();
                try {
                    ObjectNode imgNode = FastDFSUtil.upload(ipt, "png", "plan_service_qrcode" + System.currentTimeMillis());
                    com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
                    tempPaths.add(json.getString("fid"));
                    String urls = "";
                    for (String image : tempPaths) {
                        if (urls.length() == 0) {
                            urls = image;
                        } else {
                            urls += "," + image;
                        }
                    }
                    fileUrl = fastdfs_file_url + urls;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                try {
                    fileUrl = fastdfs_file_url + CommonUtil.PrescriptionQRCodetoNeiWang(ipt);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
        param.put("planDetailId", planDetailId);
        param.put("doctorCode", doctorCode);
        param.put("imageUrl",fileUrl);
        //specialistUrl= "http://localhost:10051";
        HttpResponse response = HttpUtils.doPost(specialistUrl + createServiceQrCode, param);
        JSONObject result = new JSONObject(response.getContent());
@ -449,7 +525,15 @@ public class RehabilitationManageService extends BaseService {
        HttpResponse response = HttpUtils.doGet(specialistUrl + serviceDoctorList, param);
        JSONObject result = new JSONObject(response.getContent());
        if(result.getInt("status")==200){
            return result.getJSONArray("obj");
            JSONArray jsonArray = result.getJSONArray("obj");
            String doctorCode ="";
            Doctor doctor = null;
            for(int i=0;i<jsonArray.length();i++){
                doctorCode = jsonArray.getJSONObject(i).get("doctorCode")+"";
                doctor = doctorDao.findByCode(doctorCode);
                jsonArray.getJSONObject(i).put("doctorPhoto",doctor!=null?doctor.getPhoto():"");
            }
            return jsonArray;
        }
        throw new Exception("请求微服务失败!");
    }
@ -549,21 +633,23 @@ public class RehabilitationManageService extends BaseService {
                String serviceItemId = object.getString("service_item_id");
                String title = object.getString("title");
                Patient p = patientDao.findByCode(patient);
                Doctor doctor1 = doctorDao.findByCode(doctor);
                String patientName = p.getName();
                String openId = p.getOpenid();
                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","fwxmpj");
                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_service","fwxmpj");
                String first = templateConfig.getFirst();
                first = first.replace("key1",(patientName==null?"":patientName));
                String keyword1 = templateConfig.getKeyword1();
                JSONObject json = new JSONObject();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                json.put("keyword1", keyword1);
                json.put("keyword2", sdf.format(new Date()));
                json.put("keyword1", title);
                json.put("keyword2",doctor1.getName());
                json.put("keyword3", sdf.format(new Date()));
                json.put("toUser", p.getCode());
                json.put("represented",p.getCode());//被代理人
                json.put("remark", "");
                json.put("doctor",doctor);
                json.put("serviceItemId", serviceItemId);
                json.put("planIds", planDetailId);
                first = first.replace("key2",title);
                json.put("first", first);
                if(StringUtils.isNotBlank(p.getOpenid())){
@ -656,6 +742,12 @@ public class RehabilitationManageService extends BaseService {
            json.put("patientPhoto",p.getPhoto());
            json.put("patientName",p.getName());
            json.put("patientCode",p.getCode());
            String healthyConditionSql =" select  label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+p.getCode()+"' and label_type=8";
            List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
            String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
            String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
            json.put("healthyCondition",healthyCondition);
            json.put("healthyConditionType",healthyConditionType);
            return json;
        }
        throw new Exception("请求微服务失败!");

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -851,8 +851,8 @@ public class PushMsgTask {
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }else if (type==25){
                temp.setUrl(url + "qygl/html/service_score.html?openid=" + openid + "&serviceItemId=" + json.getString("serviceItemId") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented")+"&doctor="+json.getString("doctor"));
                temp.setTemplate_id(template_doctor_survey);
                temp.setUrl(url + "kfgl/html/plan-item-detail.html?openid=" + openid + "&planIds=" + json.getString("planIds") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented")+"&doctor="+json.getString("doctor"));
                temp.setTemplate_id(template_doctor_service);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
@ -861,6 +861,10 @@ public class PushMsgTask {
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
                WechatTemplateData keyword3 = new WechatTemplateData();
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
            }
            temp.setData(m);

+ 1 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/messages/ImMessageController.java

@ -1,17 +1,12 @@
package com.yihu.wlyy.web.common.messages;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -19,9 +14,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/im/common/message", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-消息")
@ -36,7 +28,7 @@ public class ImMessageController extends BaseController {
    public String messages(@ApiParam(name = "type", value = "文章审核的时候必传,消息类型,14:提交文章审核,15:审核结果")
                               @RequestParam(value = "type", required = false,defaultValue = "15") Integer type) {
        try {
            JSONObject json = messageService.findDoctorAllMessage(getUID(),type);
            JSONObject json = messageService.findDoctorAllMessage(getUID(),type,1);
            return write(200, "获取消息总数成功!", "data", json);
        } catch (Exception e) {
            error(e);

+ 77 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -676,6 +676,7 @@ public class DataHandingService {
    @Transactional(rollbackFor = Exception.class)
    public void updateDeviceGrantDoctor()throws Exception{
        //取出所有符合逻辑的已发放的设备
        String sql ="SELECT" +
                " wd.device_code,s.* FROM device.wlyy_devices wd" +
                " LEFT JOIN (" +
@ -683,15 +684,61 @@ public class DataHandingService {
                " LEFT JOIN wlyy.wlyy_doctor d ON wat.leader_code = d.`code`" +
                " WHERE available = 1" +
                ") s ON wd.grant_admin_team = s.id" +
                " WHERE  wd.is_grant = 1 AND wd.grant_admin_team IN(SELECT id from wlyy.wlyy_admin_team where available=1)";
                " WHERE  wd.is_grant = 1 AND (wd.grant_doctor IS NULL OR wd.grant_doctor ='') AND wd.grant_admin_team IN(SELECT id from wlyy.wlyy_admin_team where available=1)";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        //wlyy_patient_device取出对应的device_sn和doctor
        String patientDeviceSql ="SELECT device_sn,doctor,doctor_name FROM `wlyy_patient_device`  WHERE doctor IS NOT NULL and  doctor = '' and category_code IN('1','2') GROUP BY device_sn";
        List<Map<String,Object>> patientDeviceList = jdbcTemplate.queryForList(patientDeviceSql);
        String patientDeviceLogSql ="SELECT s.* FROM" +
                "(SELECT device_sn, operator doctor, operator_name doctor_name FROM" +
                " wlyy_patient_device_log WHERE device_sn NOT IN (SELECT device_sn FROM wlyy_patient_device WHERE" +
                " category_code IN ('1', '2') AND doctor IS NOT NULL GROUP BY device_sn )" +
                " AND category_code IN ('1', '2')" +
                " AND operate_code = 1" +
                " AND is_del = 1" +
                " AND role = 1" +
                " ORDER BY" +
                " create_time" +
                " ) s" +
                " GROUP BY" +
                " s.device_sn";
        //List<Map<String,Object>> patientDeviceLogList = jdbcTemplate.queryForList(patientDeviceLogSql);
        patientDeviceList.addAll(jdbcTemplate.queryForList(patientDeviceLogSql));
        List<String> sqlList = new ArrayList<>();
        //设备列表和绑定关系列表比对,存入绑定医生的doctor,没有的存团队长
        for (Map<String,Object> map : list){
            String updateSql ="update device.wlyy_devices set grant_doctor='"+String.valueOf(map.get("code"))+"'," +
                    " grant_doctor_name='"+String.valueOf(map.get("name"))+"'"+
                    " where device_code='"+String.valueOf(map.get("device_code"))+"'";
            int count =0;
            String doctor = "";
            String doctorName="";
            String deviceCode = String.valueOf(map.get("device_code"));
            for (Map<String,Object> patientDeviceMap : patientDeviceList){
                if (deviceCode.equals(String.valueOf(patientDeviceMap.get("device_sn")))){
                    count++;
                    doctor=String.valueOf(patientDeviceMap.get("doctor"));
                    doctorName=String.valueOf(patientDeviceMap.get("doctor_name"));
                }
            }
            if (count==0){
                doctor = String.valueOf(map.get("code"));
                doctorName=String.valueOf(map.get("name"));
            }
            if (StringUtils.isEmpty(doctorName) || "null".equals(doctorName)){
                Doctor doctorDo = doctorDao.findByCode(doctor);
                if (doctorDo!=null){
                    doctorName = doctorDo.getName();
                }
            }
            String updateSql ="update device.wlyy_devices set grant_doctor='"+doctor+"'," +
                    " grant_doctor_name='"+doctorName+"'"+
                    " where device_code='"+deviceCode+"'";
            sqlList.add(updateSql);
        }
        String[] sqlStr = new String[sqlList.size()];
        sqlStr = sqlList.toArray(sqlStr);
        jdbcTemplate.batchUpdate(sqlStr);
@ -750,4 +797,30 @@ public class DataHandingService {
        }
        return result;
    }
    @Transactional(rollbackFor = Exception.class)
    public void addPatientDeviceDoctor()throws Exception{
        String patientDeviceSql="SELECT * FROM wlyy_patient_device WHERE doctor IS NULL OR doctor = ''";
        List<PatientDevice> patientDeviceList = jdbcTemplate.query(patientDeviceSql,new BeanPropertyRowMapper<>(PatientDevice.class));
        List<String> sqlList = new ArrayList<>();
        for (PatientDevice patientDevice : patientDeviceList){
            SignFamily signFamily = signFamilyDao.findByPatient(patientDevice.getUser());
            if (signFamily==null && signFamilyDao.findLastJySignByPatient(patientDevice.getUser(),2)!=null && signFamilyDao.findLastJySignByPatient(patientDevice.getUser(),2).size()>0){
                signFamily = signFamilyDao.findLastJySignByPatient(patientDevice.getUser(),2).get(0);
            }
            if (signFamily!=null){
                String doctorSql ="SELECT d.`code`,d.`name` FROM wlyy_admin_team wat LEFT JOIN wlyy_doctor d ON wat.leader_code = d.`code` WHERE wat.id='"+signFamily.getAdminTeamId()+"'";
                List<Map<String,Object>> doctorList = jdbcTemplate.queryForList(doctorSql);
                if (doctorList!=null && doctorList.size()>0){
                    String updateSql ="update wlyy_patient_device set doctor='"+String.valueOf(doctorList.get(0).get("code"))
                            +"',doctor_name='"+String.valueOf(doctorList.get(0).get("name"))+"' where id="+patientDevice.getId();
                    sqlList.add(updateSql);
                }
            }
        }
        String[] sqlStr = new String[sqlList.size()];
        sqlStr = sqlList.toArray(sqlStr);
        jdbcTemplate.batchUpdate(sqlStr);
    }
}

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -390,4 +390,17 @@ public class DataHandlingController extends BaseController {
        }
    }
    @RequestMapping(value = "/addPatientDeviceDoctor",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("更新居民设备关系表中绑定医生字段")
    public String addPatientDeviceDoctor(){
        try{
            dataHandingService.addPatientDeviceDoctor();
            return write(200,"清洗数据成功");
        }catch (Exception e){
            System.out.println(e.getMessage());
            e.printStackTrace();
            return write(-1,"清洗数据失败!");
        }
    }
}

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

@ -52,9 +52,11 @@ public class DoctorMessageController extends BaseController {
    @ResponseBody
    @ApiOperation("查询医生未读消息和最后消息")
    public String messages(@ApiParam(name = "type", value = "文章审核的时候必传,消息类型,14:提交文章审核,15:审核结果")
                               @RequestParam(value = "type", required = false) Integer type) {
                               @RequestParam(value = "type", required = false) Integer type,
    @ApiParam(name = "flag", value = "标识家医/专科")
    @RequestParam(value = "flag", required = false) Integer flag) {
        try {
            JSONObject json = messageService.findDoctorAllMessage(getUID(),type);
            JSONObject json = messageService.findDoctorAllMessage(getUID(),type,flag);
            return write(200, "获取消息总数成功!", "data", json);
        } catch (Exception e) {
            error(e);
@ -716,18 +718,46 @@ public class DoctorMessageController extends BaseController {
    @ResponseBody
    @ApiOperation("一键已读" )
    public String setMessageRead(@ApiParam(name = "types",value = "消息集合")
                                     @RequestParam(value = "types")String types) {
                                     @RequestParam(value = "types")String types,
                                 @ApiParam(name = "flag",value = "标识家医/专科")
                                 @RequestParam(value = "flag")Integer flag) {
        try {
            com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(types);
            List<Integer> typeList = new ArrayList<>();
            for (int i=0;i<array.size();i++){
                typeList.add(array.getInteger(i));
            }
            return write(200, "获取消息总数成功!", "data", messageService.setMessageReaded(getUID(),typeList));
            return write(200, "获取消息总数成功!", "data", messageService.setMessageReaded(getUID(),typeList,flag));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     * 设置待办消息已处理
     *
     * @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());
        }
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -189,8 +189,8 @@ es:
jkEdu:
  web:
#    articleBaseUrl: http://yihu.com:9088/
    articleBaseUrl: http://172.19.103.78:9092/
#    articleBaseUrl: http://172.19.103.87:9088/
#    articleBaseUrl: http://172.19.103.78:9092/
    articleBaseUrl: http://172.19.103.87:9088/
#消息队列
activemq:

+ 2 - 2
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt

@ -55,9 +55,9 @@
        	    "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjf%2fhtml%2funopened.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
         {
                "type":"view",
                "type":"click",
                "name":"用户指南",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjtgx%2fhtml%2ffamily.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
                "key":"caozuoshuoming"
         }
	 ]
  }

+ 51 - 78
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

@ -2,96 +2,69 @@
"button":[
   {
	  "name":"家庭医生",
	  "sub_button":[
	      {
            "type":"view",
            "name":"健康评估",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkpg%2fhtml%2fjkpg.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          },
		  {
			"type":"view",
			"name":"签约管理",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fqygl%2fhtml%2fsigning_management.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生咨询",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszx%2fhtml%2fdoctor-consultation.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
			"type":"view",
			"name":"医生指导",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszd%2fhtml%2fdoctor-guidance.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		  },
		  {
            "type":"view",
            "name":"健康文章",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjy%2fhtml%2farticle_list.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          }
	  ]
	  "type":"view",
      "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fhome%2fhtml%2findex.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
   },
   {
	  "name":"健康管理",
	  "name":"快捷服务",
	  "sub_button":[
		 {
			  "type":"view",
			  "name":"预约挂号",
			  "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fappointment-register.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		 },
         		"type":"view",
         		"name":"预约挂号",
         		"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdyy%2fhtml%2fappointment-register.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		 {
            	"type":"view",
         	    "name":"医生咨询",
         		"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyszx%2fhtml%2fdoctor-consultation.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		 {
               "type":"view",
               "name":"健康记录",
               "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjl%2fhtml%2fhealth-record.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
                "type":"view",
               	"name":"健康评估",
               	"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkpg%2fhtml%2fjkpg.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
         {
                "type":"view",
                "name":"康复管理",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fkfgl%2fhtml%2frecover_manage.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		{
			"type":"click",
			"name":"健康档案",
			"key":"jiankangdangan"
		},
         {
            "type":"view",
            "name":"疾病社区",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjbsq%2fhtml%2fdisease-community.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
        {
                    "type":"click",
                    "name":"妇幼保健",
                    "key":"fuyoubaojian"
        }
                "type":"view",
                "name":"慢病管理",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjbsq%2fhtml%2fslow-disease-manage.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         }
	  ]
   },
   {
	  "name":"我的",
	  "sub_button":[
		{
		   "type":"view",
		   "name":"集美家签特色",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fdist%2fhtml%2fexclusive-service.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
		{
           "type":"view",
           "name":"电子健康卡",
           "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-health-card.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
		{
		   "type":"view",
		   "name":"我的资料",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-detail.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
           "type":"view",
           "name":"我的家庭",
           "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjtgx%2fhtml%2ffamily.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        },
		{
		   "type":"view",
		   "name":"我的设备",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdsb%2fhtml%2fmy-equipments.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		}
	     {
         		"type":"view",
         		"name":"集美家签特色",
         		"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fdist%2fhtml%2fexclusive-service.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		 {
                "type":"view",
                "name":"电子健康卡",
                "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-health-card.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
         {
        		"type":"view",
        		"name":"我的资料",
        		"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-detail.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
		 {
        	    "type":"view",
        	    "name":"健康银行",
        	    "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjf%2fhtml%2funopened.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
         },
         {
                "type":"click",
                "name":"用户指南",
                "key":"caozuoshuoming"
         }
	 ]
  }],
    "matchrule":{
      "tag_id":"103"
      }
  }
]
}