فهرست منبع

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

chenweida 7 سال پیش
والد
کامیت
61c22e791c
49فایلهای تغییر یافته به همراه2100 افزوده شده و 856 حذف شده
  1. 3 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  3. 79 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdjustReason.java
  4. 5 5
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExplain.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionPay.java
  6. 70 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReasonDict.java
  7. 78 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReviewedReason.java
  8. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/CommonController.java
  9. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  10. 4 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/zydict/ZyIvPhysicDictDao.java
  11. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftBaseService.java
  12. 13 452
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCAService.java
  13. 509 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCATestServiceImp.java
  14. 510 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionProCAServiceImp.java
  15. 128 96
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  16. 13 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustReasonDao.java
  17. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReasonDictDao.java
  18. 12 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReviewedReasonDao.java
  19. 0 18
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  20. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  21. 2 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  22. 50 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java
  23. 6 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/MutableHttpServletRequest.java
  24. 101 101
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java
  25. 44 44
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  26. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustReasonDao.java
  27. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionInfoDao.java
  28. 17 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReasonDictDao.java
  29. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReviewedReasonDao.java
  30. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/zydict/ZyCommonDictDao.java
  31. 5 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/zydict/ZyIvPhysicDictDao.java
  32. 25 41
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  33. 49 31
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  34. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  35. 23 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionAdjustService.java
  36. 80 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  37. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  38. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  39. 75 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  40. 45 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/ZyDictService.java
  41. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/device/DeviceController.java
  42. 3 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  43. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  44. 7 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java
  45. 21 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  46. 18 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  47. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java
  48. 18 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  49. 4 3
      patient-co/patient-co-wlyy/src/main/resources/application.yml

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java


