Pārlūkot izejas kodu

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

chenweida 8 gadi atpakaļ
vecāks
revīzija
203ae54e58
20 mainītis faili ar 868 papildinājumiem un 115 dzēšanām
  1. 19 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  2. 18 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressage.java
  3. 7 3
      patient-co-service/wlyy_service/pom.xml
  4. 7 5
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  5. 3 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java
  6. 67 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/Prescription.java
  7. 19 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZyDictService.java
  8. 86 19
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  9. 8 2
      patient-co-service/wlyy_sign/pom.xml
  10. BIN
      patient-co-service/wlyy_sign/src/main/resources/libsehr.crypto.so
  11. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/MvcConfig.java
  12. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  13. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java
  14. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  15. 77 77
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  16. 288 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PCPrescriptionExpressageService.java
  17. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  18. 228 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/PCLoginController.java
  19. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescriptionPC/PrescriptionExpressagePCController.java
  20. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

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

@ -84,6 +84,9 @@ public class Prescription extends IdEntity {
    private String jwRateTypeCode;//基卫-费别类型编码
    private String jwRegisterFee; //基卫-诊金
    private String prescribeReason; //开方失败/成功原因
    private String prescribeTime ;//开方失败、成功时间
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
@ -622,4 +625,20 @@ public class Prescription extends IdEntity {
        }
        return "";
    }
    public String getPrescribeReason() {
        return prescribeReason;
    }
    public void setPrescribeReason(String prescribeReason) {
        this.prescribeReason = prescribeReason;
    }
    public String getPrescribeTime() {
        return prescribeTime;
    }
    public void setPrescribeTime(String prescribeTime) {
        this.prescribeTime = prescribeTime;
    }
}

+ 18 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionExpressage.java

@ -45,6 +45,8 @@ public class PrescriptionExpressage extends IdEntity{
    private String hospitalAddress;         // 配药机构地址
    private String hospitalName;            // 配药机构名称
    private String hospitalCode;            // 配药机构code
    private String hospitalDoctor;          // 配药机构出药人(健管师或者称工作人员)
    private String hospitalDoctorCode;     // 配药机构出药人code
    //配送人信息
    private String expressageHospitalName;            // 如果配送方式是健管师那么这个字段存服务站名称,如果是快递配送那么是快递公司名称
@ -388,4 +390,20 @@ public class PrescriptionExpressage extends IdEntity{
    public void setAcceptHospitalAddress(String acceptHospitalAddress) {
        this.acceptHospitalAddress = acceptHospitalAddress;
    }
    public String getHospitalDoctor() {
        return hospitalDoctor;
    }
    public void setHospitalDoctor(String hospitalDoctor) {
        this.hospitalDoctor = hospitalDoctor;
    }
    public String getHospitalDoctorCode() {
        return hospitalDoctorCode;
    }
    public void setHospitalDoctorCode(String hospitalDoctorCode) {
        this.hospitalDoctorCode = hospitalDoctorCode;
    }
}

+ 7 - 3
patient-co-service/wlyy_service/pom.xml

@ -108,17 +108,21 @@
            <artifactId>jedis</artifactId>
            <version>2.8.1</version>
        </dependency>
        <!--Swagger-->
        <!--Swagger start -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
            <version>2.7.0</version>
        </dependency>
        <!--Swagger end -->
        <!--Springboot tomcat -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 7 - 5
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java


+ 3 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java

@ -18,6 +18,9 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Query("from Prescription p where p.recipeNo=?1")
    Prescription findByRecipeNo(String recipeNo);
    @Query(value = "SELECT a.* from wlyy_prescription a WHERE a.jw_code = ?1 ORDER BY create_time LIMIT 0,1",nativeQuery = true)
    Prescription findByJwCode(String jwCode);
    @Modifying
    @Query("update Prescription p set p.status=?2 where p.code=?1")
    void updateStatus(String prescriptionCode, Integer status);

+ 67 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/Prescription.java

@ -9,6 +9,7 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * Created by Administrator on 2017/7/21.
@ -72,6 +73,15 @@ public class Prescription extends IdEntity {
    private String strOriginalData; //CA原文数据
    private List<PrescriptionInfo> prescriptionInfo;
    private String reviewedState;
    private String jwDeptCode;  //基卫-开处方的科室编码
    private String jwHospital;  //基卫-开处方的医院编码
    private String jwDoctorCode; //基卫-开方医生的编码
    private String jwGisterTypeCode;//基卫-挂号类型编码
    private String jwRateTypeCode;//基卫-费别类型编码
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
@ -545,4 +555,61 @@ public class Prescription extends IdEntity {
        this.strOriginalData = strOriginalData;
    }
    @Transient
    public List<PrescriptionInfo> getPrescriptionInfo() {
        return prescriptionInfo;
    }
    public void setPrescriptionInfo(List<PrescriptionInfo> prescriptionInfo) {
        this.prescriptionInfo = prescriptionInfo;
    }
    @Transient
    public String getReviewedState() {
        return reviewedState;
    }
    public void setReviewedState(String reviewedState) {
        this.reviewedState = reviewedState;
    }
    public String getJwDeptCode() {
        return jwDeptCode;
    }
    public void setJwDeptCode(String jwDeptCode) {
        this.jwDeptCode = jwDeptCode;
    }
    public String getJwDoctorCode() {
        return jwDoctorCode;
    }
    public void setJwDoctorCode(String jwDoctorCode) {
        this.jwDoctorCode = jwDoctorCode;
    }
    public String getJwGisterTypeCode() {
        return jwGisterTypeCode;
    }
    public void setJwGisterTypeCode(String jwGisterTypeCode) {
        this.jwGisterTypeCode = jwGisterTypeCode;
    }
    public String getJwRateTypeCode() {
        return jwRateTypeCode;
    }
    public void setJwRateTypeCode(String jwRateTypeCode) {
        this.jwRateTypeCode = jwRateTypeCode;
    }
    public String getJwHospital() {
        return jwHospital;
    }
    public void setJwHospital(String jwHospital) {
        this.jwHospital = jwHospital;
    }
}

+ 19 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZyDictService.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.service.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
 * 智业字典接口
 * Created by yeshijie on 2017/8/14.
 */
@Service
public class ZyDictService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
}

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

