Ver código fonte

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

huangwenjie 7 anos atrás
pai
commit
17f2fc4c62

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

@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -153,8 +154,13 @@ public class TaskService {
     *
     * @return
     */
    public JSONObject selectByOpenId(String openId){
        Patient patient = patientDao.findByOpenid(openId);
    public JSONObject selectByOpenId(String openId,String code){
        String sql = "select * from wlyy_patient where code = '"+code+"' and openid = '"+openId+"'";
        List<Patient> patients = jdbcTemplate.query(sql,new BeanPropertyRowMapper(Patient.class));
        Patient patient = new Patient();
        if (patients != null && patients.size()!=0){
            patient = patients.get(0);
        }
        List<Patient> patientList = new ArrayList<>();
        JSONObject object = new JSONObject();
        if (patient != null){

+ 82 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/CreditsLogController.java

@ -4,8 +4,15 @@
package com.yihu.wlyy.web.patient.health.bank;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.health.bank.CreditLogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -18,6 +25,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-07 8:50
@ -31,6 +41,14 @@ public class CreditsLogController extends BaseController {
    @Autowired
    private CreditLogService service;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    /**
@ -66,11 +84,73 @@ public class CreditsLogController extends BaseController {
     */
    @RequestMapping(value = "/insertCredits",method = RequestMethod.POST)
    @ApiOperation("添加积分")
    public String insert(@ApiParam(name = "creditsDetail",value = "居民对象JSON")
                          @RequestParam(name = "creditsDetail") String creditsDetail){
    public String insert(@ApiParam(name = "creditsDetail",value = "居民id集合")
                         @RequestParam(name = "creditsDetail") String creditsDetail){
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            JSONObject result = service.insert(object);
            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 integrate = 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 url = "";
                        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                        first = templateConfig.getFirst();
                        remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
                        sendJson.put("keyword1", integrate);
                        sendJson.put("keyword2", DateUtil.getStringDate());
                        sendJson.put("keyword3", total);
                        sendJson.put("first", first);
                        sendJson.put("remark", remark);
                        url = templateConfig.getUrl();
                        url = url.replace("key1",(integrate==null?"":integrate));
                        sendJson.put("url", url);//带参数的模板跳转链接
                        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 write(200,"添加成功","data",result);
        }catch (Exception e){
            error(e);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/TaskController.java

@ -114,7 +114,7 @@ public class TaskController extends BaseController{
    @ApiOperation("获取用户信息")
    public String selectByOpenId(){
        try {
            return write(200,"添加成功","data",service.selectByOpenId(getOpenid()));
            return write(200,"查询成功","data",service.selectByOpenId(getOpenid(),getUID()));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());