Переглянути джерело

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

# Conflicts:
#	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/TaskService.java
wangzhinan 7 роки тому
батько
коміт
ca418fd08b

+ 3 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/SignFamilyDao.java

@ -37,4 +37,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =1 and a.status = 1")
	SignFamily findBySanshiPatientYes(String id);
	@Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status > 0")
	SignFamily findByPatient(String code);
}

+ 6 - 1
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -503,7 +503,12 @@ public class DeviceService extends BaseService{
            } else {
                //患者信息
                String patientCode = result.getUser();
                SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
                Patient patient = patientDao.findByCode(patientCode);
                String hospital = "";
                if (signFamily!=null){
                    hospital = signFamily.getHospital();
                }
                String flagStr = "";
                if (deviceType==1){
@ -514,7 +519,7 @@ public class DeviceService extends BaseService{
                try {
                    //增加积分
                    if (dataUoloadCount == 0 && "350205".equals(patient.getTown())){
                    if (dataUoloadCount == 0 && "350205".equals(hospital.substring(0,6))){
                        String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'";
                        Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql);
                        if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/BaseInterceptor.java

@ -26,7 +26,7 @@ abstract public class BaseInterceptor implements HandlerInterceptor {
			if (StringUtils.isEmpty(userAgent)) {
				userAgent = request.getHeader("User-Agent");
			}
			logger.info("userAgent:" + userAgent);
			logger.debug("userAgent:" + userAgent);
			return new JSONObject(userAgent);
		} catch (Exception e) {
			return null;

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

@ -49,7 +49,7 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 ")
    List<Message> findByPatientRenew(String patient, String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.sender=?2 and a.tzType=?3 and a.del=1 and a.over=1 order by a.createTime desc")
    @Query("select a from Message a where a.receiver = ?1 and a.sender=?2 and a.tzType=?3  and a.over=1 order by a.createTime desc")
    List<Message> getHealthIndexMessageByPatient(String doctor, String patient, String type, Pageable pageRequest);
    //查询医生下的签约居民未读体征异常消息

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -431,6 +431,6 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    int hasSignCount(String idcard);
    //根据patient查找有效签约的hospital
    @Query("select a.hospital from SignFamily a where a.patient = ?1 and (a.status = 1 or a.status = 2) and a.expensesStatus = '1'")
    @Query("select a.hospital from SignFamily a where a.patient = ?1 and a.status = 1 and a.expensesStatus = '1'")
    String getHospital(String patient);
}

+ 84 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java

@ -7,12 +7,18 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -49,8 +55,6 @@ public class CreditLogService {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SystemDictDao systemDictDao;
@ -59,6 +63,17 @@ public class CreditLogService {
    @Autowired
    private SignFamilyDao signFamilyDao;
    
    @Autowired
    private PatientService patientService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    /**
@ -132,6 +147,9 @@ public class CreditLogService {
     * @return
     */
    public JSONObject insert(JSONObject object) throws Exception {
    
        JSONObject result = new JSONObject();
        
        String response = null;
        String patientId = object.getString("patientId");
        Patient patient = patientDao.findByCode(patientId);
@ -151,10 +169,73 @@ public class CreditLogService {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
        
        result = JSONObject.parseObject(response);
        String status = result.getString("status");
        logger.info("健康银行居民新增积分:"+result.toString());
        if ("200".equals(status)){
            List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
            if (list!=null && list.size()>0){
                //积分
                String integrateresult = String.valueOf(list.get(0).get("integrate"));
                String patientid = String.valueOf(list.get(0).get("patientId"));
                String total = String.valueOf(list.get(0).get("total"));
                
                try {
                    //@TODO 获取积分调用发送微信模板接口
                    Patient people = patientDao.findByCode(patientid);
                    String openId = people.getOpenid();
                    String name = people.getName();
                
                    org.json.JSONObject sendJson = new org.json.JSONObject();
                    String first = "";
                    String remark = "";
                    String urlresult = "";
                
                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                    first = templateConfig.getFirst();
                    remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
                
                    sendJson.put("keyword1", integrateresult);
                    sendJson.put("keyword2", DateUtil.getStringDate());
                    sendJson.put("keyword3", total);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    urlresult = templateConfig.getUrl();
                    urlresult = urlresult.replace("key1",(integrateresult==null?"":integrateresult));
                    sendJson.put("url", urlresult);//带参数的模板跳转链接
                    System.out.println(sendJson.toString());
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, openId, name, sendJson);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
//		                    for (int i = 0; i < jsonArray.length(); i++) {
//			                    org.json.JSONObject j = jsonArray.getJSONObject(i);
//			                    Patient member = (Patient) j.get("member");
//			                    int start = url.indexOf("&toUser=");
//			                    int end = url.indexOf("&", start + 1);
//			                    String touser = url.substring(start, end);
//			                    url = url.replace(touser, "&toUser=" + member.getCode());
//			                    //name患者姓名
//			                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
//			                    sendJson.put("url", url);
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
                }catch (Exception e){
                    logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                }
            
            }
        }
        
        return result;
    }
    /**
     * 按条件查询积分
     *

+ 10 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/TaskService.java

@ -84,7 +84,7 @@ public class TaskService {
     */
    public JSONObject selectActivity(JSONObject object,Integer page,Integer size){
        String response = null;
        String url ="http://localhost:10051/svr-health-bank/" + "findActivity";
        String url =getBaseUrl() + "findActivity";
        Map<String,String> params = new HashMap<>();
        params.put("activity",object.toJSONString());
        params.put("page",page.toString());
@ -135,7 +135,6 @@ public class TaskService {
        String response = null;
        String patientId = object.getString("patientId");
        SignFamily signFamily = signFamilyDao.findByPatient(patientId);
        String taskCode = object.getString("taskCode");
        if (signFamily == null){
            throw new Exception("已签约居民,才能报名!");
        }else if (signFamily!=null&&!signFamily.getExpensesStatus().equalsIgnoreCase("1")){
@ -143,18 +142,17 @@ public class TaskService {
        }
        Patient patient = patientDao.findByCode(patientId);
        String unionId = object.getString("unionId");
        if (StringUtils.isNoneBlank(taskCode)&&taskCode.equalsIgnoreCase("ACTIVITY_STEP")){
            if(StringUtils.isNoneBlank(patient.getUnionid())){
        if(!StringUtils.isNoneBlank(patient.getUnionid())){
            throw new Exception("该居民已报名!");
        }else {
            Patient patient1 = patientDao.findByUnionid(unionId);
            if (patient1 != null){
                throw new Exception("该居民已报名!");
            }else {
                Patient patient1 = patientDao.findByUnionid(unionId);
                if (patient1 != null){
                    throw new Exception("该居民已报名!");
                }
                patient.setUnionid(unionId);
                patientDao.save(patient);
            }
            patient.setUnionid(unionId);
            patientDao.save(patient);
        }
        object.put("unionId",unionId);
        object.put("patientIdcard",patient.getIdcard());
        object.put("patientOpenid",patient.getOpenid());
@ -252,7 +250,7 @@ public class TaskService {
        String step = redisTemplate.opsForValue().get(STEP);
        String step1 = systemDictDao.findByDictNameAndCode("HEALTH_STEP","HEALTH_STEP");
        JSONObject jsonObject = JSONObject.parseObject(step1);
        if (StringUtils.isNoneBlank(step) && step.equalsIgnoreCase(step1)){
        if (step1 != null && step.equalsIgnoreCase(step1)){
            return jsonObject;
        }else {
            redisTemplate.opsForValue().set(STEP,step1);