Selaa lähdekoodia

es代码提交

liuwenbin 7 vuotta sitten
vanhempi
commit
3e108894d3
42 muutettua tiedostoa jossa 2214 lisäystä ja 460 poistoa
  1. 50 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/feedback/Feedback.java
  2. 6 6
      common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java
  3. 50 7
      common/common-entity/src/main/java/com/yihu/wlyy/entity/job/QuartzJobConfig.java
  4. 66 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  5. 20 3
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/feedback/FeedbackController.java
  6. 43 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/feedback/Feedback.java
  7. 14 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java
  8. 6 6
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/FollowupDrugs.java
  9. 3 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/SignFamilyRenewLogDao.java
  10. 9 1
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java
  11. 8 8
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/Contant.java
  12. 162 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/Charge.java
  13. 195 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/OnePayService.java
  14. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/followup/FollowupDrugsService.java
  15. 9 7
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  16. 10 0
      patient-co/patient-co-wlyy/pom.xml
  17. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  18. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/feedback/FeedbackDao.java
  19. 22 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/AppealService.java
  20. 50 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/FeedbackService.java
  21. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowupDrugsService.java
  22. 202 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  23. 98 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  24. 193 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  25. 8 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  26. 418 243
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java
  27. 120 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorAppealController.java
  28. 7 73
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackController.java
  29. 79 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionExpressageController.java
  30. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  31. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java
  32. 120 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientAppealController.java
  33. 11 73
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientFeedbackController.java
  34. 33 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  35. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  36. 135 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java
  37. 5 0
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  38. 5 0
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  39. 4 0
      patient-co/patient-co-wlyy/src/main/resources/application-local.yml
  40. 5 0
      patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml
  41. 5 0
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  42. 6 1
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 50 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/feedback/Feedback.java

