Prechádzať zdrojové kódy

服务码在1.0代码中生成

zd_123 7 rokov pred
rodič
commit
3f4a9925d8

+ 56 - 0
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";//康复管理-康复计划列表
@ -419,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());