Procházet zdrojové kódy

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

humingfen před 5 roky
rodič
revize
a11f18568d

+ 5 - 0
business/base-service/pom.xml

@ -137,6 +137,11 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.3.13.RELEASE</version>
        </dependency>
    </dependencies>
    <build>

+ 51 - 3
business/base-service/src/main/java/com/yihu/jw/file_upload/FileUploadService.java

@ -14,19 +14,19 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.apache.poi.util.IOUtils;
import org.csource.common.MyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
@ -203,6 +203,54 @@ public class FileUploadService {
        }
        throw new Exception();
    }
    
    
    /**
     * 调用健康上传语音文件
     * @param voices_Path
     * @return
     * @throws Exception
     */
    public String uploadWxVoice(String voices_Path) throws Exception {
        String url = "";
        // 文件保存的临时路径
        FastDFSUtil fastDFSUtil = new FastDFSUtil();
        String fileUrls = "";
        File f = new File(voices_Path);
        if (f.exists()) {
            FileInputStream input = new FileInputStream(f);
            MultipartFile multipartFile = new MockMultipartFile("file", f.getName(), "text/plain", IOUtils.toByteArray(input));
            
            long size = multipartFile.getSize();
            if(size<=0){
//                map.put("uploadStatus",1);//size小于0
//                map.put("accessoryUrl",null);//
                return url;
            }
            String fileName = multipartFile.getOriginalFilename();
            String[] fs = fileName.split("\\.");
            String type = fs[1];
            logger.info("uploadImg type:"+type);
            //图片常见格式:bmp,jpg,png,tif,gif,pcx,tga,exif,fpx,svg,psd,cdr,pcd,dxf,ufo,eps,ai,raw,WMF,webp
//        List img = new ArrayList(Arrays.asList("bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp"));
//        if (!img.contains(type)) {
//            map.put("uploadStatus",2);//文件类型不对
//            map.put("accessoryUrl",null);//
//            return map;
//        }
            String response = request(wlyyUrl + "/upload/chat", multipartFile, null);
            org.json.JSONObject rs = new org.json.JSONObject(response);
            Integer status = (Integer) rs.get("status");
            if (status == 200) {
                url = rs.get("urls") + "";
//                map.put("uploadStatus", 0);//文件类型正确
//                map.put("accessory", url);//
                return url;
            }
            throw new Exception();
        }
        return url;
    }
    public String request(String remote_url, MultipartFile file, String type) {
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();

+ 13 - 8
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -2913,8 +2913,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if(StringUtils.isNotBlank(workingTime)){
            sql+=" JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
        }
        sql +=  " WHERE  " +
                " d.charge_type is not null ";
        sql +=  " WHERE  1=1 ";
        if(StringUtils.isBlank(chargType)){
            sql +=" AND d.charge_type is not null ";
        }
        if(StringUtils.isNotBlank(chargType)){
            if("all".equals(chargType)){
                //不过滤
            }else{
                sql+=" AND d.charge_type = '"+chargType+"'";
            }
        }
        if(StringUtils.isNotBlank(iswork)&&"1".equals(iswork)){
            logger.info("iswork:"+iswork);
@ -2932,7 +2942,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    " )";
        }
        if(StringUtils.isNotBlank(orgCode)){
            sql += " and  h.org_code = '"+orgCode+"'";
            sql += " AND  h.org_code = '"+orgCode+"'";
        }
        if(StringUtils.isNotBlank(diseaseKey)){
            sql+=" AND d.expertise like '%"+diseaseKey+"%'";
@ -2982,11 +2992,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql+=" AND d.consult_status = '"+consultStatus+"' ";
        }
    
    
        if(StringUtils.isNotBlank(chargType)){
            sql+=" AND d.charge_type = '"+chargType+"'";
        }
    
        sql += " and d.del='1' order by a.total "+ consutlSort +" limit "+page * pagesize +","+pagesize;
        
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);

+ 30 - 2
business/base-service/src/main/java/com/yihu/jw/wlyy/service/WlyyBusinessService.java

@ -377,6 +377,7 @@ public class WlyyBusinessService {
            JSONArray hospitals = JSONArray.parseArray(re.getString("data"));
            logger.info("hospitals size:"+hospitals.size());
            if(hospitals!=null&&hospitals.size()>0){
                Integer addCount = 0;
                for(int i=0;i<hospitals.size();i++){
                    JSONObject h = (JSONObject) hospitals.get(i);
                    String code = h.getString("code");
@ -393,9 +394,10 @@ public class WlyyBusinessService {
                        org.setType("1");
                        org.setWinNo("-1");
                        baseOrgDao.save(org);
                        addCount++;
                    }
                }
                logger.info("hospitals addCount:"+addCount);
            }
        }
        return "ok";
