Browse Source

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

yeshijie 4 years ago
parent
commit
493e6e537f
35 changed files with 1150 additions and 173 deletions
  1. 6 0
      business/base-service/pom.xml
  2. 9 4
      business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java
  3. 136 0
      business/base-service/src/main/java/com/yihu/jw/file_upload/FileManageService.java
  4. 4 3
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  5. 142 61
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  6. 55 7
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  7. 2 8
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  8. 91 0
      business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java
  9. 15 0
      business/base-service/src/main/java/com/yihu/jw/utils/AdminException.java
  10. 47 0
      business/base-service/src/main/java/com/yihu/jw/utils/FileUtil.java
  11. 26 0
      business/base-service/src/main/java/com/yihu/jw/utils/sfutils/MyErrorCode.java
  12. 9 1
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  13. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java
  14. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  15. 3 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  16. 73 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/MutilFileInfo.java
  17. 9 7
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyHisPrescriptionVO.java
  18. 33 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  19. 5 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  20. 32 21
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java
  21. 8 5
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  22. 17 0
      svr/svr-base/src/main/java/com/yihu/jw/base/util/ExceptionHandler.java
  23. 23 0
      svr/svr-base/src/main/java/com/yihu/jw/base/util/ExceptionResult.java
  24. 1 1
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java
  25. 2 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/Application.java
  26. 9 10
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/OutPatientRemindJob.java
  27. 2 2
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java
  28. 129 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/AutoTimeOutRemind.java
  29. 19 14
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java
  30. 8 4
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  31. 2 1
      svr/svr-internet-hospital-job/src/main/resources/system.properties
  32. 4 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  33. 68 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java
  34. 111 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  35. 38 17
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

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

@ -179,6 +179,12 @@
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.4</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>

+ 9 - 4
business/base-service/src/main/java/com/yihu/jw/doctor/service/BaseDoctorInfoService.java

@ -203,11 +203,16 @@ public class BaseDoctorInfoService extends BaseJpaService<BaseDoctorDO, BaseDoct
            }else {
                for (int i=0;i<list.size();i++){
                    if (i == 0 ){
                        disease.append(list.get(i).get("diseaseName"));
                        code.append(list.get(i).get("diseaseCode"));
                        if (list.get(i).get("diseaseName")!=null){
                            disease.append(list.get(i).get("diseaseName"));
                            code.append(list.get(i).get("diseaseCode"));
                        }
                    }else {
                        disease.append(","+list.get(i).get("diseaseName"));
                        code.append(","+list.get(i).get("diseaseCode"));
                        if (list.get(i).get("diseaseName")!=null){
                            disease.append(","+list.get(i).get("diseaseName"));
                            code.append(","+list.get(i).get("diseaseCode"));
                        }
                    }
                }
                list.get(0).put("diseaseName",disease);

+ 136 - 0
business/base-service/src/main/java/com/yihu/jw/file_upload/FileManageService.java

@ -0,0 +1,136 @@
package com.yihu.jw.file_upload;
import com.yihu.jw.restmodel.MutilFileInfo;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.utils.FileUtil;
import org.apache.commons.io.FileUtils;
import org.hibernate.service.spi.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Service
public class FileManageService {
    private static final Logger logger = LoggerFactory.getLogger(FileManageService.class);
    private String basePath = "/usr/local" ;
    private String fileUrl ="" ;
    /**
     * 分块上传
     * 第一步:获取RandomAccessFile,随机访问文件类的对象
     * 第二步:调用RandomAccessFile的getChannel()方法,打开文件通道 FileChannel
     * 第三步:获取当前是第几个分块,计算文件的最后偏移量
     * 第四步:获取当前文件分块的字节数组,用于获取文件字节长度
     * 第五步:使用文件通道FileChannel类的 map()方法创建直接字节缓冲器  MappedByteBuffer
     * 第六步:将分块的字节数组放入到当前位置的缓冲区内  mappedByteBuffer.put(byte[] b);
     * 第七步:释放缓冲区
     * 第八步:检查文件是否全部完成上传
     * @param param
     * @return
     * @throws IOException
     */
    public String chunkUploadByMappedByteBuffer(MutilFileInfo param) throws IOException {
        if(param.getTaskId() == null || "".equals(param.getTaskId())){
            param.setTaskId(UUID.randomUUID().toString());
        }
        boolean copflag =false;
        /**
         * basePath是我的路径,可以替换为你的
         * 1:原文件名改为UUID
         * 2:创建临时文件,和源文件一个路径
         * 3:如果文件路径不存在重新创建
         */
        String fileName = param.getFile().getOriginalFilename();
         //fileName.substring(fileName.lastIndexOf(".")) 这个地方可以直接写死 写成你的上传路径
        String tempFileName = param.getTaskId() + fileName.substring(fileName.lastIndexOf(".")) + "_tmp";
        String filePath = basePath+"/original";
        File fileDir = new File(filePath);
        if(!fileDir.exists()){
            fileDir.mkdirs();
        }
        File tempFile = new File(filePath,tempFileName);
        //第一步
        RandomAccessFile raf = new RandomAccessFile(tempFile,"rw");
        //第二步
        FileChannel fileChannel = raf.getChannel();
        //第三步
        long offset = param.getChunk() * param.getSize();
        //第四步
        byte[] fileData = param.getFile().getBytes();
        //第五步
        MappedByteBuffer mappedByteBuffer = fileChannel.map(FileChannel.MapMode.READ_WRITE,offset,fileData.length);
        //第六步
        mappedByteBuffer.put(fileData);
        //第七步
        FileUtil.freedMappedByteBuffer(mappedByteBuffer);
        fileChannel.close();
        raf.close();
        //第八步
        boolean isComplete = checkUploadStatus(param,fileName,filePath);
        if(isComplete){
            renameFile(tempFile,fileName);
            return filePath+"/"+fileName;
        }else {
            return "unCompelete";
        }
    }
    /**
     * 文件重命名
     * @param toBeRenamed   将要修改名字的文件
     * @param toFileNewName 新的名字
     * @return
     */
    public boolean renameFile(File toBeRenamed, String toFileNewName) {
        //检查要重命名的文件是否存在,是否是文件
        if (!toBeRenamed.exists() || toBeRenamed.isDirectory()) {
            return false;
        }
        String p = toBeRenamed.getParent();
        File newFile = new File(p + File.separatorChar + toFileNewName);
        //修改文件名
        return toBeRenamed.renameTo(newFile);
    }
    /**
     * 检查文件上传进度
     * @return
     */
    public boolean checkUploadStatus(MutilFileInfo param,String fileName,String filePath) throws IOException {
        File confFile = new File(filePath,fileName+".conf");
        RandomAccessFile confAccessFile = new RandomAccessFile(confFile,"rw");
        //设置文件长度
        confAccessFile.setLength(param.getChunkTotal());
        //设置起始偏移量
        confAccessFile.seek(param.getChunk());
        //将指定的一个字节写入文件中 127,
        confAccessFile.write(Byte.MAX_VALUE);
        byte[] completeStatusList = FileUtils.readFileToByteArray(confFile);
        byte isComplete = Byte.MAX_VALUE;
            //这一段逻辑有点复杂,看的时候思考了好久,创建conf文件文件长度为总分片数,每上传一个分块即向conf文件中写入一个127,那么没上传的位置就是默认的0,已上传的就是Byte.MAX_VALUE 127
        for(int i = 0; i<completeStatusList.length && isComplete==Byte.MAX_VALUE; i++){
            // 按位与运算,将&两边的数转为二进制进行比较,有一个为0结果为0,全为1结果为1  eg.3&5  即 0000 0011 & 0000 0101 = 0000 0001   因此,3&5的值得1。
            isComplete = (byte)(isComplete & completeStatusList[i]);
            System.out.println("check part " + i + " complete?:" + completeStatusList[i]);
        }
        if(isComplete == Byte.MAX_VALUE){
             //如果全部文件上传完成,删除conf文件
            confFile.delete();
            return true;
        }
        return false;
    }
}

+ 4 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -34,14 +34,15 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("from WlyyOutpatientDO a where a.generalDoctor = ?1 and a.registerDate >=?2 and a.registerDate <=?3 and a.status = ?4 and a.doctor is not null order by registerDate ASC")
    List<WlyyOutpatientDO> findByGeneralDoctor(String generalDoctor, Date startDate,Date endDate,String status);
    List<WlyyOutpatientDO> findByStatus(String status);
    @Query("from WlyyOutpatientDO a where a.status in(1,2) and a.payStatus = 1")
    List<WlyyOutpatientDO> findByStatus();
    List<WlyyOutpatientDO> findByDoctorAndCreateTimeAndPatientCancelRemark(String doctor,Date createTime,String patientCancelRemark);
    @Query("select count(id) from  WlyyOutpatientDO a where a.outpatientType = ?1 and a.doctor = ?2 and a.admDate >=?3 and a.admDate <=?4")
    Integer countByTime(String type,String doctor,Date startTime,Date endTime);
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1")
    List<WlyyOutpatientDO> findWaitingOutpatient();
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus = 1 and (a.remindCount<?1 or a.remindCount is null)")
    List<WlyyOutpatientDO> findWaitingOutpatient(Integer remindCount);
    /*@Query("from WlyyOutpatientDO a where a.patient = ?1 and a.outpatientType = 1")
    List<WlyyOutpatientDO> findOutpatientByPatientAndStatus(String patient);*/

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

@ -84,6 +84,7 @@ import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.enterprise.EnterpriseService;
import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.mysql.query.BaseJpaService;
@ -96,7 +97,6 @@ import jxl.write.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.codec.binary.*;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -111,18 +111,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.xml.rpc.ServiceException;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.Boolean;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Base64;
/**
 * Created by Trick on 2019/5/17.
@ -260,6 +256,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private PrescriptionSignDao prescriptionSignDao;
    @Autowired
    private EnterpriseService enterpriseService;
@ -281,14 +279,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    public List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag) throws Exception {
    public List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag,String ksdm) throws Exception {
        logger.info("findOutpatientList patient:" + patient);
        String patNo = patientMappingService.findHisPatNoByPatient(patient);
        if (StringUtils.isBlank(patNo)) {
            return null;
        }
        logger.info("findOutpatientList patNo " + patNo);
        return entranceService.BS30025(patNo, null, startTime, endTime, demoFlag);
        return entranceService.BS30025(patNo, null, startTime, endTime, demoFlag,ksdm);
    }
    /**
@ -305,7 +303,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            return null;
        }
        logger.info("findOutpatientList patNo:" + patNo);
        List<WlyyOutpatientVO> list = entranceService.BS30025(patNo, conNo, null, null, demoFlag);
        List<WlyyOutpatientVO> list = entranceService.BS30025(patNo, conNo, null, null, demoFlag,null);
        if (list != null && list.size() > 0) {
            WlyyOutpatientVO outpatientVO = list.get(0);
@ -794,8 +792,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @return
     * @throws Exception
     */
    @Transactional
    public WlyyOutpatientDO appointmentRevisit(String outpatientJson, String expressageJson, String registerJson, String chargeType) throws Exception {
        //1.保存就诊实体
        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class);
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
@ -812,7 +810,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (outpatientDO.getRegisterDate() == null) {
            outpatientDO.setRegisterDate(new Date());
        }
        WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
        if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
            WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
            wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
            return wlyyOutpatientDO;
        }
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
        Double price = 0.0;