@ -411,12 +411,13 @@ public class PrescriptionService extends ZysoftBaseService{
     * 调阅历史处方接口
     * @param cardNo 社保卡号
     * @param recipeNo 医嘱号
     * @param recipeNo 指定医嘱(处方)号时,直接返回该指定医嘱(处方)的信息
     * @param applyTimeFrom 开始时间
     * @param applyTimeEnd 结束时间
     * @return
     * @throws Exception
     */
    public String getLastRecipe(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd)  throws Exception
    public String getLastRecipe(String cardNo,String recipeNo,String appointRecipeNo,String applyTimeFrom,String applyTimeEnd)  throws Exception
    {
        Patient patient = patientDao.findBySsc(cardNo);
        SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
@ -436,6 +437,9 @@ public class PrescriptionService extends ZysoftBaseService{
            recipeNo = "0";
        }
        params.put("recipeNo",recipeNo);
        if(StringUtils.isEmpty(appointRecipeNo)){
            params.put("appointRecipeNo",appointRecipeNo);
        }
        if(StringUtils.isEmpty(applyTimeFrom)){
            applyTimeEnd = DateUtil.getStringDateShort();
            applyTimeFrom = DateUtil.getNextDay(new Date(),-60);
@ -448,6 +452,54 @@ public class PrescriptionService extends ZysoftBaseService{
        return response;
    }
    /**
     * 调阅处方详情接口
     * @param cardNo 社保卡号
     * @param appointRecipeNo 指定医嘱(处方)号时,直接返回该指定医嘱(处方)的信息
     * @return
     * @throws Exception
     */
    public String getRecipe(String cardNo,String appointRecipeNo)  throws Exception
    {
        Patient patient = patientDao.findBySsc(cardNo);
        SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
        //
        String[] hospitalMapping = getHospitalMapping(signFamily.getHospital()); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("cardNo",cardNo);
        params.put("recipeNo","0");
        if(StringUtils.isEmpty(appointRecipeNo)){
            params.put("appointRecipeNo",appointRecipeNo);
        }
        String applyTimeEnd = null;
        String applyTimeFrom = null;
        //判断是否存在续方记录,存在就取续方的创建时间为开始时间,保证从续方详情跳转处方详情是有数据
        Prescription prescription = prescriptionDao.findByJwCode(appointRecipeNo);
        if(prescription == null){
            applyTimeEnd = DateUtil.getStringDateShort();
            applyTimeFrom = DateUtil.getNextDay(new Date(),-60);
        }else{
            applyTimeEnd = DateUtil.getNextDay(prescription.getCreateTime(),10);
            applyTimeFrom = DateUtil.getNextDay(prescription.getCreateTime(),-10);
        }
        params.put("applyTimeFrom",applyTimeFrom);
        params.put("applyTimeEnd",applyTimeEnd);
        String response = postSecond("getLastRecipe","调阅处方详情接口",params,null,header,false,2);
        return response;
    }
    /**
     * 7.4 挂号开处方接口,调整处方接口
     * 开方和调整处方接口的区别-开方会传ca认证
@ -455,7 +507,6 @@ public class PrescriptionService extends ZysoftBaseService{
     * @return
     * @throws Exception
     */
    @Transactional
    public String saveRecipe(String prescriptionCode)  throws Exception
    {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
@ -471,25 +522,28 @@ public class PrescriptionService extends ZysoftBaseService{
        //拼接开方参数
        JSONObject json = new JSONObject();
        json.put("cardNo",prescription.getSsc());// "cardNo": "病人卡号",
//            "saveDept": "开单科室编码",
//            "REGISTER_TYPE": "挂号类型编码",
//            "RATE_TYPE": "费别类型编码",
        String jwdoctor = doctorMappingDao.findByDocotrCodeAndJwDoctorHospital(prescription.getDoctor(),hospital);
        json.put("saveOperator",jwdoctor);// "saveOperator": "开单人员编码",
        json.put("saveDept",prescription.getJwDeptCode());//开单科室编码
        json.put("saveOperator",prescription.getJwDoctorCode());// "saveOperator": "开单人员编码",
        json.put("RATE_TYPE","2");//费别类型编码
        json.put("REGISTER_TYPE",prescription.getJwGisterTypeCode());//挂号类型编码
        List<PrescriptionDiagnosis> prescriptionDiagnosisList = prescriptionDiagnosisDao.findByPrescriptionCode(prescriptionCode);
        json.put("DIAGNOSE_CODE",prescriptionDiagnosisList.get(0).getCode());//"DIAGNOSE_CODE": "诊断编码",
        if(prescriptionDiagnosisList.size()>1){
            json.put("DIAGNOSE_SUB_CODE",prescriptionDiagnosisList.get(1).getCode());//"DIAGNOSE_CODE": "次诊断编码",
        }
        if(prescription.getCaCertData()==null){
            json.put("OriginalData",prescription.getStrOriginalData());//原文
            json.put("OriginalDataMD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SignData",prescription.getCaMessage());//签名值
            json.put("CA_CertMainData",prescription.getCaCertData());//签名证书主体数据
            json.put("CA_DigitalSignStreamNoUuid",prescription.getDigitalSignNo());//CA数字签名唯一流水号
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据
            json.put("CA_DIGITAL_SIGN_STREAM_NO_UUID",prescription.getDigitalSignNo());//CA数字签名唯一流水号
        }else {
            json.put("OriginalData",null);
            json.put("OriginalDataMD5",null);
            json.put("CA_SignData",null);
            json.put("CA_CertMainData",null);
            json.put("CA_DigitalSignStreamNoUuid",null);
            json.put("ORIGINAL_DATA",null);
            json.put("ORIGINAL_DATA_MD5",null);
            json.put("CA_SIGN_DATA",null);
            json.put("CA_CERTMAIN_DATA",null);
            json.put("CA_DIGITAL_SIGN_STREAM_NO_UUID",null);
        }
        List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
@ -502,8 +556,8 @@ public class PrescriptionService extends ZysoftBaseService{
            js.put("ITEM_QUANTITY",info.getNum());//"ITEM_QUANTITY": "药品数量",
            js.put("ITEM_UNIT",info.getDrugNumUnit());// "ITEM_UNIT": " 数量单位编码 ",
            js.put("ITEM_SPEC",info.getDrugFormat());//  "ITEM_SPEC": "药品规格",
            js.put("ITEM_PRICE",info.getPrice());// "ITEM_PRICE": "药品单价",
            js.put("COST",info.getCode());// "COST": "药品金额",
            js.put("ITEM_PRICE",intToDouble(info.getPrice()));// "ITEM_PRICE": "药品单价",
            js.put("COST",intToDouble(info.getCost()));// "COST": "药品金额",
            js.put("BIND_FLAG",info.getBindFlag());// "BIND_FLAG": " 成组标志, 0.非成组,1.成组",
            js.put("FREQUENCY",info.getDrugRate());// "FREQUENCY": "用药频次编码",
            js.put("DAY_COUNT",info.getDayCount());// "DAY_COUNT": "用药天数",
@ -524,6 +578,19 @@ public class PrescriptionService extends ZysoftBaseService{
        return response;
    }
    /**
     * 整型除以100转
     * @param num
     * @return
     */
    private Double intToDouble(Integer num){
        if(num==null){
            return 0.0d;
        }
        return (double)num/100;
    }
    /**
     * 7.5 查询处方结算结果列表
     * @param cardNo 病人卡号

+ 8 - 2
patient-co-service/wlyy_sign/pom.xml

@ -95,12 +95,18 @@
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
            <version>2.7.0</version>
        </dependency>
        <!--Springboot tomcat -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <!-- 智业接口引用 -->

BIN
patient-co-service/wlyy_sign/src/main/resources/libsehr.crypto.so


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

@ -37,9 +37,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
        // 多个拦截器组成一个拦截器链
        // addPathPatterns 用于添加拦截规则
        // excludePathPatterns 用户排除拦截
//        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**");
//        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
//        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        registry.addInterceptor(doctorInterceptor).addPathPatterns("/doctor/**", "/statistics/province/**", "/statistics/**");
        registry.addInterceptor(patientInterceptor).addPathPatterns("/patient/**");
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**");
        super.addInterceptors(registry);
        logger.info("init doctorInterceptor,patientInterceptor");

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

@ -122,8 +122,8 @@ public class DoctorInfoService extends BaseService {
    private PrescriptionDao prescriptionDao;
    //基卫服务地址
//    @Value("${sign.check_upload}")
    private String jwUrl="http://192.168.131.131:8089";
    @Value("${sign.check_upload}")
    private String jwUrl;//="http://192.168.131.131:8089";
    @Autowired
    private HttpClientUtil HttpClientUtil;

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

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
@ -78,7 +79,10 @@ public class PrescriptionDispensaryCodeService extends BaseService {
            precriptionSql += " and p1.status = ? ";
            params.add(status);
        }else {
            precriptionSql += " and p1.status in (20,21,100)" ;
            precriptionSql += " and p1.status in (?,?,?)" ;
            params.add(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
            params.add(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
            params.add(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        }
        if(timeType!=null){
            precriptionSql +=  "and TIMESTAMPDIFF(SECOND, p2.create_Time, CURRENT_TIME) < ? ORDER BY p1.status desc ,p2.create_Time desc ";

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

@ -363,7 +363,7 @@ public class PrescriptionInfoService extends BaseService {
            int st = respone.getInteger("status");
            com.alibaba.fastjson.JSONObject data = respone.getJSONObject("data");
            String code = data.getString("CODE");
            if(st==200&&"1".equals(code)){
            if(st==200&&"1".equals(code)&&data.getJSONArray("returnData").size()>0){
                //开方成功返回遗嘱号
                com.alibaba.fastjson.JSONArray returnDatas = data.getJSONArray("returnData");
                com.alibaba.fastjson.JSONObject returnData = (com.alibaba.fastjson.JSONObject)returnDatas.get(0);

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

@ -136,102 +136,102 @@ public class PrescriptionService extends BaseService {
        //根据医保卡号和挂号号从基卫获取待结算明细
        String result = jwPrescriptionService.getDispUnSettleFeeInfoList(cardNo,visitNo);
        //根据挂号号获取处方明细
        Prescription prescription = prescriptionDao.findByVisitNo(visitNo);
        //根据机构名称,医生编码获取基卫医生详细信息
        DoctorMapping doctorMapping = doctorMappingDao.findByJwDoctorHospitalAndDoctorCode(prescription.getHospitalName(),prescription.getDoctor());
        JSONObject json = new JSONObject();
        //处方主信息{"yyksbm":"医生科室编号","bcsfcs":"本次收费次数","yszjhm":"医生证件号码","ysxm00":"医生姓名","mzlb00":"门诊类别","sfydgh":"是否药店挂号",
        // "bcghcs":"本次挂号次数","ghksmc":"挂号科室名称","cfxms0":"明细上传数量","mzlsh0":"医保挂号流水号 如果为空,将自动医保挂号并收费","ghfy00":"挂号费用",
        // "yszjdj":"医师诊金级别","bqbm00":"病情编码","sfygwd":"是否医改网点"}
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("yyksbm",prescription.getJwDeptCode());//医生科室编号
        jsonObject.put("bcsfcs",1);//本次收费次数
        jsonObject.put("yszjhm",doctorMapping.getJwDocotrIdcard());//医生证件号码
//        jsonObject.put("yszjhm","350681876766545567");//医生证件号码
        jsonObject.put("ysxm00",doctorMapping.getJwDoctorName());//医生姓名
//        jsonObject.put("ysxm00","林金城");//医生姓名
        jsonObject.put("mzlb00",101);//门诊类别---普通门诊默认为101
        jsonObject.put("sfydgh","N");//是否药店挂号,默认为N,不是药店挂号
        jsonObject.put("bcghcs",1);//本次挂号次数
        jsonObject.put("ghksmc",prescription.getDeptName());//挂号科室名称
        jsonObject.put("mzlsh0","");//医保挂号流水号
        jsonObject.put("ghfy00",0);//挂号费用
        jsonObject.put("yszjdj","医师诊金级别");//医师诊金级别--------------------------待处理
        jsonObject.put("bqbm00","");//病情编码---可为空,不传递
        jsonObject.put("sfygwd","N");//是否医改网点--默认为否
        json.put("recipeContent",jsonObject);
        List<PrescriptionDiagnosis> pds = prescriptionDiagnosisDao.findByPrescriptionCode(prescription.getCode());
        //诊断明细        {"zdms00":"诊断或症状描述","zdbh00":"诊断或症状编码"}
        if (!pds.isEmpty()){
            for (PrescriptionDiagnosis pd : pds) {
                JSONArray zdInfo = new JSONArray();
                JSONObject j1 = new JSONObject();
                j1.put("zdms00",pd.getName());//诊断或症状描述
                j1.put("zdbh00",pd.getCode());//诊断或症状编码
                zdInfo.add(j1);
                json.put("zdlist",zdInfo);
            }
        }
//        JSONArray zdInfo = new JSONArray();
//        JSONObject j1 = new JSONObject();
//        j1.put("zdms00","高血压");//诊断或症状描述
//        j1.put("zdbh00","1212121");//诊断或症状编码
//        zdInfo.add(j1);
//        json.put("zdlist",zdInfo);
        if(StringUtils.isNotBlank(result)){
            JSONObject jwobj =  JSON.parseObject(result);
            JSONObject zyCfinfo = jwobj.getJSONObject("data");
            Integer code = zyCfinfo.getInteger("CODE");
            if( 1 == code){
                JSONArray zyCfinfoListReturnData = zyCfinfo.getJSONArray("returnData");
                JSONArray zyCfinfoList = zyCfinfoListReturnData.getJSONArray(0);
                jsonObject.put("cfxms0",zyCfinfoList.size());//明细上传数量
                //收费明细       {"xmgg00":"项目规格","cfhao0":"处方号","sfybxm":"是否医保项目","dcyydw":"单次用药单位","xmje00":"项目金额","xmbh00":"项目编号",
                // "ysxm00":"医生姓名","yppl00":"药品频率","gytj00":"给药途径","ypts00":"药品天数","xmdj00":"项目单价","qyzl00":"取药总量","ylts00":"药量天数",
                // "sptxbm":"商品条形编码","xmmc00":"项目名称","fpxmbh":"发票项目编号","xmsl00":"项目数量","ypyl00":"药品用量","qyzldw":"取药单位","xmdw00":"项目单位",
                // "jx0000":"剂型"}
                JSONArray cfInfo = new JSONArray();
                for (int i = 0; i < zyCfinfoList.size(); i++) {
                    JSONObject zyCfinfoObj = zyCfinfoList.getJSONObject(i);
                    JSONObject j2 = new JSONObject();
                    j2.put("xmbh00",zyCfinfoObj.getString("INSUR_ITEM_CODE"));//项目编号
                    j2.put("xmmc00",zyCfinfoObj.getString("INSUR_ITEM_NAME"));//项目名称
                    j2.put("fpxmbh","");//发票项目编号
                    j2.put("sfybxm",zyCfinfoObj.getString("INSUR_FLAG"));//是否医保项目
                    j2.put("xmdj00",zyCfinfoObj.getString("INSUR_ITEM_PRICE"));//项目单价
                    j2.put("xmdw00",zyCfinfoObj.getString("INSUR_ITEM_UNIT_NAME"));//项目单位
                    j2.put("xmgg00",zyCfinfoObj.getString("INSUR_ITEM_SPEC"));//项目规格(医保)
                    j2.put("xmsl00",zyCfinfoObj.getString("ITEM_QUANTITY"));//项目数量
                    j2.put("xmje00",zyCfinfoObj.getString("COST"));//项目金额
                    j2.put("ysxm00",zyCfinfoObj.getString("APPLY_OPERATOR_NAME"));//医生姓名
                    j2.put("sptxbm","");//商品条形编码
                    j2.put("yppl00",zyCfinfoObj.getString("FREQUENCY"));//药品频率
                    j2.put("ypyl00",zyCfinfoObj.getString("PHYSIC_DOSE"));//药品用量
                    j2.put("cfhao0",zyCfinfoObj.getString("VISIT_NO"));//处方号
                    j2.put("jx0000",zyCfinfoObj.getString("PHYSIC_FORM"));//剂型
                    j2.put("dcyydw",zyCfinfoObj.getString("PHYSIC_DOSE_UNIT"));//单次用药单位
                    j2.put("qyzl00",zyCfinfoObj.getString("PHYSIC_AMOUNT"));//取药总量
                    j2.put("qyzldw",zyCfinfoObj.getString("PHYSIC_AMOUNT_UNIT"));//取药单位
                    j2.put("gytj00",zyCfinfoObj.getString("PHYSIC_USAGE"));//给药途径
                    j2.put("ypts00",zyCfinfoObj.getString("DAY_COUNT"));//药品天数
                    cfInfo.add(j2);
                    //支付明细
                    JSONArray zySettleDetailList = zyCfinfoList.getJSONObject(i).getJSONArray("SETTLE_DETAIL");
                    //根据挂号号获取处方明细
                    Prescription prescription = prescriptionDao.findByVisitNo(zyCfinfoObj.getString("VISIT_NO"));
                    //处方主信息     {"yyksbm":"医生科室编号","bcsfcs":"本次收费次数","yszjhm":"医生证件号码","ysxm00":"医生姓名","mzlb00":"门诊类别","sfydgh":"是否药店挂号",
                    // "bcghcs":"本次挂号次数","ghksmc":"挂号科室名称","cfxms0":"明细上传数量","mzlsh0":"医保挂号流水号 如果为空,将自动医保挂号并收费","ghfy00":"挂号费用",
                    // "yszjdj":"医师诊金级别","bqbm00":"病情编码","sfygwd":"是否医改网点"}
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("yyksbm",zyCfinfoObj.getString("VISIT_DEPT"));//医生科室编号
                    jsonObject.put("bcsfcs",1);//本次收费次数
                    jsonObject.put("yszjhm",zyCfinfoObj.getString("VISIT_IDENTITY_CARD_NO"));//医生证件号码
                    jsonObject.put("ysxm00",prescription.getDoctorName());//医生姓名
                    jsonObject.put("mzlb00",101);//门诊类别---普通门诊默认为101
                    jsonObject.put("sfydgh","N");//是否药店挂号,默认为N,不是药店挂号
                    jsonObject.put("bcghcs",1);//本次挂号次数
                    jsonObject.put("ghksmc",prescription.getDeptName());//挂号科室名称
                    jsonObject.put("mzlsh0","");//医保挂号流水号
                    jsonObject.put("ghfy00",0);//挂号费用
                    jsonObject.put("bqbm00","");//病情编码---可为空,不传递
                    jsonObject.put("sfygwd","N");//是否医改网点--默认为否
                    jsonObject.put("yszjdj",zyCfinfoObj.getString("INSUR_DOCTOR_RANK"));//医师诊金级别
                    jsonObject.put("cfxms0",zySettleDetailList.size());//明细上传数量
                    json.put("recipeContent",jsonObject);
                    List<PrescriptionDiagnosis> pds = prescriptionDiagnosisDao.findByPrescriptionCode(prescription.getCode());
                    //诊断明细        {"zdms00":"诊断或症状描述","zdbh00":"诊断或症状编码"}
                    if (!pds.isEmpty()){
                        for (PrescriptionDiagnosis pd : pds) {
                            JSONArray zdInfo = new JSONArray();
                            JSONObject j1 = new JSONObject();
                            j1.put("zdms00",pd.getName());//诊断或症状描述
                            j1.put("zdbh00",pd.getCode());//诊断或症状编码
                            zdInfo.add(j1);
                            json.put("zdlist",zdInfo);
                        }
                    }
                    //收费明细       {"xmgg00":"项目规格","cfhao0":"处方号","sfybxm":"是否医保项目","dcyydw":"单次用药单位","xmje00":"项目金额","xmbh00":"项目编号",
                    // "ysxm00":"医生姓名","yppl00":"药品频率","gytj00":"给药途径","ypts00":"药品天数","xmdj00":"项目单价","qyzl00":"取药总量","ylts00":"药量天数",
                    // "sptxbm":"商品条形编码","xmmc00":"项目名称","fpxmbh":"发票项目编号","xmsl00":"项目数量","ypyl00":"药品用量","qyzldw":"取药单位","xmdw00":"项目单位",
                    // "jx0000":"剂型"}
                    for (int j= 0; i < zySettleDetailList.size(); j++) {
                        JSONObject zySettleDetailObj = zySettleDetailList.getJSONObject(j);
                        JSONObject j2 = new JSONObject();
                        j2.put("xmbh00",zySettleDetailObj.getString("INSUR_ITEM_CODE"));//项目编号
                        j2.put("xmmc00",zySettleDetailObj.getString("INSUR_ITEM_NAME"));//项目名称
                        j2.put("fpxmbh","");//发票项目编号
                        j2.put("sfybxm",zySettleDetailObj.getString("INSUR_FLAG"));//是否医保项目
                        j2.put("xmdj00",zySettleDetailObj.getString("INSUR_ITEM_PRICE"));//项目单价
                        j2.put("xmdw00",zySettleDetailObj.getString("INSUR_ITEM_UNIT_NAME"));//项目单位
                        j2.put("xmgg00",zySettleDetailObj.getString("INSUR_ITEM_SPEC"));//项目规格(医保)
                        j2.put("xmsl00",zySettleDetailObj.getString("ITEM_QUANTITY"));//项目数量
                        j2.put("xmje00",zySettleDetailObj.getString("COST"));//项目金额
                        j2.put("ysxm00",zySettleDetailObj.getString("APPLY_OPERATOR_NAME"));//医生姓名
                        j2.put("sptxbm","");//商品条形编码
                        j2.put("yppl00",zySettleDetailObj.getString("FREQUENCY"));//药品频率
                        j2.put("ypyl00",zySettleDetailObj.getString("PHYSIC_DOSE"));//药品用量
                        j2.put("cfhao0",zySettleDetailObj.getString("VISIT_NO"));//处方号
                        j2.put("jx0000",zySettleDetailObj.getString("PHYSIC_FORM"));//剂型
                        j2.put("dcyydw",zySettleDetailObj.getString("PHYSIC_DOSE_UNIT"));//单次用药单位
                        j2.put("qyzl00",zySettleDetailObj.getString("PHYSIC_AMOUNT"));//取药总量
                        j2.put("qyzldw",zySettleDetailObj.getString("PHYSIC_AMOUNT_UNIT"));//取药单位
                        j2.put("gytj00",zySettleDetailObj.getString("PHYSIC_USAGE"));//给药途径
                        j2.put("ypts00",zySettleDetailObj.getString("DAY_COUNT"));//药品天数
                        cfInfo.add(j2);
                    }
                }
                json.put("mxlist",cfInfo);
            }else{
                String errormessage = zyCfinfo.getString("MESSAGE");
                throw new Exception(errormessage);
            }
        }
//        String aa = json.toString();
        return json;
    }
}

+ 288 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/pc/prescription/PCPrescriptionExpressageService.java

@ -0,0 +1,288 @@
package com.yihu.wlyy.service.pc.prescription;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.RoleService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by liuwenbin on 2017/8/12.
 * PC端长处方取药/领药业务层
 */
@Service
public class PCPrescriptionExpressageService extends BaseService {
    @Autowired
    private PrescriptionDispensaryCodeDao prescriptionDispensaryCodeDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    public Integer getMedicine(String code,String userCode){
        JSONObject jsonObject = new JSONObject();
        //获取根据wlyy_prescription_dispensary_code的code处方编码
        PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(code);
        Integer returnStatus = -1;
        if (prescriptionDispensaryCode == null) {
            //保存验证二维码的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("编码不存在");
            prescriptionLogDao.save(prescriptionLog);
            returnStatus = -1;
            return returnStatus;
        }
        if (prescriptionDispensaryCode.getIsUse() == 1) {
            //判断编码是否使用过
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("编码重复扫描");
            prescriptionLogDao.save(prescriptionLog);
            returnStatus = -2;
            return returnStatus;
        }
        // 判断出药机构是否与健管师所属机构一致,不一致弹窗提示:“出药机构与您所在机构不一致,无法出药,请重新确认”。一致则进入下一步。
        //获取医生角色和区域权限
//        List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(userCode);
//        if("10".equals(doctor.getLevel())&&roleMap.size()==0){
//            errorMessage="该用户没有管理员权限";
//            loginLog.setErrorMessage(errorMessage);
//            loginLogService.saveLog(loginLog);
//            return error(-1, errorMessage);
//        }
        switch (prescriptionDispensaryCode.getType()) {
            case 1: {
                //判断是1 居民取药码
//                returnStatus = dispensaryCode_1(userCode, prescriptionDispensaryCode);
                break;
            }
            case 2: {
                //判断是2 配送员(健管师)取药码
//                returnStatus = dispensaryCode_2(userCode, prescriptionDispensaryCode);
                break;
            }
            case 3: {
                //判断是3 配送员(健管师)配送码
//                returnStatus = dispensaryCode_3(userCode, prescriptionDispensaryCode);
                break;
            }
            default: {
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("编码类型错误");
                prescriptionLogDao.save(prescriptionLog);
                returnStatus = -3;
                return returnStatus;
            }
        }
        return 0;
    }
    //健管师取药码
    public JSONObject dispensaryCode_2(String userCode,PrescriptionDispensaryCode prescriptionDispensaryCode){
//        Integer returnStatus = -3;
        JSONObject jsonObject = new JSONObject();
        Doctor doctor = doctorService.findDoctorByCode(userCode);
        String sql = "select a.type,c.status,b.hospital_code as hospitalCode from wlyy_prescription_dispensary_code a \n" +
                "left join wlyy_prescription_expressage b on a.prescription_code = b.prescription_code \n" +
                "left join wlyy_prescription c on a.prescription_code = c.code \n" +
                "where a.prescription_code=?";
        Map<String, Object> result = jdbcTemplate.queryForMap(sql,prescriptionDispensaryCode.getPrescriptionCode());
        if(result.size()>0){
            int status = (Integer)result.get("status");
            if((Integer)result.get("type")==1){//居民取药码
                if(status>=30){
                    if(status==30){
                        jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                    }else if(status==40){
                        jsonObject.put("status",1);//取药成功
                    }else{
                        jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                    }
                }
            }else if((Integer)result.get("type")==2){//健管师取药码
                if(result.get("hospitalCode").toString().equals(doctor.getHospital())){
                    //20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成
                    if(status==30){
                        jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                    }else if(status>=45){
                        jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                    }else if(status==40){
                        jsonObject.put("status",1);
                    }
                }else{
                    jsonObject.put("status",-4);//出药机构与您所在机构不一致,无法出药,请重新确认
//            return jsonObject;
                }
            }else{
                jsonObject.put("status",-7); //取药码错误
                //保存验证二维码的日志
                PrescriptionLog prescriptionLog = new PrescriptionLog();
                prescriptionLog.setCode(UUID.randomUUID().toString());
                prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
                prescriptionLog.setCreateTime(new Date());
                prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                prescriptionLog.setFlag(1);
                prescriptionLog.setUserCode(userCode);
                prescriptionLog.setUserType(2);
                prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                prescriptionLog.setRemark("PC端取药码输入错误!");
                prescriptionLogDao.save(prescriptionLog);
            }
        }else{
            jsonObject.put("status",-7); //取药码错误
            //保存验证二维码的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
            prescriptionLog.setPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("编码不存在");
            prescriptionLogDao.save(prescriptionLog);
        }
        jsonObject.put("result",result);
        return jsonObject;
    }
    public JSONObject getMedicine2(String code,String userCode){
        JSONObject jsonObject = new JSONObject();
        Doctor doctor = doctorService.findDoctorByCode(userCode);
        String sql = "select a.type,a.prescription_code as prescriptionCode c.status,b.hospital_code as hospitalCode, \n" +
                "b.code as expressageCode, b.hospital_name as hospitalName,c.dispensary_type as dispensaryType, \n" +
                "b.expressage_name as expressageName, b.expressage_code as expressageCode,b.expressage_mobile as expressageMobile \n" +
                "from wlyy_prescription_dispensary_code a \n" +
                "left join wlyy_prescription_expressage b on a.prescription_code = b.prescription_code \n" +
                "left join wlyy_prescription c on a.prescription_code = c.code \n" +
                "where a.is_use=0 and a.cod=? and c.status>=30";
        Map<String, Object> result = jdbcTemplate.queryForMap(sql,code);
        if(result.size()>0){
            int type = result.get("type")!=null?(Integer) result.get("type"):0;
            int status = result.get("status")!=null?(Integer) result.get("status"):-100;
            switch (type){
                //居民取药码
                case 1:{
                    if(status==30){
                        jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                    }else if(status==40){
                        jsonObject.put("status",1);
                    }else{
                        jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                    }
                }
                //健管师取药码
                case 2:{
                    //判断出药机构是否与健管师所属机构一致,不一致弹窗提示:“出药机构与您所在机构不一致,无法出药,请重新确认”。一致则进入下一步。
                    if(doctor.getHospital().equals(result.get("hospitalCode").toString())){
                        //20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成
                        if(status==30){
                            jsonObject.put("status",-5);//订单正在配药中,暂时无法出药
                        }else if(status>=45){
                            jsonObject.put("status",-6);//”订单已取药,出药人:张三,出药时间:XXXX-XX-XX,无法重新出药
                        }else if(status==40){
                            jsonObject.put("status",1);
                        }
                    }else{
                        jsonObject.put("status",-4);//出药机构与您所在机构不一致,无法出药,请重新确认
                    }
                }
                default:{
                    PrescriptionLog prescriptionLog = new PrescriptionLog();
                    prescriptionLog.setCode(UUID.randomUUID().toString());
                    prescriptionLog.setPrescriptionCode(result.get("prescriptionCode").toString());
                    prescriptionLog.setCreateTime(new Date());
                    prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
                    prescriptionLog.setFlag(1);
                    prescriptionLog.setUserCode(userCode);
                    prescriptionLog.setUserType(2);
                    prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
                    prescriptionLog.setRemark("编码类型错误");
                    prescriptionLogDao.save(prescriptionLog);
                }
            }
        }else{
            //保存验证二维码的日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setCode(UUID.randomUUID().toString());
//            prescriptionLog.setPrescriptionCode(result.get("").toString());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.expressage.getValue());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(userCode);
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing_error.getValue());
            prescriptionLog.setRemark("PC端取药码输入错误!");
        }
//        prescriptionInfoService.
        jsonObject.put("expressageCode",result.get("expressageCode"));
        jsonObject.put("hospitalCode",result.get("hospitalCode"));
        jsonObject.put("hospitalName",result.get("hospitalName"));
        jsonObject.put("status",result.get("status"));
        jsonObject.put("dispensaryType",result.get("dispensaryType"));
        jsonObject.put("expressageName",result.get("expressageName"));
        jsonObject.put("expressageMobile",result.get("expressageMobile"));
        return jsonObject;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -99,7 +99,7 @@ public class LoginController extends BaseController {
     *  @param mobile  手机号
     * @param captcha 短信验证码
     * @param idcard  身份证号
     * @param platform  // 1患者端,2医生端app,3微信公众号wechat,4医生端pc
     * @param platform  // 1患者端,2医生端app,3微信公众号wechat,4IM医生端pc,5PC端取药系统
     * @param password 密码
     * @return
     */

+ 228 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/PCLoginController.java

@ -0,0 +1,228 @@
package com.yihu.wlyy.web.common.account;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.patchca.color.SingleColorFactory;
import org.patchca.filter.predefined.*;
import org.patchca.service.ConfigurableCaptchaService;
import org.patchca.utils.encoder.EncoderHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;
//import io.swagger.annotations.Api;
/**
 * @author calvin
 */
@Controller
@RequestMapping(value = "/loginPC", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康师登录取药系统")
public class PCLoginController extends BaseController {
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private SMSService smsService;
    @Autowired
    public TokenDao tokenDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private LoginLogService loginLogService;
    /**
     *
     * @param mobile 手机号
     * @param captcha 短信验证码
     * @param platform  1、患者端,2、医生端app,3、微信公众号wechat,4、医生端pc,5PC端取药系统
     * @param password 密码
     * @return
     */
    @RequestMapping(value = "doctor",method = RequestMethod.POST)
    @ResponseBody
    public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false,value = "mobile") String mobile,
                         @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
                         @ApiParam(required = false, name = "platform", value = "医生端pc") @RequestParam(required = false,defaultValue = "5") Integer platform,
                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
        String errorMessage;
        LoginLog loginLog=new LoginLog();
        loginLog.setCreateTime(new Date());
        loginLog.setPhone(mobile);
        loginLog.setType("2");
        loginLog.setUserType("2");
        loginLog.setAppVersion(super.getAppVersion());
        try {
            if(platform==null){
                platform = 5;//默认为医生app端
            }
            //身份证登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                password=StringUtils.reverse(password);
                Doctor doctor=doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("2");
                if(doctor==null){
                    errorMessage="该号码未注册!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1,errorMessage);
                }
                loginLog.setUserCode(doctor.getCode());
                String loginPassword= MD5.GetMD5Code(password+doctor.getSalt());
                if(loginPassword.equals(doctor.getPassword())){
                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
                    if(doctor.getLevel()!=3){
                        loginLog.setType("2");
                        errorMessage="该用户角色没有登录权限!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", doctor.getId());
                    map.put("uid", doctor.getCode());
                    map.put("token", token.getToken());
                    map.put("name", doctor.getName());
                    map.put("hospital", doctor.getHospital());
                    map.put("photo", doctor.getPhoto());
                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
                    map.put("doctorType", doctor.getLevel());
                    //获取医生角色和区域权限
//                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
//                    map.put("userRole", roleMap);
//                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
//                        errorMessage="该用户没有管理员权限";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);
//                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }else{
                    errorMessage="密码错误,登录失败";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
            }
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
                // 对验证码进行校验
                int res = smsService.check(mobile, 5, captcha);
                switch (res) {
                    case -2:{
                        errorMessage="验证码已过期!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case -1:{
                        errorMessage="请输入正确的验证码!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                    case 0:{
                        errorMessage="验证码无效!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);}
                }
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                loginLog.setLoginType("1");
                if (doctor == null) {
                    errorMessage="该手机号未注册,请确认!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else {
                    loginLog.setUserCode(doctor.getCode());
                    //使用i健康系统账号体系,只有健康师有权限登录取药系统
                    if(doctor.getLevel()!=3){
                        loginLog.setType("2");
                        errorMessage="该用户角色没有登录权限!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(doctor.getCode(), "pc", platform);
                    loginLog.setTokenId(token.getId());
                    loginLog.setType("1");
                    Map<String, Object> map = new HashMap<>();
                    map.put("id", doctor.getId());
                    map.put("uid", doctor.getCode());
                    map.put("token", token.getToken());
                    map.put("name", doctor.getName());
                    map.put("hospital", doctor.getHospital());
                    map.put("photo", doctor.getPhoto());
                    // 设置医生类型:1专科医生,2全科医生,3健康管理师
                    map.put("doctorType", doctor.getLevel());
                    //获取医生角色和区域权限
//                    List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(doctor.getCode());
//                    map.put("userRole", roleMap);
//                    if("10".equals(doctor.getLevel())&&roleMap.size()==0){
//                        errorMessage="改用户没有管理员权限";
//                        loginLog.setErrorMessage(errorMessage);
//                        loginLogService.saveLog(loginLog);
//                        return error(-1, errorMessage);
//                    }
                    loginLogService.saveLog(loginLog);
                    return write(200, "登录成功", "data", map);
                }
            }
            errorMessage="登录信息不完整,请重新输入!";
            loginLog.setErrorMessage(errorMessage);
            loginLogService.saveLog(loginLog);
            return error(-1,errorMessage);
        } catch (Exception e) {
            loginLog.setErrorMessage(e.getMessage());
            loginLogService.saveLog(loginLog);
            error(e);
            return error(-1, "系统异常,登录失败");
        }
    }
}

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescriptionPC/PrescriptionExpressagePCController.java

@ -0,0 +1,28 @@
package com.yihu.wlyy.web.doctor.prescriptionPC;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by liuwenbin on 2017/8/12.
 */
@Api(description = "PC端-长处方取药/领药接口")
@RestController
@RequestMapping(value = "/PC/prescription")
public class PrescriptionExpressagePCController extends BaseController {
    @ApiOperation(value = "取药/领药")
    @RequestMapping(value = "/getMedicine", method = RequestMethod.POST)
    public String getMedicine(
            @ApiParam(required = true, name = "code", value = "二维码(取药码、配送码)") @RequestParam(value = "code", required = true) String code){
        return "";
    }
}

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

@ -127,7 +127,7 @@ public class PatientPrescriptionInfoController extends BaseController {
    @ApiOperation("判断医生的CA是否有在线上安装证书")
    @ResponseBody
    @RequestMapping(value = "/doctor/isAuthentication", method = RequestMethod.POST)
    public String isAuthentication(@RequestParam(required = true,value="doctorCode")@ApiParam(name="doctorCode",value="医生的code")String doctorCode){
    public String isAuthentication(@RequestParam(required = true,value="doctorCode")@ApiParam(required = true,name="doctorCode",value="医生的code")String doctorCode){
        try {
            //0de6a26a62dd11e69faffa163e8aee56
            JSONObject data = doctorInfoService.isAuthentication(getRepUID());