+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -680,7 +680,7 @@ public class Prescription extends IdEntity {
    public void setMinDrugDay(Integer minDrugDay) {
        this.minDrugDay = minDrugDay;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPresCreateTime() {
        return presCreateTime;
    }

+ 79 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdjustReason.java

@ -0,0 +1,79 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2017/8/26.
 */
@Entity
@Table(name = "wlyy_prescription_adjust_reason")
public class PrescriptionAdjustReason extends IdEntity {
    private String code;//业务CODE
    private String prescriptionCode;//续方code
    private String adjustCode;//调整code
    private String reasonCode;//调整原因code
    private String reasonValue;//调整原因code
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public String getAdjustCode() {
        return adjustCode;
    }
    public void setAdjustCode(String adjustCode) {
        this.adjustCode = adjustCode;
    }
    public String getReasonCode() {
        return reasonCode;
    }
    public void setReasonCode(String reasonCode) {
        this.reasonCode = reasonCode;
    }
    public String getReasonValue() {
        return reasonValue;
    }
    public void setReasonValue(String reasonValue) {
        this.reasonValue = reasonValue;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 5 - 5
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExplain.java

@ -16,7 +16,7 @@ public class PrescriptionExplain extends IdEntity {
    private String content;//续方说明
    private String del;//是否有效,1有效,0无效
    private Date createTiem;
    private Date createTime;
    public String getContent() {
        return content;
@ -34,11 +34,11 @@ public class PrescriptionExplain extends IdEntity {
        this.del = del;
    }
    public Date getCreateTiem() {
        return createTiem;
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTiem(Date createTiem) {
        this.createTiem = createTiem;
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionPay.java

@ -9,7 +9,7 @@ import java.util.Date;
/**
 * Created by chenweida on 2017/7/26.
 * 处方支付表
 * 处方支付实体
 */
@Entity
@Table(name = "wlyy_prescription_pay")

+ 70 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReasonDict.java

@ -0,0 +1,70 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2017/8/26.
 */
@Entity
@Table(name = "wlyy_prescription_Reason_dict")
public class PrescriptionReasonDict extends IdEntity {
    private String code;//编码code
    private String value;//原因内容
    private Integer type;//类型:0 审核原因标签;1 调整原因标签
    private Integer sort;//排序号
    private Date createTime;//创建时间
    private Date updateTime;//修改时间
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 78 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionReviewedReason.java

@ -0,0 +1,78 @@
package com.yihu.wlyy.entity.patient.prescription;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2017/8/26.
 */
@Entity
@Table(name = "wlyy_prescription_reviewed_reason")
public class PrescriptionReviewedReason extends IdEntity {
    private String code;//业务CODE
    private String prescriptionCode;//续方code
    private String reviewedCode;//调整code
    private String reasonCode;//审核原因code
    private String reasonValue;//审核原因值
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public String getReviewedCode() {
        return reviewedCode;
    }
    public void setReviewedCode(String reviewedCode) {
        this.reviewedCode = reviewedCode;
    }
    public String getReasonCode() {
        return reasonCode;
    }
    public void setReasonCode(String reasonCode) {
        this.reasonCode = reasonCode;
    }
    public String getReasonValue() {
        return reasonValue;
    }
    public void setReasonValue(String reasonValue) {
        this.reasonValue = reasonValue;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/CommonController.java

@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
@Controller
@RestController
@RequestMapping(value = "/common/")
@Api(description = "长处方接口")
@Api(description = "公共请求接口")
public class CommonController {
    private static Logger logger = LoggerFactory.getLogger(CommonController.class);

+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java

@ -85,7 +85,7 @@ public class PrescriptionController extends BaseController{
	@RequestMapping(value = "readNewsOnline",method = RequestMethod.POST)
	@ApiOperation("提供在线问诊消息调阅")
	public String readNewsOnline(@ApiParam(name="data",value="json串",defaultValue = "{}")
	public String readNewsOnline(@ApiParam(name="data",value="json串",defaultValue = "{\"CODE\":1,\"RECIPE_NO\":\"0\",\"ORDER_NO\":\"DB0537136\"}")
								 @RequestParam(value = "data",required = true) String data){
		try {
			String url = prescriptionService.getReadNewsOnline(data);

+ 4 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/zydict/ZyIvPhysicDictDao.java

@ -2,10 +2,14 @@ package com.yihu.wlyy.service.dao.zydict;
import com.yihu.wlyy.service.entity.zydict.ZyIvPhysicDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/8/11.
 */
public interface ZyIvPhysicDictDao extends PagingAndSortingRepository<ZyIvPhysicDict, Long>, JpaSpecificationExecutor<ZyIvPhysicDict> {
    @Query("select p from ZyIvPhysicDict p where p.physicCode=?1")
    ZyIvPhysicDict findByPhysicCode(String physicCode);
}

+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftBaseService.java

@ -243,7 +243,7 @@ public class ZysoftBaseService {
            //保存http日志
//            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            logService.saveZyPushLog(api,content,null,"POST",msgHeader+","+msgBody,re,"0","2");
            logService.saveZyPushLog(api,content,error,"POST",msgHeader+","+msgBody,re,"0","2");
            if(ex instanceof ApiException)
            {

+ 13 - 452
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCAService.java

@ -1,18 +1,11 @@
package com.yihu.wlyy.service.service.prescription;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.SystemConfig;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.common.util.WebserviceUtil;
import com.yihu.wlyy.service.service.LogService;
import com.yihu.wlyy.service.service.ZysoftApi;
import com.yihu.wlyy.service.service.ZysoftBaseService;
import com.zoe.phip.ssp.sdk.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
@ -20,48 +13,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * Created by hzp on 2017-07-31
 * 长处方CA认证服务
 * Created by ${liuwenbin} on 2017/8/28.
 */
@Service
public class PrescriptionCAService extends ZysoftBaseService {
    private String IS_APPLIED="XMCAF_SOFT_judgeRealNameSoftCertIsApplied"; //判断实名软证书是否已申请
    private String REQUEST_SIGN = "XMCAF_SOFT_requestRealNameSoftCertAndSign";//请求实名软证书并进行数字签名
    private String EXPIRED_DATETIME = "XMCAF_SOFT_getRealNameSoftCertExpiredDatetime"; //获取实名软证书的过期时间
    private String MODIFY_PASSWD = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd"; //修改实名软证书调用保护口令
    private String VERIFY_SIGN = "XMCA3_JMSVR_verifySignOnMultiServer"; //验证签名(带多服务器负载均衡)
    private String unifiedCallInterface = "XMCA6_UnifiedCallInterface";
    @Autowired
    private LogService logService;
    @Autowired
    private ObjectMapper objectMapper;
public interface PrescriptionCAService {
    private String getHeaderXml(String api,String srcBusinessStreamNO,String srcRequestStreamNO)
    {
        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<root>\n" +
            "   <serverName>"+api+"</serverName>\n" +
            "   <format>xml</format>\n" +
            "   <callOperator></callOperator>\n" +
            "   <certificate></certificate>\n" +
            "   <srcIP>10.95.22.10</srcIP >\n" +
            "   <srcUserMac>00:50:56:85:39:82</srcUserMac>\n" +
            "   <srcSystemCode>1</srcSystemCode>\n" +
            "   <srcSystemName>厦门i健康</srcSystemName>\n" +
            "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
            "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
            "   <srcOperatorAccount>"+srcBusinessStreamNO+"</srcOperatorAccount>\n" +
            "   <srcBusinessStreamNO>"+srcBusinessStreamNO+"</srcBusinessStreamNO>\n" +
            "   <srcRequestStreamNO>"+srcRequestStreamNO+"</srcRequestStreamNO>\n" +
            "   <srcDataExtProperty></srcDataExtProperty>\n" +
            "</root>";
    }
//    String getHeaderXml(String api,String srcBusinessStreamNO,String srcRequestStreamNO);
    /**
     * 生产环境 智业CA接口二次封装
@ -71,432 +28,36 @@ public class PrescriptionCAService extends ZysoftBaseService {
     * @return
     * @throws Exception
     */
    public String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<root>\n";
        if(params!=null && params.size()>0)
        {
            for(String key : params.keySet())
            {
                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
            }
        }
        msgBody += "</root>";
        String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
        String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
        System.out.println("msgHerder:"+msgHeader);
        System.out.println("msgBody:"+msgBody);
        String re = "";
        Map<String,String> paramsList = new HashMap<>();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        int times = 0;
        try {
//            re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
            re = ZysoftApi.getSingleton().capost(paramsList, null,true);
            System.out.println("re=====>:"+re);
//            Map<String,String> map = objectMapper.readValue(re,Map.class);
//            String code = map.get("CODE");
//
//            if(!code.equals("1"))
//            {
//                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
//            }
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            System.out.println("error1:"+ex.getMessage());
            error = sw.toString();
            System.out.println("error2:"+error);
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                System.out.println("error3:"+ex.getMessage());
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                System.out.println("error4:"+ex.getMessage());
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
//    public String postZyCaServer(String api, Map<String,String> params, String srcBusinessStreamNO, String content) throws Exception;
    /**
     * 测试环境:CA认证服务二次封装
     */
    private String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception
    {
        String urlString = SystemConfig.sysPropertiesSets.get("ca_url");
        String namespace = SystemConfig.sysPropertiesSets.get("ca_namespace");
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                         "<root>\n";
        if(params!=null && params.size()>0)
        {
            for(String key : params.keySet())
            {
                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
            }
        }
        msgBody += "</root>";
        String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
        String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
        Map<String,String> p = new HashMap<>();
        p.put("msgHeader",msgHeader);
        p.put("msgBody",msgBody);
        return WebserviceUtil.post(urlString,namespace,unifiedCallInterface,p);
    }
    /**
     * 判断是否有实名证书
     **/
    public String isApplied(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = IS_APPLIED;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            //生产环境,调用智业统一平台接口,rest接口
            re = postZyCaServer(action, params,srcBusinessStreamNO,"判断是否有实名证书");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"判断是否有实名证书","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
//    public String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception;
    /**
     * 请求实名软证书并进行数字签名
     **/
    public String requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = REQUEST_SIGN;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            params.put("strRealNameSoftCertCalledPasswd",strRealNameSoftCertCalledPasswd);
            params.put("strOriginalData",strOriginalData);
//            params.put("srcBusinessStreamNO",srcBusinessStreamNO);
            body = objectMapper.writeValueAsString(params);
            //测试环境开启下面这行代码,webservice接口
//            re = postCAServer(action, params,srcBusinessStreamNO);
            //生产环境,调用智业统一平台接口,rest接口
            re = postZyCaServer(action, params,srcBusinessStreamNO,"请求实名软证书并进行数字签名");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
    public String requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData,String srcBusinessStreamNO)  throws Exception;
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess, action, "请求实名软证书并进行数字签名", "POST", null, body, re, error, logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 获取实名软证书的过期时间
     **/
    public String getRealNameSoftCertExpiredDatetime(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = EXPIRED_DATETIME;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            re = postZyCaServer(action, params,srcBusinessStreamNO,"获取实名软证书的过期时间");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"获取实名软证书的过期时间","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    public String getRealNameSoftCertExpiredDatetime(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception;
    /**
     * 修改实名软证书调用保护口令
     **/
    public String modifyRealNameSoftCertCalledPasswd(String strUserIdcardNum,String strOldCalledPasswd,String strNewCalledPasswd,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        Throwable errorLog =null;
        String action = MODIFY_PASSWD;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            params.put("strOldCalledPasswd",strOldCalledPasswd);
            params.put("strNewCalledPasswd",strNewCalledPasswd);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            re = postZyCaServer(action, params,srcBusinessStreamNO,"修改实名软证书调用保护口令");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
            errorLog = ex.getCause();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"修改实名软证书调用保护口令","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        if(errorLog!=null)
        {
            throw new Exception("CA服务器维护中。。。");
        }
        return re;
    }
    public String modifyRealNameSoftCertCalledPasswd(String strUserIdcardNum,String strOldCalledPasswd,String strNewCalledPasswd,String srcBusinessStreamNO) throws Exception;
    /**
     * 验证签名(带多服务器负载均衡)
     **/
    public String verifySignOnMultiServer(String strSignData,String strCertData,String strOriginalData,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = VERIFY_SIGN;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strSignData",strSignData);
            params.put("strCertData",strCertData);
            params.put("strOriginalData",strOriginalData);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            re = postZyCaServer(action, params,srcBusinessStreamNO,"验证签名(带多服务器负载均衡)");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
    public String verifySignOnMultiServer(String strSignData,String strCertData,String strOriginalData,String srcBusinessStreamNO)  throws Exception;
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"验证签名","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
//    public static void main(String args[]) {
//        try {
//            String caUrl = SystemConfig.getInstance().getCAUrl();
//            String caNamespace = SystemConfig.getInstance().getCANamespace();
//            /*//获取实名软证书的过期时间
//            String api = "XMCAF_SOFT_getRealNameSoftCertExpiredDatetime";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "</root>";*/
//
//            /*//判断实名软证书是否已申请
//            String api = "XMCAF_SOFT_judgeRealNameSoftCertIsApplied";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "</root>";*/
//
//            //修改实名软证书调用保护口令
//            String api = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "   <strOldCalledPasswd>12345678</strOldCalledPasswd>\n" +
//                    "   <strNewCalledPasswd>11111111</strNewCalledPasswd>\n" +
//                    "</root>";
//
//
//            //请求实名软证书并进行数字签名
//            /*String orgData = "测试数据";
//            String api = "XMCAF_SOFT_requestRealNameSoftCertAndSign";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "   <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "   <strRealNameSoftCertCalledPasswd>11111111</strRealNameSoftCertCalledPasswd>\n" +
//                    "   <strOriginalData>"+ MD5Util.GetMD5Code(orgData)+"</strOriginalData>\n" +
//                    "</root>";*/
//
//            String msgHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n" +
//                    "   <serverName>"+api+"</serverName>\n" +
//                    "   <format>xml</format>\n" +
//                    "   <callOperator></callOperator>\n" +
//                    "   <certificate></certificate>\n" +
//
//                    "   <srcIP>10.95.22.10</srcIP >\n" +
//                    "   <srcUserMac>60-D8-19-57-66-E3</srcUserMac>\n" +
//                    "   <srcSystemCode>1</srcSystemCode>\n" +
//                    "   <srcSystemName>厦门i健康</srcSystemName>\n" +
//                    "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
//                    "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
//                    "   <srcOperatorAccount>Zhuangsd</srcOperatorAccount>\n" +
//                    "   <srcBusinessStreamNO>11111</srcBusinessStreamNO>\n" +
//                    "   <srcDataExtProperty></srcDataExtProperty>\n" +
//                    "</root>";
//
//
//
//            Map<String, String> params = new HashMap<>();
//            params.put("msgBody", msgBody);
//            params.put("msgHeader", msgHeader);
//            System.out.print(WebserviceUtil.post(caUrl, caNamespace, "XMCA6_UnifiedCallInterface", params) + "\r\n");
//
//
//
//        }
//        catch (Exception ex)
//        {
//            ex.printStackTrace();
//        }
//    }
    /**
     * 判断是否有实名证书
     **/
    public String isApplied(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception;
}

+ 509 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionCATestServiceImp.java

@ -0,0 +1,509 @@
package com.yihu.wlyy.service.service.prescription;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.SystemConfig;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.common.util.WebserviceUtil;
import com.yihu.wlyy.service.service.LogService;
import com.yihu.wlyy.service.service.ZysoftApi;
import com.yihu.wlyy.service.service.ZysoftBaseService;
import com.zoe.phip.ssp.sdk.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * Created by hzp on 2017-07-31
 * 长处方CA认证服务
 */
@Profile({"dev","test"})
@Service
public class PrescriptionCATestServiceImp extends ZysoftBaseService implements PrescriptionCAService{
    private String IS_APPLIED="XMCAF_SOFT_judgeRealNameSoftCertIsApplied"; //判断实名软证书是否已申请
    private String REQUEST_SIGN = "XMCAF_SOFT_requestRealNameSoftCertAndSign";//请求实名软证书并进行数字签名
    private String EXPIRED_DATETIME = "XMCAF_SOFT_getRealNameSoftCertExpiredDatetime"; //获取实名软证书的过期时间
    private String MODIFY_PASSWD = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd"; //修改实名软证书调用保护口令
    private String VERIFY_SIGN = "XMCA3_JMSVR_verifySignOnMultiServer"; //验证签名(带多服务器负载均衡)
    private String unifiedCallInterface = "XMCA6_UnifiedCallInterface";
    @Autowired
    private LogService logService;
    @Autowired
    private ObjectMapper objectMapper;
    private String getHeaderXml(String api,String srcBusinessStreamNO,String srcRequestStreamNO)
    {
        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<root>\n" +
            "   <serverName>"+api+"</serverName>\n" +
            "   <format>xml</format>\n" +
            "   <callOperator></callOperator>\n" +
            "   <certificate></certificate>\n" +
            "   <srcIP>10.95.22.10</srcIP >\n" +
            "   <srcUserMac>00:50:56:85:39:82</srcUserMac>\n" +
            "   <srcSystemCode>1</srcSystemCode>\n" +
            "   <srcSystemName>厦门i健康</srcSystemName>\n" +
            "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
            "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
            "   <srcOperatorAccount>"+srcBusinessStreamNO+"</srcOperatorAccount>\n" +
            "   <srcBusinessStreamNO>"+srcBusinessStreamNO+"</srcBusinessStreamNO>\n" +
            "   <srcRequestStreamNO>"+srcRequestStreamNO+"</srcRequestStreamNO>\n" +
            "   <srcDataExtProperty></srcDataExtProperty>\n" +
            "</root>";
    }
    /**
     * 生产环境 智业CA接口二次封装
     * @param api
     * @param params
     * @param srcBusinessStreamNO
     * @return
     * @throws Exception
     */
//    public String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
//
//
//        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                "<root>\n";
//        if(params!=null && params.size()>0)
//        {
//            for(String key : params.keySet())
//            {
//                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
//            }
//        }
//        msgBody += "</root>";
//        String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
//        String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
//
//        System.out.println("msgHerder:"+msgHeader);
//        System.out.println("msgBody:"+msgBody);
//
//        String re = "";
//        Map<String,String> paramsList = new HashMap<>();
//        paramsList.put("msgHeader",msgHeader);
//        paramsList.put("msgBody",msgBody);
//
//
//        //新增日志
//        String method = "POST";
//        Boolean isSuccess = true;
//        String error = "";
//
//        int times = 0;
//        try {
////            re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
//            re = ZysoftApi.getSingleton().capost(paramsList, null,true);
//
//            System.out.println("re=====>:"+re);
////            Map<String,String> map = objectMapper.readValue(re,Map.class);
////            String code = map.get("CODE");
////
////            if(!code.equals("1"))
////            {
////                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
////            }
//
//            //保存http日志
//            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
//        }
//        catch (Exception ex)
//        {
//            StringWriter sw = new StringWriter();
//            PrintWriter pw = new PrintWriter(sw);
//            ex.printStackTrace(pw);
//            System.out.println("error1:"+ex.getMessage());
//            error = sw.toString();
//            System.out.println("error2:"+error);
//
//            //保存http日志
//            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
//
//            if(ex instanceof ApiException)
//            {
//                ApiException apiEx = (ApiException) ex;
//                System.out.println("error3:"+ex.getMessage());
//                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
//            }
//            else{
//                System.out.println("error4:"+ex.getMessage());
//                throw new HttpApiException(-1,ex.getMessage());
//            }
//        }
//
//        return re;
//
//    }
    /**
     * 测试环境:CA认证服务二次封装
     */
    private String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception
    {
        String urlString = SystemConfig.getInstance().getSystemProperties().getProperty("ca_url");
        String namespace = SystemConfig.getInstance().getSystemProperties().getProperty("ca_namespace");
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                         "<root>\n";
        if(params!=null && params.size()>0)
        {
            for(String key : params.keySet())
            {
                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
            }
        }
        msgBody += "</root>";
        String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
        String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
        Map<String,String> p = new HashMap<>();
        p.put("msgHeader",msgHeader);
        p.put("msgBody",msgBody);
        return WebserviceUtil.post(urlString,namespace,unifiedCallInterface,p);
    }
    /**
     * 判断是否有实名证书
     **/
    @Override
    public String isApplied(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = IS_APPLIED;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(action, params,srcBusinessStreamNO);
            //生产环境,调用智业统一平台接口,rest接口
//            re = postZyCaServer(action, params,srcBusinessStreamNO,"判断是否有实名证书");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"判断是否有实名证书","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 请求实名软证书并进行数字签名
     **/
    @Override
    public String requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = REQUEST_SIGN;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            params.put("strRealNameSoftCertCalledPasswd",strRealNameSoftCertCalledPasswd);
            params.put("strOriginalData",strOriginalData);
//            params.put("srcBusinessStreamNO",srcBusinessStreamNO);
            body = objectMapper.writeValueAsString(params);
            //测试环境开启下面这行代码,webservice接口
            re = postCAServer(action, params,srcBusinessStreamNO);
            //生产环境,调用智业统一平台接口,rest接口
//            re = postZyCaServer(action, params,srcBusinessStreamNO,"请求实名软证书并进行数字签名");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess, action, "请求实名软证书并进行数字签名", "POST", null, body, re, error, logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 获取实名软证书的过期时间
     **/
    @Override
    public String getRealNameSoftCertExpiredDatetime(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = EXPIRED_DATETIME;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(action, params,srcBusinessStreamNO);
//            re = postZyCaServer(action, params,srcBusinessStreamNO,"获取实名软证书的过期时间");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"获取实名软证书的过期时间","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 修改实名软证书调用保护口令
     **/
    @Override
    public String modifyRealNameSoftCertCalledPasswd(String strUserIdcardNum,String strOldCalledPasswd,String strNewCalledPasswd,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        Throwable errorLog =null;
        String action = MODIFY_PASSWD;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            params.put("strOldCalledPasswd",strOldCalledPasswd);
            params.put("strNewCalledPasswd",strNewCalledPasswd);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(action, params,srcBusinessStreamNO);
//            re = postZyCaServer(action, params,srcBusinessStreamNO,"修改实名软证书调用保护口令");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
            errorLog = ex.getCause();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"修改实名软证书调用保护口令","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        if(errorLog!=null)
        {
            throw new Exception("CA服务器维护中。。。");
        }
        return re;
    }
    /**
     * 验证签名(带多服务器负载均衡)
     **/
    @Override
    public String verifySignOnMultiServer(String strSignData,String strCertData,String strOriginalData,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = VERIFY_SIGN;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strSignData",strSignData);
            params.put("strCertData",strCertData);
            params.put("strOriginalData",strOriginalData);
            body = objectMapper.writeValueAsString(params);
            re = postCAServer(action, params,srcBusinessStreamNO);
//            re = postZyCaServer(action, params,srcBusinessStreamNO,"验证签名(带多服务器负载均衡)");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"验证签名","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
//    public static void main(String args[]) {
//        try {
//            String caUrl = SystemConfig.getInstance().getCAUrl();
//            String caNamespace = SystemConfig.getInstance().getCANamespace();
//            /*//获取实名软证书的过期时间
//            String api = "XMCAF_SOFT_getRealNameSoftCertExpiredDatetime";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "</root>";*/
//
//            /*//判断实名软证书是否已申请
//            String api = "XMCAF_SOFT_judgeRealNameSoftCertIsApplied";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "</root>";*/
//
//            //修改实名软证书调用保护口令
//            String api = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "   <strOldCalledPasswd>12345678</strOldCalledPasswd>\n" +
//                    "   <strNewCalledPasswd>11111111</strNewCalledPasswd>\n" +
//                    "</root>";
//
//
//            //请求实名软证书并进行数字签名
//            /*String orgData = "测试数据";
//            String api = "XMCAF_SOFT_requestRealNameSoftCertAndSign";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "   <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "   <strRealNameSoftCertCalledPasswd>11111111</strRealNameSoftCertCalledPasswd>\n" +
//                    "   <strOriginalData>"+ MD5Util.GetMD5Code(orgData)+"</strOriginalData>\n" +
//                    "</root>";*/
//
//            String msgHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n" +
//                    "   <serverName>"+api+"</serverName>\n" +
//                    "   <format>xml</format>\n" +
//                    "   <callOperator></callOperator>\n" +
//                    "   <certificate></certificate>\n" +
//
//                    "   <srcIP>10.95.22.10</srcIP >\n" +
//                    "   <srcUserMac>60-D8-19-57-66-E3</srcUserMac>\n" +
//                    "   <srcSystemCode>1</srcSystemCode>\n" +
//                    "   <srcSystemName>厦门i健康</srcSystemName>\n" +
//                    "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
//                    "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
//                    "   <srcOperatorAccount>Zhuangsd</srcOperatorAccount>\n" +
//                    "   <srcBusinessStreamNO>11111</srcBusinessStreamNO>\n" +
//                    "   <srcDataExtProperty></srcDataExtProperty>\n" +
//                    "</root>";
//
//
//
//            Map<String, String> params = new HashMap<>();
//            params.put("msgBody", msgBody);
//            params.put("msgHeader", msgHeader);
//            System.out.print(WebserviceUtil.post(caUrl, caNamespace, "XMCA6_UnifiedCallInterface", params) + "\r\n");
//
//
//
//        }
//        catch (Exception ex)
//        {
//            ex.printStackTrace();
//        }
//    }
}

+ 510 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionProCAServiceImp.java

@ -0,0 +1,510 @@
package com.yihu.wlyy.service.service.prescription;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.SystemConfig;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.common.util.WebserviceUtil;
import com.yihu.wlyy.service.service.LogService;
import com.yihu.wlyy.service.service.ZysoftApi;
import com.yihu.wlyy.service.service.ZysoftBaseService;
import com.zoe.phip.ssp.sdk.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * Created by hzp on 2017-07-31
 * 长处方CA认证服务
 */
@Profile({"production"})
@Service
public class PrescriptionProCAServiceImp extends ZysoftBaseService implements PrescriptionCAService{
    private String IS_APPLIED="XMCAF_SOFT_judgeRealNameSoftCertIsApplied"; //判断实名软证书是否已申请
    private String REQUEST_SIGN = "XMCAF_SOFT_requestRealNameSoftCertAndSign";//请求实名软证书并进行数字签名
    private String EXPIRED_DATETIME = "XMCAF_SOFT_getRealNameSoftCertExpiredDatetime"; //获取实名软证书的过期时间
    private String MODIFY_PASSWD = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd"; //修改实名软证书调用保护口令
    private String VERIFY_SIGN = "XMCA3_JMSVR_verifySignOnMultiServer"; //验证签名(带多服务器负载均衡)
    private String unifiedCallInterface = "XMCA6_UnifiedCallInterface";
    @Autowired
    private LogService logService;
    @Autowired
    private ObjectMapper objectMapper;
    private String getHeaderXml(String api,String srcBusinessStreamNO,String srcRequestStreamNO)
    {
        return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<root>\n" +
            "   <serverName>"+api+"</serverName>\n" +
            "   <format>xml</format>\n" +
            "   <callOperator></callOperator>\n" +
            "   <certificate></certificate>\n" +
            "   <srcIP>10.95.22.10</srcIP >\n" +
            "   <srcUserMac>00:50:56:85:39:82</srcUserMac>\n" +
            "   <srcSystemCode>1</srcSystemCode>\n" +
            "   <srcSystemName>厦门i健康</srcSystemName>\n" +
            "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
            "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
            "   <srcOperatorAccount>"+srcBusinessStreamNO+"</srcOperatorAccount>\n" +
            "   <srcBusinessStreamNO>"+srcBusinessStreamNO+"</srcBusinessStreamNO>\n" +
            "   <srcRequestStreamNO>"+srcRequestStreamNO+"</srcRequestStreamNO>\n" +
            "   <srcDataExtProperty></srcDataExtProperty>\n" +
            "</root>";
    }
    /**
     * 生产环境 智业CA接口二次封装
     * @param api
     * @param params
     * @param srcBusinessStreamNO
     * @return
     * @throws Exception
     */
    private String postZyCaServer(String api, Map<String,String> params,String srcBusinessStreamNO,String content) throws Exception{
        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<root>\n";
        if(params!=null && params.size()>0)
        {
            for(String key : params.keySet())
            {
                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
            }
        }
        msgBody += "</root>";
        String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
        String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
        System.out.println("msgHerder:"+msgHeader);
        System.out.println("msgBody:"+msgBody);
        String re = "";
        Map<String,String> paramsList = new HashMap<>();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        int times = 0;
        try {
//            re = ZysoftApi.getSingleton().post(ca_url, paramsList, null,true);
            re = ZysoftApi.getSingleton().capost(paramsList, null,true);
            System.out.println("re=====>:"+re);
//            Map<String,String> map = objectMapper.readValue(re,Map.class);
//            String code = map.get("CODE");
//
//            if(!code.equals("1"))
//            {
//                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
//            }
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            System.out.println("error1:"+ex.getMessage());
            error = sw.toString();
            System.out.println("error2:"+error);
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                System.out.println("error3:"+ex.getMessage());
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                System.out.println("error4:"+ex.getMessage());
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /**
     * 测试环境:CA认证服务二次封装
     */
//    public String postCAServer(String api, Map<String,String> params,String srcBusinessStreamNO) throws Exception
//    {
//
//        String urlString = SystemConfig.sysPropertiesSets.get("ca_url");
//        String namespace = SystemConfig.sysPropertiesSets.get("ca_namespace");
//
//        String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                         "<root>\n";
//        if(params!=null && params.size()>0)
//        {
//            for(String key : params.keySet())
//            {
//                msgBody += "    <"+key+">"+params.get(key)+"</"+key+">\n";
//            }
//        }
//
//        msgBody += "</root>";
//        String srcRequestStreamNO = UUID.randomUUID().toString().replace("-", "");
//        String msgHeader = getHeaderXml(api,srcBusinessStreamNO,srcRequestStreamNO);
//
//        Map<String,String> p = new HashMap<>();
//        p.put("msgHeader",msgHeader);
//        p.put("msgBody",msgBody);
//        return WebserviceUtil.post(urlString,namespace,unifiedCallInterface,p);
//    }
    /**
     * 判断是否有实名证书
     **/
    @Override
    public String isApplied(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = IS_APPLIED;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            //生产环境,调用智业统一平台接口,rest接口
            re = postZyCaServer(action, params,srcBusinessStreamNO,"判断是否有实名证书");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"判断是否有实名证书","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 请求实名软证书并进行数字签名
     **/
    @Override
    public String requestRealNameSoftCertAndSign(String strUserIdcardNum,String strRealNameSoftCertCalledPasswd,String strOriginalData,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = REQUEST_SIGN;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            params.put("strRealNameSoftCertCalledPasswd",strRealNameSoftCertCalledPasswd);
            params.put("strOriginalData",strOriginalData);
//            params.put("srcBusinessStreamNO",srcBusinessStreamNO);
            body = objectMapper.writeValueAsString(params);
            //测试环境开启下面这行代码,webservice接口
//            re = postCAServer(action, params,srcBusinessStreamNO);
            //生产环境,调用智业统一平台接口,rest接口
            re = postZyCaServer(action, params,srcBusinessStreamNO,"请求实名软证书并进行数字签名");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess, action, "请求实名软证书并进行数字签名", "POST", null, body, re, error, logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 获取实名软证书的过期时间
     **/
    @Override
    public String getRealNameSoftCertExpiredDatetime(String strUserIdcardNum,String srcBusinessStreamNO)  throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = EXPIRED_DATETIME;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            re = postZyCaServer(action, params,srcBusinessStreamNO,"获取实名软证书的过期时间");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"获取实名软证书的过期时间","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
    /**
     * 修改实名软证书调用保护口令
     **/
    @Override
    public String modifyRealNameSoftCertCalledPasswd(String strUserIdcardNum,String strOldCalledPasswd,String strNewCalledPasswd,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        Throwable errorLog =null;
        String action = MODIFY_PASSWD;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strUserIdcardNum",strUserIdcardNum);
            params.put("strOldCalledPasswd",strOldCalledPasswd);
            params.put("strNewCalledPasswd",strNewCalledPasswd);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            re = postZyCaServer(action, params,srcBusinessStreamNO,"修改实名软证书调用保护口令");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
            errorLog = ex.getCause();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"修改实名软证书调用保护口令","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        if(errorLog!=null)
        {
            throw new Exception("CA服务器维护中。。。");
        }
        return re;
    }
    /**
     * 验证签名(带多服务器负载均衡)
     **/
    @Override
    public String verifySignOnMultiServer(String strSignData,String strCertData,String strOriginalData,String srcBusinessStreamNO) throws Exception
    {
        Boolean isSuccess = true;
        String re = "";
        String body = "";
        String error = "";
        String action = VERIFY_SIGN;
        try {
            Map<String,String> params = new HashMap<>();
            params.put("strSignData",strSignData);
            params.put("strCertData",strCertData);
            params.put("strOriginalData",strOriginalData);
            body = objectMapper.writeValueAsString(params);
//            re = postCAServer(action, params,srcBusinessStreamNO);
            re = postZyCaServer(action, params,srcBusinessStreamNO,"验证签名(带多服务器负载均衡)");
            if(StringUtil.isEmpty(re))
            {
                throw new Exception("返回为空!");
            }
            else{
                if(re.startsWith("error"))
                {
                    throw new Exception(re);
                }
            }
        }
        catch (Exception ex)
        {
            isSuccess = false;
            ex.printStackTrace();
            error = ex.getMessage();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,action,"验证签名","POST",null,body,re,error,logService.caType);
        if(!StringUtil.isEmpty(error))
        {
            throw new Exception(error);
        }
        return re;
    }
//    public static void main(String args[]) {
//        try {
//            String caUrl = SystemConfig.getInstance().getCAUrl();
//            String caNamespace = SystemConfig.getInstance().getCANamespace();
//            /*//获取实名软证书的过期时间
//            String api = "XMCAF_SOFT_getRealNameSoftCertExpiredDatetime";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "</root>";*/
//
//            /*//判断实名软证书是否已申请
//            String api = "XMCAF_SOFT_judgeRealNameSoftCertIsApplied";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "</root>";*/
//
//            //修改实名软证书调用保护口令
//            String api = "XMCAF_SOFT_ModifyRealNameSoftCertCalledPasswd";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "    <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "   <strOldCalledPasswd>12345678</strOldCalledPasswd>\n" +
//                    "   <strNewCalledPasswd>11111111</strNewCalledPasswd>\n" +
//                    "</root>";
//
//
//            //请求实名软证书并进行数字签名
//            /*String orgData = "测试数据";
//            String api = "XMCAF_SOFT_requestRealNameSoftCertAndSign";
//            String msgBody = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n"+
//                    "   <strUserIdcardNum>123456</strUserIdcardNum>\n" +
//                    "   <strRealNameSoftCertCalledPasswd>11111111</strRealNameSoftCertCalledPasswd>\n" +
//                    "   <strOriginalData>"+ MD5Util.GetMD5Code(orgData)+"</strOriginalData>\n" +
//                    "</root>";*/
//
//            String msgHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
//                    "<root>\n" +
//                    "   <serverName>"+api+"</serverName>\n" +
//                    "   <format>xml</format>\n" +
//                    "   <callOperator></callOperator>\n" +
//                    "   <certificate></certificate>\n" +
//
//                    "   <srcIP>10.95.22.10</srcIP >\n" +
//                    "   <srcUserMac>60-D8-19-57-66-E3</srcUserMac>\n" +
//                    "   <srcSystemCode>1</srcSystemCode>\n" +
//                    "   <srcSystemName>厦门i健康</srcSystemName>\n" +
//                    "   <srcBusinessNodeCode>node01</srcBusinessNodeCode>\n" +
//                    "   <srcBusinessNodeName>审核</srcBusinessNodeName>\n" +
//                    "   <srcOperatorAccount>Zhuangsd</srcOperatorAccount>\n" +
//                    "   <srcBusinessStreamNO>11111</srcBusinessStreamNO>\n" +
//                    "   <srcDataExtProperty></srcDataExtProperty>\n" +
//                    "</root>";
//
//
//
//            Map<String, String> params = new HashMap<>();
//            params.put("msgBody", msgBody);
//            params.put("msgHeader", msgHeader);
//            System.out.print(WebserviceUtil.post(caUrl, caNamespace, "XMCA6_UnifiedCallInterface", params) + "\r\n");
//
//
//
//        }
//        catch (Exception ex)
//        {
//            ex.printStackTrace();
//        }
//    }
}

+ 128 - 96
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -11,6 +11,7 @@ import com.yihu.wlyy.service.common.util.DateUtil;
import com.yihu.wlyy.service.dao.*;
import com.yihu.wlyy.service.dao.consult.ConsultTeamDao;
import com.yihu.wlyy.service.dao.prescription.*;
import com.yihu.wlyy.service.dao.zydict.ZyIvPhysicDictDao;
import com.yihu.wlyy.service.entity.*;
import com.yihu.wlyy.service.entity.consult.ConsultTeam;
import com.yihu.wlyy.service.entity.prescription.*;
@ -75,6 +76,8 @@ public class PrescriptionService extends ZysoftBaseService{
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private AmoutUtils amoutUtils;
    @Autowired
    private ZyIvPhysicDictDao zyIvPhysicDictDao;
    /**
     * 新增续方日志
@ -115,105 +118,126 @@ public class PrescriptionService extends ZysoftBaseService{
            JSONObject pre = json.getJSONObject("Data");
            String recipeNo = pre.getString("RECIPE_NO");
            Prescription prescription = prescriptionDao.findByRecipeNo(recipeNo);
            if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.changeing.getValue()||prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
                if(CODE==1){
                    prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.change_success.getValue());
                    prescriptionDao.save(prescription);
                    //调整续方的药品信息
                    JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL");
                    List<PrescriptionInfo> infoList = new ArrayList<>();
                    for(int i =0;i<prescription_detail.size();i++){
                        JSONObject info = prescription_detail.getJSONObject(i);
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                        prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                        prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                        prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                        prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                        prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                        prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                        prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode(info.getString("SUB_NO"));//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
                        prescriptionInfo.setCharge(CommonUtil.doubleToInt(info.getDouble("CHARGE")));//自付
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
                        prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                        prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                        prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                        prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                        prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                        prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                        prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                        prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                        prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                        prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                        prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        prescriptionInfo.setPrescriptionCode(prescription.getCode());
                        //设置是否冷藏
                        Integer isRefrigerate = 0;
                        StringBuffer sqlbuf = new StringBuffer("SELECT storage_conditions from zy_iv_physic_dict WHERE physic_code = '"+info.getString("ITEM_CODE")+"'");
                        List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlbuf.toString());
                        if(list!=null&&list.size()>0){
                            Object storage_conditions = list.get(0).get("storage_conditions");
                            if(storage_conditions!=null){
                                String storageConditions = storage_conditions.toString();
                                isRefrigerate = "2".equals(storageConditions)?1:isRefrigerate;
            if(prescription==null){
                error = "没有找到对应的续方";
                errMsg = "没有找到对应的续方";
                status = "0";
            }else {
                if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.changeing.getValue()||prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
                    if(CODE==1){
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.change_success.getValue());
                        prescriptionDao.save(prescription);
                        //调整续方的药品信息
                        JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL");
                        List<PrescriptionInfo> infoList = new ArrayList<>();
                        for(int i =0;i<prescription_detail.size();i++){
                            JSONObject info = prescription_detail.getJSONObject(i);
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setCode(getCode());
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            String subjectClass = info.getString("SUBJECT_CLASS");
                            if(StringUtils.isBlank(subjectClass)){//处理默认药品的科目类型为空
                                StringBuffer sql = new StringBuffer("SELECT subject_class from zy_iv_physic_dict WHERE physic_code = ?");
                                List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString(),info.getString("ITEM_CODE"));
                                if(list!=null&&list.size()>0){
                                    Object subject_class = list.get(0).get("subject_class");
                                    if(subject_class!=null){
                                        subjectClass = subject_class.toString();
                                    }
                                }
                            }
                        }
                        prescriptionInfo.setIsRefrigerate(isRefrigerate);
                            prescriptionInfo.setSubjectClass(subjectClass);//科目编码
                            //prescriptionInfo.setSubjectClass(info.getString("SUBJECT_CLASS"));//"科目类别编码",
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode(info.getString("SUB_NO"));//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                            prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
                            prescriptionInfo.setCharge(CommonUtil.doubleToInt(info.getDouble("CHARGE")));//自付
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                            prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                            prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                            prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
                            prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                            prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            prescriptionInfo.setPrescriptionCode(prescription.getCode());
                            prescriptionInfo.setDel(1);
                            //设置是否冷藏
                            Integer isRefrigerate = 0;
                            StringBuffer sqlbuf = new StringBuffer("SELECT storage_conditions from zy_iv_physic_dict WHERE physic_code = '"+info.getString("ITEM_CODE")+"'");
                            List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlbuf.toString());
                            if(list!=null&&list.size()>0){
                                Object storage_conditions = list.get(0).get("storage_conditions");
                                if(storage_conditions!=null){
                                    String storageConditions = storage_conditions.toString();
                                    isRefrigerate = "2".equals(storageConditions)?1:isRefrigerate;
                                }
                            }
                            prescriptionInfo.setIsRefrigerate(isRefrigerate);
                        //用药频率
                        prescriptionInfo.setDrugRateName(getZyCommonDictName(info.getString("drugRate")));
                            //用药频率
                            prescriptionInfo.setDrugRateName(getZyCommonDictName(info.getString("drugRate")));
                        infoList.add(prescriptionInfo);
                            infoList.add(prescriptionInfo);
                        }
                        //删除所有药品
                        StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription_info SET del = 0 WHERE prescription_code = '" + prescription.getCode() + "'");
                        jdbcTemplate.execute(sql.toString());
                        //保存新的药品
                        prescriptionInfoDao.save(infoList);
                        //发送系统消息
                        Message message = new Message();
                        message.setCzrq(new Date());
                        message.setCreateTime(new Date());
                        message.setContent("您有1个续方申请已在线下调整完成,请点击进行CA认证。");
                        message.setRead(1);//设置未读
                        message.setReceiver(prescription.getDoctor());//设置接受医生的code
                        message.setSender("系统");//设置发送的用户
                        message.setSenderName("system");
                        message.setCode(getCode());
                        message.setTitle("新增系统消息");
                        message.setType(9);
                        message.setReadonly(1);//是否只读消息
                        message.setOver("1");//未处理
                        message.setRelationCode(prescription.getCode());
                        messageDao.save(message);
                        // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  }
    //                    JSONObject redisMessage = new JSONObject();
    //                    redisMessage.put("title","adjustPrescription");
    //                    redisMessage.put("state",1);
    //                    redisMessage.put("prescription",prescription.getCode());
    //                    redisMessage.put("mes","调整处方完成");
    //                    redisTemplate.opsForList().leftPush(channelTopic,redisMessage.toString());
                    }else {
                        //调整失败
                        prescription.setStatus(4);
                        prescriptionDao.save(prescription);
                        msg = json.getString("MSG");
                    }
                    //删除所有药品
                    StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription_info SET del = 0 WHERE prescription_code = '" + prescription.getCode() + "'");
                    jdbcTemplate.execute(sql.toString());
                    //保存新的药品
                    prescriptionInfoDao.save(infoList);
                    //发送系统消息
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setContent("您有1个续方申请已在线下调整完成,请点击进行CA认证。");
                    message.setRead(1);//设置未读
                    message.setReceiver(prescription.getDoctor());//设置接受医生的code
                    message.setSender("系统");//设置发送的用户
                    message.setSenderName("system");
                    message.setCode(getCode());
                    message.setTitle("新增系统消息");
                    message.setType(9);
                    message.setReadonly(1);//是否只读消息
                    message.setOver("1");//未处理
                    message.setRelationCode(prescription.getCode());
                    messageDao.save(message);
                    // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  }
//                    JSONObject redisMessage = new JSONObject();
//                    redisMessage.put("title","adjustPrescription");
//                    redisMessage.put("state",1);
//                    redisMessage.put("prescription",prescription.getCode());
//                    redisMessage.put("mes","调整处方完成");
//                    redisTemplate.opsForList().leftPush(channelTopic,redisMessage.toString());
                }else {
                    //调整失败
                    prescription.setStatus(4);
                    prescriptionDao.save(prescription);
                    msg = json.getString("MSG");
                    //新增续方日志
                    addPrescriptionLog(prescription,"接收线下处方调整完成消息-"+msg);
                }
                //新增续方日志
                addPrescriptionLog(prescription,"接收线下处方调整完成消息-"+msg);
            }
        }catch (JSONException ex){
            ex.printStackTrace();
@ -651,8 +675,8 @@ public class PrescriptionService extends ZysoftBaseService{
            applyTimeEnd = DateUtil.getStringDateShort();
            applyTimeFrom = DateUtil.getNextDay(new Date(),-60);
        }else{
            applyTimeEnd = DateUtil.getNextDay(prescription.getCreateTime(),10);
            applyTimeFrom = DateUtil.getNextDay(prescription.getCreateTime(),-10);
            applyTimeEnd = DateUtil.getNextDay(prescription.getCreateTime(),0);
            applyTimeFrom = DateUtil.getNextDay(prescription.getCreateTime(),-60);
        }
        params.put("applyTimeFrom",applyTimeFrom);
        params.put("applyTimeEnd",applyTimeEnd);
@ -784,8 +808,16 @@ public class PrescriptionService extends ZysoftBaseService{
    public String getDispUnSettleFeeInfoList(String cardNo, String visitNo,String recipeNo)  throws Exception
    {
        Prescription prescription = prescriptionDao.findByVisitNoAndRecipeNo(visitNo,recipeNo);
        String hos = "";
        if(prescription==null){
            Patient patient = patientDao.findBySsc(cardNo);
            SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
            hos = signFamily.getHospital();
        }else {
            hos = prescription.getHospital();
        }
        String[] hospitalMapping = getHospitalMapping(prescription.getHospital()); //获取机构映射
        String[] hospitalMapping = getHospitalMapping(hos); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
//        String licence = "5YGl5bq35LmL6Lev";

+ 13 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustReasonDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjustReason;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/26.
 */
public interface PrescriptionAdjustReasonDao extends PagingAndSortingRepository<PrescriptionAdjustReason, Long>, JpaSpecificationExecutor<PrescriptionAdjustReason> {
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReasonDictDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReasonDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2017/8/26.
 */
public interface PrescriptionReasonDictDao extends PagingAndSortingRepository<PrescriptionReasonDict, Long>, JpaSpecificationExecutor<PrescriptionReasonDict> {
    List<PrescriptionReasonDict> findByTypeOrderBySortAsc(Integer type);
    PrescriptionReasonDict findByTypeAndCode(Integer type,String code);
}

+ 12 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReviewedReasonDao.java

@ -0,0 +1,12 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReasonDict;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReviewedReason;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/26.
 */
public interface PrescriptionReviewedReasonDao  extends PagingAndSortingRepository<PrescriptionReviewedReason, Long>, JpaSpecificationExecutor<PrescriptionReviewedReason> {
}

+ 0 - 18
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -255,24 +255,6 @@ public class WeiXinEventProcess {
        articlePrescription.put("PicUrl", prescription_pic);
        articles.add(articlePrescription);
//        新增居民取药码图文消息 by wjj 2017.08.25
        Map<String, String> articlePatientQRCode = new HashMap<>();
        // 图文URL
        String patientQRCode = systemConf.getProperty("patient_QRCode_url");
        // 图文消息图片URL
        String patientQRCode_pic = systemConf.getProperty("patient_QRCode_pic");
        // URL设置服务器URL、AppId
        patientQRCode = patientQRCode.replace("{server}", wechat_base_url)
                .replace("{appId}", appId);
        //图片地址
        patientQRCode_pic = patientQRCode_pic.replace("{server}", serverUrl);
        articlePatientQRCode.put("Url", patientQRCode);
        articlePatientQRCode.put("Title", "我的取药码");
        articlePatientQRCode.put("Description", "我的取药码");
        articlePatientQRCode.put("PicUrl", patientQRCode_pic);
        articles.add(articlePatientQRCode);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java

@ -52,6 +52,19 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        return registration;
    }
//    /**
//     * 编码过滤
//     */
//    @Bean
//    public FilterRegistrationBean testFilterRegistration2() {
//        FilterRegistrationBean registration = new FilterRegistrationBean();
//        registration.setFilter(new UserAgentFilter());
//        registration.addUrlPatterns("/doctor/requestRealNameSoftCertAndSign");
//        registration.setName("EncodingFilter");
//        registration.setOrder(2);
//        return registration;
//    }
//    /**
//     * 为null的数据不返回
//     * @param converters

+ 2 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -1,9 +1,7 @@
package com.yihu.wlyy.event;
import com.yihu.wlyy.redis.RedisThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
@ -15,8 +13,8 @@ import org.springframework.stereotype.Service;
public class ApplicationEvent implements ApplicationListener<ContextRefreshedEvent> {
    private Logger logger = LoggerFactory.getLogger(ApplicationEvent.class);
    @Autowired
    private RedisThread redisThread;
//    @Autowired
//    private RedisThread redisThread;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {

+ 50 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.interceptors;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/22.
 */
@Component
public class EncodingFilter implements Filter {
    private Logger logger= LoggerFactory.getLogger(EncodingFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        Map<String, String[]> params = request.getParameterMap();
        MutableHttpServletRequest newRequest = new MutableHttpServletRequest(request);
        newRequest.getParameterNames();
        for (String key : params.keySet()) {
            String[] values = params.get(key);
            for (int i = 0; i < values.length; i++) {
                String value = values[i];
                newRequest.removeAttribute(key);
                newRequest.addParameter(key, URLDecoder.decode((value),"utf-8"));
            }
        }
        chain.doFilter(newRequest, response);
    }
    @Override
    public void destroy() {
    }
}

+ 6 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/MutableHttpServletRequest.java

@ -53,4 +53,10 @@ final class MutableHttpServletRequest extends HttpServletRequestWrapper {
        // create an enumeration from the set and return
        return Collections.enumeration(set);
    }
    public void addParameter(String name , Object value) {//增加参数
        if(value != null) {
            customHeaders.put(name , String.valueOf(value));
        }
    }
}

+ 101 - 101
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java

@ -1,101 +1,101 @@
package com.yihu.wlyy.redis;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPubSub;
/**
 * Created by Trick on 2017/8/7.
 */
@Component
public class RedisMsgPubSubListener extends JedisPubSub {
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    @Autowired
    private PrescriptionService prescriptionService;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
    @Override
    public void unsubscribe() {
        super.unsubscribe();
    }
    @Override
    public void unsubscribe(String... channels) {
        super.unsubscribe(channels);
    }
    @Override
    public void subscribe(String... channels) {
        super.subscribe(channels);
    }
    @Override
    public void psubscribe(String... patterns) {
        super.psubscribe(patterns);
    }
    @Override
    public void punsubscribe() {
        super.punsubscribe();
    }
    @Override
    public void punsubscribe(String... patterns) {
        super.punsubscribe(patterns);
    }
    @Override
    public void onMessage(String channel, String message) {
        logger.info("redis_onMessage...:"+message);
        //this.unsubscribe();
        try{
            JSONObject json = new JSONObject(message);
            String title =  json.getString("title");
            if("redisAddPrescription".equals(title)){
                logger.info(json.toString());
                //审核消息发送
                prescriptionInfoService.onMesSquareState(message);
            }else if("dispensingComplete".equals(title)){//配药完成
                //药品配送完成,提醒取药
                String prescriptionCode = json.getString("prescription");
                prescriptionService.dispensingComplete(prescriptionCode);
            }
        }catch (Exception e){
            logger.error("redis_error...",e);
        }
    }
    @Override
    public void onPMessage(String pattern, String channel, String message) {
    }
    @Override
    public void onSubscribe(String channel, int subscribedChannels) {
        //System.out.println("channel:" + channel + "is been subscribed:" + subscribedChannels);
    }
    @Override
    public void onPUnsubscribe(String pattern, int subscribedChannels) {
    }
    @Override
    public void onPSubscribe(String pattern, int subscribedChannels) {
    }
    @Override
    public void onUnsubscribe(String channel, int subscribedChannels) {
        System.out.println("channel:" + channel + "is been unsubscribed:" + subscribedChannels);
    }
}
//package com.yihu.wlyy.redis;
//
//import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
//import com.yihu.wlyy.service.app.prescription.PrescriptionService;
//import com.yihu.wlyy.util.HttpUtil;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import redis.clients.jedis.JedisPubSub;
//
///**
// * Created by Trick on 2017/8/7.
// */
//@Component
//public class RedisMsgPubSubListener extends JedisPubSub {
//
//    @Autowired
//    private PrescriptionInfoService prescriptionInfoService;
//    @Autowired
//    private PrescriptionService prescriptionService;
//
//    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
//
//    @Override
//    public void unsubscribe() {
//        super.unsubscribe();
//    }
//
//    @Override
//    public void unsubscribe(String... channels) {
//        super.unsubscribe(channels);
//    }
//
//    @Override
//    public void subscribe(String... channels) {
//        super.subscribe(channels);
//    }
//
//    @Override
//    public void psubscribe(String... patterns) {
//        super.psubscribe(patterns);
//    }
//
//    @Override
//    public void punsubscribe() {
//        super.punsubscribe();
//    }
//
//    @Override
//    public void punsubscribe(String... patterns) {
//        super.punsubscribe(patterns);
//    }
//
//    @Override
//    public void onMessage(String channel, String message) {
//        logger.info("redis_onMessage...:"+message);
//        //this.unsubscribe();
//        try{
//            JSONObject json = new JSONObject(message);
//            String title =  json.getString("title");
//            if("redisAddPrescription".equals(title)){
//                logger.info(json.toString());
//                //审核消息发送
//                prescriptionInfoService.onMesSquareState(message);
//            }else if("dispensingComplete".equals(title)){//配药完成
//                //药品配送完成,提醒取药
//                String prescriptionCode = json.getString("prescription");
//                prescriptionService.dispensingComplete(prescriptionCode);
//            }
//        }catch (Exception e){
//            logger.error("redis_error...",e);
//        }
//    }
//
//    @Override
//    public void onPMessage(String pattern, String channel, String message) {
//
//    }
//
//    @Override
//    public void onSubscribe(String channel, int subscribedChannels) {
//        //System.out.println("channel:" + channel + "is been subscribed:" + subscribedChannels);
//    }
//
//    @Override
//    public void onPUnsubscribe(String pattern, int subscribedChannels) {
//
//    }
//
//    @Override
//    public void onPSubscribe(String pattern, int subscribedChannels) {
//
//    }
//
//    @Override
//    public void onUnsubscribe(String channel, int subscribedChannels) {
//        System.out.println("channel:" + channel + "is been unsubscribed:" + subscribedChannels);
//    }
//}

+ 44 - 44
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -1,44 +1,44 @@
package com.yihu.wlyy.redis;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
/**
 * Created by Trick on 2017/8/7.
 */
@Component
public class RedisThread implements Runnable {
    @Value("${spring.redis.host}")
    private String url;
    @Autowired
    private RedisMsgPubSubListener redisMsgPubSubListener;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PrescriptionService prescriptionService;
    @Override
    public void run() {
        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
        while (true){
            redisTemplate.watch(key);
            String message = redisTemplate.opsForList().rightPop(key);
            redisTemplate.unwatch();
            if(StringUtils.isEmpty(message)){
                try{
                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒
                }catch (Exception e){
                    e.printStackTrace();
                }
            }else {
                prescriptionService.redisMessage(message);
            }
        }
    }
}
//package com.yihu.wlyy.redis;
//
//import com.yihu.wlyy.service.app.prescription.PrescriptionService;
//import com.yihu.wlyy.util.SystemConf;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//
///**
// * Created by Trick on 2017/8/7.
// */
//@Component
//public class RedisThread implements Runnable {
//
//    @Value("${spring.redis.host}")
//    private String url;
//    @Autowired
//    private RedisMsgPubSubListener redisMsgPubSubListener;
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//    @Autowired
//    private PrescriptionService prescriptionService;
//
//    @Override
//    public void run() {
//        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
//        while (true){
//            redisTemplate.watch(key);
//            String message = redisTemplate.opsForList().rightPop(key);
//            redisTemplate.unwatch();
//            if(StringUtils.isEmpty(message)){
//                try{
//                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒
//                }catch (Exception e){
//                    e.printStackTrace();
//                }
//            }else {
//                prescriptionService.redisMessage(message);
//            }
//        }
//    }
//}

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdjustReasonDao.java

@ -0,0 +1,12 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdjustReason;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/26.
 */
public interface PrescriptionAdjustReasonDao extends PagingAndSortingRepository<PrescriptionAdjustReason, Long>, JpaSpecificationExecutor<PrescriptionAdjustReason> {
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionInfoDao.java

@ -18,7 +18,7 @@ public interface PrescriptionInfoDao extends PagingAndSortingRepository<Prescrip
    @Modifying
    @Query("update PrescriptionInfo p set p.cost=?2 where p.code=?1")
    void updateStatus(String code,Integer cost);
    @Query("update PrescriptionInfo p set p.cost=?2 where p.drugCode=?1 and p.prescriptionCode=?3 and p.del=1")
    void updateStatus(String code,Integer cost,String prescriptionCode);
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReasonDictDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReasonDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2017/8/26.
 */
public interface PrescriptionReasonDictDao extends PagingAndSortingRepository<PrescriptionReasonDict, Long>, JpaSpecificationExecutor<PrescriptionReasonDict> {
    List<PrescriptionReasonDict> findByTypeOrderBySortAsc(Integer type);
    PrescriptionReasonDict findByTypeAndCode(Integer type, String code);
}

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionReviewedReasonDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReviewedReason;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/26.
 */
public interface PrescriptionReviewedReasonDao  extends PagingAndSortingRepository<PrescriptionReviewedReason, Long>, JpaSpecificationExecutor<PrescriptionReviewedReason> {
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/zydict/ZyCommonDictDao.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.repository.zydict;
import com.yihu.wlyy.entity.zydict.ZyCommonDict;
import com.yihu.wlyy.entity.zydict.ZyIvPhysicDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
@ -9,5 +11,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface ZyCommonDictDao extends PagingAndSortingRepository<ZyCommonDict, Long>, JpaSpecificationExecutor<ZyCommonDict> {
    @Query("select p.name from ZyCommonDict p where p.dictName=?1 and p.code=?2 ")
    String findByDictNameAndCode(String dictName,String code);
}

+ 5 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/zydict/ZyIvPhysicDictDao.java

@ -1,11 +1,16 @@
package com.yihu.wlyy.repository.zydict;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.zydict.ZyIvPhysicDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/8/11.
 */
public interface ZyIvPhysicDictDao extends PagingAndSortingRepository<ZyIvPhysicDict, Long>, JpaSpecificationExecutor<ZyIvPhysicDict> {
    @Query("select p from ZyIvPhysicDict p where p.physicCode=?1")
    ZyIvPhysicDict findByPhysicCode(String physicCode);
}

+ 25 - 41
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -1317,12 +1317,8 @@ public class DoctorInfoService extends BaseService {
            int status = responseObject.getInt("status");
            if (status == 200) {
                data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                }else{
                    if("0".equals(data)){
                        return true;
                    }
                if("0".equals(data)){
                    return true;
                }
            }
        }else {
@ -1383,26 +1379,22 @@ public class DoctorInfoService extends BaseService {
            int status = responseObject.getInt("status");
            if (status == 200) {
                data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                } else {
                    //1、线上未认证,有证书,并有效,2、线上未认证,有证书,已过期,3、线上未认证,无证书,4、线上已认证,并有效
                    if(StringUtils.isNotEmpty(data)){
                        Date CertifiedOvertime = simpleDateFormat.parse(data);
                        doctor.setCertifiedOvertime(CertifiedOvertime);
                        doctorDao.save(doctor);
                        long times = CertifiedOvertime.getTime();
                        if(System.currentTimeMillis()<=times){
                            jsonObject.put("type",1);
                        }else{
                            jsonObject.put("type",2);
                        }
                //1、线上未认证,有证书,并有效,2、线上未认证,有证书,已过期,3、线上未认证,无证书,4、线上已认证,并有效
                if(StringUtils.isNotEmpty(data)){
                    Date CertifiedOvertime = simpleDateFormat.parse(data);
                    doctor.setCertifiedOvertime(CertifiedOvertime);
                    doctorDao.save(doctor);
                    long times = CertifiedOvertime.getTime();
                    if(System.currentTimeMillis()<=times){
                        jsonObject.put("type",1);
                    }else{
//                        jsonObject.put("type",3);
                        throw new Exception("null data.");
                        jsonObject.put("type",2);
                    }
                }else{
//                        jsonObject.put("type",3);
                    throw new Exception("null data.");
                }
            } else {
                jsonObject.put("type",3);
            }
@ -1431,16 +1423,12 @@ public class DoctorInfoService extends BaseService {
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                }else{
                    if("0".equals(data)){
                        Doctor doctor = findDoctorByCode(doctorCode);
                        doctor.setCheckPassword(strNewCalledPasswd);//保存密码,以便忘记密码时候使用
                        doctor.setIscertified(1);//说明已经(线上认证,已修改密码)
                        doctorDao.save(doctor);
                        return true;
                    }
                if("0".equals(data)){
                    Doctor doctor = findDoctorByCode(doctorCode);
                    doctor.setCheckPassword(strNewCalledPasswd);//保存密码,以便忘记密码时候使用
                    doctor.setIscertified(1);//说明已经(线上认证,已修改密码)
                    doctorDao.save(doctor);
                    return true;
                }
            }else{
                String error = msg.split(":")[2];
@ -1478,8 +1466,8 @@ public class DoctorInfoService extends BaseService {
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                if (StringUtils.isEmpty(data)) {
                    throw new Exception("null data");
                }else{
                    String[] str = data.split("\\|\\|");
//                    String strSignData = str[0];
@ -1524,12 +1512,8 @@ public class DoctorInfoService extends BaseService {
            String msg = responseObject.getString("msg");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                    throw new Exception(data);
                }else{
                    if("0".equals(data)){
                        return true;
                    }
                if("0".equals(data)){
                    return true;
                }
            }else{
                throw new Exception(responseObject.getString("msg"));

+ 49 - 31
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -16,6 +16,7 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.zydict.ZyIvPhysicDict;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
import com.yihu.wlyy.repository.consult.ConsultTeamLogDao;
@ -176,27 +177,28 @@ public class ConsultTeamService extends ConsultService {
            return json;
        }
        //点击后判断,如果用户当前存在可申请续方的处方记录,则进入续方申请流程,若不存在可续方记录,alert“当前没有可以申请续方的处方记录”
        int num = 0;
        Patient p = patientDao.findByCode(patient);
        String rp= jwPrescriptionService.getLastRecipe(p.getSsc(),null,null,null);
        com.alibaba.fastjson.JSONArray pres =presModeAdapter.modeToPrescription(rp);
        Iterator iterator = pres.iterator();
        while (iterator.hasNext()){
            com.alibaba.fastjson.JSONObject r = ( com.alibaba.fastjson.JSONObject)iterator.next();
            com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
            for(int i=0 ;i<des.size();i++){
                PrescriptionDiagnosis ds = des.getObject(i,PrescriptionDiagnosis.class);
                if(gxy.equals(ds.getHealthProblem())||tnb.equals(ds.getHealthProblem())){
                    //为糖尿病高血压
                    num++;
                    break;
                }
            }
        }
        if(num==0){
            json.put("msg","当前没有可以申请续方的处方记录");
            return json;
        }
        // 智业接口没有返回列表,是单条 所以先不处理
//        int num = 0;
//        Patient p = patientDao.findByCode(patient);
//        String rp= jwPrescriptionService.getRecipeList(p.getSsc(),null,null,null);
//        com.alibaba.fastjson.JSONArray pres =presModeAdapter.modeToPrescription(rp);
//        Iterator iterator = pres.iterator();
//        while (iterator.hasNext()){
//            com.alibaba.fastjson.JSONObject r = ( com.alibaba.fastjson.JSONObject)iterator.next();
//            com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
//            for(int i=0 ;i<des.size();i++){
//                PrescriptionDiagnosis ds = des.getObject(i,PrescriptionDiagnosis.class);
//                if(gxy.equals(ds.getHealthProblem())||tnb.equals(ds.getHealthProblem())){
//                    //为糖尿病高血压
//                    num++;
//                    break;
//                }
//            }
//        }
//        if(num==0){
//            json.put("msg","当前没有可以申请续方的处方记录");
//            return json;
//        }
        //续方说明
        List<PrescriptionExplain> list = prescriptionExplainDao.findList();
@ -954,10 +956,10 @@ public class ConsultTeamService extends ConsultService {
                return -2;
            }
            String checkPre = prescriptionInfoService.checkPre(patient,DateUtil.getStringDateShort()+" 00:00:00");
            if("0".equals(checkPre)){//存在未结算的续方
                return -3;
            }
//            String checkPre = prescriptionInfoService.checkPre(patient,DateUtil.getStringDateShort()+" 00:00:00");
//            if("0".equals(checkPre)){//存在未结算的续方
//                return -3;
//            }
            Doctor doctor = doctorDao.findByCode(doctorCode);
            // 查询患者信息
@ -1131,7 +1133,7 @@ public class ConsultTeamService extends ConsultService {
        }
        //设置费别类型
        prescription.setJwRateTypeCode(zyDictService.getRateType());
        prescription.setPresCreateTime(DateUtil.stringToDate(jsonObject.getString("createTime"),"yyyy-MM-dd "));
        prescription.setPresCreateTime(DateUtil.stringToDate(jsonObject.getString("createTime"),"yyyy-MM-dd"));
        //保存续方药品(处方)信息
@ -1156,7 +1158,7 @@ public class ConsultTeamService extends ConsultService {
            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("price")));//药品单价
//            prescriptionInfo.setIsRefrigerate(0);//是否冷藏 1是 0否
            prescriptionInfo.setJwSubCode(info.getString("jwSubCode"));//智业子处方号
            prescriptionInfo.setSubjectClass(info.getString("subjectClass"));//科目编码
            prescriptionInfo.setDrugNumUnit(info.getString("drugNumUnit"));//数量单位编码
            prescriptionInfo.setDrugNumUnitName(info.getString("drugNumUnitName"));//数量单位名称
            prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("cost")));//金额
@ -1172,15 +1174,31 @@ public class ConsultTeamService extends ConsultService {
            prescriptionInfo.setPhysicDose(info.getString("physicDose"));//用药剂量
            prescriptionInfo.setPhysicDoseUnit(info.getString("physicDoseUnit"));//剂量单位编码
            prescriptionInfo.setPhysicDoseUnitName(info.getString("physicDoseUnitName"));//剂量单位名称
            prescriptionInfo.setPhysicAmount(info.getString("physicAmount"));//用药总量
            prescriptionInfo.setPhysicAmountUnit(info.getString("physicAmount"));//总量单位编码
            prescriptionInfo.setPhysicAmountUnitName(info.getString("physicAmountUnitName"));//总量单位名称
            prescriptionInfo.setPhysicInjectPlace(info.getString("physicInjectPlace"));//注射地点编码
            prescriptionInfo.setPhysicInjectPlaceName(info.getString("physicInjectPlaceName"));//注射地点名称
            prescriptionInfo.setPhysicSkinTest(info.getString("physicSkinTest"));//注射地点名称
            prescriptionInfo.setPhysicSkinTestName(info.getString("physicSkinTestName"));//皮试类型名称
            prescriptionInfo.setRemark(info.getString("Remark"));//备注
            prescriptionInfo.setIsRefrigerate(zyDictService.getIsRefrigerate(prescriptionInfo.getDrugCode()));
            //需要特殊处理的字段
            ZyIvPhysicDict physicDict = zyDictService.findByPhysicCode(prescriptionInfo.getDrugCode());
            String subjectClass = info.getString("subjectClass");//科目类型
            String physicAmount = info.getString("physicAmount");//用药总量
            String physicAmountUnit = info.getString("physicAmountUnit");//总量单位编码
            String physicAmountUnitName = info.getString("physicAmountUnitName");//总量单位名称
            Integer isRefrigerate = 0;
            if(physicDict!=null){
                subjectClass = physicDict.getSubjectClass();
                isRefrigerate = "2".equals(physicDict.getStorageConditions())?1:isRefrigerate;
                physicAmount = null;
                physicAmountUnit = physicDict.getPackUnit();
                physicAmountUnitName = zyDictService.findByDictNameAndCode("IV_MEASURE_UNIT_DICT",physicAmountUnit);
            }
            prescriptionInfo.setPhysicAmount(physicAmount);
            prescriptionInfo.setPhysicAmountUnit(physicAmountUnit);
            prescriptionInfo.setPhysicAmountUnitName(physicAmountUnitName);
            prescriptionInfo.setIsRefrigerate(isRefrigerate);
            prescriptionInfo.setSubjectClass(subjectClass);//科目编码
            prescriptionInfoDao.save(prescriptionInfo);
        }
        //设置最小用药天数

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -632,7 +632,7 @@ public class PatientPrescriptionPayService extends BaseService {
            }
            expressage.setPrescriptionCode(prescriptionCode);
            prescription = prescriptionDao.findByCode(prescriptionCode);
            // 续方居民信息
            // 续方居民信息.
            String paySsc = prescription.getSsc();
            String payPatientCode = prescription.getPatient();
            String payName = prescription.getPatientName();

+ 23 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionAdjustService.java

@ -42,6 +42,21 @@ public class PrescriptionAdjustService extends BaseService {
    @Autowired
    private ImUtill imUtill;
    /**
     * 保存续方科室和挂号类型
     * @param code 续方code
     * @param jwGisterTypeCode 基卫-挂号类型编码
     * @param jwDeptCode 基卫-挂号科室
     * @param jwRegisterFee 基卫-诊金
     */
    public void saveDept(String code,String jwDeptCode,String jwGisterTypeCode,String jwRegisterFee){
        Prescription prescription = prescriptionDao.findByCode(code);
        prescription.setJwGisterTypeCode(jwGisterTypeCode);
        prescription.setJwDeptCode(jwDeptCode);
        prescription.setJwRegisterFee(jwRegisterFee);
        prescriptionDao.save(prescription);
    }
    /**
     * 线下调整处方
     * @param code
@ -69,14 +84,6 @@ public class PrescriptionAdjustService extends BaseService {
                        prescription.setRecipeNo(recipeNo);
                        prescriptionDao.save(prescription);
                        //发送Im消息
                        JSONObject content = new JSONObject();
                        content.put("title", "我已经审核您" + DateUtil.dateToStr(prescription.getCreateTime(), "yyyy-MM-dd") + "发起的续方申请");
                        content.put("result", "审核通过");
                        content.put("reason", "");
                        content.put("url", "");
                        imUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "15", content.toString(), null);
                        //添加日志
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),1,2);
@ -135,6 +142,14 @@ public class PrescriptionAdjustService extends BaseService {
                        //审核通过模板消息
                        prescriptionInfoService.sendRMess(prescription.getCode(), 1);
                        //发送Im消息
                        JSONObject content = new JSONObject();
                        content.put("title", "我已经审核您" + DateUtil.dateToStr(prescription.getCreateTime(), "yyyy-MM-dd") + "发起的续方申请");
                        content.put("result", "审核通过");
                        content.put("reason", "");
                        content.put("url", "");
                        imUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "15", content.toString(), null);
                        //修改系统的续方消息的审核状态
                        messageDao.updatePreScriptionMessage(prescription.getConsult(), "1", 6);

+ 80 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -35,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * Created by Trick on 2017/7/25.
 * Created  Trick on 2017/7/25.
 */
@Service
@Transactional
@ -90,6 +90,12 @@ public class PrescriptionInfoService extends BaseService {
    private PrescriptionExpressageService expressageService;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private PrescriptionReasonDictDao prescriptionReasonDictDao;
    @Autowired
    private PrescriptionReviewedReasonDao prescriptionReviewedReasonDao;
    @Autowired
    private PrescriptionAdjustReasonDao prescriptionAdjustReasonDao;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -104,7 +110,7 @@ public class PrescriptionInfoService extends BaseService {
    }
    public JSONObject getPrescriptionFilter(Integer teamCode) {
    public JSONObject getPrescriptionFilter(Integer teamCode,String patient) {
        JSONObject rs = new JSONObject();
        List<SystemDict> sdict = systemDictDao.findByDictName("PRESCRIPTION_STATE");
@ -113,7 +119,7 @@ public class PrescriptionInfoService extends BaseService {
            Map<String,Object> m = new HashedMap();
            m.put("code",sd.getCode());
            m.put("value",sd.getValue());
            m.put("count",getPresCountByState(teamCode,sd.getCode()));
            m.put("count",getPresCountByState(teamCode,sd.getCode(),patient));
            states.add(m);
        }
        rs.put("states", states);
@ -131,7 +137,7 @@ public class PrescriptionInfoService extends BaseService {
        return rs;
    }
    public int getPresCountByState(Integer teamCode,String states){
    public int getPresCountByState(Integer teamCode,String states,String patient){
        String sql = "SELECT " +
                " COUNT(1) AS count " +
                " FROM " +
@ -139,9 +145,13 @@ public class PrescriptionInfoService extends BaseService {
                " WHERE " +
                " p.admin_team_id =" +teamCode+
                " AND p.`status` in ("+states+")";
        if(StringUtils.isNotBlank(patient)){
            sql = sql+ " AND p.patient = '"+patient+"'";
        }
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        if(rs!=null&&rs.size()>0){
            return (Integer) rs.get(0).get("count");
            Long r = (Long) rs.get(0).get("count");
            return r.intValue();
        }
        return 0;
    }
@ -152,13 +162,13 @@ public class PrescriptionInfoService extends BaseService {
     * @param type
     * @return
     */
    public com.alibaba.fastjson.JSONArray getPrescriptionInfos(String type, String diagnosisCode, String startDate, String endDate, String patient, String isRenewal, Integer page, Integer size) throws Exception {
    public com.alibaba.fastjson.JSONArray getPrescriptionInfos(String type,String recipeNo, String diagnosisCode, String startDate, String endDate, String patient, String isRenewal, Integer page, Integer size) throws Exception {
        if (StringUtils.isNotBlank(type)) {
            if ("1".equals(type)) {
                Patient p = patientDao.findByCode(patient);
                String rp = jwPrescriptionService.getLastRecipe(p.getSsc(), null, startDate, endDate);
                String rp = jwPrescriptionService.getLastRecipe(p.getSsc(), recipeNo, startDate, endDate);
                com.alibaba.fastjson.JSONArray pres = presModeAdapter.modeToPrescription(rp);
                if(pres==null||pres.size()==0){
@ -510,7 +520,9 @@ public class PrescriptionInfoService extends BaseService {
                " pr.`status`, " +
                " pr.`code`, " +
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor " +
                " pr.doctor, " +
                " pr.min_drug_day AS minDrugDay," +
                " pr.pres_create_time AS presCreateTime" +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` ");
@ -564,7 +576,13 @@ public class PrescriptionInfoService extends BaseService {
            pre_sql.append(" AND pr.patient = ?");
            params.add(patient);
        }
        pre_sql.append(" GROUP BY pr.code ORDER BY pr.min_drug_day-TIMESTAMPDIFF(DAY, pr.pres_create_time, NOW()) ASC");
        //排序
        if(StringUtils.isNotBlank(state)&&"0,2,3,4,10".equals(state)){
            pre_sql.append(" GROUP BY pr.code ORDER BY pr.min_drug_day-TIMESTAMPDIFF(DAY, pr.pres_create_time, NOW()) ASC");
        }else{
            pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");
        }
        if (page != null && page > 0 && size != null && size > 0) {
            pre_sql.append(" LIMIT " + (page - 1) * size + "," + size);
        }
@ -605,7 +623,7 @@ public class PrescriptionInfoService extends BaseService {
        return rs;
    }
    public int reviewPrescription(String code, String reason, String state, String dept, String registerFee, String rateTypeCode) throws Exception {
    public int reviewPrescription(String code, String reason,String reasonCode, String state, String dept, String registerFee, String rateTypeCode) throws Exception {
        if (StringUtils.isNotBlank(state)) {
            Prescription p = prescriptionDao.findByCode(code);
            //更新审核记录
@ -625,6 +643,8 @@ public class PrescriptionInfoService extends BaseService {
                reviewed.setReason(reason);
                reviewed.setReviewedTime(new Date());
                reviewed.setStatus(PrescriptionReviewed.PrescriptionReviewedStatus.reviewed_fail.getValue());
                //保存审核不通过原因
                saveReviewedReason(reasonCode,reviewed.getCode(),code);
                //修改系统的续方消息的审核状态
                messageDao.updatePreScriptionMessage(p.getConsult(), "2", 6);
@ -666,7 +686,7 @@ public class PrescriptionInfoService extends BaseService {
        return 0;
    }
    public int updatePresInfo(String code, String infos, String diagnosis, String reason) {
    public int updatePresInfo(String code, String infos, String diagnosis, String reason,String reasonCode) {
        if (StringUtils.isNotBlank(code) && StringUtils.isNotBlank(infos)) {
            //同步智业接口
            upload();
@ -738,11 +758,48 @@ public class PrescriptionInfoService extends BaseService {
            prescriptionAdjust.setPrescriptionCode(code);
            prescriptionAdjustDao.save(prescriptionAdjust);
            //保存原因
            saveAjustReason(reasonCode,prescriptionAdjust,code);
            return 1;
        }
        return 0;
    }
    public void saveAjustReason(String reasonCode,PrescriptionAdjust prescriptionAdjust,String code){
        if(StringUtils.isNotBlank(reasonCode)){
            String reasoncodes[] = reasonCode.split(",");
            for(int i=0;i<reasoncodes.length;i++){
                PrescriptionReasonDict  dict =  prescriptionReasonDictDao.findByTypeAndCode(0,reasoncodes[i]);
                PrescriptionAdjustReason prescriptionAdjustReason = new PrescriptionAdjustReason();
                prescriptionAdjustReason.setCode(getCode());
                prescriptionAdjustReason.setPrescriptionCode(code);
                prescriptionAdjustReason.setAdjustCode(prescriptionAdjust.getCode());
                prescriptionAdjustReason.setReasonCode(reasoncodes[i]);
                prescriptionAdjustReason.setReasonValue(dict.getValue());
                prescriptionAdjustReason.setCreateTime(new Date());
                prescriptionAdjustReasonDao.save(prescriptionAdjustReason);
            }
        }
    }
    public void saveReviewedReason(String reasonCode,String reviewedCode ,String code){
        if(StringUtils.isNotBlank(reasonCode)){
            String reasoncodes[] = reasonCode.split(",");
            for(int i=0;i<reasoncodes.length;i++){
                PrescriptionReasonDict  dict =  prescriptionReasonDictDao.findByTypeAndCode(0,reasoncodes[i]);
                PrescriptionReviewedReason prescriptionReviewedReason = new PrescriptionReviewedReason();
                prescriptionReviewedReason.setCode(getCode());
                prescriptionReviewedReason.setPrescriptionCode(code);
                prescriptionReviewedReason.setReviewedCode(reviewedCode);
                prescriptionReviewedReason.setReasonCode(reasoncodes[i]);
                prescriptionReviewedReason.setReasonValue(dict.getValue());
                prescriptionReviewedReason.setCreateTime(new Date());
                prescriptionReviewedReasonDao.save(prescriptionReviewedReason);
            }
        }
    }
    public String upload() {
        return null;
    }
@ -1234,6 +1291,7 @@ public class PrescriptionInfoService extends BaseService {
    /**
     * @param doctor
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONArray getPrescriptionTemp(String doctor) throws Exception {
@ -1301,7 +1359,8 @@ public class PrescriptionInfoService extends BaseService {
                " com2.`name` AS quantityUnitName, " +
                " t.pack_unit As packUnit, " +
                " com3.`name` As packUnitName, " +
                " pack_spec AS packSpec" +
                " pack_spec AS packSpec, " +
                " subject_class AS subjectClass" +
                " FROM " +
                " zy_iv_physic_dict t, " +
                " (SELECT code,name FROM zy_common_dict WHERE dict_name = 'IV_MEASURE_UNIT_DICT') com1, " +
@ -1315,4 +1374,13 @@ public class PrescriptionInfoService extends BaseService {
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{code});
        return rs;
    }
    public JSONArray getReasonByType(Integer type){
        String sql = "SELECT t.value,t.code FROM wlyy_prescription_reason_dict t WHERE t.type = "+type+" ORDER BY t.sort ASC ";
        List<Map<String,Object>> list =  jdbcTemplate.queryForList(sql);
        //System.out.println("list:"+list.size());
        return  new JSONArray(list);
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -362,7 +362,7 @@ public class PrescriptionService extends BaseService {
                            JSONObject zySettleDetailObj = zySettleDetailList.getJSONObject(j);
                            //药品编码
                            String zyinfoKey = zySettleDetailObj.getString("INSUR_ITEM_CODE");
                            String zyinfoKey = zySettleDetailObj.getString("ITEM_CODE");
                            //总金额
                            String cost = zySettleDetailObj.getString("COST");
@ -390,7 +390,7 @@ public class PrescriptionService extends BaseService {
                    for (String infoCode : zyInfoCodeAndCost.keySet()) {
                        Double _cost = Double.parseDouble(zyInfoCodeAndCost.get(infoCode));
                        Integer infocost = CommonUtil.doubleToInt(_cost);
                        prescriptionInfoDao.updateStatus(infoCode,infocost);
                        prescriptionInfoDao.updateStatus(infoCode,infocost,prescriptionCode);
                    }
                    //事务提交
                    transactionManager.commit(status);

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -2334,6 +2334,7 @@ public class StatisticsService extends BaseService {
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.type <> 8  " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
@ -2491,6 +2492,7 @@ public class StatisticsService extends BaseService {
                    "  d.id = p.participant_id " +
                    " AND c.consult = t.id " +
                    " AND c.patient = s.id " +
                    " AND c.type <> 8" +
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND p.session_id = t.session_id " +
@ -2512,6 +2514,7 @@ public class StatisticsService extends BaseService {
                    " AND c.consult = t.id " +
                    " AND c.patient = s.id " +
                    " AND p.session_id = t.session_id " +
                    " AND c.type <> 8" +
                    " AND c.admin_team_code = " + teamCode +
                    " AND t.create_time >= '" + startDate + "' " +
                    " AND t.create_time <= '" + endDate + "' " +
@ -2532,6 +2535,7 @@ public class StatisticsService extends BaseService {
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND c.type <> 8" +
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND t. STATUS <> 10  " +
                    "  AND t.`reply` = 0  " +
@ -2552,6 +2556,7 @@ public class StatisticsService extends BaseService {
                    "  AND c.consult = t.id " +
                    "  AND c.patient = s.id " +
                    "  AND p.session_id = t.session_id " +
                    "  AND c.type <> 8" +
                    "  AND c.admin_team_code = " + teamCode +
                    "  AND t.create_time >= '" + startDate + "' " +
                    "  AND t.create_time <= '" + endDate + "' " +
@ -2713,6 +2718,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.admin_team_code = " + teamCode +
                " AND t. STATUS <> 10 " +
                " AND t.`reply` = 0 " +
@ -2755,6 +2761,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.admin_team_code = " + teamCode +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "' " +
@ -2795,6 +2802,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.admin_team_code = " + teamCode +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "' " +
@ -2913,6 +2921,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time <= '" + endDate + "'";
@ -2930,6 +2939,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND t.`reply`=1 " +
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
@ -2949,6 +2959,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND c.admin_team_code =" + teamCode +
                " AND d.id='" + doctor + "'" +
                " AND t.create_time >= '" + startDate + "' " +
@ -2967,6 +2978,7 @@ public class StatisticsService extends BaseService {
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.type <> 8"+
                " AND t. STATUS <> 10  " +
                " AND t.`reply` = 0  " +
                " AND c.admin_team_code =" + teamCode +

+ 75 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
@ -16,7 +17,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 基位长处方接口
@ -35,6 +38,8 @@ public class JwPrescriptionService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Value("${spring.profiles}")
    private String profiles;
    /**
     * 获取字典列表
@ -70,7 +75,7 @@ public class JwPrescriptionService {
    /**
     * 获取历史处方记录
     * 获取历史处方记录列表
     * @param cardNo 社保卡号
     * @param recipeNo 医嘱号
     * @param applyTimeFrom 开始时间
@ -86,17 +91,77 @@ public class JwPrescriptionService {
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        String response = httpClientUtil.post(url, params, "UTF-8");
//        String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
//        List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
//        String response = list.get(0).get("response").toString();
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("status",200);
//        jsonObject.put("data",response);
//        response = jsonObject.toString();
        String response = "";
        if("prod".equals(profiles)){
            response = httpClientUtil.post(url, params, "UTF-8");
        }else {
            String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
            List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
            response = list.get(0).get("response").toString();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("status",200);
            jsonObject.put("data",response);
            response = jsonObject.toString();
        }
        return response;
    }
    /**
     * 获取处方列表
     * @param cardNo
     * @param recipeNo
     * @param applyTimeFrom
     * @param applyTimeEnd
     * @return
     */
    public String getRecipeList(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd){
        JSONObject recipeJson = new JSONObject();
        try{
            Map<String,String> map = new HashMap<>();
            JSONArray jsonArray = new JSONArray();
            for (int i=0;i<3;i++){
                if(!map.containsKey(recipeNo)){
                    map.put(recipeNo,recipeNo);
                    String response = getLastRecipe(cardNo,recipeNo,applyTimeFrom,applyTimeEnd);
                    JSONObject json = JSONObject.parseObject(response);
                    if(json.getInteger("status")==200){
                        //智业接口每次返回一条数据,需要遍历请求
                        JSONObject data = json.getJSONObject("data");
                        String code = data.getString("CODE");
                        if("1".equals(code)){
                            JSONArray returnData = data.getJSONArray("returnData");
                            if(returnData.size()>0){
                                JSONObject recipe = returnData.getJSONArray(0).getJSONObject(0);//获取最后一条处方
                                jsonArray.add(recipe);
                                recipeNo = recipe.getString("RECIPE_NO");
                                if(recipeJson.isEmpty()){
                                    recipeJson = json;
                                }else {
                                    recipeJson.getJSONObject("data").getJSONArray("returnData").getJSONArray(0).add(recipe);
                                }
                            }
                        }
                    }
                }
            }
            if(jsonArray.size()>1){
                JSONObject re = new JSONObject();
                re.put("status",200);
                re.put("msg","调阅历史处方接口!");
                JSONObject data = new JSONObject();
                data.put("CODE","1");
                JSONArray returnData = new JSONArray();
                returnData.add(jsonArray);
                data.put("returnData",returnData);
                re.put("data",data);
                return re.toString();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return recipeJson.toString();
    }
    /**
     * 获取单条历史处方
     * @param recipeNo
@ -199,6 +264,7 @@ public class JwPrescriptionService {
            params.add(new BasicNameValuePair("visitNo", prescription.getVisitNo()));//挂号号
            params.add(new BasicNameValuePair("fadeDept", prescription.getJwDeptCode()));//作废科室编码
            params.add(new BasicNameValuePair("fadeOperator", prescription.getJwDoctorCode()));//作废人员编码
            params.add(new BasicNameValuePair("recipeNo", prescription.getRecipeNo()));//基卫处方号
            String response = httpClientUtil.post(url, params, "UTF-8");
            if(StringUtils.isNotBlank(response)){
                JSONObject reobj =  JSON.parseObject(response);

+ 45 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/ZyDictService.java

@ -2,9 +2,12 @@ package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.zydict.ZyIvPhysicDict;
import com.yihu.wlyy.repository.doctor.DoctorMappingDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.zydict.ZyCommonDictDao;
import com.yihu.wlyy.repository.zydict.ZyIvPhysicDictDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -29,7 +32,10 @@ public class ZyDictService {
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    private ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    private ZyCommonDictDao zyCommonDictDao;
    @Transactional
    public void synchronousDict(String dictName) {
@ -125,6 +131,42 @@ public class ZyDictService {
        return isRefrigerate;
    }
    /**
     * 按药品查找code
     * @param physicCode
     * @return
     */
    public ZyIvPhysicDict findByPhysicCode(String physicCode){
        return zyIvPhysicDictDao.findByPhysicCode(physicCode);
    }
    /**
     * 查找公共字典名称
     * @param dictName
     * @param code
     * @return
     */
    public String findByDictNameAndCode(String dictName,String code){
        return zyCommonDictDao.findByDictNameAndCode(dictName,code);
    }
    /**
     * 获取药品科目类型
     * @param physicCodde
     * @return
     */
    public String getSubjectClass(String physicCodde){
        StringBuffer sql = new StringBuffer("SELECT subject_class from zy_iv_physic_dict WHERE physic_code = ?");
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString(),physicCodde);
        if(list!=null&&list.size()>0){
            Object subject_class = list.get(0).get("subject_class");
            if(subject_class!=null){
                return subject_class.toString();
            }
        }
        return "";
    }
    /**
     * 获取药品字典
@ -183,9 +225,9 @@ public class ZyDictService {
                " ho.physic_code = p.physic_code " ;
        if(StringUtils.isNotBlank(name)){
            if(isEnglish(name)){
                sql += " and p.spell_code like '%"+name.toUpperCase()+"%'";
                sql += " and (p.spell_code like '%"+name.toUpperCase()+"%' or p.physic_code like '%"+name+"%')";
            }else{
                sql += " and p.physic_name like '%"+name+"%'";
                sql += " and (p.physic_name like '%"+name+"%' or p.physic_code like '%"+name+"%')";
            }
        }
        sql +=" ) yp " +

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/device/DeviceController.java

@ -23,7 +23,7 @@ public class DeviceController extends BaseController {
    @ApiOperation("获取设备分类")
    @RequestMapping(value = "DeviceCategory", method = RequestMethod.POST)
    @RequestMapping(value = "DeviceCategory", method = {RequestMethod.POST,RequestMethod.GET})
    @ResponseBody
    public String getDeviceCategory() {
        try {

+ 3 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -1900,7 +1900,7 @@ public class DoctorController extends BaseController {
    }
    /**
     * 重置密码
     * 初始设置实名软证书调用保护口令
     */
    @ApiOperation("初始设置实名软证书调用保护口令")
    @ObserverRequired
@ -1909,7 +1909,8 @@ public class DoctorController extends BaseController {
    public String installAuthenticationPassword(@RequestParam(value = "strNewCalledPasswd",required = true) String strNewCalledPasswd){
        try {
            Doctor doctor = doctorInfoService.findDoctorByCode(getUID());
            boolean b = doctorInfoService.updateAuthenticationPassword(doctor.getIdcard(),"11111111",strNewCalledPasswd,getUID());
            String strOldCalledPasswd = StringUtils.isNotEmpty(doctor.getCheckPassword())?doctor.getCheckPassword():"11111111";
            boolean b = doctorInfoService.updateAuthenticationPassword(doctor.getIdcard(),strOldCalledPasswd,strNewCalledPasswd,getUID());
            if(b){
                return write(200, "设置密码成功!", "data", b);
            }

+ 1 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.web.BaseController;
@ -86,7 +85,7 @@ public class DoctorDeviceController extends BaseController {
	 * 设备删除
	 */
	@ApiOperation("设备删除--医生端")
	@RequestMapping(value = "DeletePatientDevice",method = RequestMethod.POST)
	@RequestMapping(value = "DeletePatientDevice",method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	@ObserverRequired
	public String delete(@ApiParam(name="id",value="删除设备关联ID")

+ 7 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

@ -32,8 +32,14 @@ public class PrescriptionAdjustController extends BaseController {
    @ObserverRequired
    @ApiOperation("线下调整处方")
    public String adjustPrescription(@ApiParam(name = "code", value = "续方code", defaultValue = "10")
                                     @RequestParam(value = "code", required = true) String code){
                                     @RequestParam(value = "code", required = true) String code,
                                     @ApiParam(value = "科室", name = "dept") @RequestParam(required = true) String dept,
                                     @ApiParam(value = "诊金", name = "registerFee") @RequestParam(required = true) String registerFee,
                                     @ApiParam(value = "诊金类型", name = "rateTypeCode") @RequestParam(required = true) String rateTypeCode){
        try{
            //1、保存科室和挂号信息
            prescriptionAdjustService.saveDept(code,dept,rateTypeCode,registerFee);
            //2、调整处方
            JSONObject json = prescriptionAdjustService.adjustPrescription(code);
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));

+ 21 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -52,9 +52,10 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤规则信息列表")
    public String getPrescriptionFilter(Integer teamCode) {
    public String getPrescriptionFilter(@RequestParam(required = true) @ApiParam(value = "团队code", name = "teamCode")Integer teamCode,
                                        @RequestParam(required = false) @ApiParam(value = "居民code", name = "patient")String patient) {
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionFilter(teamCode));
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionFilter(teamCode,patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -97,12 +98,13 @@ public class PrescriptionInfoController extends BaseController {
    @ObserverRequired
    public String reviewPrescription(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false) @ApiParam(value = "不同意原因", name = "reason") String reason,
                                     @RequestParam(required = false) @ApiParam(value = "不同意原因CODE", name = "reasonCode") String reasonCode,
                                     @RequestParam(required = false) @ApiParam(value = "1同意,2不同意", name = "state") String state,
                                     @RequestParam(required = false) @ApiParam(value = "科室", name = "dept") String dept,
                                     @RequestParam(required = false) @ApiParam(value = "诊金", name = "registerFee") String registerFee,
                                     @RequestParam(required = false) @ApiParam(value = "诊金类型", name = "rateTypeCode") String rateTypeCode) {
        try {
            int rs = prescriptionInfoService.reviewPrescription(code, reason, state, dept, registerFee, rateTypeCode);
            int rs = prescriptionInfoService.reviewPrescription(code, reason,reasonCode, state, dept, registerFee, rateTypeCode);
            if (rs == 0) {
                return write(200, "开方失败!", "data", rs);
            } else {
@ -120,9 +122,10 @@ public class PrescriptionInfoController extends BaseController {
    public String updatePresInfo(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                 @RequestParam(required = true) @ApiParam(value = "续方药品JSON", name = "infos") String infos,
                                 @RequestParam(required = false) @ApiParam(value = "疾病JSON", name = "diagnosis") String diagnosis,
                                 @RequestParam(required = false) @ApiParam(value = "调整原因", name = "reason") String reason) {
                                 @RequestParam(required = false) @ApiParam(value = "调整原因", name = "reason") String reason,
                                 @RequestParam(required = false) @ApiParam(value = "调整原因标签Code,用,分割", name = "reasonCode") String reasonCode) {
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.updatePresInfo(code, infos, diagnosis, reason));
            return write(200, "操作成功!", "data", prescriptionInfoService.updatePresInfo(code, infos, diagnosis, reason,reasonCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -465,7 +468,7 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getPhysicInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取药品信息")
    public String getPhysicInfo(String code) {
    public String getPhysicInfo(@RequestParam(required = true) @ApiParam(name = "code", value = "药品code") String code) {
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPhysicInfo(code));
        } catch (Exception e) {
@ -473,4 +476,16 @@ public class PrescriptionInfoController extends BaseController {
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getReasonByType", method = RequestMethod.GET)
    @ApiOperation(value = "获取原因")
    public String getReasonByType(@RequestParam(required = true) @ApiParam(name = "code", value = "类型:0 审核原因标签;1 调整原因标签") Integer type) {
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getReasonByType(type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 18 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -8,20 +8,18 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.service.app.prescription.*;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.axis.encoding.Base64;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
 * Created by Administrator on 2017/7/21.
@ -42,6 +40,8 @@ public class PatientPrescriptionController extends WeixinBaseController {
    private PrescriptionPayService prescriptionPayService;
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    /**
     * 生成取药码
@ -252,4 +252,19 @@ public class PatientPrescriptionController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/fadeRecipe", method = RequestMethod.POST)
    @ApiOperation(value = "挂号作废处方接口")
    public String fadeRecipe(
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode){
        try {
            String result = jwPrescriptionService.fadeRecipe(prescriptionCode);
            return write(200, "挂号作废成功!", "result", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "挂号作废失败+"+e.getMessage());
        }
    }
}

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

@ -41,13 +41,14 @@ public class PatientPrescriptionInfoController extends BaseController {
    @ApiOperation(value = "获取长处方信息列表")
    public String getPrescriptionInfos(@RequestParam(required = true)@ApiParam(name="type",value="1:查询处方;2我的续方;3:续方记录")String type,
                                       @RequestParam(required = false)@ApiParam(name="isRenewal",value="处方是否可续方:1.是;2.无过滤")String isRenewal,
                                       @RequestParam(required = false)@ApiParam(name="recipeNo",value="医嘱号,第一次获取上一方时传入0,第二次获取上一方时传入第一次返回的医嘱号,以此类推")String recipeNo,
                                       @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                       @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                       @RequestParam(required = false,defaultValue = "0")@ApiParam(name="diagnosisCode",value="所有诊断(0 全部 1高血压 2糖尿病)")String diagnosisCode,
                                       @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                       @RequestParam(required = false)@ApiParam(name="size",value="每页记录数")Integer size){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionInfos(type,diagnosisCode,startDate,endDate,getRepUID(),isRenewal,page,size));
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionInfos(type,recipeNo,diagnosisCode,startDate,endDate,getRepUID(),isRenewal,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");

+ 18 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -254,6 +254,24 @@ public class WeiXinEventProcess {
        articlePrescription.put("PicUrl", prescription_pic);
        articles.add(articlePrescription);
//        新增居民取药码图文消息 by wjj 2017.08.25
        Map<String, String> articlePatientQRCode = new HashMap<>();
        // 图文URL
        String patientQRCode = systemConf.getProperty("patient_QRCode_url");
        // 图文消息图片URL
        String patientQRCode_pic = systemConf.getProperty("patient_QRCode_pic");
        // URL设置服务器URL、AppId
        patientQRCode = patientQRCode.replace("{server}", wechat_base_url)
                .replace("{appId}", appId);
        //图片地址
        patientQRCode_pic = patientQRCode_pic.replace("{server}", serverUrl);
        articlePatientQRCode.put("Url", patientQRCode);
        articlePatientQRCode.put("Title", "我的取药码");
        articlePatientQRCode.put("Description", "我的取药码");
        articlePatientQRCode.put("PicUrl", patientQRCode_pic);
        articles.add(articlePatientQRCode);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);

+ 4 - 3
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -275,10 +275,11 @@ ylzpay:
  onepayAppSecret: 1BLF5SCBO01V3E78A8C00000F3A0FFE7
express:
  sf_url: http://bsp-ois.sit.sf-express.com:9080/bsp-ois/sfexpressService
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: BSPdevelop
  sf_check_word: j8DzkIFgmlomPt0aLuwU
  sf_code: sddf
  sf_check_word: PqFN0ADkTwnvXArMhqGxVduag44vyDQ7
---
##开发的配置