@ -843,19 +848,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        } catch (Exception e) {
            throw new RuntimeException("号源已经被预约,请选择其他号源");
        }
        WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
        //2.物流信息
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
      /*  if (null!=previous&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
            outpatientDao.delete(outpatient.getId());
            businessOrderDao.delete(businessOrderDO.getId());
            throw new Exception("您今日发起过复诊,不允许更改取药方式");
        }*/
        if (0==expressageDO.getOneselfPickupFlg()){
            /*if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                expressageDO.setHospitalCode(drugCode);
            }*/
            }
            System.out.println("进入物流信息");
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
@ -885,6 +883,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //3.创建候诊室
        createRoom(outpatient, chargeType);
        //发送企业模板消息给医生
        String msg = "";
        String name=outpatient.getPatientName();
        String sex = "";
        String age="";
        String date = "";
        String title = "";
        String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatient.getDescription()+"&type=3&id="+outpatient.getId();
        if (patientDO!=null){
            sex=IdCardUtil.getSexForIdcard(patientDO.getIdcard());
            age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard())+"";
        }
        if (outpatient!=null){
            if (outpatient.getType().equalsIgnoreCase("1")){
                title = "图文复诊";
                msg = name+"("+sex+" "+age+"岁)向您发起了图文复诊,点击查看";
            }else if (outpatient.getType().equalsIgnoreCase("2")){
                title = "视频复诊";
                date = DateUtil.dateToStrLong(outpatient.getRegisterDate());
                msg = name+"("+sex+" "+age+"岁)预约了"+date+"的视频复诊,点击查看";
            }
        }
        enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
        System.out.println("发送企业模板消息成功");
        String content = "向您发起了图文复诊,点击查看";
        return outpatient;
    }
@ -1492,7 +1515,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " JOIN base_doctor_role r ON r.doctor_code = d.id " +
                " WHERE  " +
                " h.org_code = '" + orgCode + "'" +
                " AND r.role_code ='specialist'";
                " AND r.role_code ='specialist' and d.del=1 ";
        if (StringUtils.isNotBlank(chargeType)) {
            if ("all".equalsIgnoreCase(chargeType)) {
                //不过滤号别
@ -1557,7 +1580,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " JOIN base_doctor_role r ON r.doctor_code = d.id " +
                " WHERE  " +
                " h.org_code = '" + orgCode + "'" +
                " AND r.role_code ='specialist'";
                " AND r.role_code ='specialist' and d.del=1 ";
        if (StringUtils.isNotBlank(chargeType)) {
            if ("all".equalsIgnoreCase(chargeType)) {
                //不过滤号别
@ -1653,12 +1676,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                outpatientDao.save(outpatientDO);
                //调用电子病历注册
                manageType = 2;
                registDianziBingli(outpatientDO, basePatientDO, manageType, registerDO.getRegisterNo(), registerDO.getConNo());
                try {
                    registDianziBingli(outpatientDO, basePatientDO, manageType, registerDO.getRegisterNo(), registerDO.getConNo());
                }catch (Exception e){
                    e.printStackTrace();
                }
                return res;
            }
        }
        //下载银医通
        net.sf.json.JSONObject object1 = entranceService.qutpatientBalance(outpatientDO.getCardNo(), demoFlag);
        logger.info("下载银医通");
        net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(), doctorMappingDO.getMappingCode(), outpatientDO.getDept(), null, outpatientDO.getWinNo(), demoFlag);
        net.sf.json.JSONObject res = rs.getJSONObject("resquest");
        logger.info("挂号结果 res: " + res.toString());
@ -1775,7 +1803,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "<CardNO>" + outpatientDO.getCardNo() + "</CardNO>\n" +
                "<PatientName>" + basePatientDO.getName() + "</PatientName>" +
                "<SexCode>" + basePatientDO.getSex() + "</SexCode>";
        if (1 == basePatientDO.getSex()) {
        if (basePatientDO.getSex()!=null&&1 == basePatientDO.getSex()) {
            _xmlStr = _xmlStr + "<Sex>男</Sex>";
        } else {
            _xmlStr = _xmlStr + "<Sex>女</Sex>";
@ -2056,7 +2084,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param diagnosisJson
     * @return
     */
    public Map<String, Object> makeDiagnosis(String outPatientId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
    public Map<String, Object> makeDiagnosis(String outPatientId,String prescriptionId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
        Map<String, Object> result = new HashedMap();
@ -2067,26 +2095,28 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        //========================处方操作=============================================================
        //创建处方记录
        List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
        WlyyPrescriptionDO prescriptionDO = null;
        if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
            prescriptionDO = prescriptionDOs.get(0);
        } else {
            prescriptionDO = new WlyyPrescriptionDO();
        WlyyPrescriptionDO  prescriptionDO= new WlyyPrescriptionDO();
        /*List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);*/
        List<WlyyPrescriptionDO> wlyyPrescriptionDO1 = new ArrayList<>();
        if(StringUtils.isNotBlank(prescriptionId)){
            wlyyPrescriptionDO1 = prescriptionDao.findById(prescriptionId);
            prescriptionDO =wlyyPrescriptionDO1.get(0);
        }else{
            prescriptionDO.setOutpatientId(outPatientId);
            prescriptionDO.setType(1);
            prescriptionDO.setDept(outpatientDO.getDept());
            prescriptionDO.setCreateTime(new Date());
            prescriptionDO.setStatus(10);
            prescriptionDO.setPatientCode(outpatientDO.getPatient());
            prescriptionDO.setPatientName(outpatientDO.getPatientName());
            prescriptionDO.setDoctor(outpatientDO.getDoctor());
            prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
            prescriptionDO.setPayStatus(0);
            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
                prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
            }
        }
        prescriptionDO.setType(1);
        prescriptionDO.setDept(outpatientDO.getDept());
        prescriptionDO.setCreateTime(new Date());
        prescriptionDO.setStatus(10);
        prescriptionDO.setPatientCode(outpatientDO.getPatient());
        prescriptionDO.setPatientName(outpatientDO.getPatientName());
        prescriptionDO.setDoctor(outpatientDO.getDoctor());
        prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
        prescriptionDO.setPayStatus(0);
        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
            prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
        }
        WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
        //========================处方操作结束=============================================================
@ -2141,7 +2171,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            savePrescriptionCheck(prescription.getDoctor(), "开具处方", 5, prescription.getId());
        }
        if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
        if (wlyyPrescriptionDO1 != null && wlyyPrescriptionDO1.size() > 0) {
            savePrescriptionCheck(prescription.getDoctor(), "处方修改", 3, prescription.getId());
        }
@ -2238,6 +2268,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                result.put("code", 1);
                result.put("mes", "诊断完成");
                result.put("prescriptionId",prescription.getId());
                return result;
            } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
                Double price = prescription.getDrugFee();
@ -2248,6 +2279,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                Map<String, Object> result1 = new HashedMap();
                result1.put("code", 1);
                result1.put("mes", "开方提交成功");
                result1.put("prescriptionId",prescription.getId());
                return result1;
            } else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
                Double price = prescription.getDrugFee();
@ -2258,10 +2290,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                Map<String, Object> result1 = new HashedMap();
                result1.put("code", 1);
                result1.put("mes", "开方提交成功");
                result1.put("prescriptionId",prescription.getId());
                return result1;
            }else {
                result.put("code", 1);
                result.put("mes", "诊断完成");
                result.put("prescriptionId",prescription.getId());
                return result;
            }