@ -407,6 +409,7 @@ public class WlyyBusinessService {
            JSONArray depts = JSONArray.parseArray(re.getString("data"));
            logger.info("depts size:"+depts.size());
            if(depts!=null&&depts.size()>0){
                Integer addCount = 0;
                for(int i=0;i<depts.size();i++){
                    JSONObject d = (JSONObject) depts.get(i);
                    String code = d.getString("code");
@ -419,9 +422,11 @@ public class WlyyBusinessService {
                        deptDO.setConsultDeptFlag("1");
                        deptDO.setCreateTime(new Date());
                        dictHospitalDeptDao.save(deptDO);
                        addCount++;
                    }
                }
                logger.info("Dept addCount"+addCount);
            }
        }
        return "ok";
@ -444,7 +449,28 @@ public class WlyyBusinessService {
                        if(StringUtils.isNotBlank(idcard)) {
                            List<BaseDoctorDO> ds = baseDoctorDao.findByIdcard(idcard);
                            if (ds != null && ds.size() > 0) {
                                //已有账号不更新
                                //已有账号更新
                                BaseDoctorDO doctor = ds.get(0);
                                doctor.setName(doctorJson.getString("name"));
                                doctor.setIdcard(doctorJson.getString("idcard"));
                                doctor.setMobile(doctorJson.getString("mobile"));
                                doctor.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)));
                                doctor.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
                                doctor.setProvinceCode(doctorJson.getString("province"));
                                doctor.setProvinceName(doctorJson.getString("provinceName"));
                                doctor.setTownCode(doctorJson.getString("town"));
                                doctor.setTownName(doctorJson.getString("townName"));
                                doctor.setCityCode(doctorJson.getString("city"));
                                doctor.setCityName(doctorJson.getString("cityName"));
                                doctor.setExpertise(doctorJson.getString("expertise"));
                                doctor.setIntroduce(doctorJson.getString("introduce"));
                                String jobName = doctorJson.getString("jobName");
                                doctor.setJobTitleCode(getDutysCode(dutys, jobName));
                                doctor.setJobTitleName(jobName);
                                baseDoctorDao.save(doctor);
                            } else {
                                BaseDoctorDO doctor = new BaseDoctorDO();
@ -459,6 +485,8 @@ public class WlyyBusinessService {
                                doctor.setTownName(doctorJson.getString("townName"));
                                doctor.setCityCode(doctorJson.getString("city"));
                                doctor.setCityName(doctorJson.getString("cityName"));
                                doctor.setExpertise(doctorJson.getString("expertise"));
                                doctor.setIntroduce(doctorJson.getString("introduce"));
                                //认证信息设置
                                String salt = randomString(5);

+ 73 - 33
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -413,15 +413,22 @@ public class ImService {
		}
		
		String[] arr = null;
		if (type == 3) {
//			String path = fetchWxVoices(wechat_appid);
//			JSONObject obj = new JSONObject();
//			// 将临时语音拷贝到正式存储路径下
//			if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
//				content = fileUtil.copyTempVoice(path,fastdfs_file_url);
//				obj.put("path", path);
//				obj.put("times", times);
//				content = obj.toString();
		if (type == 3) {//语音文件处理
//			if(!StringUtils.isEmpty(wechat_appid)){
//				String path = fetchWxVoices(wechat_appid);
//				JSONObject obj = new JSONObject();
//				// 将临时语音拷贝到正式存储路径下
//				if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
//					if("xm_ihealth_wx".equals(wechat_appid)){
//						Map<String, Object> map = fileUploadService.uploadImg(file);
//						uploadVO.setFullUri(map.get("accessory").toString());
//					}else{
//						content = fileUtil.copyTempVoice(path,fastdfs_file_url);
//					}
//					obj.put("path", path);
//					obj.put("times", times);
//					content = obj.toString();
//				}
//			}
			ConsultTeamLogDo log = new ConsultTeamLogDo();
			log.setConsult(consult);
@ -649,7 +656,13 @@ public class ImService {
	 * @return
	 */
	public InputStream getInputStream(String mediaId,String wechat_appid) {
		String accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
		String accessToken = "";
		//中山医院互联网医院
		if("xm_zsyy_wx".equals(wechat_appid)){
			accessToken = entranceService.getAccessToken("100033");
		}else{
			accessToken = wxAccessTokenService.getWxAccessTokenById(wechat_appid).getAccessToken();
		}
		InputStream is = null;
		String url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
		try {
@ -1581,29 +1594,56 @@ public class ImService {
			pagesize = 10;
		}
		
		String  sql = "SELECT " +
				"a.id AS id," +
				"a.type AS type," +
				"a.title AS title," +
				"a.symptoms AS symptoms," +
				"a.czrq AS czrq," +
				"b.status AS status," +
				"b.evaluate AS evaluate," +
				"d.name AS patientName," +
				"d.id as patientId," +
				"d.idcard as patientIdcard," +
				"d.sex as patientsex," +
				"op.id as outpatientid," +
				"op.type as consultType," +
				"op.general_doctor as generalDoctor," +
				"op.icd10_name as icd10Name," +
				"d.photo AS patientphoto " +
				"FROM wlyy_consult a," +
				"wlyy_consult_team b," +
				"base_patient d, " +
				"wlyy_outpatient op " +
				"WHERE a.id=b.consult " +
				"AND b.patient=d.id AND b.doctor='"+doctor+"' AND a.relation_code = op.id ";
		String  sql = "";
		if(1 == type || 15 ==type){
			sql = "SELECT " +
					"a.id AS id," +
					"a.type AS type," +
					"a.title AS title," +
					"a.symptoms AS symptoms," +
					"a.czrq AS czrq," +
					"b.status AS status," +
					"b.evaluate AS evaluate," +
					"d.name AS patientName," +
					"d.id as patientId," +
					"d.idcard as patientIdcard," +
					"d.sex as patientsex," +
					"d.photo AS patientphoto " +
					"FROM wlyy_consult a," +
					"wlyy_consult_team b," +
					"base_patient d " +
					"WHERE a.id=b.consult " +
					"AND b.patient=d.id AND b.doctor='"+doctor+"'";
		}else{
			
			sql = "SELECT " +
					"a.id AS id," +
					"a.type AS type," +
					"a.title AS title," +
					"a.symptoms AS symptoms," +
					"a.czrq AS czrq," +
					"b.status AS status," +
					"b.evaluate AS evaluate," +
					"d.name AS patientName," +
					"d.id as patientId," +
					"d.idcard as patientIdcard," +
					"d.sex as patientsex," +
					"op.id as outpatientid," +
					"op.type as consultType," +
					"op.general_doctor as generalDoctor," +
					"op.icd10_name as icd10Name," +
					"d.photo AS patientphoto " +
					"FROM wlyy_consult a," +
					"wlyy_consult_team b," +
					"base_patient d, " +
					"wlyy_outpatient op " +
					"WHERE a.id=b.consult " +
					"AND b.patient=d.id AND b.doctor='"+doctor+"' AND a.relation_code = op.id ";
		}
		
		
		
		List<ConsultVO> result = new ArrayList<>();
		
		if(!StringUtils.isEmpty(title)){

+ 32 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -8,6 +8,7 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.service.ImService;
@ -20,6 +21,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.FileUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.WechatDao;
@ -33,6 +35,7 @@ import org.apache.axis.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.net.URLEncoder;
@ -80,6 +83,14 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	private BasePatientDao basePatientDao;
	
	@Autowired
	FileUploadService fileUploadService;
	
	public FileUtil fileUtil;
	
	@Value("${fastDFS.fastdfs_file_url}")
	private String fastdfs_file_url;
	
	@GetMapping(value = BaseHospitalRequestMapping.PatientIM.records)
	@ApiOperation(value = "患者咨询记录查询")
	public Envelop records(
@ -214,11 +225,30 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "type",required = true) Integer type,
			@ApiParam(name = "times", value = "")
			@RequestParam(value = "times",required = false) Integer times,
			@ApiParam(name = "wechat_appid", value = "")
			@ApiParam(name = "wechat_appid", value = "来源:xm_ihealth_wx厦门i健康,xm_zsyy_wx中山医院")
			@RequestParam(value = "wechat_appid",required = false) String wechat_appid,
			@ApiParam(name = "patientCode", value = "居民CODE")
			@RequestParam(value = "patientCode",required = false) String patientCode) throws Exception {
		List<String> failed = new ArrayList<>();
		
		//处理语音文件
		if(!org.springframework.util.StringUtils.isEmpty(wechat_appid)){
			String path = imService.fetchWxVoices(wechat_appid);
			JSONObject obj = new JSONObject();
			// 将临时语音拷贝到正式存储路径下
			if (org.apache.commons.lang3.StringUtils.isNotEmpty(path)) {
				if("xm_ihealth_wx".equals(wechat_appid)){
					content = fileUploadService.uploadWxVoice(path);
//					uploadVO.setFullUri(map.get("accessory").toString());
				}else{
					content = fileUtil.copyTempVoice(path,fastdfs_file_url);
				}
				obj.put("path", path);
				obj.put("times", times);
				content = obj.toString();
			}
		}
		
		failed = imService.append(consult,content,type,times,patientCode,wechat_appid);
		return success(failed);
	}
@ -228,7 +258,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
	public ListEnvelop findDoctorByHospitalAndDiseaseAndDept(@ApiParam(name = "iswork", value = "机构code")
																 @RequestParam(value = "iswork", required = false)String iswork,
			                                       @ApiParam(name = "orgCode", value = "机构code")
	                                               @RequestParam(value = "orgCode", required = false,defaultValue = "350211A1002")String orgCode,
	                                               @RequestParam(value = "orgCode", required = false)String orgCode,
	                                               @ApiParam(name = "dept", value = "部门code")
	                                               @RequestParam(value = "dept", required = false)String dept,
	                                               @ApiParam(name = "diseaseKey", value = "疾病名称关键字")