@ -1,8 +1,12 @@
package com.yihu.wlyy.entity.feedback;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Reece on 2017/5/6.
@ -21,7 +25,7 @@ public class Feedback extends IdEntity{
//    反馈人身份 1、患者  2、医生
    @Column(name="identity")
    private  int identity;
    private Integer identity;
//    问题描述
    @Column(name="description")
@ -39,7 +43,7 @@ public class Feedback extends IdEntity{
    @Column(name="contact")
    private String contact;
//    状态 0、未读 1、已读
//  状态 0、未读 1、待处理  2、已处理
    @Column(name="status")
    private int status;
@ -51,6 +55,11 @@ public class Feedback extends IdEntity{
    @Column(name="creater_name")
    private String createrName;
    private String phone; //    '手机号'
    private String result; //    '处理结果'
    private String idcard;//反馈人身份证
    private Date createTime;//反馈时间
    public Integer getDel() {
        return del;
    }
@ -146,4 +155,42 @@ public class Feedback extends IdEntity{
    public void setStatus(int status) {
        this.status = status;
    }
    public void setIdentity(Integer identity) {
        this.identity = identity;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
}

+ 6 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/FollowupDrugs.java

@ -26,7 +26,7 @@ public class FollowupDrugs extends IdEntity {
	//药品分组(糖尿病--胰岛特殊处理)
	private String drugsGroup;
	//次剂量
	private Double dose;
	private String dose;
	//用药单位【字典MEASURE_UNIT_DICT】
	private String unit;
	//用药频率【字典RECIPE_FREQUENCY_DICT】
@ -65,15 +65,15 @@ public class FollowupDrugs extends IdEntity {
	public void setDrugsGroup(String drugsGroup) {
		this.drugsGroup = drugsGroup;
	}
	public Double getDose() {
	
	public String getDose() {
		return dose;
	}
	public void setDose(Double dose) {
	
	public void setDose(String dose) {
		this.dose = dose;
	}
	
	public String getUnit() {
		return unit;
	}

+ 50 - 7
common/common-entity/src/main/java/com/yihu/wlyy/entity/job/QuartzJobConfig.java

@ -1,17 +1,14 @@
package com.yihu.wlyy.entity.job;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
 * 计划任务
 */
@Entity
@Table(name = "wlyy_job_config")
@Table(name = "wlyy_job_config_cwd")
public class QuartzJobConfig implements java.io.Serializable {
	private String id;
@ -23,6 +20,11 @@ public class QuartzJobConfig implements java.io.Serializable {
	private String quartzCron;//quartz表达式
	private String status;//1 启动 0停止
	private String del;//是否删除 1正常 0删除
	private String sql;
	private String sqlCount;
	private String sqlDay;
	private String sqlYear;
	private String cacheKey;//缓存的key
	/** minimal constructor */
	public QuartzJobConfig() {
@ -31,7 +33,7 @@ public class QuartzJobConfig implements java.io.Serializable {
	/** full constructor */
	public QuartzJobConfig(String jobName, String jobInfo, String jobType,
						   String jobClass, String quartzCron, String status) {
                           String jobClass, String quartzCron, String status) {
		this.jobName = jobName;
		this.jobInfo = jobInfo;
		this.jobType = jobType;
@ -124,4 +126,45 @@ public class QuartzJobConfig implements java.io.Serializable {
	public void setDel(String del) {
		this.del = del;
	}
	public String getSql() {
		return sql;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}
	public String getSqlCount() {
		return sqlCount;
	}
	public void setSqlCount(String sqlCount) {
		this.sqlCount = sqlCount;
	}
	public String getSqlDay() {
		return sqlDay;
	}
	public void setSqlDay(String sqlDay) {
		this.sqlDay = sqlDay;
	}
	public String getSqlYear() {
		return sqlYear;
	}
	public void setSqlYear(String sqlYear) {
		this.sqlYear = sqlYear;
	}
	public String getCacheKey() {
		return cacheKey;
	}
	public void setCacheKey(String cacheKey) {
		this.cacheKey = cacheKey;
	}
}

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

@ -100,6 +100,16 @@ public class Prescription extends IdEntity {
    private Integer zyCancelState; //智业同步取消表示:0 位同步取消 1已经同步取消
    //1.4.0新增字段
    private Integer drugDeliveryflag;
    private String drugDeliveryReasonCode;
    private String drugDeliveryReasonValue;
    private String drugDeliveryReason;
    private String drugDeliveryOperator;
    private String drugDeliveryOperatorName;
    private Date drugDeliveryTime;
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
@ -698,4 +708,60 @@ public class Prescription extends IdEntity {
    public void setZyCancelState(Integer zyCancelState) {
        this.zyCancelState = zyCancelState;
    }
    public Integer getDrugDeliveryflag() {
        return drugDeliveryflag;
    }
    public void setDrugDeliveryflag(Integer drugDeliveryflag) {
        this.drugDeliveryflag = drugDeliveryflag;
    }
    public String getDrugDeliveryReasonCode() {
        return drugDeliveryReasonCode;
    }
    public void setDrugDeliveryReasonCode(String drugDeliveryReasonCode) {
        this.drugDeliveryReasonCode = drugDeliveryReasonCode;
    }
    public String getDrugDeliveryReasonValue() {
        return drugDeliveryReasonValue;
    }
    public void setDrugDeliveryReasonValue(String drugDeliveryReasonValue) {
        this.drugDeliveryReasonValue = drugDeliveryReasonValue;
    }
    public String getDrugDeliveryReason() {
        return drugDeliveryReason;
    }
    public void setDrugDeliveryReason(String drugDeliveryReason) {
        this.drugDeliveryReason = drugDeliveryReason;
    }
    public String getDrugDeliveryOperator() {
        return drugDeliveryOperator;
    }
    public void setDrugDeliveryOperator(String drugDeliveryOperator) {
        this.drugDeliveryOperator = drugDeliveryOperator;
    }
    public String getDrugDeliveryOperatorName() {
        return drugDeliveryOperatorName;
    }
    public void setDrugDeliveryOperatorName(String drugDeliveryOperatorName) {
        this.drugDeliveryOperatorName = drugDeliveryOperatorName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDrugDeliveryTime() {
        return drugDeliveryTime;
    }
    public void setDrugDeliveryTime(Date drugDeliveryTime) {
        this.drugDeliveryTime = drugDeliveryTime;
    }
}

+ 20 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/feedback/FeedbackController.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.controller.manager.feedback;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.service.manager.feedback.AppealService;
import com.yihu.wlyy.service.manager.feedback.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -24,8 +23,7 @@ import java.util.Map;
@RequestMapping(value = "admin/feedback")
@Api(description = "管理系统意见反馈接口")
public class FeedbackController extends BaseController {
    @Autowired
    private AppealService appealService;
    @Autowired
    private FeedbackService feedbackService;
@ -109,4 +107,23 @@ public class FeedbackController extends BaseController {
        }
    }
    /**
     * 根据反馈id,回复内容result进行处理
     * @param id
     * @param result
     * @return
     */
    @RequestMapping(value="dealFeedback", method = RequestMethod.POST)
    @ResponseBody
    public String dealAppeal(@RequestParam(required = true,value="id") Long id,
                             @RequestParam(required = true,value="result") String result){
        try {
            feedbackService.dealFeedback(id,result);
            return write(200,"操作成功!");
        }catch (Exception e){
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 43 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/feedback/Feedback.java

@ -1,9 +1,12 @@
package com.yihu.wlyy.entity.feedback;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 意见反馈表
@ -26,13 +29,18 @@ public class Feedback extends IdEntity {
    private String images;
    //    联系方式: qq号或者邮箱
    private String contact;
    //    状态 0、未读 1、已读
    //    /状态 0、未读 1、待处理  2、已处理
    private int status;
    //    是否删除 0、删除 1、正常
    private int del;
    //    创建人姓名
    private String createrName;
    private String result; //    '处理结果'
    private String phone; //    '手机号'
    private String idcard;//反馈人身份证
    private Date createTime;//反馈时间
    public Feedback() {
    }
@ -115,4 +123,38 @@ public class Feedback extends IdEntity {
    public void setStatus(int status) {
        this.status = status;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
}

+ 14 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/feedback/FeedbackService.java

@ -156,4 +156,18 @@ public class FeedbackService extends BaseService {
            }
        }
    }
    /***
     * 根据反馈id保存处理结果
     * @param id
     * @param result
     * @throws Exception
     */
    public void dealFeedback(Long id,String result) throws Exception {
        Feedback feedback = feedbackDao.findFeedbackById(id);
        feedback.setResult(result);
        feedback.setStatus(2);
        feedbackDao.save(feedback);
    }
}

+ 6 - 6
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/FollowupDrugs.java

@ -26,7 +26,7 @@ public class FollowupDrugs extends IdEntity {
	//药品分组(糖尿病--胰岛特殊处理)
	private String drugsGroup;
	//次剂量
	private Double dose;
	private String dose;
	//用药单位【字典MEASURE_UNIT_DICT】
	private String unit;
	//用药频率【字典RECIPE_FREQUENCY_DICT】
@ -65,15 +65,15 @@ public class FollowupDrugs extends IdEntity {
	public void setDrugsGroup(String drugsGroup) {
		this.drugsGroup = drugsGroup;
	}
	public Double getDose() {
	
	public String getDose() {
		return dose;
	}
	public void setDose(Double dose) {
	
	public void setDose(String dose) {
		this.dose = dose;
	}
	
	public String getUnit() {
		return unit;
	}

+ 3 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/SignFamilyRenewLogDao.java

@ -40,4 +40,7 @@ public interface SignFamilyRenewLogDao extends PagingAndSortingRepository<SignFa
     */
    @Query("select a from SignFamilyRenewLog a where a.doctor<>a.oldDoctor")
    List<SignFamilyRenewLog> findChangeDoctor(Pageable pageable) throws Exception;
    @Query("select a.proId from SignFamilyRenewLog a where a.signCode=?1")
    String getProId(String signCode);
}

+ 9 - 1
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java

@ -37,6 +37,8 @@ public class ChargeZYService {
    private PatientDao patientDao;
    @Autowired
    private SignFamilyMappingDao signFamilyMappingDao;
    @Autowired
    private SignFamilyRenewLogDao signFamilyRenewLogDao;
    /**
     * 获取机构映射
@ -122,7 +124,13 @@ public class ChargeZYService {
                params.put("CHARGE_TIME", DateUtil.dateToStrLong(sign.getExpensesTime()));  //缴费时间
                params.put("INSUR_PRO_ID", charge.getMiRegisterNo());  //医保签约号
                proId = signFamilyMappingDao.getProId(signCode);
                if("1".equals(sign.getRenewFlag())||"2".equals(sign.getRenewFlag())){
                    proId = signFamilyRenewLogDao.getProId(signCode);
                }else {
                    proId = signFamilyMappingDao.getProId(signCode);
                }
                params.put("PRO_ID", proId);  //标志(智业签约主键)
                operator = doctorMappingDao.findByDocotrCodeAndJwDoctorHospital(operator,hm[0]);  //【医生映射】

+ 8 - 8
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/Contant.java

@ -146,14 +146,14 @@ public class Contant {
        public static String status_3="3";
        public static String status_4="4";
        public static String status_5="5";
        public static String status_6="6";
        public static String status_7="7";
        public static String status_8="8";
        public static String status_9="9";
        public static String status_10="10";
        public static String status_11="11";
        public static String status_12="12";
        public static String status_13="13";
//        public static String status_6="6";
//        public static String status_7="7";
//        public static String status_8="8";
//        public static String status_9="9";
//        public static String status_10="10";
//        public static String status_11="11";
//        public static String status_12="12";
//        public static String status_13="13";
//        public static String status_1_name="续方取消";

+ 162 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/Charge.java

@ -0,0 +1,162 @@
package com.yihu.wlyy.service.app.charge;
/**
 * 医保扣费
 * add by hzp at 20170524
 */
public class Charge {
    private String tradeStatus; //交易状态    0 成功 1 失败  2 已退款
    private String chargeNo;  //医保业务流水号
    private String chargeTime;  //  医保交易成功时间
    private String outChargeNo;  //  接入应用业务流水号
    private String outChargeTime;  //  接入应用内业务时间
    private String medOrgNo;  //  医疗机构编号
    private String medOrgName;  //  医疗机构名称
    private String billNo;  //  待结算费用单据号
    private String cardNo;  //  医保卡号
    private String totalAmount;  //  交易总金额
    private String insuranceAmount;  //  医保支付金额
    private String selfPayAmount;  //  自付金额
    private String userId;  // 用户openId
    private String userName;  // 用户姓名
    private String idType;  // 证件号码
    private String idNo;  // 证件类型
    private String responseContent;  //扣费详情
    public String getResponseContent() {
        return responseContent;
    }
    public void setResponseContent(String responseContent) {
        this.responseContent = responseContent;
    }
    public String getTradeStatus() {
        return tradeStatus;
    }
    public void setTradeStatus(String tradeStatus) {
        this.tradeStatus = tradeStatus;
    }
    public String getChargeNo() {
        return chargeNo;
    }
    public void setChargeNo(String chargeNo) {
        this.chargeNo = chargeNo;
    }
    public String getChargeTime() {
        return chargeTime;
    }
    public void setChargeTime(String chargeTime) {
        this.chargeTime = chargeTime;
    }
    public String getOutChargeNo() {
        return outChargeNo;
    }
    public void setOutChargeNo(String outChargeNo) {
        this.outChargeNo = outChargeNo;
    }
    public String getOutChargeTime() {
        return outChargeTime;
    }
    public void setOutChargeTime(String outChargeTime) {
        this.outChargeTime = outChargeTime;
    }
    public String getMedOrgNo() {
        return medOrgNo;
    }
    public void setMedOrgNo(String medOrgNo) {
        this.medOrgNo = medOrgNo;
    }
    public String getMedOrgName() {
        return medOrgName;
    }
    public void setMedOrgName(String medOrgName) {
        this.medOrgName = medOrgName;
    }
    public String getBillNo() {
        return billNo;
    }
    public void setBillNo(String billNo) {
        this.billNo = billNo;
    }
    public String getCardNo() {
        return cardNo;
    }
    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }
    public String getTotalAmount() {
        return totalAmount;
    }
    public void setTotalAmount(String totalAmount) {
        this.totalAmount = totalAmount;
    }
    public String getInsuranceAmount() {
        return insuranceAmount;
    }
    public void setInsuranceAmount(String insuranceAmount) {
        this.insuranceAmount = insuranceAmount;
    }
    public String getSelfPayAmount() {
        return selfPayAmount;
    }
    public void setSelfPayAmount(String selfPayAmount) {
        this.selfPayAmount = selfPayAmount;
    }
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getIdType() {
        return idType;
    }
    public void setIdType(String idType) {
        this.idType = idType;
    }
    public String getIdNo() {
        return idNo;
    }
    public void setIdNo(String idNo) {
        this.idNo = idNo;
    }
}

+ 195 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/charge/OnePayService.java

@ -67,9 +67,9 @@ public class OnePayService {
    private static final Logger LOGGER = LoggerFactory.getLogger(OnePayService.class);
    /**
     * 家庭医生签约支付查询
     * 家庭医生签约支付查询(v1.4.0作废)
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
    public String chargeQueryBak(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
@ -248,4 +248,197 @@ public class OnePayService {
        return result;
    }
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        try {
            WlyyCharge charge = chargeDao.findByCode(code);
            HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(hospitalMapping.getAppId());
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTransType(config.getChargeQueryType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", code);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            if (OnepayDefaultClient.isSuccessful(res)) {
                //业务处理*******************
                result = JSON.toJSONString(res.getParam());
                Charge chargeView = objectMapper.readValue(result, Charge.class);
                saveToWlyyCharge(chargeView);
                LOGGER.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
        if (!isSuccess) {
            throw new Exception(error);
        }
        return result;
    }
    /**
     * 只保存到家庭签约支付表
     *
     * @param chargeView 家庭签约支付展示类Charge
     * @throws Exception
     */
    public void saveToWlyyCharge(Charge chargeView) throws Exception {
        String outChargeNo = chargeView.getOutChargeNo();
        WlyyCharge chargePay = chargeDao.findByCode(outChargeNo);
        String tradeStatus = chargeView.getTradeStatus();
        String chargeNo = chargeView.getChargeNo();
        String chargeTime = chargeView.getChargeTime();
        String outChargeTime = chargeView.getOutChargeTime();
        String medOrgNo = chargeView.getMedOrgNo();
        String medOrgName = chargeView.getMedOrgName();
        String billNo = chargeView.getBillNo();
        String cardNo = chargeView.getCardNo();
        String totalAmount = chargeView.getTotalAmount();
        String insuranceAmount = chargeView.getInsuranceAmount();
        String selfPayAmount = chargeView.getSelfPayAmount();
        String userId = chargeView.getUserId();
        String userName = chargeView.getUserName();
        String idType = chargeView.getIdType();
        String idNo = chargeView.getIdNo();
        String responseContent = chargeView.getResponseContent();
        chargePay.setChargeNo(chargeNo);//支付流水号
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        chargePay.setChargeTime(chargeTime);//支付平台交易成功时间
        chargePay.setCreateTime(formatDate.parse(outChargeTime));//接入应用内业务时间
        chargePay.setMedOrgNo(medOrgNo);//医疗机构编号
        chargePay.setMedOrgName(medOrgName);//医疗机构名称
        chargePay.setBillNo(billNo);//待结算费用单据号
        chargePay.setSsc(cardNo);//医保卡号
        chargePay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
        chargePay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
        chargePay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
        chargePay.setOpenid(userId);
        chargePay.setName(userName);
        chargePay.setIdType(idType);//证件类型
        chargePay.setIdNo(idNo);//证件号码
        JSONObject response = JSON.parseObject(responseContent);
        String miRegisterNo = null;//医保挂号
        String miCollectDate = null;//收费日期
        String miCollectTime = null;//收费时间
        String miSettleNo = null;//医保收费单据号 (医保签约号)
        String miCollectStatus = null;//扣费状态
        String miRegisterStatus = null;//登记状态
        String cadresPay = "0";//公务员补助
        String miTotalFee = "0";//本次报销总额
        String healthCarePay = "0";//保健基金支付
        String heathPay = "0";//健康账户支付
        String accountPay = "0";//个人账户支付
        String selfPay = "0";//个人现金支付
        String civilPay = "0";//民政补助金额
        if (response != null && response.containsKey("miRegisterNo")) {
            miRegisterNo = response.getString("miRegisterNo");
        }
        if (response != null && response.containsKey("miCollectDate")) {
            miCollectDate = response.getString("miCollectDate");
        }
        if (response != null && response.containsKey("miCollectTime")) {
            miCollectTime = response.getString("miCollectTime");
        }
        if (response != null && response.containsKey("miSettleNo")) {
            miSettleNo = response.getString("miSettleNo");
        }
        if (response != null && response.containsKey("miCollectStatus")) {
            miCollectStatus = response.getString("miCollectStatus");
        }
        if (response != null && response.containsKey("miRegisterStatus")) {
            miRegisterStatus = response.getString("miRegisterStatus");
        }
        if (response != null && response.containsKey("cadresPay")) {
            cadresPay = response.getString("cadresPay");
        }
        if (response != null && response.containsKey("miTotalFee")) {
            miTotalFee = response.getString("miTotalFee");
        }
        if (response != null && response.containsKey("healthCarePay")) {
            healthCarePay = response.getString("healthCarePay");
        }
        if (response != null && response.containsKey("heathPay")) {
            heathPay = response.getString("heathPay");
        }
        if (response != null && response.containsKey("accountPay")) {
            accountPay = response.getString("accountPay");
        }
        if (response != null && response.containsKey("selfPay")) {
            selfPay = response.getString("selfPay");
        }
        if (response != null && response.containsKey("civilPay")) {
            civilPay = response.getString("civilPay");
        }
        chargePay.setMiRegisterNo(miRegisterNo);//医保挂号
        chargePay.setMiCollectDate(miCollectDate);
        chargePay.setMiCollectTime(miCollectTime);
        chargePay.setMiSettleNo(miSettleNo);
        chargePay.setMiCollectStatus(miCollectStatus);
        chargePay.setMiRegisterStatus(miRegisterStatus);
        chargePay.setCadresPay(cadresPay);
        chargePay.setMiTotalFee(miTotalFee);
        chargePay.setHealthCarePay(healthCarePay);
        chargePay.setHeathPay(heathPay);
        chargePay.setAccountPay(accountPay);
        chargePay.setSelfPay(selfPay);
        chargePay.setCivilPay(civilPay);
        //                判断是否需要更新数据 needUpload为0不需要更新
        LOGGER.info("before  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        if (chargePay != null && !("0".equals(chargePay.getNeedUpload()))) {
            updateData(tradeStatus, formatDate.parse(chargeTime), chargeNo, chargePay);
            LOGGER.info("after  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        }
    }
    /**
     * 更改数据 wlyy_sign_family wlyy_charge
     */
    public void updateData(String chargeStatus, Date chargeTime, String chargeNo, WlyyCharge charge) throws Exception {
        if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
            charge.setNeedUpload("1");
            charge.setTradeStatus("0");//交易状态 成功0 失败1
            //        成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
            signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
        } else {
            charge.setTradeStatus("1");//交易状态 成功0 失败1
        }
        charge.setUpdateTime(new Date());
        chargeDao.save(charge);
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/followup/FollowupDrugsService.java

@ -85,7 +85,7 @@ public class FollowupDrugsService extends BaseService {
				drug.setDrugsGroup(item.get("drugsGroup"));
				drug.setDrugsCode(item.get("drugsCode"));
				drug.setDrugsName(item.get("drugsName"));
				drug.setDose(Double.valueOf(String.valueOf(item.get("dose"))));
				drug.setDose(item.get("dose"));
				drug.setUnit(item.get("unit"));
				drug.setFrequency(item.get("frequency"));
				drug.setCreateTime(new Date());

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

@ -378,6 +378,9 @@ public class JwPrescriptionService {
                        String idcard = json.getString("IDENTITY_CARD_NO");//身份证号码
                        String medicalNo = json.getString("MEDICAL_NO");//体检编码
                        String patientName = json.getString("SICK_NAME");//姓名
                        if(StringUtils.isNoneBlank(patientName) && patientName.length() >200){
                            patientName = patientName.substring(0,200);
                        }
                        String orgName = json.getString("ORG_NAME");//医院名称
                        String orgCode = json.getString("ORG_CODE");//医院机构编码
                        String jwDoctorCode = json.getString("MEDICAL_OPERATOR");//体检医生
@ -447,6 +450,7 @@ public class JwPrescriptionService {
                    Integer jwCode = jwData.getInteger("CODE");
                    if (1 == jwCode) {
                        JSONArray dataArray = jwData.getJSONArray("DATA");
                        logger.info("从基卫获取随访信息数量"+ dataArray.size());
                        for (int i = 0; i < dataArray.size(); i++) {
                            Followup followup = new Followup();
                    
@ -806,10 +810,7 @@ public class JwPrescriptionService {
                                        drug.setDrugsGroup("normal");
                                        drug.setDrugsCode("");
                                        drug.setDrugsName(json.getString("PHYSIC_NAME" + j));//药物名称
                                        if(StringUtils.isNoneBlank(json.getString("PHYSIC_DOSE" + j))){
                                            drug.setDose(Double.valueOf(json.getString("PHYSIC_DOSE" + j)));//剂量
                                        }
                                        
                                        drug.setDose(json.getString("PHYSIC_DOSE" + j));//剂量
                                        drug.setUnit(json.getString("PHYSIC_UNIT" + j));//单位【MEASURE_UNIT_DICT】
                                        drug.setFrequency(json.getString("FREQUENCY" + j));//频次【RECIPE_FREQUENCY_DICT】
                                        drug.setCreateTime(new Date());
@ -824,9 +825,7 @@ public class JwPrescriptionService {
                                        drug.setDrugsGroup("insulin");
                                        drug.setDrugsCode("");
                                        drug.setDrugsName(json.getString("INSULIN_NAME" + k));//胰岛素药物名称
                                        if(StringUtils.isNoneBlank(json.getString("INSULIN_DOSE" + k))){
                                            drug.setDose(Double.valueOf(json.getString("INSULIN_DOSE" + k)));//胰岛素剂量
                                        }
                                        drug.setDose(json.getString("PHYSIC_DOSE" + k));//剂量
                                        drug.setUnit(json.getString("INSULIN_UNIT" + k));//v单位【MEASURE_UNIT_DICT】
                                        drug.setFrequency(json.getString("INSULIN_FREQUENCY" + k));//胰岛素频次【RECIPE_FREQUENCY_DICT】
                                        drug.setCreateTime(new Date());
@ -839,6 +838,9 @@ public class JwPrescriptionService {
                        
                                transactionManager.commit(transactionStatus);
                            } catch (Exception ex) {
                                logger.info("查询居民随访记录,开始时间" + startdate + ",结束时间:" + enddate);
                                logger.info("查询居民随访记录,机构" + hospitalMapping.getName() + ",编码:" + hospitalMapping.getCode());
                                logger.info("基卫随访信息报文:"+json.toString());
                                logger.info("同步随访信息报错,errmessage:" + ex.toString());
                                transactionManager.rollback(transactionStatus);
                                continue;

+ 10 - 0
patient-co/patient-co-wlyy/pom.xml

@ -452,6 +452,16 @@
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.5</version>
        </dependency>
        <!--elasticsearch end-->
    </dependencies>
    <build>

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -178,6 +178,8 @@ public class SwaggerConfig {
                        regex("/im_new/.*"),
                        regex("/version/.*"),
                        regex("/express/.*"),
                        regex("/doctorFeeback/.*"),
                        regex("/patientFeeback/.*"),
                        regex("/esstatistics/.*")
                ))
                .build()

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/feedback/FeedbackDao.java

@ -1,11 +1,20 @@
package com.yihu.wlyy.repository.feedback;
import com.yihu.wlyy.entity.feedback.Feedback;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/5/6.
 */
public interface FeedbackDao extends PagingAndSortingRepository<Feedback, Long>,JpaSpecificationExecutor<Feedback> {
    @Query("from Feedback p where p.creater = ?1 and p.identity=?2 and p.del=1 ")
    Page<Feedback> findByCreater(String creater,Integer identity,Pageable pageRequest);
    @Query("select p from Feedback p where p.code=?1")
    Feedback findByCode(String code);
}

+ 22 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/AppealService.java

@ -5,11 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.feedback.Appeal;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.feedback.AppealDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -29,9 +32,12 @@ public class AppealService extends BaseService {
    @Autowired
    private PatientService patientService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private DoctorDao doctorDao;
    /**
     * 保存账号申诉
@ -78,10 +84,24 @@ public class AppealService extends BaseService {
     * @param idcard
     * @param page
     * @param pagesize
     * @param type 类型 1居民 2医生
     * @return
     */
    public JSONArray findAppealByIdcard(String idcard,Integer page,Integer pagesize){
    public JSONArray findAppealByIdcard(String idcard,String userCode,Integer page,Integer pagesize,Integer type){
        JSONArray re = new JSONArray();
        if(StringUtils.isEmpty(idcard)&&StringUtils.isEmpty(userCode)){
            return re;
        }
        if(StringUtils.isEmpty(idcard)){
            if(type==1){
                Patient patient = patientDao.findByCode(userCode);
                idcard = patient.getIdcard();
            }else {
                Doctor doctor = doctorDao.findByCode(userCode);
                idcard = doctor.getIdcard();
            }
        }
        pagesize = pagesize==null? 10:pagesize;
        // 排序

+ 50 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/FeedbackService.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.service.app.feedback;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.entity.patient.Patient;
@ -7,10 +9,17 @@ import com.yihu.wlyy.repository.feedback.FeedbackDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
 * Created by Reece on 2017/5/6.
 */
@ -42,12 +51,53 @@ public class FeedbackService extends BaseService {
        if(identity==1){//说明是患者
            Patient patient = patientService.findByCode(creater);
            name = patient.getName();
            feedback.setIdcard(patient.getIdcard());
            feedback.setPhone(patient.getMobile());
        }else{//说明是医生
            Doctor doctor = doctorService.findDoctorByCode(creater);
            name = doctor.getName();
            feedback.setIdcard(doctor.getIdcard());
            feedback.setPhone(doctor.getMobile());
        }
        feedback.setCreateTime(new Date());
        feedback.setCreaterName(name);
        feedbackDao.save(feedback);
    }
    /**
     * 按用户code查找
     * @param userCode
     * @param page
     * @param pagesize
     * @param type 类型 1居民 2医生
     * @return
     */
    public JSONArray findByCreater(String userCode, Integer page, Integer pagesize, Integer type){
        JSONArray re = new JSONArray();
        page = page == null?0:page;
        pagesize = pagesize==null? 10:pagesize;
        // 排序
        Sort sort = new Sort(Direction.DESC, "createTime");
        // 分页信息
        PageRequest pageRequest = new PageRequest(page, pagesize, sort);
        Page<Feedback> pages = feedbackDao.findByCreater(userCode,type,pageRequest);
        pages.forEach(feedback -> {
            JSONObject json = new JSONObject();
            json.put("code",feedback.getCode());
            json.put("createTime", DateUtil.dateToStrLong(feedback.getCreateTime()));
            json.put("type",feedback.getType());
            json.put("status",feedback.getStatus());
            json.put("description",feedback.getDescription());
            re.add(json);
        });
        return re;
    }
    public Feedback findByCode(String code){
        return feedbackDao.findByCode(code);
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowupDrugsService.java

@ -85,7 +85,7 @@ public class FollowupDrugsService extends BaseService {
				drug.setDrugsGroup(item.get("drugsGroup"));
				drug.setDrugsCode(item.get("drugsCode"));
				drug.setDrugsName(item.get("drugsName"));
				drug.setDose(Double.valueOf(String.valueOf(item.get("dose"))));
				drug.setDose(item.get("dose"));
				drug.setUnit(item.get("unit"));
				drug.setFrequency(item.get("frequency"));
				drug.setCreateTime(new Date());

+ 202 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -8,21 +8,24 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.UUID;
import java.util.*;
/**
 * Created by chenweida on 2017/7/27.
 * 订单物流相关
 * 订单物流相关。
 */
@Service
public class PrescriptionExpressageService {
public class PrescriptionExpressageService extends BaseService {
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
@ -43,6 +46,8 @@ public class PrescriptionExpressageService {
    private DoctorDao doctorDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
@ -247,8 +252,8 @@ public class PrescriptionExpressageService {
        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        //回填配送表的配送时间
        PrescriptionExpressage prescriptionExpressage=prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionExpressage.setExpressageTime(expressageing );
        PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
        prescriptionExpressage.setExpressageTime(expressageing);
        //得到patient
        Patient patient = patientDao.findByCode(prescription.getPatient());
@ -458,4 +463,195 @@ public class PrescriptionExpressageService {
            prescriptionExpressage.setExpressageHospitalAddress(hospitalAddress);
        }
    }
    public List<Map<String, Object>> getDrugDeliveryState() {
        String sql = "SELECT * FROM system_dict t WHERE t.dict_name = 'DRUGDELIVERY_STATE' ORDER BY DESC";
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String, Object>> getEsListByIDCardOrSSC(String keyWord, Integer page, Integer pageSize) {
        Patient p = null;
        if (StringUtils.isNotBlank(keyWord)) {
            p = patientDao.findByIdcard(keyWord);
            if (p == null) {
                p = patientDao.findBySsc(keyWord);
            }
            if (p != null) {
                int start = (page - 1) * pageSize;
                String sql = "SELECT " +
                        "  py.charge_no AS chargeNo, " +
                        "  p.patient_name AS patientName, " +
                        "  p.patient AS patientCode, " +
                        "  py.pay_time AS payTime, " +
                        "  p.dispensary_type AS dispensaryType, " +
                        "  p.`status` " +
                        " FROM " +
                        " wlyy_prescription p " +
                        " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                        " WHERE " +
                        " p.patient = '" + p.getCode() + "' " +
                        " AND p.`status`>=50 " +
                        " ORDER BY p.`status` ASC " +
                        " LIMIT " + start + "," + pageSize;
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                return list;
            }
        }
        return null;
    }
    public String saveDrugDelivery(String doctor, String prescriptionCode, String reasonCode, String reasonName, String reason) {
        Prescription p = prescriptionDao.findByCode(prescriptionCode);
        Doctor d = doctorDao.findByCode(doctor);
        if (p != null) {
            p.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            p.setDrugDeliveryflag(1);
            p.setDrugDeliveryOperator(doctor);
            p.setDrugDeliveryOperatorName(d.getName());
            p.setDrugDeliveryReason(reason);
            p.setDrugDeliveryReasonCode(reasonCode);
            p.setDrugDeliveryOperatorName(reasonName);
            p.setDrugDeliveryTime(new Date());
            prescriptionDao.save(p);
            //更新日志
            PrescriptionLog prescriptionLog = new PrescriptionLog();
            prescriptionLog.setPrescriptionCode(p.getCode());
            prescriptionLog.setCode(getCode());
            prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.finish.getValue());
            prescriptionLog.setCreateTime(new Date());
            prescriptionLog.setFlag(1);
            prescriptionLog.setUserCode(doctor);
            prescriptionLog.setUserName(d.getName());
            prescriptionLog.setUserType(2);
            prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
            prescriptionLogDao.save(prescriptionLog);
            //更新二维码(isUse)
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeDao.finByCode(prescriptionCode);
            //修改取药码code为已经使用
            prescriptionDispensaryCode.setIsUse(1);
            prescriptionDispensaryCodeDao.save(prescriptionDispensaryCode);
            //更新配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageDao.findByPrescriptionCode(prescriptionDispensaryCode.getPrescriptionCode());
            prescriptionExpressage.setHospitalDoctor(doctor);
            prescriptionExpressage.setHospitalDoctorCode(d.getCode());
            prescriptionExpressage.setFetchingMedicineTime(new Date());
            prescriptionExpressageDao.save(prescriptionExpressage);
            return "1";
        }
        return "0";
    }
    public List<Map<String, Object>> getPresStatesList() {
        List<Map<String, Object>> rs = new ArrayList<>();
        Map<String, Object> map1 = new HashedMap();
        map1.put("code", PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
        map1.put("name", PrescriptionLog.PrescriptionLogStatus.pay_success.getName());
        rs.add(map1);
        Map<String, Object> map2 = new HashedMap();
        map2.put("code", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
        map2.put("name", PrescriptionLog.PrescriptionLogStatus.wait_expressage.getName());
        rs.add(map2);
        Map<String, Object> map3 = new HashedMap();
        map3.put("code", PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        map3.put("name", PrescriptionLog.PrescriptionLogStatus.expressageing.getName());
        rs.add(map3);
        Map<String, Object> map4 = new HashedMap();
        map4.put("code", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getValue());
        map4.put("name", PrescriptionLog.PrescriptionLogStatus.expressage2hospital.getName());
        rs.add(map4);
        Map<String, Object> map5 = new HashedMap();
        map5.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        map5.put("name", PrescriptionLog.PrescriptionLogStatus.finish.getName());
        rs.add(map5);
        return rs;
    }
    public List<Map<String, Object>> getPresEsPayList(String keyWord, String state, String type, String startDate, String endDate, String operator,String flag,Integer page, Integer pageSize) {
        int start = (page - 1) * pageSize;
        String sql = "SELECT " +
                "  py.charge_no AS chargeNo, " +
                "  p.patient_name AS patientName, " +
                "  p.patient AS patientCode, " +
                "  py.pay_time AS payTime, " +
                "  p.dispensary_type AS dispensaryType, " +
                "  p.drug_delivery_operator_name AS operatorName," +
                "  p.drug_delivery_flag AS drugDeliveryFlag, " +
                "  p.`status` " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_pay py ON py.prescription_code = p.`code` " +
                " WHERE" +
                " 1=1 ";
        sql = setSQL( sql,keyWord,state,type,startDate,endDate,operator,flag);
        sql +=  " AND p.`status`>=50 " +
                " ORDER BY py.create_time DESC " +
                " LIMIT " + start + "," + pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public String setSQL(String sql,String keyWord, String state, String type, String startDate, String endDate,String operator,String flag){
        //关键字搜索
        if(StringUtils.isNotBlank(keyWord)){
            Patient p = patientDao.findByIdcard(keyWord);
            if(p!=null){
                sql += " AND p.patient = '"+p.getCode()+"' ";
            }else{
                p = patientDao.findBySsc(keyWord);
                if(p!=null){
                    sql += " AND p.patient = '"+p.getCode()+"' ";
                }else{
                    sql += " AND ( py.charge_no = '"+keyWord+"' OR p.patient_name ='"+keyWord+"' )";
                }
            }
        }
        if(StringUtils.isNotBlank(state)){
            sql += " AND p.status = "+state ;
        }
        if(StringUtils.isNotBlank(type)){
            sql +=" AND p.dispensary_type =" +type;
        }
        if(StringUtils.isNotBlank(startDate)){
            startDate +=" 00:00:00";
            sql += " AND py.create_time >='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            endDate +=" 23:59:59";
            sql += " AND py.create_time <='"+endDate+"' ";
        }
        if(StringUtils.isNotBlank(operator)){
            sql += " AND p.drug_delivery_operator ='"+operator+"' ";
        }
        if(StringUtils.isNotBlank(flag)){
            sql += " AND p.drug_delivery_flag ="+flag+" ";
        }
        return sql;
    }
    public List<Map<String,Object>> getHospitalOperator(String doctor){
        Doctor d = doctorDao.findByCode(doctor);
        String sql = "SELECT " +
                " p.drug_delivery_operator AS operator, " +
                " p.drug_delivery_operator_name AS operatorName " +
                " FROM " +
                " wlyy_prescription p " +
                " WHERE " +
                " p.hospital = '"+d.getHospital()+"' " +
                " GROUP BY " +
                " p.drug_delivery_operator ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
}

+ 98 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -2885,4 +2885,102 @@ public class StatisticsESService {
        map.put("65ageRate",decimalFormat.format(ageRate));
        return map;
    }
    /**
     *
     * @param level 等级
     * @param area 等级编码
     * @param disease 疾病编码
     * @param type 类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消
     * @return
     */
    public List<Map<String,Object>> getPrescriptionTotalHistogram(int level,String area,String disease,String type) throws Exception{
        String index ="58";
        List<Map<String,Object>> rs =new ArrayList<>();
        Calendar dd = Calendar.getInstance();//定义日期实例
        Date endDate = new Date();
        dd.setTime(endDate);
        for(int i=1;i<7;i++){
            Map<String,Object> mc = new HashedMap();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            String date = sdf.format(dd.getTime());
            mc.put("month",date);
            mc.put("count",0);
            dd.add(Calendar.MONTH,-1);
            rs.add(mc);
        }
        String startTime = DateUtil.dateToStr(dd.getTime(),"YYYY-MM-dd HH:mm:ss");
        String endTime = DateUtil.dateToStr(new Date(),"YYYY-MM-dd HH:mm:ss");
        List<SaveModel> resultList = new ArrayList<>();
        //类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消
        if("1".equals(type)){
            //总数
            resultList =  elasticsearchUtil.findLineChartDateQuotaLevel1(null,null,area,level,index,"2","3",disease);
        }else{
            resultList =  elasticsearchUtil.findLineChartDateQuotaLevel2(null,null,area,level,index,"2","3",disease,type);
        }
        for(Map<String,Object> m:rs){
            Iterator iterator = resultList.iterator();
            while (iterator.hasNext()){
                SaveModel saveModel = (SaveModel)iterator.next();
                String monthKey = (String)m.get("month");
                String monthKeyEs = DateUtil.changeQuotaDate(saveModel.getQuotaDate());
                if(monthKey.equals(monthKeyEs)){
                    m.put("count",saveModel.getResult2());
                }
            }
        }
        return rs;
    }
    /**
     *
     * @param level 等级 1 省 2 市 3 区县 4 机构 5团队
     * @param lowlevel 等级 1 省 2 市 3 区县 4 机构 5团队
     * @param area
     * @param disease
     * @param type 0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消
     * @return
     */
    public List<SaveModel> getPrescriptionTotalLowLevel(int level,String lowlevel,String area,String disease,String type)throws Exception{
        String index = "58";
        List<SaveModel> saveModels = new ArrayList<>();
        //一级维度
        if (StringUtils.isNotBlank(disease)){
            //类型 0.总量,1.已完成,2.居民取消,3.审核不通过,4.进行中,5.其他原因取消
            if("1".equals(type)){
                saveModels = elasticsearchUtil.findListDateQuotaLevel0("",area,level,index,"2",lowlevel);
            }else {
                saveModels = elasticsearchUtil.findListDateQuotaLevel1("",area,level,index,"2",lowlevel,type);
            }
        }else{
            //类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消
            if("1".equals(type)){
                saveModels = elasticsearchUtil.findListDateQuotaLevel1("",area,level,index,"2",lowlevel,disease);
            }else {
                saveModels = elasticsearchUtil.findListDateQuotaLevel2("",area,level,index,"2",lowlevel,disease,type);
            }
        }
        if ("5".equals(lowlevel)){
            translateTeamLeaderName2(saveModels);
        }
        return saveModels;
    }
    public List<SaveModel> translateTeamLeaderName2(List<SaveModel> rs) {
        Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
        if (rs != null && rs.size() > 0) {
            for (SaveModel saveModel : rs) {
                Integer id = Integer.valueOf(saveModel.getTeam());
                String name = getTeamLeaderNameByTeamCode(leaders, id);
                if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
                    saveModel.setTeamName(name);
                }
            }
        }
        return rs;
    }
}

+ 193 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -392,9 +392,9 @@ public class OnePayService {
    }
    /**
     * 家庭医生签约支付查询
     * 家庭医生签约支付查询(v1.4.0作废)
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
    public String chargeQueryBak(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
@ -538,9 +538,9 @@ public class OnePayService {
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    chargePay.setTradeStatus("1");//交易状态 成功1 失败0
                    chargePay.setTradeStatus("0");//交易状态 成功0 失败1
                } else {
                    chargePay.setTradeStatus("0");//交易状态 成功1 失败0
                    chargePay.setTradeStatus("1");//交易状态 成功0 失败1
                }
                chargePay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
@ -583,6 +583,68 @@ public class OnePayService {
        return result;
    }
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        try {
            WlyyCharge charge = chargeDao.findByCode(code);
            HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
            OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(hospitalMapping.getAppId());
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTransType(config.getChargeQueryType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", code);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                //业务处理*******************
                result = JSON.toJSONString(res.getParam());
                Charge chargeView = objectMapper.readValue(result, Charge.class);
                saveToWlyyCharge(chargeView);
                LOGGER.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
        //type = 3易联众接口保存http日志
        logService.saveHttpLog(isSuccess, config.getChargeType(), "家庭医生签约支付查询", "POST", null, msgBody, response, error, logService.onepayType);
        if (!isSuccess) {
            throw new Exception(error);
        }
        return result;
    }
    /**
     * 生成电子社保卡
     */
@ -712,12 +774,135 @@ public class OnePayService {
     * 更改数据 wlyy_sign_family wlyy_charge
     */
    public void updateData(String chargeStatus, Date chargeTime, String chargeNo, WlyyCharge charge) throws Exception {
        charge.setUploadLog("1");
        if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
            charge.setNeedUpload("1");
            charge.setTradeStatus("0");//交易状态 0 成功 1 失败
            //        成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
            signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
        } else {
            charge.setTradeStatus("1");//交易状态 0 成功 1 失败
        }
        charge.setUpdateTime(new Date());
        chargeDao.save(charge);
//        成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
        if ("0".equals(chargeStatus)) {
            signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
    }
    /**
     * 只保存到家庭签约支付表
     *
     * @param chargeView 家庭签约支付展示类Charge
     * @throws Exception
     */
    public void saveToWlyyCharge(Charge chargeView) throws Exception {
        String outChargeNo = chargeView.getOutChargeNo();
        WlyyCharge chargePay = chargeDao.findByCode(outChargeNo);
        String tradeStatus = chargeView.getTradeStatus();
        String chargeNo = chargeView.getChargeNo();
        String chargeTime = chargeView.getChargeTime();
        String outChargeTime = chargeView.getOutChargeTime();
        String medOrgNo = chargeView.getMedOrgNo();
        String medOrgName = chargeView.getMedOrgName();
        String billNo = chargeView.getBillNo();
        String cardNo = chargeView.getCardNo();
        String totalAmount = chargeView.getTotalAmount();
        String insuranceAmount = chargeView.getInsuranceAmount();
        String selfPayAmount = chargeView.getSelfPayAmount();
        String userId = chargeView.getUserId();
        String userName = chargeView.getUserName();
        String idType = chargeView.getIdType();
        String idNo = chargeView.getIdNo();
        String responseContent = chargeView.getResponseContent();
        chargePay.setChargeNo(chargeNo);//支付流水号
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        chargePay.setChargeTime(chargeTime);//支付平台交易成功时间
        chargePay.setCreateTime(formatDate.parse(outChargeTime));//接入应用内业务时间
        chargePay.setMedOrgNo(medOrgNo);//医疗机构编号
        chargePay.setMedOrgName(medOrgName);//医疗机构名称
        chargePay.setBillNo(billNo);//待结算费用单据号
        chargePay.setSsc(cardNo);//医保卡号
        chargePay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
        chargePay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
        chargePay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
        chargePay.setOpenid(userId);
        chargePay.setName(userName);
        chargePay.setIdType(idType);//证件类型
        chargePay.setIdNo(idNo);//证件号码
        JSONObject response = JSON.parseObject(responseContent);
        String miRegisterNo = null;//医保挂号
        String miCollectDate = null;//收费日期
        String miCollectTime = null;//收费时间
        String miSettleNo = null;//医保收费单据号 (医保签约号)
        String miCollectStatus = null;//扣费状态
        String miRegisterStatus = null;//登记状态
        String cadresPay = "0";//公务员补助
        String miTotalFee = "0";//本次报销总额
        String healthCarePay = "0";//保健基金支付
        String heathPay = "0";//健康账户支付
        String accountPay = "0";//个人账户支付
        String selfPay = "0";//个人现金支付
        String civilPay = "0";//民政补助金额
        if (response != null && response.containsKey("miRegisterNo")) {
            miRegisterNo = response.getString("miRegisterNo");
        }
        if (response != null && response.containsKey("miCollectDate")) {
            miCollectDate = response.getString("miCollectDate");
        }
        if (response != null && response.containsKey("miCollectTime")) {
            miCollectTime = response.getString("miCollectTime");
        }
        if (response != null && response.containsKey("miSettleNo")) {
            miSettleNo = response.getString("miSettleNo");
        }
        if (response != null && response.containsKey("miCollectStatus")) {
            miCollectStatus = response.getString("miCollectStatus");
        }
        if (response != null && response.containsKey("miRegisterStatus")) {
            miRegisterStatus = response.getString("miRegisterStatus");
        }
        if (response != null && response.containsKey("cadresPay")) {
            cadresPay = response.getString("cadresPay");
        }
        if (response != null && response.containsKey("miTotalFee")) {
            miTotalFee = response.getString("miTotalFee");
        }
        if (response != null && response.containsKey("healthCarePay")) {
            healthCarePay = response.getString("healthCarePay");
        }
        if (response != null && response.containsKey("heathPay")) {
            heathPay = response.getString("heathPay");
        }
        if (response != null && response.containsKey("accountPay")) {
            accountPay = response.getString("accountPay");
        }
        if (response != null && response.containsKey("selfPay")) {
            selfPay = response.getString("selfPay");
        }
        if (response != null && response.containsKey("civilPay")) {
            civilPay = response.getString("civilPay");
        }
        chargePay.setMiRegisterNo(miRegisterNo);//医保挂号
        chargePay.setMiCollectDate(miCollectDate);
        chargePay.setMiCollectTime(miCollectTime);
        chargePay.setMiSettleNo(miSettleNo);
        chargePay.setMiCollectStatus(miCollectStatus);
        chargePay.setMiRegisterStatus(miRegisterStatus);
        chargePay.setCadresPay(cadresPay);
        chargePay.setMiTotalFee(miTotalFee);
        chargePay.setHealthCarePay(healthCarePay);
        chargePay.setHeathPay(heathPay);
        chargePay.setAccountPay(accountPay);
        chargePay.setSelfPay(selfPay);
        chargePay.setCivilPay(civilPay);
        //                判断是否需要更新数据 needUpload为0不需要更新
        LOGGER.info("before  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        if (chargePay != null && !("0".equals(chargePay.getNeedUpload()))) {
            updateData(tradeStatus, formatDate.parse(chargeTime), chargeNo, chargePay);
            LOGGER.info("after  goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
        }
    }

+ 8 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -24,6 +24,7 @@ public class DateUtil {
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_M_D_HH_MM_SS = "yyyy/M/d HH:mm:ss";
	public static final String YYYYMMddHHmmssSSS  = "yyyyMMddHHmmssSSS";
	public static final String YYYY_MM ="yyyy-MM";
	/**
@ -1077,4 +1078,11 @@ public class DateUtil {
		return weekOfMonth;
	}
	//将时间维度查出来的quotaDate转成yyyy-MM
	public static String changeQuotaDate(Date quotaDate){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
		String  date = sdf.format(quotaDate);
		return date;
	}
}

+ 418 - 243
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -1,24 +1,34 @@
package com.yihu.wlyy.web.common;
import java.beans.Encoder;
import java.io.*;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.web.third.gateway.vo.UploadModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultOneModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.codec.EncoderException;
import org.apache.commons.io.FileUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -27,14 +37,13 @@ import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
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 org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImageCompress;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.BaseController;
import org.springframework.web.multipart.MultipartRequest;
@Controller
@RequestMapping(value = "/upload", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ -47,6 +56,10 @@ public class FileUploadController extends BaseController {
    private CommonUtil CommonUtil;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Value("${neiwang.enable}")
    private Boolean isneiwang = false;  //如果不是内网项目要转到到内网wlyy在上传
    @Value("${neiwang.wlyy}")
    private String neiwangWlyy;  //内网的项目地址
    /**
     * 患者头像上传
@ -58,32 +71,36 @@ public class FileUploadController extends BaseController {
    @RequestMapping(value = "patientPhoto", method = RequestMethod.POST/* , headers = "Accept=image/png" */)
    @ResponseBody
    public String patientPhoto(HttpServletRequest request, HttpServletResponse response, String photo) {
        try {
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
            String fileName = null;
            String firstPhoto = null;
            for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                // 上传文件
                MultipartFile mf = entity.getValue();
                fileName = mf.getOriginalFilename();
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                // 重命名文件
                firstPhoto = photo.substring(0, photo.lastIndexOf(".")) + "_small." + fileExt;
                File uploadFile = new File(SystemConf.getInstance().getTempPath() + File.separator + firstPhoto);
                // 拷贝文件流到指定文件路径
                FileCopyUtils.copy(mf.getBytes(), uploadFile);
        if (isneiwang) {
            try {
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                String fileName = null;
                String firstPhoto = null;
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    fileName = mf.getOriginalFilename();
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    // 重命名文件
                    firstPhoto = photo.substring(0, photo.lastIndexOf(".")) + "_small." + fileExt;
                    File uploadFile = new File(SystemConf.getInstance().getTempPath() + File.separator + firstPhoto);
                    // 拷贝文件流到指定文件路径
                    FileCopyUtils.copy(mf.getBytes(), uploadFile);
                }
                JSONObject json = new JSONObject();
                json.put("status", 200);
                json.put("msg", "上传成功");
                // 图片标识对象的HTTP链接
                json.put("urls", String.join(",", firstPhoto));
                System.out.println("图片上传:" + json.toString());
                return json.toString();
            } catch (Exception e) {
                error(e);
                return error(-1, "上传失败");
            }
            JSONObject json = new JSONObject();
            json.put("status", 200);
            json.put("msg", "上传成功");
            // 图片标识对象的HTTP链接
            json.put("urls", String.join(",", firstPhoto));
            System.out.println("图片上传:" + json.toString());
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "上传失败");
        } else {
            return toNeiWang(request, response);
        }
    }
@ -97,65 +114,69 @@ public class FileUploadController extends BaseController {
    @RequestMapping(value = "image", method = RequestMethod.POST/* , headers = "Accept=image/png" */)
    @ResponseBody
    public String image(HttpServletRequest request, HttpServletResponse response) {
        // 圖片列表
        List<File> images = new ArrayList<File>();
        List<String> tempPaths = new ArrayList<String>();
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        // 拼接年月日路径
        String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
        try {
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
            // 创建文件夹
            File file = new File(tempPath + datePath);
            if (!file.exists()) {
                file.mkdirs();
            }
            String fileName = null;
            for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                // 上传文件
                MultipartFile mf = entity.getValue();
                fileName = mf.getOriginalFilename();
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                // 重命名文件
                SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
                String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
                File uploadFile = new File(tempPath + datePath + newFileName);
                // 拷贝文件流到指定文件路径
                FileCopyUtils.copy(mf.getBytes(), uploadFile);
                // 生成缩略图
                ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
                // 添加到上传成功数组中
                images.add(uploadFile);
                tempPaths.add(datePath + newFileName);
            }
            String urls = "";
            for (String image : tempPaths) {
                if (urls.length() == 0) {
                    urls = image;
                } else {
                    urls += "," + image;
                }
            }
            JSONObject json = new JSONObject();
            json.put("status", 200);
            json.put("msg", "上传成功");
            // 图片标识对象的HTTP链接
            json.put("urls", urls);
            System.out.println("图片上传:" + json.toString());
            return json.toString();
        } catch (Exception e) {
            error(e);
        if (isneiwang) {
            // 圖片列表
            List<File> images = new ArrayList<File>();
            List<String> tempPaths = new ArrayList<String>();
            // 文件保存的临时路径
            String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
            // 拼接年月日路径
            String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
            try {
                // 清除垃圾图片
                for (File file : images) {
                    FileUtils.forceDelete(file);
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                // 创建文件夹
                File file = new File(tempPath + datePath);
                if (!file.exists()) {
                    file.mkdirs();
                }
                String fileName = null;
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    fileName = mf.getOriginalFilename();
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    // 重命名文件
                    SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
                    String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
                    File uploadFile = new File(tempPath + datePath + newFileName);
                    // 拷贝文件流到指定文件路径
                    FileCopyUtils.copy(mf.getBytes(), uploadFile);
                    // 生成缩略图
                    ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
                    // 添加到上传成功数组中
                    images.add(uploadFile);
                    tempPaths.add(datePath + newFileName);
                }
                String urls = "";
                for (String image : tempPaths) {
                    if (urls.length() == 0) {
                        urls = image;
                    } else {
                        urls += "," + image;
                    }
                }
                JSONObject json = new JSONObject();
                json.put("status", 200);
                json.put("msg", "上传成功");
                // 图片标识对象的HTTP链接
                json.put("urls", urls);
                System.out.println("图片上传:" + json.toString());
                return json.toString();
            } catch (Exception e) {
                error(e);
                try {
                    // 清除垃圾图片
                    for (File file : images) {
                        FileUtils.forceDelete(file);
                    }
                } catch (Exception e2) {
                    error(e2);
                }
            } catch (Exception e2) {
                error(e2);
                return error(-1, "上传失败");
            }
            return error(-1, "上传失败");
        } else {
            return toNeiWang(request, response);
        }
    }
@ -169,93 +190,97 @@ public class FileUploadController extends BaseController {
    @RequestMapping(value = "chat", method = RequestMethod.POST)
    @ResponseBody
    public String chatFile(HttpServletRequest request, HttpServletResponse response) {
        List<String> tempPaths = new ArrayList<String>();
        try {
            String fastUrl = fastdfs_file_url;
            String type  = request.getParameter("type");
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
            String fileName = null;
            for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        if (isneiwang) {
            List<String> tempPaths = new ArrayList<String>();
            try {
                String fastUrl = fastdfs_file_url;
                String type = request.getParameter("type");
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                String fileName = null;
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                // 上传文件
                MultipartFile mf = entity.getValue();
                fileName = mf.getOriginalFilename();
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    fileName = mf.getOriginalFilename();
                if("3".equals(type)){
                    String tempPath  =  CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
                    String map3Path = tempPath.substring(0,tempPath.lastIndexOf("."));
                    CommonUtil.changeToMp3(tempPath,map3Path);
                    File tempFile = new File(tempPath);
                    File mp3File = new File(map3Path);
                    ObjectNode objectNode = fastDFSUtil.upload(new FileInputStream(mp3File),"mp3","");
                    //1.3.7 去掉前缀,返回相对路径
                    if ("3".equals(type)) {
                        String tempPath = CommonUtil.saveVoiceToDisk(mf.getInputStream(), fileName);
                        String map3Path = tempPath.substring(0, tempPath.lastIndexOf("."));
                        CommonUtil.changeToMp3(tempPath, map3Path);
                        File tempFile = new File(tempPath);
                        File mp3File = new File(map3Path);
                        ObjectNode objectNode = fastDFSUtil.upload(new FileInputStream(mp3File), "mp3", "");
                        //1.3.7 去掉前缀,返回相对路径
//                    tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
//                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(objectNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                    if(tempFile!=null){
                        tempFile.delete();
                    }
                    if(mp3File!=null){
                        mp3File.delete();
                    }
                }else if("4".equals(type)){
                    String tempPath  =  CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
                    String pngPath = tempPath.substring(0,tempPath.lastIndexOf("."))+".png";
                    File tempFile = new File(tempPath);
                    File pngFile = new File(pngPath);
                    long times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
                    if(times<1000){
                        JSONObject json = new JSONObject();
                        json.put("status", -1);
                        json.put("success",true);
                        json.put("msg", "视频录制时间太短!");
                        json.put("times", times);
                        return json.toString();
                    }
                    ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath),"png","");
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath),fileExt,"");
                        tempPaths.add(objectNode.get("groupName").toString().replaceAll("\"", "")
                                + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"", ""));
                        if (tempFile != null) {
                            tempFile.delete();
                        }
                        if (mp3File != null) {
                            mp3File.delete();
                        }
                    } else if ("4".equals(type)) {
                        String tempPath = CommonUtil.saveVoiceToDisk(mf.getInputStream(), fileName);
                        String pngPath = tempPath.substring(0, tempPath.lastIndexOf(".")) + ".png";
                        File tempFile = new File(tempPath);
                        File pngFile = new File(pngPath);
                        long times = CommonUtil.getVideoTimeAndImg(tempPath, pngPath);
                        if (times < 1000) {
                            JSONObject json = new JSONObject();
                            json.put("status", -1);
                            json.put("success", true);
                            json.put("msg", "视频录制时间太短!");
                            json.put("times", times);
                            return json.toString();
                        }
                        ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath), "png", "");
                        String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                        ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath), fileExt, "");
                    //1.3.7 去掉前缀,返回相对路径
                        //1.3.7 去掉前缀,返回相对路径
//                    tempPaths.add(fastUrl + imgNode.get("groupName").toString().replaceAll("\"","")
//                            + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
//                    tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"","")
//                            + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(imgNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(videoNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(times+"");
                    if(tempFile!=null){
                        tempFile.delete();
                    }
                    if(pngFile!=null){
                        pngFile.delete();
                    }
                } else{
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream() ,fileExt,"");
                    //1.3.7 去掉前缀,返回相对路径
                        tempPaths.add(imgNode.get("groupName").toString().replaceAll("\"", "")
                                + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"", ""));
                        tempPaths.add(videoNode.get("groupName").toString().replaceAll("\"", "")
                                + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"", ""));
                        tempPaths.add(times + "");
                        if (tempFile != null) {
                            tempFile.delete();
                        }
                        if (pngFile != null) {
                            pngFile.delete();
                        }
                    } else {
                        String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                        ObjectNode objectNode = fastDFSUtil.upload(mf.getInputStream(), fileExt, "");
                        //1.3.7 去掉前缀,返回相对路径
//                  tempPaths.add(fastUrl + objectNode.get("groupName").toString().replaceAll("\"","")
//                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(objectNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"",""));
                        tempPaths.add(objectNode.get("groupName").toString().replaceAll("\"", "")
                                + "/" + objectNode.get("remoteFileName").toString().replaceAll("\"", ""));
                    }
                }
                String urls = String.join(",", tempPaths);
                JSONObject json = new JSONObject();
                json.put("status", 200);
                json.put("success", true);
                json.put("msg", "上传成功");
                // 图片标识对象的HTTP链接
                json.put("urls", urls);
                System.out.println("附件上传:" + json.toString());
                return json.toString();
            } catch (Exception e) {
                error(e);
                return error(-1, "上传失败");
            }
            String urls = String.join(",", tempPaths);
            JSONObject json = new JSONObject();
            json.put("status", 200);
            json.put("success",true);
            json.put("msg", "上传成功");
            // 图片标识对象的HTTP链接
            json.put("urls", urls);
            System.out.println("附件上传:" + json.toString());
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "上传失败");
        } else {
            return toNeiWang(request, response);
        }
    }
@ -269,104 +294,254 @@ public class FileUploadController extends BaseController {
    @RequestMapping(value = "voice", method = RequestMethod.POST)
    @ResponseBody
    public String voice(HttpServletRequest request, HttpServletResponse response) {
        // 圖片列表
        List<File> voices = new ArrayList<File>();
        List<String> tempPaths = new ArrayList<String>();
        // 文件保存的临时路径
        String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
        // 拼接年月日路径
        String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
        try {
        if (isneiwang) {
            // 圖片列表
            List<File> voices = new ArrayList<File>();
            List<String> tempPaths = new ArrayList<String>();
            // 文件保存的临时路径
            String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
            // 拼接年月日路径
            String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
            try {
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                // 创建文件夹
                File file = new File(tempPath + datePath);
                if (!file.exists()) {
                    file.mkdirs();
                }
                String fileName = null;
                for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                    // 上传文件
                    MultipartFile mf = entity.getValue();
                    fileName = mf.getOriginalFilename();
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    // 重命名文件
                    SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
                    String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
                    File uploadFile = new File(tempPath + datePath + newFileName);
                    // 拷贝文件流到指定文件路径
                    FileCopyUtils.copy(mf.getBytes(), uploadFile);
                    // 添加到上传成功数组中
                    voices.add(uploadFile);
                    tempPaths.add(datePath + newFileName);
                }
                String urls = "";
                for (String voice : tempPaths) {
                    if (urls.length() == 0) {
                        urls = voice;
                    } else {
                        urls += "," + voice;
                    }
                }
                JSONObject json = new JSONObject();
                json.put("status", 200);
                json.put("msg", "上传成功");
                // 图片标识对象的HTTP链接
                json.put("urls", urls);
                System.out.println("语音上传:" + json.toString());
                return json.toString();
            } catch (Exception e) {
                error(e);
                try {
                    // 清除垃圾图片
                    for (File file : voices) {
                        FileUtils.forceDelete(file);
                    }
                } catch (Exception e2) {
                    error(e2);
                }
                return error(-1, "上传失败");
            }
        } else {
            return toNeiWang(request, response);
        }
    }
    /**
     * 语音上传
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "test", method = RequestMethod.POST)
    @ResponseBody
    public String test(HttpServletRequest request, HttpServletResponse response) throws Exception {
        if (isneiwang) {
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
            // 创建文件夹
            File file = new File(tempPath + datePath);
            if (!file.exists()) {
                file.mkdirs();
            }
            String fileName = null;
            List<String> tempPaths = new ArrayList<String>();
            String fastUrl = fastdfs_file_url;
            for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                // 上传文件
                MultipartFile mf = entity.getValue();
                fileName = mf.getOriginalFilename();
                String fileName = mf.getOriginalFilename();
                String tempPath = CommonUtil.saveVoiceToDisk(mf.getInputStream(), fileName);
                String pngPath = tempPath.substring(0, tempPath.lastIndexOf(".")) + ".png";
                File tempFile = new File(tempPath);
                File pngFile = new File(pngPath);
                long times = CommonUtil.getVideoTimeAndImg(tempPath, pngPath);
                ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath), "png", "");
                String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                // 重命名文件
                SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
                String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
                File uploadFile = new File(tempPath + datePath + newFileName);
                // 拷贝文件流到指定文件路径
                FileCopyUtils.copy(mf.getBytes(), uploadFile);
                // 添加到上传成功数组中
                voices.add(uploadFile);
                tempPaths.add(datePath + newFileName);
            }
            String urls = "";
            for (String voice : tempPaths) {
                if (urls.length() == 0) {
                    urls = voice;
                } else {
                    urls += "," + voice;
                ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath), fileExt, "");
                tempPaths.add(fastUrl + imgNode.get("groupName").toString().replaceAll("\"", "")
                        + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"", ""));
                tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"", "")
                        + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"", ""));
                tempPaths.add(times + "");
                if (tempFile != null) {
                    tempFile.delete();
                }
            }
            JSONObject json = new JSONObject();
            json.put("status", 200);
            json.put("msg", "上传成功");
            // 图片标识对象的HTTP链接
            json.put("urls", urls);
            System.out.println("语音上传:" + json.toString());
            return json.toString();
        } catch (Exception e) {
            error(e);
            try {
                // 清除垃圾图片
                for (File file : voices) {
                    FileUtils.forceDelete(file);
                if (pngFile != null) {
                    pngFile.delete();
                }
            } catch (Exception e2) {
                error(e2);
            }
            return error(-1, "上传失败");
            String urls = String.join(",", tempPaths);
            return urls;
        } else {
            return toNeiWang(request, response);
        }
    }
    /**
     * 语音上传
     * 测试
     *
     * @return
     * @throws IOException
     * @throws IllegalStateException
     */
    @RequestMapping(value = "/test_cwd", method = RequestMethod.POST)
    @ApiOperation(value = "单文件上传")
    @ResponseBody
    public String uploadFile(
            @ApiParam(value = "文件", required = true) @RequestParam(value = "file", required = true) MultipartFile file1,
            HttpServletRequest request,
            HttpServletResponse response
    ) {
        try {
            if (isneiwang) {
                // 圖片列表
                List<File> images = new ArrayList<File>();
                List<String> tempPaths = new ArrayList<String>();
                // 文件保存的临时路径
                String tempPath = SystemConf.getInstance().getTempPath() + File.separator;
                // 拼接年月日路径
                String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
                try {
                    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
                    // 创建文件夹
                    File file = new File(tempPath + datePath);
                    if (!file.exists()) {
                        file.mkdirs();
                    }
                    String fileName = null;
                    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                        // 上传文件
                        MultipartFile mf = entity.getValue();
                        fileName = mf.getOriginalFilename();
                        String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                        // 重命名文件
                        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
                        String newFileName = df.format(new Date()) + "_" + new Random().nextInt(1000) + "." + fileExt;
                        File uploadFile = new File(tempPath + datePath + newFileName);
                        // 拷贝文件流到指定文件路径
                        FileCopyUtils.copy(mf.getBytes(), uploadFile);
                        // 生成缩略图
                        ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
                        // 添加到上传成功数组中
                        images.add(uploadFile);
                        tempPaths.add(datePath + newFileName);
                    }
                    String urls = "";
                    for (String image : tempPaths) {
                        if (urls.length() == 0) {
                            urls = image;
                        } else {
                            urls += "," + image;
                        }
                    }
                    JSONObject json = new JSONObject();
                    json.put("status", 200);
                    json.put("msg", "上传成功");
                    // 图片标识对象的HTTP链接
                    json.put("urls", urls);
                    System.out.println("图片上传:" + json.toString());
                    return json.toString();
                } catch (Exception e) {
                    error(e);
                    try {
                        // 清除垃圾图片
                        for (File file : images) {
                            FileUtils.forceDelete(file);
                        }
                    } catch (Exception e2) {
                        error(e2);
                    }
                    return error(-1, "上传失败");
                }
            } else {
                return  toNeiWang(request, response);
            }
        } catch (Exception e) {
            e.printStackTrace();
            // return new ResultOneModel(BaseResultModel.statusEm.file_upload_error.getCode(), BaseResultModel.statusEm.file_upload_error.getMessage() + "," + e.getMessage(), new com.alibaba.fastjson.JSONObject());
            return e.getMessage();
        }
    }
    /**
     * 如果是外网那是发送到内网的服务器
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "test", method = RequestMethod.POST)
    @ResponseBody
    public String test(HttpServletRequest request, HttpServletResponse response) throws Exception {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        List<String> tempPaths = new ArrayList<String>();
        String fastUrl = fastdfs_file_url;
        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
            MultipartFile mf = entity.getValue();
            String fileName = mf.getOriginalFilename();
            String tempPath  =  CommonUtil.saveVoiceToDisk(mf.getInputStream(),fileName);
            String pngPath = tempPath.substring(0,tempPath.lastIndexOf("."))+".png";
            File tempFile = new File(tempPath);
            File pngFile = new File(pngPath);
            long times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
            ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath),"png","");
            String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
            ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath),fileExt,"");
            tempPaths.add(fastUrl + imgNode.get("groupName").toString().replaceAll("\"","")
                    + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
            tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"","")
                    + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
            tempPaths.add(times+"");
            if(tempFile!=null){
                tempFile.delete();
    private String toNeiWang(HttpServletRequest request, HttpServletResponse response) {
        try {
            MultipartRequest multipartRequest= (MultipartRequest) request;
            String url = neiwangWlyy + request.getRequestURI();//uri请求路径 http://172.19.103.88/wlyy/upload/chat
            String responseEntity =null;
            for(Map.Entry<String,List<MultipartFile >> one:multipartRequest.getMultiFileMap().entrySet()){
                 responseEntity = request(url,one.getValue().get(0));
            }
            return responseEntity;
        } catch (Exception e) {
            return error(-1, "上传失败");
        }
    }
    private String request(String remote_url, MultipartFile file) {
        CloseableHttpClient httpClient = HttpClientBuilder.create().build();
        System.out.println(file.getOriginalFilename());
        String result = "";
        try {
            String fileName = file.getOriginalFilename();
            HttpPost httpPost = new HttpPost(remote_url);
            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
            builder.addBinaryBody("file", file.getInputStream(), ContentType.MULTIPART_FORM_DATA, fileName);// 文件流
            builder.addTextBody("filename", fileName);// 类似浏览器表单提交,对应input的name和value
            HttpEntity entity = builder.build();
            httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost);// 执行提交
            HttpEntity responseEntity = response.getEntity();
            if (responseEntity != null) {
                // 将响应内容转换为字符串
                result = EntityUtils.toString(responseEntity, Charset.forName("UTF-8"));
            }
            if(pngFile!=null){
                pngFile.delete();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        String urls = String.join(",", tempPaths);
        return urls;
        return result;
    }
}

+ 120 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorAppealController.java

@ -0,0 +1,120 @@
package com.yihu.wlyy.web.doctor.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.feedback.Appeal;
import com.yihu.wlyy.service.app.feedback.AppealService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
 * 因账号申诉不需要登录 所以剥离出来
 * Created by yeshijie on 2017/10/30.
 */
@Controller
@RestController
@RequestMapping(value = "/doctorFeeback/feedback")
@Api(description = "医生端账号申诉")
public class DoctorAppealController extends BaseController{
    @Autowired
    private AppealService appealService;
    @Autowired
    private CommonUtil commonUtil;
    @RequestMapping(value = "/saveAppeal", method = RequestMethod.POST)
    @ApiOperation(value = "医生端保存申诉")
    @ResponseBody
    @ObserverRequired
    public String saveAppeal(
            @ApiParam(name = "description", value = "申诉人描述")
            @RequestParam(value = "description", required = true) String description,
            @ApiParam(name = "type", value = "申诉人类型")
            @RequestParam(value = "type", required = true) int type,
            @ApiParam(name = "images", value = "图片")
            @RequestParam(required = false) String images,
            @ApiParam(name = "phone", value = "手机号码")
            @RequestParam(value = "phone", required = true) String phone,
            @ApiParam(name = "name", value = "申诉人姓名")
            @RequestParam(value = "name", required = true) String name,
            @ApiParam(name = "idcard", value = "申诉人身份证号码")
            @RequestParam(value = "idcard", required = true) String idcard) {
        try {
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号!");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号!");
            }
            String imagesUrl = null;
            String imageRow = "";
            String imageUrls = "";
            if (StringUtils.isNotEmpty(images)) {
                String[] imgs = images.split(",");
                for (String image : imgs) {
                    if (image.contains("group1")) {
                        imageUrls += image + ",";
                    } else {
                        try {
                            imageRow += commonUtil.copyTempImage(image) + ",";
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                imagesUrl = imageUrls + imageRow;
                imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
            }
//             保存到数据库
            appealService.saveAppeal(getUID(),description,type,imagesUrl,phone,2,name,idcard);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存失败!");
        }
    }
    @RequestMapping(value = "findByIdcard", method = RequestMethod.GET)
    @ApiOperation(value = "按身份证查询")
    public String findByIdcard(@ApiParam(name = "idcard", value = "申诉人身份证号码")
                               @RequestParam(value = "idcard", required = true) String idcard,
                               @ApiParam(name = "page", value = "第几页")
                               @RequestParam(value = "page", required = true) Integer page,
                               @ApiParam(name = "pagesize", value = "页面大小")
                               @RequestParam(value = "pagesize", required = true) Integer pagesize){
        try {
            JSONArray jsonArray = appealService.findAppealByIdcard(idcard,getUID(),page,pagesize,2);
            return write(200,"查询成功","list",jsonArray);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "findByCode", method = RequestMethod.GET)
    @ApiOperation(value = "按code查询")
    public String findByCode(@ApiParam(name = "code", value = "code")
                             @RequestParam(value = "code", required = true) String code){
        try {
            Appeal appeal = appealService.findByCode(code);
            return write(200,"查询成功","data",appeal);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
}

+ 7 - 73
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackController.java

@ -2,11 +2,9 @@ package com.yihu.wlyy.web.doctor.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.feedback.Appeal;
import com.yihu.wlyy.service.app.feedback.AppealService;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -22,13 +20,11 @@ import org.springframework.web.bind.annotation.*;
@Controller
@RestController
@RequestMapping(value = "/doctor/feedback")
@Api(description = "医生端意见反馈与账号申诉")
@Api(description = "医生端意见反馈")
public class DoctorFeedbackController extends BaseController {
    @Autowired
    private FeedbackService feedbackService;
    @Autowired
    private AppealService appealService;
    @Autowired
    private CommonUtil CommonUtil;
    /**
@ -63,75 +59,14 @@ public class DoctorFeedbackController extends BaseController {
        }
    }
    @RequestMapping(value = "/saveAppeal", method = RequestMethod.POST)
    @ApiOperation(value = "医生端保存申诉")
    @ResponseBody
    @ObserverRequired
    public String saveAppeal(
            @ApiParam(name = "description", value = "申诉人描述")
            @RequestParam(value = "description", required = true) String description,
            @ApiParam(name = "type", value = "申诉人类型")
            @RequestParam(value = "type", required = true) int type,
            @ApiParam(name = "images", value = "图片")
            @RequestParam(required = false) String images,
            @ApiParam(name = "phone", value = "手机号码")
            @RequestParam(value = "phone", required = true) String phone,
            @ApiParam(name = "name", value = "申诉人姓名")
            @RequestParam(value = "name", required = true) String name,
            @ApiParam(name = "idcard", value = "申诉人身份证号码")
            @RequestParam(value = "idcard", required = true) String idcard) {
        try {
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号!");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号!");
            }
            String imagesUrl = null;
            String imageRow = "";
            String imageUrls = "";
            if (StringUtils.isNotEmpty(images)) {
                String[] imgs = images.split(",");
                for (String image : imgs) {
                    if (image.contains("group1")) {
                        imageUrls += image + ",";
                    } else {
                        try {
                            imageRow += CommonUtil.copyTempImage(image) + ",";
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                imagesUrl = imageUrls + imageRow;
                imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
            }
//             保存到数据库
            appealService.saveAppeal(getUID(),description,type,imagesUrl,phone,2,name,idcard);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存失败!");
        }
    }
    @RequestMapping(value = "findByIdcard", method = RequestMethod.GET)
    @RequestMapping(value = "findByCreater", method = RequestMethod.GET)
    @ApiOperation(value = "按身份证查询")
    public String findByIdcard(@ApiParam(name = "idcard", value = "申诉人身份证号码")
                               @RequestParam(value = "idcard", required = true) String idcard,
                               @ApiParam(name = "page", value = "第几页")
    public String findByIdcard(@ApiParam(name = "page", value = "第几页")
                               @RequestParam(value = "page", required = true) Integer page,
                               @ApiParam(name = "pagesize", value = "页面大小")
                               @RequestParam(value = "pagesize", required = true) Integer pagesize){
        try {
            JSONArray jsonArray = appealService.findAppealByIdcard(idcard,page,pagesize);
            JSONArray jsonArray = feedbackService.findByCreater(getUID(),page,pagesize,2);
            return write(200,"查询成功","list",jsonArray);
        }catch (Exception e){
            error(e);
@ -144,13 +79,12 @@ public class DoctorFeedbackController extends BaseController {
    public String findByCode(@ApiParam(name = "code", value = "code")
                             @RequestParam(value = "code", required = true) String code){
        try {
            Appeal appeal = appealService.findByCode(code);
            return write(200,"查询成功","data",appeal);
            Feedback feedback = feedbackService.findByCode(code);
            return write(200,"查询成功","data",feedback);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
}

+ 79 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionExpressageController.java

@ -74,4 +74,83 @@ public class PrescriptionExpressageController extends WeixinBaseController {
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getDrugDeliveryState", method = RequestMethod.GET)
    @ApiOperation(value = "获取异常原因列表")
    public String getDrugDeliveryState(){
        try {
            return write(200, "获取成功", "data", expressageService.getDrugDeliveryState());
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getEsListByIDCardOrSSC", method = RequestMethod.GET)
    @ApiOperation(value = "根据医保号和身份证查询订单")
    public String getEsListByIDCardOrSSC(@ApiParam(required = true, name = "keyWord", value = "医保号或身份证") @RequestParam(required = true)String keyWord,
                                         @ApiParam(required = true, name = "page", value = "起始页,重1开始") @RequestParam(required = true)Integer page,
                                         @ApiParam(required = true, name = "pageSize", value = "每页大小") @RequestParam(required = true)Integer pageSize){
        try {
            return write(200, "获取成功", "data", expressageService.getEsListByIDCardOrSSC( keyWord, page, pageSize));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/saveDrugDelivery", method = RequestMethod.POST)
    @ApiOperation(value = "异常出操作")
    public String saveDrugDelivery(@ApiParam(required = true, name = "prescriptionCode", value = "续方code") @RequestParam(required = true)String prescriptionCode,
                                   @ApiParam(required = true, name = "reasonCode", value = "原因code") @RequestParam(required = true)String reasonCode,
                                   @ApiParam(required = true, name = "reasonName", value = "原因名称") @RequestParam(required = true)String reasonName,
                                   @ApiParam(required = true, name = "reason", value = "详细原因") @RequestParam(required = true)String reason){
        try {
            return write(200, "获取成功", "data", expressageService.saveDrugDelivery( getUID(), prescriptionCode, reasonCode, reasonName, reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getPresStatesList", method = RequestMethod.GET)
    @ApiOperation(value = "获取续方状态原因列表")
    public String getPresStatesList(){
        try {
            return write(200, "获取成功", "data", expressageService.getPresStatesList());
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getPresEsPayList", method = RequestMethod.GET)
    @ApiOperation(value = "获取订单列表")
    public String getPresEsPayList(@ApiParam(required = true, name = "keyWord", value = "订单号,接收人,医保号或身份证") @RequestParam(required = false)String keyWord,
                                   @ApiParam(required = true, name = "state", value = "续方状态") @RequestParam(required = false)String state,
                                   @ApiParam(required = true, name = "type", value = "1 自取 2快递配送 3健管师配送") @RequestParam(required = false)String type,
                                   @ApiParam(required = true, name = "startDate", value = "开始时间yyyy-MM--dd") @RequestParam(required = false)String startDate,
                                   @ApiParam(required = true, name = "endDate", value = "结束时间yyyy-MM-dd") @RequestParam(required = false)String endDate,
                                   @ApiParam(required = true, name = "operator", value = "操作人") @RequestParam(required = false)String operator,
                                   @ApiParam(required = true, name = "flag", value = "1.扫描2.异常出药") @RequestParam(required = false)String flag,
                                   @ApiParam(required = true, name = "page", value = "页面") @RequestParam(required = false)Integer page,
                                   @ApiParam(required = true, name = "pageSize", value = "页面大小") @RequestParam(required = false)Integer pageSize){
        try {
            return write(200, "获取成功", "data", expressageService.getPresEsPayList(keyWord,state,type,startDate,endDate,operator,flag,page,pageSize));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
    @RequestMapping(value = "/getHospitalOperator", method = RequestMethod.GET)
    @ApiOperation(value = "获取操作人员下拉列表")
    public String getHospitalOperator(){
        try {
            return write(200, "获取成功", "data", expressageService.getHospitalOperator(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败");
        }
    }
}

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

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
@ -13,6 +14,7 @@ import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
@ -48,6 +50,8 @@ public class PrescriptionInfoController extends BaseController {
    private ZyDictService zyDictService;
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private PatientService patientService;
    @RequestMapping(value = "getRecipeMasterList" , method = RequestMethod.GET)
    @ResponseBody
@ -264,6 +268,11 @@ public class PrescriptionInfoController extends BaseController {
                jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
                jo.put("prescriptionStatus", prescription.getStatus());//处方状态
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), "",""));//处方状态名称
                Patient p =  patientService.findByCode(prescription.getPatient());
                jo.put("patient",p.getCode());
                jo.put("patientName",p.getName());
                jo.put("IdCard",p.getIdcard());
                jo.put("ssc",p.getSsc());
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -1,9 +1,11 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
@ -32,6 +34,8 @@ public class PrescriptionLogController extends BaseController {
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private PrescriptionExpressageLogService prescriptionExpressageLogService;
    @Autowired
    private PrescriptionService prescriptionService;
    @RequestMapping(value = "/getPrescriptionLogs", method = RequestMethod.GET)
    @ApiOperation(value = "获取处方流程")
@ -125,6 +129,15 @@ public class PrescriptionLogController extends BaseController {
                    JSONObject jo = new JSONObject();
                    jo.put("createTime", DateUtil.dateToStrLong(one.getCreateTime()));
                    jo.put("statusName", one.getStatusName());
                    jo.put("drugDeliveryflag", "0");
                    if(one.getStatus()==100){
                        Prescription prescription = prescriptionService.findByCode(one.getPrescriptionCode());
                        if(prescription!=null&&prescription.getDrugDeliveryflag()==1){
                            jo.put("drugDeliveryflag", "1");
                            jo.put("drugDeliveryOperatorName",prescription.getDrugDeliveryOperatorName());
                            jo.put("drugDelivery",prescription.getDrugDeliveryReasonValue()+","+prescription.getDrugDeliveryReason());
                        }
                    }
                    ja.put(jo);
                }
                return write(200, "获取处方流程成功", "data", ja);

+ 120 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientAppealController.java

@ -0,0 +1,120 @@
package com.yihu.wlyy.web.patient.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.feedback.Appeal;
import com.yihu.wlyy.service.app.feedback.AppealService;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
/**
 * Created by yeshijie on 2017/10/30.
 */
@Controller
@RestController
@RequestMapping(value = "/patientFeedback/feedback")
@Api(description = "居民端意见反馈与账号申诉")
public class PatientAppealController extends WeixinBaseController {
    @Autowired
    private AppealService appealService;
    @Autowired
    private com.yihu.wlyy.util.CommonUtil commonUtil;
    @RequestMapping(value = "/saveAppeal", method = RequestMethod.POST)
    @ApiOperation(value = "居民端保存申诉")
    public String saveAppeal(
            @ApiParam(name = "description", value = "申诉人姓名")
            @RequestParam(value = "description", required = true) String description,
            @ApiParam(name = "type", value = "申诉人类型")
            @RequestParam(value = "type", required = true) int type,
            @ApiParam(name = "images", value = "图片")
            @RequestParam(required = false) String images,
            @ApiParam(name = "phone", value = "手机号码")
            @RequestParam(value = "phone", required = true) String phone,
            @ApiParam(name = "name", value = "申诉人姓名")
            @RequestParam(value = "name", required = true) String name,
            @ApiParam(name = "idcard", value = "申诉人身份证号码")
            @RequestParam(value = "idcard", required = true) String idcard) {
        try {
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号!");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号!");
            }
//        图片上传
            String photos="";
            if (StringUtils.isNotEmpty(images)) {
                String[] mediaIds = images.split(",");
                for (String mediaId : mediaIds) {
                    if (StringUtils.isEmpty(mediaId)) {
                        continue;
                    }
                    String temp = saveImageToDisk(mediaId);
                    if (StringUtils.isNotEmpty(temp)) {
                        if (photos.length() == 0) {
                            photos = temp;
                        } else {
                            photos += "," + temp;
                        }
                    }
                }
            }
            if (StringUtils.isNotEmpty(photos)) {
                photos = commonUtil.copyTempImage(photos);
            }
//             保存到数据库
            appealService.saveAppeal(getUID(),description,type,photos,phone,1,name,idcard);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存失败!");
        }
    }
    @RequestMapping(value = "findByIdcard", method = RequestMethod.GET)
    @ApiOperation(value = "按身份证查询")
    public String findByIdcard(@ApiParam(name = "idcard", value = "申诉人身份证号码")
                               @RequestParam(value = "idcard", required = false) String idcard,
                               @ApiParam(name = "page", value = "第几页")
                               @RequestParam(value = "page", required = true) Integer page,
                               @ApiParam(name = "pagesize", value = "页面大小")
                               @RequestParam(value = "pagesize", required = true) Integer pagesize){
        try {
            JSONArray jsonArray = appealService.findAppealByIdcard(idcard,getUID(),page,pagesize,1);
            return write(200,"查询成功","list",jsonArray);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "findByCode", method = RequestMethod.GET)
    @ApiOperation(value = "按code查询")
    public String findByCode(@ApiParam(name = "code", value = "code")
                             @RequestParam(value = "code", required = true) String code){
        try {
            Appeal appeal = appealService.findByCode(code);
            return write(200,"查询成功","data",appeal);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
}

+ 11 - 73
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientFeedbackController.java

@ -1,11 +1,9 @@
package com.yihu.wlyy.web.patient.feedback;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.feedback.Appeal;
import com.yihu.wlyy.service.app.feedback.AppealService;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.service.app.feedback.FeedbackService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -21,13 +19,11 @@ import org.springframework.web.bind.annotation.*;
@Controller
@RestController
@RequestMapping(value = "/patient/feedback")
@Api(description = "居民端意见反馈与账号申诉")
@Api(description = "居民端意见反馈")
public class PatientFeedbackController extends WeixinBaseController {
    @Autowired
    private FeedbackService feedbackService;
    @Autowired
    private AppealService appealService;
    @Autowired
    private CommonUtil CommonUtil;
    /**
@ -78,75 +74,14 @@ public class PatientFeedbackController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/saveAppeal", method = RequestMethod.POST)
    @ApiOperation(value = "居民端保存申诉")
    public String saveAppeal(
            @ApiParam(name = "description", value = "申诉人姓名")
            @RequestParam(value = "description", required = true) String description,
            @ApiParam(name = "type", value = "申诉人类型")
            @RequestParam(value = "type", required = true) int type,
            @ApiParam(name = "images", value = "图片")
            @RequestParam(required = false) String images,
            @ApiParam(name = "phone", value = "手机号码")
            @RequestParam(value = "phone", required = true) String phone,
            @ApiParam(name = "name", value = "申诉人姓名")
            @RequestParam(value = "name", required = true) String name,
            @ApiParam(name = "idcard", value = "申诉人身份证号码")
            @RequestParam(value = "idcard", required = true) String idcard) {
        try {
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号!");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号!");
            }
//        图片上传
            String photos="";
            if (StringUtils.isNotEmpty(images)) {
                String[] mediaIds = images.split(",");
                for (String mediaId : mediaIds) {
                    if (StringUtils.isEmpty(mediaId)) {
                        continue;
                    }
                    String temp = saveImageToDisk(mediaId);
                    if (StringUtils.isNotEmpty(temp)) {
                        if (photos.length() == 0) {
                            photos = temp;
                        } else {
                            photos += "," + temp;
                        }
                    }
                }
            }
            if (StringUtils.isNotEmpty(photos)) {
                photos = CommonUtil.copyTempImage(photos);
            }
//             保存到数据库
            appealService.saveAppeal(getUID(),description,type,photos,phone,1,name,idcard);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存失败!");
        }
    }
    @RequestMapping(value = "findByIdcard", method = RequestMethod.GET)
    @RequestMapping(value = "findByCreater", method = RequestMethod.GET)
    @ApiOperation(value = "按身份证查询")
    public String findByIdcard(@ApiParam(name = "idcard", value = "申诉人身份证号码")
                               @RequestParam(value = "idcard", required = true) String idcard,
                               @ApiParam(name = "page", value = "第几页")
    public String findByIdcard(@ApiParam(name = "page", value = "第几页")
                               @RequestParam(value = "page", required = true) Integer page,
                               @ApiParam(name = "pagesize", value = "页面大小")
                               @RequestParam(value = "pagesize", required = true) Integer pagesize){
        try {
            JSONArray jsonArray = appealService.findAppealByIdcard(idcard,page,pagesize);
            JSONArray jsonArray = feedbackService.findByCreater(getUID(),page,pagesize,1);
            return write(200,"查询成功","list",jsonArray);
        }catch (Exception e){
            error(e);
@ -157,21 +92,24 @@ public class PatientFeedbackController extends WeixinBaseController {
    @RequestMapping(value = "findByCode", method = RequestMethod.GET)
    @ApiOperation(value = "按code查询")
    public String findByCode(@ApiParam(name = "code", value = "code")
                               @RequestParam(value = "code", required = true) String code){
                             @RequestParam(value = "code", required = true) String code){
        try {
            Appeal appeal = appealService.findByCode(code);
            return write(200,"查询成功","data",appeal);
            Feedback feedback = feedbackService.findByCode(code);
            return write(200,"查询成功","data",feedback);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    /**
     * 获取微信服务器图片
     *
     * @return
     */
    @Override
    public String fetchWxImages() {
        String photos = "";
        try {

+ 33 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -1437,7 +1437,7 @@ public class EsStatisticsController extends BaseController {
                                         @RequestParam(required = true) String endDate,
                                         @RequestParam(required = true) String type) {
        try {
            return write(200, "查询成功", "data", statisticsESService.getTeamRenewChangeLine(teamCode, startDate, endDate, type));
            return write(200, "查询成功", "data", statisticsService.getTeamRenewChangeLine(teamCode, startDate, endDate, type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -1600,7 +1600,7 @@ public class EsStatisticsController extends BaseController {
    }
    /*=================================长处方分析start===============================================*/
    //=================================长处方分析===============================================
    @RequestMapping("/getPrescriptionCount")
    @ResponseBody
    @ApiOperation("订单统计-顶部总数获取")
@ -1670,5 +1670,36 @@ public class EsStatisticsController extends BaseController {
        }
    }
    @RequestMapping("/getPrescriptionTotalHistogram")
    @ResponseBody
    @ApiOperation("订单统计-中部树状图获取")
    public String getPrescriptionTotalHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                                @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
                                                @ApiParam(name="type", value="类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消") @RequestParam(required = true)String type){
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionTotalHistogram(elasticsearchUtil.changeLevel(Integer.valueOf(level)),area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionTotalLowLevel")
    @ResponseBody
    @ApiOperation("订单统计-下部列表接口")
    public String getPrescriptionTotalLowLevel(@ApiParam(name="level", value="级别") @RequestParam(required = true)Integer level,
                                               @ApiParam(name="lowlevel", value="第二级别") @RequestParam(required = true)String lowlevel,
                                               @ApiParam(name="area", value="界别编码") @RequestParam(required = true)String area,
                                               @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease,
                                               @ApiParam(name="type", value="类型0.总量,1.进行中,2.已完成,3.居民取消,4.审核不通过,5.其他原因取消") @RequestParam(required = true)String type){
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionTotalLowLevel(elasticsearchUtil.changeLevel(level),lowlevel,area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /*=================================长处方分析end===============================================*/
}

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -1684,6 +1684,7 @@ public class StatisticsController extends BaseController {
    @RequestMapping("/getPrescriptionTotalHistogram")
    @ResponseBody
    @Deprecated
    @ApiOperation("订单统计-中部树状图获取")
    public String getPrescriptionTotalHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
@ -1699,6 +1700,7 @@ public class StatisticsController extends BaseController {
    @RequestMapping("/getPrescriptionTotalLowLevel")
    @ResponseBody
    @Deprecated
    @ApiOperation("订单统计-下部列表接口")
    public String getPrescriptionTotalLowLevel(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                               @ApiParam(name="lowlevel", value="第二级别") @RequestParam(required = true)String lowlevel,

+ 135 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -34,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -81,6 +82,8 @@ public class OnePayController extends WeixinBaseController {
    private HospitalMappingDao mappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @RequestMapping(value = "bindCard", method = RequestMethod.POST)
    @ApiOperation("查询绑卡信息")
@ -289,15 +292,15 @@ public class OnePayController extends WeixinBaseController {
    }
    /**
     * 页面回调更新数据
     * 页面回调更新数据(v1.4.0 作废)
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
    @RequestMapping(value = "/returnUrlBak")
    public void returnUrlBak(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
@ -437,15 +440,49 @@ public class OnePayController extends WeixinBaseController {
    }
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作
     * 页面回调更新数据
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        try {
            //		如:查询显示订单信息
            isSuccess = true;
            String outChargeNo = request.getParameter("outChargeNo");//接入应用业务流水号
            pay.chargeQuery(outChargeNo, getAccessToken());//业务出参
        } catch (Exception e) {
            isSuccess = false;
            response.getWriter().write(e.getMessage());
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReturnUrl(), "支付页面跳转", "POST", null, "", responses, error, logService.onepayType);
    }
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作(v1.4.0作废)
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotifyBak")
    public void receiveNotifyBak(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
@ -617,6 +654,74 @@ public class OnePayController extends WeixinBaseController {
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        InputStream inputStream = request.getInputStream();
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        try {
            JSONObject json = new JSONObject(params);
            String appId = json.getString("appId");
            HospitalMapping hospital = mappingDao.findByAppId(appId);
            String appSecret = hospital.getAppSecret();
            LOGGER.info("回调参数:{}", params);
            if (StringUtil.isEmpty(params)) {
                response.getWriter().write("empty");
                return;
            }
            // 参数转换
            ResponseParams<?> encryptRes = JSON.parseObject(params, ResponseParams.class);
            OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
            LOGGER.info("解密前:{}", JSON.toJSONString(encryptRes));
            ResponseParams<?> decryptRes = client.decryptNotifyResponse(encryptRes);
            LOGGER.info("解密后:{}", JSON.toJSONString(decryptRes));
            boolean isDecrypt = ("-1".equals(decryptRes.getRespCode()) ? false : true); // 是否解密失败
            if (!isDecrypt) {
                response.getWriter().write("DECRYPT FAILURE");
            } else {
                boolean isVerify = client.verifyResponseSign(decryptRes);
                LOGGER.info("验签结果:{}", isVerify);
                if (!isVerify) {
                    response.getWriter().write("FAILURE");
                } else {
//					业务逻辑代码
                    isSuccess = true;
                    responses = JSON.toJSONString(decryptRes);
                    JSONObject requestParam = new JSONObject(responses);//业务出参
                    JSONObject responseParam = requestParam.getJSONObject("param");
                    Charge chargeView = objectMapper.readValue(responseParam.toString(), Charge.class);
                    pay.saveToWlyyCharge(chargeView);
                    response.getWriter().write("SUCCESS");
                }
            }
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
    /**
     * 获取按月缴费总金额
     *
@ -641,4 +746,28 @@ public class OnePayController extends WeixinBaseController {
            return write(-1, "查询签约金额失败!");
        }
    }
    /**
     * 支付数据整理
     *
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/cleaData", method = RequestMethod.POST)
    @ApiOperation("支付数据整理")
    @ResponseBody
    public String cleaData() throws IOException, PayException {
        try {
            String sql = "SELECT t.code FROM wlyy_charge t WHERE (t.need_upload != '0' OR t.need_upload is null) AND (t.trade_status = '0' OR t.trade_status = '1')";
            List<Map<String, Object>> codes = jdbcTemplate.queryForList(sql);
            for (Map<String, Object> code :codes) {
                String outChargeNo = code.get("code").toString();
                pay.chargeQuery(outChargeNo,getAccessToken());
            }
            return write(200, "数据整理成功!");
        } catch (Exception e) {
            return write(-1, "数据整理成功失败!");
        }
    }
}

+ 5 - 0
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -109,3 +109,8 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_dev  #健康文章推送
##如果是外网项目就是flase 内网是true
neiwang:
  enable: true
  wlyy: http://59.61.92.90:8072/wlyy

+ 5 - 0
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -109,3 +109,8 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
##如果是外网项目就是flase 内网是true
neiwang:
  enable: false
  wlyy: http://localhost:8081

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

@ -107,3 +107,7 @@ activemq:
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
##如果是外网项目就是flase 内网是true
neiwang:
  enable: true
  wlyy: http://59.61.92.90:8072/wlyy

+ 5 - 0
patient-co/patient-co-wlyy/src/main/resources/application-localtest.yml

@ -108,3 +108,8 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送
##如果是外网项目就是flase 内网是true
neiwang:
  enable: true
  wlyy: http://59.61.92.90:8072/wlyy

+ 5 - 0
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -108,3 +108,8 @@ activemq:
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送
##如果是外网项目就是flase 内网是true
neiwang:
  enable: false
  wlyy: http://59.61.92.90:8072/wlyy

+ 6 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -104,4 +104,9 @@ activemq:
  password: admin
  url: tcp://172.19.103.87:61616
  queue:
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
    healtHarticleQueue: healthArticleChannel_test  #健康文章推送
##如果是外网项目就是flase,false会调用内网http接口项目提交  内网是true直接上传fastDfs
neiwang:
  enable: true
  wlyy: http://59.61.92.90:8072/wlyy