@ -2271,6 +2305,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            outpatientDao.save(outpatientDO);
            result.put("code", 1);
            result.put("mes", "诊断完成");
            result.put("prescriptionId",prescription.getId());
            return result;
        }
@ -3659,17 +3694,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
            contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
            first = outpatientDO.getPatientName() + ",您好!";
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId=    "+outpatientId;
            logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
            msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
        } else if ("payRemind".equalsIgnoreCase(titelType)) {
            if ("9".equals(type)) {
                contentMsg = "您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = outpatientDO.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。";
                contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                first = outpatientDO.getPatientName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("图文复诊订单待支付微信消息模板推送开始");
            } else if ("16".equals(type)) {
                contentMsg = "您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
                first = outpatientDO.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。";
                contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
                first = outpatientDO.getPatientName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
                msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
                logger.info("视频复诊订单待支付微信消息模板推送开始");
            }
@ -3689,7 +3725,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            first = outpatientDO.getPatientName() + ",您好! 医生已为您开具处方,请及时支付。";
            contentMsg = "医生已为您开具处方,请及时支付。";
            remark = "点击完成支付,如您已支付请忽略本条信息";
            msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId;
            msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
            logger.info("处方支付微信消息模板推送开始");
        } else if ("msgRemind".equalsIgnoreCase(titelType)) {
            first = outpatientDO.getPatientName() + ",您好!";
@ -3994,6 +4030,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
        } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
            String responseMsg="";
            String prefix="https://hlwyy.xmzsh.com";
            if(StringUtils.isNotEmpty(outpatientId)){
@ -4006,6 +4043,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        contentMsg,
                        remark
                );
                System.out.println("结束发送模板消息");
            }
            if (consultTeam!=null&&consPatientDO!=null){
                responseMsg = entranceService.ehospitalNotice(
@ -4653,7 +4691,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " base_doctor d " +
                " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
                " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 3 GROUP BY doctor ) a on a.doctor = d.id ";
        Map<String, Object> params = new HashedMap();
        Date date = new Date();
        sql+="LEFT JOIN (SELECT  COUNT(t1.doctor) as workTotal, t1.doctor FROM  wlyy_doctor_work_time t1   WHERE   " +
                "t1.start_time <=:startTime  AND t1.end_time >=:endTime GROUP BY t1.doctor) dw ON dw.doctor=d.id ";
        params.put("startTime", date);
        params.put("endTime", date);
        if ("1".equalsIgnoreCase(isAttention)) {
            sql += " join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient ='" + patientid + "' ";
        }
@ -4672,9 +4715,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            sql += " JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
        }
        sql += " WHERE  1=1 ";
        Map<String, Object> params = new HashedMap();
        sql += " WHERE  1=1 ";
        if (StringUtils.isBlank(chargType)) {
            sql += " AND d.charge_type is not null ";
@ -4690,7 +4732,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (StringUtils.isNotBlank(iswork) && "1".equals(iswork)) {
            logger.info("iswork:" + iswork);
            Date date = new Date();
            sql += " AND (" +
                    " EXISTS ( " +
                    " SELECT " +
@ -4766,9 +4807,32 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        sql += " and d.del='1' order by a.total " + consutlSort;
        sql += " and d.del='1' order by dw.workTotal desc,d.consult_status DESC,a.total " + consutlSort;
        String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
        for (Map<String,Object> map:list){
            String doctor = map.get("id").toString();
            //查询医生各项评价平均分
            String sqlscore = "SELECT " +
                    "AVG(a.score) AS \"score\"," +
                    "a.score_type AS \"score_type\" " +
                    "FROM base_evaluate a,base_evaluate_score b " +
                    "WHERE " +
                    "a.relation_code=b.id " +
                    "AND b.doctor='" + doctor + "' " +
                    "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
            List<Map<String, Object>> listscore = jdbcTemplate.queryForList(sqlscore);
            Double doctorScore = new Double("0");
            if (listscore != null && listscore.size() > 0) {
                for (Map<String, Object> _listscore : listscore) {
                    doctorScore += Double.parseDouble(_listscore.get("score").toString());
                }
            }
            doctorScore = doctorScore / 3;
            map.put("doctorScore", doctorScore);
        }
        List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount, params);
        Long count = 0L;
        if(listCount!=null){
@ -6823,7 +6887,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param name
     * @return
     */
    public List<Map<String, Object>> findDoctorByName(String hospital, String name, String chargeType) {
    public List<Map<String, Object>> findDoctorByName(String hospital, String name, String chargeType,String dept) {
        String sql = "SELECT " +
                " d.id AS \"id\", " +
                " d.name AS \"name\"" +
@ -6838,6 +6902,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (StringUtils.isNotBlank(hospital)) {
            sql += " AND h.org_code ='" + hospital + "'";
        }
        if(StringUtils.isNotBlank(dept)){
            sql+= " AND h.dept_code = '"+dept+"'";
        }
        if (StringUtils.isNotBlank(chargeType)) {
            if ("all".equals(chargeType)) {
@ -7112,7 +7179,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
                    List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
                    DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
                    List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
                    //his处方拼接开方条件
                    com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
                    for (WlyyPrescriptionInfoDO info : infoDOS) {
@ -7123,6 +7190,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        //设置his药品查询条件
                        setInspectionParam(jsonData, doctorMappingDO, outpatientDO, wlyyPrescriptionDO, ins, outpatientDO.getIcd10());
                    }
                    if (expressageDOS!=null&&expressageDOS.size()!=0){
                        WlyyPrescriptionExpressageDO prescriptionExpressageDO = expressageDOS.get(0);
                        if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==0){
                            for (int i=0;i<jsonData.size();i++){
                                com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
                                object.put("selfDelivered",0);
                            }
                        }else if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==1){
                            for (int i=0;i<jsonData.size();i++){
                                com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
                                object.put("selfDelivered",1);
                            }
                        }
                    }
                    Map<String, Object> map = sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);
                    //处方签名
                    logger.info("处方签名");
@ -7210,7 +7291,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
            }
            sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "prescriptionPayRemind", "");
            sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "prescriptionPayRemind", wlyyPrescriptionDO.getId());
        } else {
            wlyyPrescriptionDO.setId(prescriptionId);
            wlyyPrescriptionDO.setCheckStatus(status);
@ -8224,7 +8305,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @throws Exception
     */
    public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionEmrDO prescriptionEmrDO) throws Exception {
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionEmrDO.getId());
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionEmrDO.getPrescriptionId());
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(prescriptionDO.getDoctor());
        BaseDoctorDO doctorDO = baseDoctorDao.findById(prescriptionDO.getDoctor());
        BasePatientDO patientDO = basePatientDao.findById(prescriptionDO.getPatientCode());

+ 55 - 7
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -1,6 +1,7 @@
package com.yihu.jw.hospital.prescription.service.entrance;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
@ -36,7 +37,6 @@ import net.sf.json.JSONArray;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -359,10 +359,13 @@ public class EntranceService {
                                wlyyPrescriptionInfoVO.setDispDeposite(null != jsonObjectBody.get("DISP_DEPOSITE") ? jsonObjectBody.get("DISP_DEPOSITE").toString() : "");
                                wlyyPrescriptionInfoVO.setDosage(null != jsonObjectBody.get("YPYL00") ? jsonObjectBody.get("YPYL00").toString() : "");
                                wlyyPrescriptionInfoVO.setQuantity(null != jsonObjectBody.get("DRUG_QTY") ? jsonObjectBody.get("DRUG_QTY").toString() : "");
                                wlyyPrescriptionInfoVO.setUnit(null != jsonObjectBody.get("UNIT") ? jsonObjectBody.get("UNIT").toString() : "");
                                wlyyPrescriptionInfoVO.setUnitName(null != jsonObjectBody.get("DCYYDW") ? jsonObjectBody.get("DCYYDW").toString() : "");
                                wlyyPrescriptionInfoVO.setUsageName(null != jsonObjectBody.get("YPPL00") ? jsonObjectBody.get("YPPL00").toString() : "");
                                wlyyPrescriptionInfoVO.setSupplyName(null != jsonObjectBody.get("YPYF00") ? jsonObjectBody.get("YPYF00").toString() : "");
                                wlyyPrescriptionInfoVO.setDays(null != jsonObjectBody.get("days") ? jsonObjectBody.get("days").toString() : "");
                                wlyyPrescriptionInfoVO.setUsageCode(null != jsonObjectBody.get("YPPLCODE") ? jsonObjectBody.get("YPPLCODE").toString() : "");
                                wlyyPrescriptionInfoVO.setSupplyCode(null != jsonObjectBody.get("YPYFCODE") ? jsonObjectBody.get("YPYFCODE").toString() : "");
                                wlyyPrescriptionInfoVO.setDays(null != jsonObjectBody.get("drug_win") ? jsonObjectBody.get("drug_win").toString() : "");
                                wlyyPrescriptionInfoVO.setFrequency(null != jsonObjectBody.get("frequency") ? jsonObjectBody.get("frequency").toString() : "");
                                wlyyPrescriptionInfoVO.setGroupNo(null != jsonObjectBody.get("DISP_DEPOSITE") ? jsonObjectBody.get("DISP_DEPOSITE").toString() : "");
                                //规格
@ -555,7 +558,8 @@ public class EntranceService {
     * @return
     * @throws Exception
     */
    public List<WlyyOutpatientVO> BS30025(String PAT_NO, String conNo, String startTime, String endTime, boolean demoFlag) throws Exception {
    public List<WlyyOutpatientVO> BS30025(String PAT_NO, String conNo, String startTime, String endTime, boolean demoFlag ,String ksdm) throws Exception {
        System.out.println("ksdm="+ksdm);
        String fid = BS30025;
        logger.info("EntranceService " + fid + " PAT_NO :" + PAT_NO + " conNo:" + conNo + " startTime:" + startTime + " endTime:" + endTime);
@ -584,6 +588,9 @@ public class EntranceService {
            if (StringUtils.isNotBlank(endTime)) {
                sbs.append("<query compy=\"&lt;\" item=\"CON_DATE\" splice=\"and\" value=\"'" + endTime + "'\"/>");
            }
            if (StringUtils.isNotBlank(ksdm)) {
                sbs.append("<query compy=\"=\" item=\"ADM_SPEC\" splice=\"and\" value=\"'" + ksdm + "'\"/>");
            }
            sbs.append("<order item=\"CON_DATE\" sort=\"desc\"/>");
            //查询信息结束
            sbs.append("</MsgInfo></ESBEntry>");
@ -593,8 +600,7 @@ public class EntranceService {
        }
        JSONArray jsonArray = ConvertUtil.convertListEnvelopInRow(resp);
        if (null == jsonArray) {
            return null;
        }
            return null;        }
        List<WlyyOutpatientVO> wlyyOutpatientVOS = new ArrayList<>();
        WlyyOutpatientVO wlyyOutpatientVO;
        for (Object object : jsonArray) {
@ -978,6 +984,10 @@ public class EntranceService {
                if (StringUtils.isNotBlank(vo.getFixationfluid())) {
                    sbs.append(" fixationfluid=\"" + vo.getFixationfluid() + "\"");
                }
                logger.info("判断自取或者快递标识"+vo.getSelfDelivered());
                if (StringUtils.isNotBlank(vo.getSelfDelivered())){
                    sbs.append(" self_delivered=\"" + vo.getSelfDelivered() + "\"");
                }
                sbs.append("/>");
            }
            sbs.append("</root>]]></Msg><startNum>1</startNum></MsgInfo></ESBEntry>");
@ -1999,6 +2009,7 @@ public class EntranceService {
        jsonObject.put("url", url);
        jsonObject.put("content", content);
        jsonObject.put("contentString", contentString);
        System.out.println(serverUrl);
        String responseMsg = httpClientUtil.sendPost(serverUrl + "/interface/ehospitalNoticePush.htm", jsonObject.toString());
        logger.info("ehospitalNoticePushResult:" + responseMsg);
        return responseMsg;
@ -2709,8 +2720,45 @@ public class EntranceService {
    }
*/
    /**
     * 支付成功提醒
     * @param userName 用户名 (不能为空)
     * @param idCard 身份证 (能为空)
     * @param phone 推送人手机号 (不能为空)
     * @param title 推送标题 (不能为空)
     * @param url 支付链接   (不能为空)
     * @param doctorName 就诊医生 (不能为空)
     * @param total 总费用 (不能为空)
     * @param miPay 医保支付 (不能为空)
     * @param selfPay 个人支付 (不能为空)
     * @param orderNo 单据号 (不能为空)
     * @param remark 备注 (不能为空)
     * @return
     * @throws Exception
     */
    public String paySuccessNotice(String userName,String idCard,String phone,String title,String url,
                                        String doctorName,String total,String miPay,String selfPay,String orderNo,String remark) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("userName", userName);
        jsonObject.put("idCard", idCard);
        jsonObject.put("phone", phone);
        jsonObject.put("title", title);
        jsonObject.put("url", url);
        jsonObject.put("doctorName", doctorName);
        jsonObject.put("total", total);
        jsonObject.put("miPay", miPay);
        jsonObject.put("selfPay", selfPay);
        jsonObject.put("orderNo", orderNo);
        jsonObject.put("remark", remark);
        String responseMsg = httpClientUtil.sendPost(url + "/interface/paySuccessNoticePush.htm", jsonObject.toJSONString());
        JSONObject result = new JSONObject();
        String respCode = "";
        if (responseMsg != null) {
            result = JSONObject.parseObject(responseMsg);
            respCode = result.get("respCode").toString();
        }
        return respCode;
    }
}

+ 2 - 8
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -14,7 +14,6 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.dict.BaseDeptDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDataDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import com.yihu.jw.entity.hospital.jgpt.HospitalImgDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.internet.dao.HospitalImgDao;
import com.yihu.jw.internet.dao.IntUpErrorLogDao;
@ -24,19 +23,15 @@ import com.yihu.jw.internet.entity.InternetUpLogDO;
import com.yihu.jw.internet.wsapi.Wsapi;
import com.yihu.jw.internet.wsapi.WsapiProxy;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.ImgUtils;
import com.yihu.jw.utils.JSONUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.encode.AESUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import nu.xom.jaxen.function.IdFunction;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -45,7 +40,6 @@ import org.springframework.util.LinkedCaseInsensitiveMap;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Date;
import java.util.List;
@ -358,7 +352,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                jb.put("docimg", "");
                jb.put("id_card", info.get("idcard")== null ? "0":info.get("idcard"));
                jb.put("sex", info.get("sex")== null ? "0":info.get("sex"));
                jb.put("birthday", info.get("birthday")  == null?"1900-01-01": DateUtil.dateToStrLong((Date)info.get("birthday")));
                jb.put("birthday", info.get("birthday")  == null?"1900-01-01": DateUtil.dateToStrShort((Date)info.get("birthday")));
                jb.put("subject", dept.length>=1?dept[0]:"");
                jb.put("subject_name",dept.length>=2?dept[1]:"");
                jb.put("belong_dept",jb.getString("dept_code"));
@ -1346,7 +1340,7 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
        return resInfo;
    }
    // 12.在线诊疗服务信息-过程图片上传     --- 完成
    // 12.服务信息-过程图片上传     --- 完成
    public String upNsOnlineImg(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();

+ 91 - 0
business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java

@ -11,8 +11,11 @@ import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.utils.ByteToInputStream;
import com.ylzinfo.onepay.sdk.HisOnepayClient;
import com.ylzinfo.onepay.sdk.OnepayClient;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ext.*;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -560,4 +563,92 @@ public class YlzPayService {
    }
//============================================预交金充值 end======================================================
    /**
     * 查看线上结算记录
     *
     * @param cardNo 卡号,多个按逗号隔开
     * @param beginDate 开始时间(可空) yyyyMMdd:20200818
     * @param endDate 结束时间(可空) yyyyMMdd:20200818
     * @param queryType online:(不为空)记录明细一起返回,下面两个参数的合体;onlineRecord:查询结算记录 onlineRecordDetail:查询结算明细
     * @param billSn    当 queryType = onlineRecordDetail billsn和traceno必有值
     * @param traceNo
     * @param pageNo
     * @param pageSize
     * @return
     */
    public String querySettledRecord(String cardNo,String beginDate,String endDate,String queryType,String billSn,String traceNo,String pageNo,String pageSize ){
        Boolean isSuccess = true;
        String jsonObject = null;
        String error = null;
        RequestParams requestParams = new RequestParams();
        try {
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
        if(oauthYlzConfigDO==null){
            return "未找到支付配置文件";
        }
        String appId = oauthYlzConfigDO.getAppId();
        String appSecret = oauthYlzConfigDO.getAppKey();
        String onepayUrl = oauthYlzConfigDO.getUrl();
        String signType=oauthYlzConfigDO.getSignType();
        String encryptType = oauthYlzConfigDO.getEncType();
        requestParams.setAppId(appId);
        requestParams.setTimestamp(DateUtil.getCurrentDateTime());
        requestParams.setSignType(signType);
        requestParams.setEncryptType(encryptType);
        requestParams.setTimestamp(DateUtil.getCurrentDateTime());
        //分页参数
        if(StringUtils.isNotBlank(queryType)&&"online".equalsIgnoreCase(queryType)){
            JSONObject pageParam = new JSONObject();
            pageParam.put("pageNo",pageNo);
            pageParam.put("pageSize",pageSize);
            requestParams.setPageParam(pageParam);
        }
        JSONObject params = new JSONObject();
        if (StringUtils.isBlank(cardNo)||StringUtils.isBlank(queryType)){
            return "cardNo或者queryType不能为空";
        }
        if (queryType.equalsIgnoreCase("onlineRecordDetail")){
            if(StringUtils.isBlank(billSn)||StringUtils.isBlank(traceNo)){
                return "billSn和traceNo不能为空";
            }
        }
        params.put("cardNo",cardNo);
        params.put("queryType",queryType);
        if (StringUtils.isNotBlank(beginDate)){
            params.put("beginDate",beginDate);
        }if (StringUtils.isNotBlank(endDate)){
            params.put("endDate",endDate);
        }
        if (StringUtils.isNotBlank(billSn)){
            params.put("billSn",billSn);
        }
        if (StringUtils.isNotBlank(traceNo)){
            params.put("traceNo",traceNo);
        }
        requestParams.setParam(params);
        requestParams.setTransType("hop.query.settle");
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(onepayUrl, appId, appSecret, signType, encryptType);
        ResponseParams<JSONObject> respnse = onepayClient.execute(requestParams);
        if (respnse.getRespCode().equals("000000")){
            jsonObject = JSON.toJSONString(respnse);
            System.out.println(jsonObject);
        }else {
            isSuccess = false;
            jsonObject = JSON.toJSONString(respnse);
            error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
        }
        } catch (Exception e) {
            e.printStackTrace();
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.query", "查看线上结算记录", "POST", null,JSON.toJSONString(requestParams), jsonObject, error,logService.shoppatType);
        return jsonObject;
    }
}

+ 15 - 0
business/base-service/src/main/java/com/yihu/jw/utils/AdminException.java

@ -0,0 +1,15 @@
package com.yihu.jw.utils;
import com.yihu.jw.utils.sfutils.MyErrorCode;
public class AdminException extends RuntimeException {
    private MyErrorCode exceptionEnum;
    public AdminException(MyErrorCode exceptionEnum) {
        this.exceptionEnum = exceptionEnum;
    }
    public MyErrorCode getMyErrorCode() {
        return exceptionEnum;
    }
}

+ 47 - 0
business/base-service/src/main/java/com/yihu/jw/utils/FileUtil.java

@ -0,0 +1,47 @@
package com.yihu.jw.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.nio.MappedByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
public class FileUtil {
    private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
    /**
     * 在MappedByteBuffer释放后再对它进行读操作的话就会引发jvm crash,在并发情况下很容易发生
     * 正在释放时另一个线程正开始读取,于是crash就发生了。所以为了系统稳定性释放前一般需要检 查是否还有线程在读或写
     * @param mappedByteBuffer
     */
    public static void freedMappedByteBuffer(final MappedByteBuffer mappedByteBuffer) {
        try {
            if (mappedByteBuffer == null) {
                return;
            }
            mappedByteBuffer.force();
            AccessController.doPrivileged(new PrivilegedAction<Object>() {
                @Override
                public Object run() {
                    try {
                        Method getCleanerMethod = mappedByteBuffer.getClass().getMethod("cleaner", new Class[0]);
                        //可以访问private的权限
                        getCleanerMethod.setAccessible(true);
                        //在具有指定参数的 方法对象上调用此 方法对象表示的底层方法
                        sun.misc.Cleaner cleaner = (sun.misc.Cleaner) getCleanerMethod.invoke(mappedByteBuffer,
                                new Object[0]);
                        cleaner.clean();
                    } catch (Exception e) {
                        logger.error("clean MappedByteBuffer error!!!", e);
                    }
                    logger.info("clean MappedByteBuffer completed!!!");
                    return null;
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 26 - 0
business/base-service/src/main/java/com/yihu/jw/utils/sfutils/MyErrorCode.java

@ -0,0 +1,26 @@
package com.yihu.jw.utils.sfutils;
public enum MyErrorCode {
    EXCEPTION_ONE(725,"请选择与上次相同的快递方式"),
    EXCEPTION_TWO(400,"异常二提示信息"),
    EXCEPTION_THREE(400,"异常三提示信息")
    ;
    //状态码
    private Integer code;
    //异常提示信息
    private String msg;
    MyErrorCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public Integer getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
}

+ 9 - 1
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -2251,6 +2251,14 @@ public class ImService {
			}else {
				map.put("patientAge",null);
			}
			if (map.get("doctor")!=null){
				String doctorId = map.get("doctor").toString();
				BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctorId);
				if (baseDoctorDO!=null){
					map.put("doctorName",baseDoctorDO.getName());
				}
			}
		}
		return mapList;
	}
@ -3077,7 +3085,7 @@ public class ImService {
				"count(id) AS \"total\"," +
				"doctor as \"doctor\"" +
				"FROM wlyy_consult_team " +
				"WHERE doctor IN ("+doctorids+") AND (type=1 OR type=15) and status = 0 GROUP BY doctor";
				"WHERE doctor IN ("+doctorids+") AND (type=1 OR type=15 OR type=9 OR type =16) and status = 0 GROUP BY doctor";
		List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
		return list;
	}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -234,7 +234,18 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
    private String  operator;
    private String source;//来源
    /*
    *提醒次数
     */
    private Integer remindCount;
    @Column(name = "remind_count")
    public Integer getRemindCount() {
        return remindCount;
    }
    public void setRemindCount(Integer remindCount) {
        this.remindCount = remindCount;
    }
    @Column(name = "operator")
    public String getOperator() {
        return operator;

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -239,6 +239,7 @@ public class BaseRequestMapping {
        public static final String PREFIX  = "/open/fileUpload";
        public static final String UPLOAD_STREAM_IMG  = "/upload_stream_img";
        public static final String UPLOAD_STREAM  = "/upload_stream";
        public static final String UPLOAD_STREAM_video  = "/upload_stream_video";
        public static final String UPLOAD_STRING  = "/upload_string";
        public static final String UPLOAD_STREAM_ATTACHMENT  = "/upload_stream_attachment";
    }

+ 3 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1332,6 +1332,9 @@ public class BaseHospitalRequestMapping {
        public static final String findLevelOneDoctorUpcoming="/findLevelOneDoctorUpcoming";
        public static final String getUpcomingByDoctor="/getUpcomingByDoctor";
        public static final String checkOperateTime="/checkOperateTime";
        public static final String querySettledRecord="/querySettledRecord";
        public static final String paySuccessNotice="/paySuccessNotice";
    }
    /**

+ 73 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/MutilFileInfo.java

@ -0,0 +1,73 @@
package com.yihu.jw.restmodel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
/*
*   文件上传实体类
 */
@ApiModel("大文件分片入参实体")
public class MutilFileInfo {
    @ApiModelProperty("文件传输任务ID")
    private String taskId;
    @ApiModelProperty("当前为第几分片")
    private int chunk;
    @ApiModelProperty("每个分块的大小")
    private long size;
    @ApiModelProperty("分片总数")
    private int chunkTotal;
    @ApiModelProperty("主体类型--这个字段是我项目中的其他业务逻辑可以忽略")
    private int objectType;
    @ApiModelProperty("分块文件传输对象")
    private MultipartFile file;
    public String getTaskId() {
        return taskId;
    }
    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }
    public int getChunk() {
        return chunk;
    }
    public void setChunk(int chunk) {
        this.chunk = chunk;
    }
    public long getSize() {
        return size;
    }
    public void setSize(long size) {
        this.size = size;
    }
    public int getChunkTotal() {
        return chunkTotal;
    }
    public void setChunkTotal(int chunkTotal) {
        this.chunkTotal = chunkTotal;
    }
    public int getObjectType() {
        return objectType;
    }
    public void setObjectType(int objectType) {
        this.objectType = objectType;
    }
    public MultipartFile getFile() {
        return file;
    }
    public void setFile(MultipartFile file) {
        this.file = file;
    }
}

+ 9 - 7
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyHisPrescriptionVO.java

@ -1,14 +1,7 @@
package com.yihu.jw.restmodel.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
/**
@ -132,6 +125,7 @@ public class WlyyHisPrescriptionVO extends UuidIdentityVOWithOperator {
    private String ywjcDate;//以往检查时间-病理申请单选填 格式:yyyy-mm-dd',
    private String blzd;//病理诊断-病理申请单选填',
    private String fixationfluid;//固定液
    private String selfDelivered;//快递是否1是0否
@ -440,4 +434,12 @@ public class WlyyHisPrescriptionVO extends UuidIdentityVOWithOperator {
    public void setComm(String comm) {
        this.comm = comm;
    }
    public String getSelfDelivered() {
        return selfDelivered;
    }
    public void setSelfDelivered(String selfDelivered) {
        this.selfDelivered = selfDelivered;
    }
}

+ 33 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -1,12 +1,13 @@
package com.yihu.jw.security.core.userdetails.jdbc;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.security.core.userdetails.SaltUser;
import com.yihu.jw.security.dao.patient.BasePatientDao;
import com.yihu.jw.security.dao.patient.BasePatientWechatDao;
import com.yihu.jw.security.model.WlyyUserDetails;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.utils.security.MD5;
@ -82,6 +83,8 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private BasePatientDao patientDao;
    public WlyyUserDetailsService(DataSource dataSource) {
        this.setDataSource(dataSource);
@ -628,6 +631,35 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
            JSONObject object1 = JSONObject.parseObject(res);
            if (null != object1&&null!=object1.get("status") && "200".equals(object1.get("status").toString())) {
                JSONObject patient = object1.getJSONObject("userinfo");
                logger.info("开始同步患者数据");
                String idcard = patient.getString("idcard");
                BasePatientDO patientDO2 = patientDao.findByIdcardAndDel(idcard,"1");
                BasePatientDO patient1 = new BasePatientDO();
                if (patientDO2!=null){
                    patient1=patientDO2;
                }
                String salt = UUID.randomUUID().toString().substring(0,5);
                String mobile = patient.getString("mobile");
                String pw = null;
                if(org.apache.commons.lang3.StringUtils.isNotBlank(mobile)){
                    pw = mobile.substring(mobile.length()-6);
                }else{
                    pw = idcard.substring(idcard.length()-6);
                }
                patient1.setIdcard(idcard);
                patient1.setName(patient.getString("name"));
                patient1.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                patient1.setSalt(salt);
                patient1.setSex(StringUtils.isNotBlank(idcard)?Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)):null);
                patient1.setMobile(mobile);
                patient1.setDel("1");
                patient1.setEnabled(1);
                patient1.setLocked(0);
                patient1.setCreateTime(new Date());
                patient1.setUpdateTime(new Date());
                patient1.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
                patient1 = patientDao.save(patient1);
                logger.info("结束同步患者数据");
                return patient;
            }
        }catch (Exception e){

+ 5 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -475,6 +475,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
        }
        if (username.length()>12){
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
@ -490,7 +493,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            _captcha.setExpiresIn(300);
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, null);
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
@ -819,6 +822,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                        JSONObject patient =  userDetailsService.getHLWyyUser(opid);
                        rs.put("idcard",patient.getString("idcard"));
                        rs.put("mobile",patient.getString("mobile"));
                    }
                }else {
                    rs.put("openid",openid);

+ 32 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -7,7 +7,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.exception.code.BaseErrorCode;
import com.yihu.jw.file_upload.FileManageService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.restmodel.MutilFileInfo;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -16,15 +18,18 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.apache.http.entity.ContentType;
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.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.Map;
@ -53,6 +58,8 @@ public class FileUploadController extends EnvelopRestEndpoint {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private FileManageService filemanage;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
@ -137,26 +144,30 @@ public class FileUploadController extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
                                             @RequestParam(value = "file", required = true) MultipartFile file
            /*@ApiParam(value = "jsonData", required = true)
            @RequestBody MutilFileInfo param, HttpServletResponse response, HttpServletRequest request*/) throws Exception{
        UploadVO uploadVO = new UploadVO();
        if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
            uploadVO.setFullUri(map.get("accessory").toString());
            uploadVO.setFileName(file.getOriginalFilename());
        }else if(isClose.equals("2")){
            //内网上传
            String rs = fileUploadService.request(remote_inner_url,file,null);
            logger.info(rs);
            JSONObject json = JSON.parseObject(rs);
            uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
        }else {
            // 得到文件的完整名称  xxx.txt
            String originalFilename = file.getOriginalFilename();
            InputStream inputStream = file.getInputStream();
            uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
            if (isClose.equalsIgnoreCase("1")){
                Map<String, Object> map = fileUploadService.uploadImg(file);
                uploadVO.setFullUri(map.get("accessory").toString());
                uploadVO.setFileName(file.getOriginalFilename());
            }else if(isClose.equals("2")){
                //内网上传
                String rs = fileUploadService.request(remote_inner_url,file,null);
                logger.info(rs);
                JSONObject json = JSON.parseObject(rs);
                uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
            }else {
                // 得到文件的完整名称  xxx.txt
                String originalFilename = file.getOriginalFilename();
                InputStream inputStream = file.getInputStream();
                uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
            }
            return success("上传成功", uploadVO);
        }
        return success("上传成功", uploadVO);
    }
}

+ 8 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -228,13 +228,16 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                "\tEND AS status,\n" +
                "\tdoc.create_time\n" +
                "FROM\n" +
                "\tbase_doctor doc,\n" +
                " base_doctor doc LEFT join base_doctor_hospital hos on doc.id = hos.doctor_code " +
                " LEFT JOIN dict_hospital_dept dept on hos.org_code = dept.org_code" +
                " AND hos.dept_code = dept.code"+
                /*"\tbase_doctor doc,\n" +
                "\tbase_doctor_hospital hos,\n" +
                "\tdict_hospital_dept dept\n" +
                "WHERE\n" +
                "\tdoc.id = hos.doctor_code\n" +
                "\tdict_hospital_dept dept\n" +*/
                " WHERE 1=1";
                /*"\tdoc.id = hos.doctor_code\n" +
                "AND hos.org_code = dept.org_code\n" +
                "AND hos.dept_code = dept.code\n" ;
                "AND hos.dept_code = dept.code\n"*/
        if (!StringUtils.isEmpty(nameOrIdcard)){
            sql += " and (doc.idcard LIKE '%"+nameOrIdcard+"%' or doc.name LIKE '%"+nameOrIdcard+"%')";
        }if (!StringUtils.isEmpty(orgCode)){

+ 17 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/ExceptionHandler.java

@ -0,0 +1,17 @@
package com.yihu.jw.base.util;
import com.yihu.jw.utils.AdminException;
import com.yihu.jw.utils.sfutils.MyErrorCode;
import org.csource.common.MyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
//该类全局拦截Controller请求
@ControllerAdvice
public class ExceptionHandler {
    //对自定义RuntimeException进行拦截和相关响应的修改
    @org.springframework.web.bind.annotation.ExceptionHandler(AdminException.class)
    public ResponseEntity<ExceptionResult> handlerException(AdminException e) {
        MyErrorCode ee = e.getMyErrorCode();
        return ResponseEntity.status(ee.getCode()).body(new ExceptionResult(ee));
    }}

+ 23 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/ExceptionResult.java

@ -0,0 +1,23 @@
package com.yihu.jw.base.util;
import com.yihu.jw.utils.sfutils.MyErrorCode;
public class ExceptionResult {
    private Integer code;
    private String msg;
    private Long timestamp;
    public Integer getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public ExceptionResult(MyErrorCode ee) {
        this.code = ee.getCode();
        this.msg = ee.getMsg();
        this.timestamp = System.currentTimeMillis();
    }
}

+ 1 - 1
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java

@ -95,7 +95,7 @@ public class MqSdkController extends EnvelopRestEndpoint {
                               @RequestParam(value = "startTime", required = false) String startTime,
                               @ApiParam(name = "endTime", value = "结束时间")
                               @RequestParam(value = "endTime", required = false) String endTime) throws Exception {
        List<WlyyOutpatientVO> obj = entranceService.BS30025(patNo,conNo, startTime, endTime, demoFlag);
        List<WlyyOutpatientVO> obj = entranceService.BS30025(patNo,conNo, startTime, endTime, demoFlag,null);
        return success(obj);
    }

+ 2 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/Application.java

@ -5,12 +5,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
 * Created by Trick on 2019/5/13.
 */
@SpringBootApplication
@EnableJpaAuditing
@EnableScheduling
public class Application extends SpringBootServletInitializer {
    public static void main(String[] args)  {

+ 9 - 10
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/OutPatientRemindJob.java

@ -6,7 +6,6 @@ import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import org.quartz.Job;
@ -20,11 +19,8 @@ import org.springframework.beans.factory.annotation.Value;
import java.util.Date;
import java.util.List;
/**
 * Created by Trick on 2020/3/11
 */
public class OutPatientRemindJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(OutPatientRemindJob.class);
public class DoctorTimeOutTipsJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(DoctorTimeOutTipsJob.class);
    @Autowired
    public ImUtil imUtil;
    @Autowired
@ -33,11 +29,15 @@ public class OutPatientRemindJob implements Job {
    private PrescriptionService prescriptionService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Value("${wechat.id}")
    @Value("${wechat.ids}")
    private String wxId;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient();
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("启动发送超时提示消息开始");
        System.out.println(wxId);
        System.out.println("启动发送超时提示消息开始");
        List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient(5);
        String senderId ="";
        String reciverId = "";
        long timeCount = 0l;
@ -70,6 +70,5 @@ public class OutPatientRemindJob implements Job {
                }
            }
        }
    }
}

+ 2 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java

@ -282,7 +282,7 @@ public class PrescriptionStatusUpdateService {
        //复诊记录状态状态安全锁,每天0~2点才允许触发,避免误调用
        //将所有的已接诊的处方记录
        if(i==0||i==1){
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus("1");
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
            if(outpatientDOs!=null&&outpatientDOs.size()>0){
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){
@ -339,7 +339,7 @@ public class PrescriptionStatusUpdateService {
        //复诊记录状态状态安全锁,每天0~2点才允许触发,避免误调用
        //将所有的已接诊的处方记录
        if(i==0||i==1){
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus("2");
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
            if(outpatientDOs!=null&&outpatientDOs.size()>0){
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){

+ 129 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/AutoTimeOutRemind.java

@ -0,0 +1,129 @@
package com.yihu.jw.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.asn1.cmp.CertOrEncCert;
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.context.annotation.Lazy;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Lazy(false)
@Component
@EnableScheduling
public class AutoTimeOutRemind implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(AutoTimeOutRemind.class);
    private static String cron = "0 0/1 * * * ?";
    private static String dictName = "remind_patient_job";
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    public ImUtil imUtil;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private PrescriptionService prescriptionService;
    @Value("${wechat.ids}")
    private String wxId;
    public AutoTimeOutRemind() {
      cron = "0 0/1 * * * ?";
        System.out.println("创建时的corn"+cron);
    }
    public String change(String corIn){
        if (StringUtils.isNotBlank(corIn)){
            cron = corIn;
        }else {
            List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDO =wlyyHospitalSysDictDao.findByDictName(dictName);
            if (wlyyHospitalSysDictDO.size()>0){
                cron = wlyyHospitalSysDictDO.get(0).getDictValue();
                System.out.println("dict"+ cron);
            }
        }
        System.out.println(cron);
        return "success";
    }
    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.addTriggerTask(new Runnable() {
            @Override
            public void run() {
                logger.info("启动发送超时提示消息开始");
                System.out.println(wxId);
                System.out.println("启动发送超时提示消息开始");
                Integer remindCount = 3;
                List<WlyyHospitalSysDictDO> countList = wlyyHospitalSysDictDao.findByDictName("remind_count");
                if (countList.size()>0){
                    remindCount= null!=countList.get(0).getDictValue()?Integer.parseInt(countList.get(0).getDictValue()):remindCount;
                }
                List<WlyyOutpatientDO> wlyyOutpatientDOS= outpatientDao.findWaitingOutpatient(remindCount);
                String senderId ="";
                String reciverId = "";
                long timeCount = 0l;
                String content = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
                JSONObject object = new JSONObject();
                object.put("socket_sms_type",14);
                object.put("msg",content);
                object.put("msg_time", DateUtil.dateToStrLong(new Date()));
                if (null!=wlyyOutpatientDOS){
                    for (WlyyOutpatientDO wlyyOutpatientDO:wlyyOutpatientDOS){
                        long patientTime = wlyyOutpatientDO.getCreateTime().getTime();
                        Integer currentRemindCount = null==wlyyOutpatientDO.getRemindCount()?0:wlyyOutpatientDO.getRemindCount();
                        logger.info("接诊创建时间="+patientTime);
                        List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDOS = wlyyHospitalSysDictDao.findByDictName("outpatient_timeout_remind");
                        if (wlyyHospitalSysDictDOS.size()>0){
                            timeCount = Long.valueOf(wlyyHospitalSysDictDOS.get(0).getDictValue());
                        }
                        long currentTime = new Date().getTime();
                        logger.info("当前时间="+currentTime);
                        logger.info("数据库配置时间=0"+timeCount);
                        if (currentTime-patientTime>timeCount*60*1000){
                            wlyyOutpatientDO.setRemindCount(currentRemindCount+1);
                            System.out.println("remind_count"+currentRemindCount+1);
                            outpatientDao.save(wlyyOutpatientDO);
                            logger.info("--便利发送消息");
                            reciverId = wlyyOutpatientDO.getPatient();
                            logger.info("---发送人id"+senderId);
                            senderId= wlyyOutpatientDO.getDoctor();
                            logger.info("---接受人Id"+reciverId);
                            imUtil.sendMessage(senderId,reciverId,"1",object.toString());
                            logger.info("--发送结束");
                            logger.info("--模板发送开始");
                            prescriptionService.sendWxTemplateMsg(wxId,wlyyOutpatientDO.getId(),null,null,"outPatientTimeOutRemind","");
                        }
                    }
                }
            }
        }, new Trigger() {
            @Override
            public Date nextExecutionTime(TriggerContext triggerContext) {
                // 任务触发,可修改任务的执行周期
                CronTrigger trigger = new CronTrigger(cron);
                System.out.println("任务触发,可修改任务的执行周期"+cron);
                Date nextExec = trigger.nextExecutionTime(triggerContext);
                return nextExec;
            }
        });
    }
}

+ 19 - 14
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -2,7 +2,6 @@ package com.yihu.jw.web.quota;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.job.QuartzJobConfig;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.internet.service.DataGeneratorService;
@ -16,6 +15,7 @@ import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.repository.job.QuartzJobConfigDao;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.quota.JobService;
import com.yihu.jw.util.AutoTimeOutRemind;
import com.yihu.jw.util.SystemConf;
import com.yihu.jw.web.BaseController;
import com.yihu.jw.wechat.service.WxTemplateService;
@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.sound.midi.Soundbank;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@ -194,20 +195,16 @@ public class JobController extends BaseController {
                    } else {
                        logger.info("pay_status_notice_job  job exist");
                    }
                case "out_patient_remind_job":
                    //互联网医院 待结算消息推送
                    if (!quartzHelper.isExistJob("out_patient_remind_job")) {
                        List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDOS = wlyyHospitalSysDictDao.findByDictName("out_patient_remind_job");
                        String trigger = "";
                        if (wlyyHospitalSysDictDOS.size()>0){
                            trigger = wlyyHospitalSysDictDOS.get(0).getDictValue();
                        }else {
                            trigger = SystemConf.getInstance().getSystemProperties().getProperty("out_patient_remind_job");
                        }
                        quartzHelper.addJob(OutPatientRemindJob.class, trigger, "out_patient_remind_job", new HashMap<String, Object>());
                        logger.info("out_patient_remind_job  job success");
                    break;
                case "CSTXJOB" :
                    if (!quartzHelper.isExistJob("CSTXJOB")) {
                        System.out.println("id"+taskId);
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("CSTXJOB");
                        System.out.println(trigger);
                        quartzHelper.addJob(DoctorTimeOutTipsJob.class, trigger, "CSTXJOB", new HashMap<String, Object>());
                        logger.info("CSTXJOB  job success");
                    } else {
                        logger.info("out_patient_remind_job  job exist");
                        logger.info("CSTXJOB  job exist");
                    }
                    break;
@ -617,4 +614,12 @@ public class JobController extends BaseController {
    }
    @RequestMapping(value = "changeDoctorRemindTimeOut", method = RequestMethod.GET)
    public String changeDoctorRemindTimeOut(String corn){
        AutoTimeOutRemind autoTimeOutRemind = new AutoTimeOutRemind();
        return autoTimeOutRemind.change(corn);
    }
}

+ 8 - 4
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -125,11 +125,13 @@ wlyy:
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
  ids: xm_zsyy_wx
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
jobs:
  schedule: 0 */1 * * * ?
---
spring:
  profiles: jwOracleTest
@ -222,7 +224,7 @@ express:
spring:
  profiles: jwprod
  datasource:
    url: jdbc:mysql://192.0.33.27:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    url: jdbc:mysql://172.16.1.42:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false #jdbc:mysql://192.0.33.27:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: im
    password: 2oEq3Kf7
@ -235,7 +237,7 @@ demo:
pay:
  flag: true
hospital:
  url: https://172.16.1.34
  url: https://wx.xmzsh.com #https://172.16.1.34
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
@ -250,11 +252,13 @@ wlyy:
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
  ids: xm_zsyy_wx
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: WH000091
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
jobs:
  schedule: 0 */30 * * * ?
---
spring:

+ 2 - 1
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -8,13 +8,14 @@ prescription_overdue_job=0 0 1 * * ?
#每天13 点触发
data_upload_job=0 0 2 * * ?
#每10分钟触发一次
out_patient_remind_job = 0 0/10 * * * ? 
#-------------------------中山医院end-----------------------------#
#-------------------------眼科医院-----------------------------#
data_ykupload_job=0 0 0 * * ?
#每间隔1分钟触发
unsettled_prescription_notice_job=0 */1 * * * ?
pay_status_notice_job=0 */1 * * * ?
CSTXJOB=0 */1 * * * ?
#-------------------------眼科医院end-----------------------------#
#-------------------------监管平台通用医院-----------------------------#
data_common_upload_job=0 0 0 * * ?

+ 4 - 5
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -220,15 +220,14 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
					if("0".equals(rsCode)||"-2".equals(rsCode)){
						//挂号成功,已经挂号
						//2.
						result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId);
					}else{
						failed(mes);
						return failed(mes);
					}
					logger.info("调用挂号接口====END");
				}
				
				
				//2.
				result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId);
			}
			return success("操作成功",result);
	}

+ 68 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java

@ -3,7 +3,9 @@ package com.yihu.jw.hospital.endpoint.file_upload;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.file_upload.FileManageService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.restmodel.MutilFileInfo;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -11,17 +13,21 @@ import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.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.mock.web.MockMultipartFile;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;
@ -46,6 +52,8 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private FileManageService fileManageService;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
@ -120,6 +128,66 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
        }
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_video)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStreamVideo(@ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "file", required = true) MultipartFile file,
                                                  @ApiParam(value = "文件", required = false)
                                                  @RequestParam(value = "filename", required = false) String filename,
                                                  @ApiParam(value = "taskId", required = false)
                                                      @RequestParam(value = "taskId", required = false) String taskId,
                                                  @ApiParam(value = "chunk", required = false)
                                                      @RequestParam(value = "chunk", required = false) Integer chunk,
                                                  @ApiParam(value = "文件", required = false)
                                                      @RequestParam(value = "sizesize", required = false) Long size,
                                                  @ApiParam(value = "chunkTotal", required = false)
                                                      @RequestParam(value = "chunkTotal", required = false) Integer chunkTotal,
                                                  @ApiParam(value = "objectType", required = false)
                                                      @RequestParam(value = "objectType", required = false) Integer objectType
                                             ) throws Exception{
        UploadVO uploadVO = new UploadVO();
        MutilFileInfo files = new MutilFileInfo();
        files.setChunk(chunk);
        files.setChunkTotal(chunkTotal);
        files.setFile(file);
        files.setObjectType(objectType);
        files.setSize(file.getSize());
        files.setTaskId(taskId);
        String taskid = fileManageService.chunkUploadByMappedByteBuffer(files);
        if ("unCompelete".equalsIgnoreCase(taskid)){
            System.out.println("第"+files.getChunk());
            return success("未传完",uploadVO);
        }else {
            File file1 = new File(taskid);
            FileInputStream input = new FileInputStream(file1);
            MultipartFile multipartFile = new MockMultipartFile("file", file1.getName(), "text/plain", IOUtils.toByteArray(input));
            if (isClose.equalsIgnoreCase("1")){
                Map<String, Object> map = fileUploadService.uploadImg(multipartFile);
                uploadVO.setFullUri(map.get("accessory").toString());
            }else if(isClose.equals("2")){
                //内网上传
                String rs = fileUploadService.request(remote_inner_url,multipartFile,null);
                logger.info(rs);
                JSONObject json = JSON.parseObject(rs);
                uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
            }else {
                // 得到文件的完整名称  xxx.txt
                String originalFilename = multipartFile.getOriginalFilename();
                //判断文件名称是否有包含后缀,及前端是否有传后缀名称,有的话拼接图片后缀
                if(originalFilename.lastIndexOf(".") == 0 && StringUtils.isNotEmpty(filename)){
                    originalFilename = originalFilename +"."+filename;
                }
                InputStream inputStream = multipartFile.getInputStream();
                uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
                file1.delete();
            }
            return success("上传成功", uploadVO);
        }
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STRING)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")

+ 111 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -26,6 +26,7 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.WorkTimeService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleService;
import com.yihu.jw.hospital.service.consult.QrcodeService;
import com.yihu.jw.hospital.service.consult.SysDictService;
@ -33,6 +34,7 @@ import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
@ -138,6 +140,10 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private KnowledgeArticleService knowledgeArticleService;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private YlzPayService ylzPayService;
    @Autowired
    private EntranceService entranceService;
    private String successxml = "SUCCESS";
@ -730,6 +736,111 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        String uri = qrcodeService.makeSpecialistQrcode(doctor);
        return success("操作成功",uri);
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientNoLogin.querySettledRecord)
    @ApiOperation(value = "易联众_查询结算状态")
    public Envelop querySettledRecord(@ApiParam(name = "cardNo", value = "cardNo", required = true)
                             @RequestParam(value = "cardNo", required = true)String cardNo,
                                      @ApiParam(name = "beginDate", value = "beginDate", required = false)
                                      @RequestParam(value = "beginDate", required = false)String beginDate,
                                      @ApiParam(name = "endDate", value = "endDate", required = false)
                                          @RequestParam(value = "endDate", required = false)String endDate,
                                      @ApiParam(name = "queryType", value = "queryType", required = false)
                                          @RequestParam(value = "queryType", required = false)String queryType,
                                      @ApiParam(name = "billSn", value = "billSn", required = false)
                                          @RequestParam(value = "billSn", required = false)String billSn,
                                      @ApiParam(name = "traceNo", value = "traceNo", required = false)
                                          @RequestParam(value = "traceNo", required = false)String traceNo,
                                      @ApiParam(name = "pageNo", value = "页码", required = false)
                                          @RequestParam(value = "pageNo", required = false)String pageNo,
                                      @ApiParam(name = "pageSize", value = "分页大小", required = false)
                                          @RequestParam(value = "pageSize", required = false)String pageSize) throws Exception{
       String result = ylzPayService.querySettledRecord(cardNo,beginDate,endDate,queryType,billSn,traceNo,pageNo,pageSize);
       logger.info(result);
       return success("操作成功",result);
    }
    @GetMapping(value = BaseHospitalRequestMapping.PatientNoLogin.paySuccessNotice)
    @ApiOperation(value = "微信支付状态查询")
    public Envelop paySuccessNotice(@ApiParam(name = "userName", value = "userName", required = true)
                                      @RequestParam(value = "userName", required = true)String userName,
                                      @ApiParam(name = "idCard", value = "idCard", required = false)
                                      @RequestParam(value = "idCard", required = false)String idCard,
                                      @ApiParam(name = "phone", value = "phone", required = false)
                                      @RequestParam(value = "phone", required = false)String phone,
                                      @ApiParam(name = "title", value = "title", required = false)
                                      @RequestParam(value = "title", required = false)String title,
                                      @ApiParam(name = "url", value = "url", required = false)
                                      @RequestParam(value = "url", required = false)String url,
                                      @ApiParam(name = "doctorName", value = "doctorName", required = false)
                                      @RequestParam(value = "doctorName", required = false)String doctorName,
                                      @ApiParam(name = "total", value = "总费用", required = false)
                                      @RequestParam(value = "total", required = false)String total,
                                      @ApiParam(name = "miPay", value = "医保支付", required = false)
                                      @RequestParam(value = "miPay", required = false)String miPay,
                                    @ApiParam(name = "selfPay", value = "个人支付", required = false)
                                        @RequestParam(value = "selfPay", required = false)String selfPay,
                                    @ApiParam(name = "orderNo", value = "单据号", required = false)
                                        @RequestParam(value = "orderNo", required = false)String orderNo,
                                    @ApiParam(name = "remark", value = "备注", required = false)
                                        @RequestParam(value = "remark", required = false)String remark) throws Exception{
        String result = entranceService.paySuccessNotice(userName,idCard,phone,title,url,doctorName,total,miPay,selfPay,orderNo,remark);
        logger.info(result);
        return success("操作成功",result);
    }
    /**
     * 商户回调通知
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/ylzSettleRecord")
    public String ylzSettleRecord(HttpServletRequest request, HttpServletResponse response) throws Exception{
        response.setContentType("text/html;charset=utf-8");
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
        if(oauthYlzConfigDO==null){
            return "未找到支付配置文件";
        }
        String appId = oauthYlzConfigDO.getAppId();
        String appSecret = oauthYlzConfigDO.getAppKey();
        InputStream inputStream = request.getInputStream();
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        logger.info("回调参数:{}", params);
        if (StringUtil.isEmpty(params)) {
            response.getWriter().write("empty");
            return appId;
        }
        // 参数转换
        ResponseParams<?> encryptRes = JSON.parseObject(params, ResponseParams.class);
        OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
        try {
            logger.info("解密前:{}", JSON.toJSONString(encryptRes));
            ResponseParams<?> decryptRes = client.decryptNotifyResponse(encryptRes);
            logger.info("解密后:{}",JSON.toJSONString(decryptRes) );
            boolean isDecrypt = ("-1".equals(decryptRes.getRespCode()) ? false : true); // 是否解密失败
            if (!isDecrypt) {
                response.getWriter().write("DECRYPT FAILURE");
            } else {
                boolean isVerify = client.verifyResponseSign(decryptRes);
                logger.info("验签结果:{}", isVerify);
                if (!isVerify) {
                    response.getWriter().write("FAILURE");
                } else {
                    JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(decryptRes));
                    JSONObject param = jsonObject.getJSONObject("param");
                    logger.info("param"+params);
                    String cardNo = param.getString("cardNo");
                    String traceNo = param.getString("traceNo");
                    String result = ylzPayService.querySettledRecord(cardNo,null,null,"",null,traceNo,"1","10000");
                    response.getWriter().write("SUCCESS");
                }
            }
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
        }
        return appId;
    }
}

+ 38 - 17
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -130,8 +130,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                          @ApiParam(name = "startTime", value = "开始时间")
                                          @RequestParam(value = "startTime",required = false) String startTime,
                                          @ApiParam(name = "endTime", value = "结束时间")
                                          @RequestParam(value = "endTime",required = false) String endTime) throws Exception {
        List<WlyyOutpatientVO> vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag);
                                          @RequestParam(value = "endTime",required = false) String endTime,
                                          @ApiParam(name = "ksdm", value = "科室代码")
                                              @RequestParam(value = "ksdm",required = false) String ksdm) throws Exception {
        List<WlyyOutpatientVO> vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag,ksdm);
        return success(vos);
    }
    
@ -343,18 +345,33 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "chargeType", required = false)String chargeType)throws Exception {
        
        WlyyOutpatientDO wlyyOutpatientDO = prescriptionService.appointmentRevisit(outpatientJson,expressageJson,registerJson,chargeType);
        
        //发送系统消息
        SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
        //发送IM消息
        hospitalSystemMessageService.sendImMessage(systemMessageDO);
        
        //发送医生抢单消息
        if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
            hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
        if (wlyyOutpatientDO!=null&&null==wlyyOutpatientDO.getId()){
            ObjEnvelop objEnvelop =new ObjEnvelop();
            String msg = "";
            if (1==wlyyOutpatientDO.getRemindCount()){
                msg = "自取";
            }else {
                msg = "快递配送";
            }
            objEnvelop.setMessage("您已经选择过"+msg+"方式,请勿修改");
            objEnvelop.setStatus(300);
            return objEnvelop;
        }else {
            //发送系统消息
            SystemMessageDO systemMessageDO = prescriptionService.sendOutPatientMes(wlyyOutpatientDO,payFlag);
            //发送IM消息
            hospitalSystemMessageService.sendImMessage(systemMessageDO);
            //发送医生抢单消息
            if(StringUtils.isBlank(wlyyOutpatientDO.getDoctor())){
                hospitalSystemMessageService.sendImPichCheckMessage(wlyyOutpatientDO);
            }
            return success(BaseHospitalRequestMapping.Prescription.api_success,wlyyOutpatientDO);
        }
        
        return success(BaseHospitalRequestMapping.Prescription.api_success,wlyyOutpatientDO);
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getICD10)
@ -411,8 +428,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                    @ApiParam(name = "inspectionJson", value = "检查检验")
                                    @RequestParam(value = "inspectionJson", required = false)String inspectionJson,
                                    @ApiParam(name = "emrJson", value = "电子病历")
                                        @RequestParam(value = "emrJson", required = false)String emrJson)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson);
                                        @RequestParam(value = "emrJson", required = false)String emrJson,
                                    @ApiParam(name = "prescriptionId", value = "处方id")
                                        @RequestParam(value = "prescriptionId", required = false)String prescriptionId)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,prescriptionId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson);
        try {
            
            com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
@ -1200,8 +1219,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                        @ApiParam(name = "name", value = "医生名称")
                                        @RequestParam(value = "name",required = false)String name,
                                        @ApiParam(name = "chargeType", value = "号别")
                                        @RequestParam(value = "chargeType",required = false)String chargeType) {
        return success(prescriptionService.findDoctorByName(hospital,name,chargeType));
                                        @RequestParam(value = "chargeType",required = false)String chargeType,
                                        @ApiParam(name = "dept", value = "科室")
                                            @RequestParam(value = "dept",required = false)String dept) {
        return success(prescriptionService.findDoctorByName(hospital,name,chargeType,dept));
    }
    
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findDeptWithDoctorWorkTime)