Selaa lähdekoodia

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

wangzhinan 4 vuotta sitten
vanhempi
commit
7000c80133
31 muutettua tiedostoa jossa 1398 lisäystä ja 627 poistoa
  1. 6 0
      business/base-service/pom.xml
  2. 2 1
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  3. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  4. 40 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/service/SystemMessageService.java
  5. 60 17
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  6. 162 18
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  7. 25 6
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  8. 389 0
      business/base-service/src/main/java/com/yihu/jw/utils/YkyySMSService.java
  9. 1 1
      business/base-service/src/main/java/com/yihu/jw/utils/hibernate/HibenateUtils.java
  10. 5 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxPushLogDao.java
  11. 266 0
      business/sms-service/src/main/java/com/yihu/jw/sms/service/YkyyINSMSService.java
  12. 0 29
      business/sms-service/src/main/java/com/yihu/jw/sms/service/YkyySMSService.java
  13. 0 2
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/AccountDO.java
  14. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskPatientDetailDO.java
  15. 4 4
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  16. 8 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/YkyyController.java
  17. 16 30
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  18. 6 0
      svr/svr-internet-hospital/pom.xml
  19. 3 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java
  20. 15 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  21. 11 5
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  22. 1 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatCoreController.java
  23. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/wechat/WeiXinEventProcess.java
  24. 9 1
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/AccountDao.java
  25. 5 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskPatientDetailDao.java
  26. 12 28
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/AccountService.java
  27. 97 97
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java
  28. 142 299
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java
  29. 7 2
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskPatientDtailService.java
  30. 82 78
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskService.java
  31. 21 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/TransforSqlUtl.java

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

@ -191,6 +191,12 @@
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>sms-service</artifactId>
            <version>2.0.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>

+ 2 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -132,6 +132,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                        mixEnvelop.setMessage("您所添加的家属的名称有误,无法添加");
                        return mixEnvelop;
                    }
                    basePatientDO.setMobile(phoneNum);
                    familyId= jsonObject.getString("brid");
                    birth= jsonObject.getString("csny");
                    long lt = new Long(birth);
@ -178,7 +179,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                        }
                    }else {
                        if (null!=basePatientDO1){
                            res = ykyyService.addYktFamily(familyName,idCard, familySex,familyAge,phoneNum,medicare,relationName,"1",basePatientDO1.getUserId(),birth);
                            res = ykyyService.addYktFamily(familyName,idCard, familySex,familyAge,phoneNum,medicare,relationName,clinicId,basePatientDO1.getUserId(),birth);
                        }
                        if (StringUtils.isNotEmpty(res)){
                            JSONObject jsonObject1 = JSONObject.parseObject(res);

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java

@ -91,7 +91,7 @@ public class PatientMappingService {
        if(patientMappingDO!=null){
            return patientMappingDO.getMappingCode();
        }
        com.alibaba.fastjson.JSONArray rs = ykyyEntranceService.findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        com.alibaba.fastjson.JSONArray rs = ykyyEntranceService.findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
        if(rs!=null&&rs.size()>0){
            //获取居民信息

+ 40 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/SystemMessageService.java

@ -2,12 +2,21 @@ package com.yihu.jw.hospital.message.service;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.YkyySMSService;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,6 +35,14 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
    private SystemMessageDao systemMessageDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private YkyySMSService ykyySMSService;
    @Value("${wechat.id}")
    private String wechatId;
    /**
@ -109,6 +126,29 @@ public class SystemMessageService extends BaseJpaService<SystemMessageDO,SystemM
        }
        return null;
    }
    public String  sendDoctorRemindSms(ConsultDo consultDo){
        String msg = "";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            if (consultDo!=null){
                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(consultDo.getRelationCode());
                if (wlyyOutpatientDO!=null){
                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(wlyyOutpatientDO.getDoctor());
                    if (baseDoctorDO!=null){
                        ykyySMSService.sendSmsByTempcode("message_remind_paitent",wlyyOutpatientDO,null,baseDoctorDO.getMobile());
                        msg="发送成功";
                    }else{
                        msg="发送失败,医生不存在";
                    }
                }else {
                    msg="发送失败,门诊不存在";
                }
            }else {
                msg="发送失败,consult不存在";
            }
        }
        return msg;
    }
}

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

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.BaseDictJobTitleDao;
import com.yihu.jw.dict.dao.BaseJobCategoryDao;
import com.yihu.jw.dict.dao.DictDeptDescDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
@ -17,8 +18,10 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.base.yx.YxTokenMappingDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
@ -74,6 +77,7 @@ import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
@ -91,6 +95,7 @@ import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.yx.dao.YxTokenMappingDao;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.pinyin.PinyinUtil;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.common.utils.DateUtils;
@ -126,6 +131,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import static javafx.scene.input.KeyCode.L;
/**
 * Created by Trick on 2019/5/17.
 */
@ -276,6 +283,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private BaseJobCategoryDao jobCategoryDao;
    @Autowired
    private BaseSmsTemplateDao smsTemplateDao;
    @Autowired
    private YkyySMSService ykyySMSService;
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
@ -975,6 +986,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            outpatientDO.setPayStatus(1);
        } else {
            outpatientDO.setPayStatus(0);
            outpatientDO.setFee(price);
            outpatient = outpatientDao.save(outpatientDO);
        }
        if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
@ -2610,8 +2623,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                        } else {
                            ykyyService.updateDrugorderInfo(businessOrderDO.getOrderNo(), wlyyPrescriptionDO.getOrderId(), wlyyPrescriptionDO.getRealOrder());
                        }
                        ykyySMSService.sendSmsByTempcode("prescription_remind",outpatientDO,wlyyPrescriptionDO,"");
                    }
                }
                result.put("code", 1);
@ -2635,6 +2648,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
                }
                result.put("code", 1);
                result.put("mes", "诊断完成");
                result.put("prescriptionId",prescription.getId());
@ -2792,6 +2806,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        try {
            BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
            WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeTypeAndDeptTypeCode(doctorDO.getChargeType(), "6");
            return chargeDictDO.getReqFee();
        } catch (Exception e) {
            logger.error("getChargeFee:" + e.toString());
@ -7001,8 +7016,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                    msg = "您的视频咨询已预约成功。\n" +
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "17", "videoOrderRemind", "");
                }
                systemMessageDO.setReceiver(outpatient.getDoctor());
                systemMessageDO.setReceiverName(outpatient.getDoctorName());
@ -7038,6 +7053,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                            "预计" + outpatient.getDoctorName() + "医生将于" + outpatient.getRegisterDate() + " 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    sendWxTemplateMsg(wechatId, outpatient.getId(),null, "16", "videoOrderRemind", "");
                }
                systemMessageDO.setReceiver(outpatient.getDoctor());
                systemMessageDO.setReceiverName(outpatient.getDoctorName());
@ -7073,6 +7089,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        systemMessageDO.setTitle("支付提醒");
        systemMessageDO.setType("11");
        JSONObject data = new JSONObject();
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatient.getId());
        if (outpatient!=null){
            if("1".equalsIgnoreCase(outpatient.getOutpatientType())){
                if ("1".equals(outpatient.getType())) {
@ -7110,7 +7127,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            } catch (Exception e) {
                e.printStackTrace();
            }
            sendWxTemplateMsg(wechatId, outpatient.getId(),null, type, "payRemind", "");
            if (businessOrderDO!=null&&0!=businessOrderDO.getPayPrice()){
                sendWxTemplateMsg(wechatId, outpatient.getId(),null, type, "payRemind", "");
            }
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
                ykyyService.pushNotificationToYktPatient(patient.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
@ -7147,7 +7166,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            } catch (Exception e) {
                e.printStackTrace();
            }
            sendWxTemplateMsg(wechatId, "",consultTeamDo, type, "payRemind", "");
            if (businessOrderDO!=null&&0!=businessOrderDO.getPayPrice()){
                sendWxTemplateMsg(wechatId, "",consultTeamDo, type, "payRemind", "");
            }
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                ykyyService.pushNotificationToYktPatient(patientDO.getYktId(), systemMessageDO.getTitle(), data.get("msg").toString());
            }
@ -11201,11 +11222,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param medicare 社保卡
     * @param createTime 创建时间
     * @param appointmentTime 预约时间
     * @param appointmentTimeStart
     * @param appointmentTimeEnd
     * @param page
     * @param pageSize
     * @param size
     * @return
     */
    public Envelop getNatAppointmentList(String realOrder, String name, String hospitalFlag, String mobile, String idcard, String payStatus, String medicare, String createTime, String appointmentTime, Integer page, Integer pageSize) {
    public Envelop getNatAppointmentList(String realOrder, String name, String hospitalFlag, String mobile, String idcard, String payStatus, String medicare, String createTimeStart, String createTimeEnd, String appointmentTimeStart, String appointmentTimeEnd, Integer isSuccess, Integer page, Integer pageSize) {
        String sql = "select t.name as \"name\"," +
                "t.card_no as \"cardNo\"," +
                "t.card_type as \"cardType\"," +
@ -11225,7 +11249,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "t.appointment_time as \"appointmentTime\" " +
                " from base_nat_appointment t where 1=1 ";
        if (StringUtils.isNotBlank(realOrder)) {
            sql += " and t.real_order = '" + realOrder + "' ";
            sql += " and t.real_order like '%" + realOrder + "%' ";
        }
        if (StringUtils.isNotBlank(name)) {
            sql += " and t.name like '%" + name + "%'";
@ -11244,23 +11268,42 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        if (StringUtils.isNotBlank(medicare)) {
            sql += " and t.medicare like '%" + medicare + "%' ";
        }
        if (StringUtils.isNotBlank(appointmentTime)) {
        if (StringUtils.isNotBlank(hospitalFlag)) {
            sql += " and t.hospital_flag ='" + hospitalFlag + "' ";
        }
        if(isSuccess != null){
            sql += " and t.is_success = " + isSuccess ;
        }
        if (StringUtils.isNotBlank(appointmentTimeStart)) {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                sql += " and t.appointment_time >= to_date('" + appointmentTimeStart + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss')";
//                sql += " and t.appointment_time <= to_date('" + appointmentTime + " 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";
            } else {
                sql += " and t.appointment_time >='" + appointmentTimeStart + " 00:00:00'";
//                sql += " and t.appointment_time <='" + appointmentTime + " 23:59:59'";
            }
        }
        if (StringUtils.isNotBlank(appointmentTimeEnd)) {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                sql += " and t.appointment_time <= to_date('" + appointmentTimeEnd + " 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";
            } else {
                sql += " and t.appointment_time <='" + appointmentTimeEnd + " 23:59:59' ";
            }
        }
        if (StringUtils.isNotBlank(createTimeStart)) {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                sql += " and t.appointment_time >= to_date('" + appointmentTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss')";
                sql += " and t.appointment_time <= to_date('" + appointmentTime + " 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";
                sql += " and t.create_time >= to_date('" + createTimeStart + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss')";
//                sql+=" and t.create_time <= to_date('" + createTime + " 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";
            } else {
                sql += " and t.appointment_time >='" + appointmentTime + " 00:00:00'";
                sql += " and t.appointment_time <='" + appointmentTime + " 23:59:59'";
                sql += " and t.create_time >='" + createTimeStart + " 00:00:00' ";
//                sql+=" and t.create_time <='"+createTime+" 23:59:59'";
            }
        }
        if (StringUtils.isNotBlank(createTime)) {
        if (StringUtils.isNotBlank(createTimeEnd)) {
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)) {
                sql += " and t.create_time >= to_date('" + createTime + " 00:00:00', 'yyyy-mm-dd hh24:mi:ss')";
                sql+=" and t.create_time <= to_date('" + createTime + " 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";
                sql+=" and t.create_time <= to_date('" + createTimeEnd + " 23:59:59', 'yyyy-mm-dd hh24:mi:ss')";
            } else {
                sql += " and t.create_time >='" + createTime + " 00:00:00'";
                sql+=" and t.create_time <='"+createTime+" 23:59:59'";
                sql+=" and t.create_time <='"+createTimeEnd+" 23:59:59'";
            }
        }

+ 162 - 18
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -38,6 +38,7 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.YkyySMSService;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
@ -150,6 +151,8 @@ public class YkyyEntranceService {
    private FileUploadService fileUploadService;
    @Autowired
    private BaseNatAppointmentDao baseNatAppointmentDao;
    @Autowired
    private YkyySMSService ykyySMSService;
    public List<Map<String, Object>> createSQLQuery(String sql, Map<String, Object> params, Integer page, Integer size){
@ -1581,6 +1584,121 @@ public class YkyyEntranceService {
        return array;
    }
    /**
     * 获取his病人信息--身份证/卡号
     * @param ssc
     * @return
     * @throws Exception
     */
    public JSONArray findHisPatientBySscAndIdcard(String ssc,String idcard,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.jzkh = '"+ssc+"' and x.sfzh ='"+idcard+"'";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }
    /**
     * 获取his病人信息
     * @param idcard
     * @return
     * @throws Exception
     */
    public JSONArray findHisPatientByIdCard(String idcard,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.sfzh = '"+idcard+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }
    /**
     * 获取his病人信息
     * @param medicare
@ -1743,6 +1861,13 @@ public class YkyyEntranceService {
            //同步检查检验
            if(null!=inspectionDOS&&inspectionDOS.size()>0){
                synInspect(inspectionDOS);
                WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
                //向患者发送检查提醒短信
                if (wlyyOutpatientDO!=null){
                    ykyySMSService.sendSmsByTempcode("inspection_remind",wlyyOutpatientDO,null,"");
                }
            }
        }
@ -1903,6 +2028,7 @@ public class YkyyEntranceService {
        //挂号
        Map<String,Object> map = findYkDoctor(natAppointmentDO.getHospitalFlag());
        BasePatientDO patientDO = basePatientDao.findById(natAppointmentDO.getPatientId());
        //PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(natAppointmentDO.getPatientId());
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",natAppointmentDO.getPatientId(),"1");
        Integer brid= 0;
@ -1910,7 +2036,7 @@ public class YkyyEntranceService {
        Integer GHXH = 0;
        //挂号明细表HLW_GHMX
        HlwGhmxDO hlwGhmxDO = new HlwGhmxDO();
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        JSONArray jsonArray = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
            JSONObject json = jsonArray.getJSONObject(0);
@ -2070,11 +2196,16 @@ public class YkyyEntranceService {
        YkEmrJcsqDO ykEmrJcsqDO = new YkEmrJcsqDO();
        ykEmrJcsqDO.setJzxh(jzxh);
        ykEmrJcsqDO.setXmid(Integer.valueOf("12220"));
        JSONArray jsonArray1 = this.findZlxm(null, "12220");
        String deptNo = null;
        /*JSONArray jsonArray1 = this.findZlxm(null, "12220");
        if (jsonArray1 != null && jsonArray1.size() > 0) {
            JSONObject deptobject = jsonArray1.getJSONObject(0);
            deptNo = deptobject.getString("dept");
        }*/
        if ("3".equalsIgnoreCase(natAppointmentDO.getHospitalFlag())){
            deptNo = "96";
        }else {
            deptNo="1111";
        }
        ykEmrJcsqDO.setZxks(deptNo == null ? 0 : Integer.parseInt(deptNo));
        ykEmrJcsqDO.setJcxm("新冠病毒核酸检测");
@ -2092,7 +2223,7 @@ public class YkyyEntranceService {
        Integer kdks = 0;
        /*Integer brid=0;*/
        String mzhm="0";
        JSONArray jsonArray3 = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        JSONArray jsonArray3 = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
        Map<String,Object> resultMap = new HashMap();
        if(jsonArray3!=null&&jsonArray3.size()>0){
            //获取居民信息
@ -2138,6 +2269,8 @@ public class YkyyEntranceService {
            String yjxh = object.getString("yjxh");
            natAppointmentDO.setRealOrder(yjxh);
            natAppointmentDO.setIsSuccess("1");
            natAppointmentDO.setDoctorId(map.get("doctorCode").toString());
            natAppointmentDO.setDoctorName(map.get("doctorName").toString());
            baseNatAppointmentDao.save(natAppointmentDO);
        }else {
        }
@ -2204,7 +2337,7 @@ public class YkyyEntranceService {
        hlwGhmxDO.setYSDM(doctorMappingDO.getMappingCode());//医生代码
        hlwGhmxDO.setJZYS(doctorMappingDO.getMappingCode());//接诊医生
        //病人性质
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        JSONArray jsonArray = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
            JSONObject json = jsonArray.getJSONObject(0);
@ -2680,7 +2813,7 @@ public class YkyyEntranceService {
        String sql = "select t.ztmc as\"ztmc\",t.ztid as\"ztid\"," +
                "t.gslb as\"gslb\",t.gsdm as\"gsdm\"," +
                "t.pydm as\"pydm\",t.Mzsy as\"Mzsy\"" +
                "from portal_his.emr_yzzt@ykzxtest t where 1=1";
                "from portal_his.emr_yzzt@xec_link t where 1=1";
        if(StringUtils.isNotEmpty(gslb)){
            sql+=" and t.gslb = "+Integer.valueOf(gslb);
            }
@ -2704,7 +2837,7 @@ public class YkyyEntranceService {
    public JSONArray findZtmxByid(String ztId) throws Exception{
        String sql = "select t.ztid as \"ztid\",t.xmdm as \"code\"," +
                "t.xmmc as \"name\",t.mrsl as \"quantity\",t.zxks as \"dept\"" +
                "from portal_his.emr_ztmx@ykzxtest t where 1=1";
                "from portal_his.emr_ztmx@xec_link t where 1=1";
        if (StringUtils.isNotEmpty(ztId)){
            sql += " and t.ztid = '"+ztId+"'";
        }
@ -2797,6 +2930,7 @@ public class YkyyEntranceService {
    }
    //门诊开单操作
    public Map<String,Object> outPatientOrder(List<YkEmrJcsqDO> surveys,Boolean demoFlag,String doctor,String patient) throws Exception{
        BasePatientDO patientDO = basePatientDao.findById(patient);
        DoctorMappingDO doctorMappingDO = new DoctorMappingDO();
        if (StringUtils.isNoneBlank(doctor)){
            doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
@ -2810,7 +2944,7 @@ public class YkyyEntranceService {
        String doctorHis="";
        Integer kdks = 0;
        Integer brid=0;
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        JSONArray jsonArray = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
        Map<String,Object> resultMap = new HashMap();
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
@ -2921,6 +3055,7 @@ public class YkyyEntranceService {
    public String outPatientOrderYk(String jsonDate,Boolean demoFlag,String doctor,String patient) throws Exception{
        BasePatientDO patientDO = basePatientDao.findById(patient);
        List<YkEmrJcsqDO> surveys = EntityUtils.jsonToList(jsonDate,YkEmrJcsqDO.class);
        DoctorMappingDO doctorMappingDO = new DoctorMappingDO();
        if (StringUtils.isNotEmpty(doctor)){
@ -2934,7 +3069,7 @@ public class YkyyEntranceService {
        String doctorHis="";
        Integer kdks = 0;
        Integer brid=0;
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        JSONArray jsonArray = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),patientDO.getIdcard(),demoFlag);
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
            JSONObject json = jsonArray.getJSONObject(0);
@ -3075,7 +3210,7 @@ public class YkyyEntranceService {
    public void updatePatientJd(String patient,String address,String phone,Float zy, boolean demoFlag) throws Exception {
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
        JSONArray jsonArray = findHisPatientBySscAndIdcard(patientMedicareCardDO.getCode(),basePatientDO.getIdcard(),demoFlag);
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
            JSONObject json = jsonArray.getJSONObject(0);
@ -3107,6 +3242,9 @@ public class YkyyEntranceService {
    public String updateJzkh(Float brid,String jzkh){
        return  hibenateUtils.updateJzkh(brid,jzkh);
    }
    public String updateSfzh(Float brid,String sfzh){
        return  hibenateUtils.updateSfzh(brid,sfzh);
    }
    public String findInfoBysql(String sql) throws Exception {
        Map<String,Object> params = new HashedMap();
@ -3145,15 +3283,15 @@ public class YkyyEntranceService {
        String jzkhSql = "SELECT brid \"brid\",sfzh \"sfzh\" from portal_his.V_ZKSG_BRCX@xec_link where jzkh = '" + medicare + "' order by JDSJ ";
        JSONArray sfzhArray = getSqlResult(sfzhSql);
        int size = sfzhArray.size();
        if (size == 1) {
        /*if (size == 1) {
            JSONObject json = sfzhArray.getJSONObject(0);
            Object jzkh = json.get("jzkh");//社保卡
            //获取居民信息
            brid = json.getFloat("brid");//病人id
            if (jzkh != null && !jzkh.toString().equals(medicare)) {//判断是否跟当前医保卡号一致
                res.put("status", -1);
                res.put("message", "您输入的卡号和该就诊人在医院预留的卡号不一致,请重新输入。");
                return res;
//                res.put("status", -1);
//                res.put("message", "您输入的卡号和该就诊人在医院预留的卡号不一致,请重新输入。");
//                return res;
            } else if (jzkh == null) {//若为空则更新社保卡
                Map<String, Object> updateParams = new HashedMap();
                updateParams.put("brid", brid);
@ -3171,18 +3309,24 @@ public class YkyyEntranceService {
                    return res;
                }
            }
        } else if (size > 1) {//如果存在多条数据,查看是否有跟当前社保卡号一致的,如果有则跳过,如果社保卡都为空则取其中一条更新,否则就提示与预留卡号不一致
        } else*/ if (size > 1) {//如果存在多条数据,查看是否有跟当前社保卡号一致的,如果有则跳过,如果社保卡都为空则取其中一条更新,否则就提示与预留卡号不一致
            String sql = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where sfzh = '" + idcard + "' and  jzkh = '" + medicare + "' ";
            JSONArray array = getSqlResult(sql);
            logger.info("查询身份证和社保卡:" + array.toString());
            if (array==null||array.size()==0){
            /*if (array==null||array.size()==0){
                res.put("status", -1);
                res.put("message", "您输入的卡号和该就诊人在医院预留的卡号不一致,请重新输入。");
                return res;
            }
            }*/
            if (array.size() == 1) {
                brid = sfzhArray.getJSONObject(0).getFloat("brid");
            } else { //否则就去最早一条更新
                return res;
            }else if(size >= 6){//查不到数据就判断建档次数,超过6次不让新增
                res.put("status", -1);
                res.put("message", "建档超过6次,请到线下变更。");
                return res;
            }
            }/*else { //否则就去最早一条更新
                String nullSql = "SELECT brid \"brid\" from portal_his.V_ZKSG_BRCX@xec_link where sfzh = '" + idcard + "' and  jzkh is null ";
                Integer count = getSqlResult(nullSql).size();
                if (count == size) {//如果都为空就默认取一条,然后更新社保卡号
@ -3213,7 +3357,7 @@ public class YkyyEntranceService {
            if (jzkhArray!=null&&jzkhArray.size()>0){
                brid = jzkhArray.getJSONObject(0).getFloat("brid");
            }
        }
        }*/
        //查询是否有这个病人id 如果有直接返回 如果没有则新建
        if (brid == null)
        {

+ 25 - 6
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -7,6 +7,7 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxPayLogDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
@ -34,6 +35,7 @@ import com.yihu.jw.order.dao.ConsultOrderDao;
import com.yihu.jw.order.pay.wx.WeChatConfig;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.common.XMLUtil;
@ -41,6 +43,7 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeiXinPayUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.ByteToInputStream;
import com.yihu.jw.utils.YkyySMSService;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPayLogDao;
@ -50,6 +53,7 @@ import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -127,6 +131,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    private WlyyHttpLogDao wlyyHttpLogDao;
    @Autowired
    private BaseNatAppointmentDao baseNatAppointmentDao;
    @Autowired
    private BaseSmsTemplateDao smsTemplateDao;
    @Autowired
    private YkyySMSService ykyySMSService;
@ -453,12 +461,14 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    public Map<String,Object> selectOrderByRelationCode(String relationCode,String tradeType,String wechatId,boolean payFlag,String appletCode) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(Integer.parseInt(relationCode));
        if (baseNatAppointmentDO!=null&&"-1".equalsIgnoreCase(baseNatAppointmentDO.getIsSuccess())){
            throw new Exception("订单已取消");
        }
        if (businessOrderDO!=null&&businessOrderDO.getStatus()==1){
            throw new Exception("订单已支付");
        if (NumberUtils.isDigits(relationCode) ){
            BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(Integer.valueOf(relationCode));
            if (baseNatAppointmentDO!=null&&"-1".equalsIgnoreCase(baseNatAppointmentDO.getIsSuccess())){
                throw new Exception("订单已取消");
            }
            if (businessOrderDO!=null&&businessOrderDO.getStatus()==1){
                throw new Exception("订单已支付");
            }
        }
        String body = businessOrderDO.getDescription();
        String totalFee = businessOrderDO.getPayPrice().intValue()+"";
@ -848,6 +858,12 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                    WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
                    wlyyOutpatientDO.setPayStatus(1);
                    outpatientDao.save(wlyyOutpatientDO);
                    if (StringUtils.isNoneBlank(wlyyOutpatientDO.getDoctor())){
                        BaseDoctorDO baseDoctorDO= doctorDao.findById(wlyyOutpatientDO.getDoctor());
                        if (baseDoctorDO!=null){
                            ykyySMSService.sendSmsByTempcode("outpatient_remind",wlyyOutpatientDO,null,baseDoctorDO.getMobile());
                        }
                    }
                }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                    List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findById(businessOrderDO.getRelationCode());
                    if (wlyyPrescriptionDOS!=null&&wlyyPrescriptionDOS.size()!=0){
@ -877,6 +893,9 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                                            " where "+condition+" t.CFSB ='"+wlyyPrescriptionDO.getRealOrder()+"'";
                                    ykyyEntranceService.updateHisStatus(updatesql);
                                    logger.info("自取写入更新his");
                                    WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(wlyyPrescriptionDO.getOutpatientId());
                                    ykyySMSService.sendSmsByTempcode("oneself_pick",wlyyOutpatientDO,wlyyPrescriptionDO,"");
                                }else {
                                    //向顺丰下单
                                    logger.info("向顺丰快递下单");

+ 389 - 0
business/base-service/src/main/java/com/yihu/jw/utils/YkyySMSService.java

@ -0,0 +1,389 @@
package com.yihu.jw.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.WlyyInspectionDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.sms.util.ykyy.client.SmsClient;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2020/3/19.
 */
@Service
public class YkyySMSService {
    private static final Logger logger = LoggerFactory.getLogger(YkyySMSService.class);
    private final String usrCode ="300643";
    private final String pw ="T9IHN69DDF";
    private final String urlSms ="https://smsapp.wlwx.com";
    private final static String url="http://192.168.20.55:10023/ykyy/createSQLQuery";
    @Autowired
    private BaseSmsTemplateDao smsTemplateDao;
    @Autowired
    private WlyyInspectionDao inspectionDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    /**
     * 发送短信验证码
     * @param mobile
     * @param content
     * @return
     */
    public ResultMsg ykyySendSMS(String mobile, String content){
        SmsClient smsClient = new SmsClient();
        return smsClient.sendSms("ykyy",usrCode, content,mobile,"yes","","8",urlSms,pw);
    }
    public void sendSmsByTempcode(String temlateCode, WlyyOutpatientDO wlyyOutpatientDO, WlyyPrescriptionDO wlyyPrescriptionDO,String doctorMobile){
        SmsTemplateDO smsTemplateDO =  null;
        String content="";
        String sex = "先生/女士";
        String mobile = "";
        //由于审方情况比较特殊单独标记下
        WxPushLogDO wxPushLogDO = null;
        WxPushLogDO wxPushLogDODoctor = null;
        //新增字典判断是否发送短信
        String sendMesControl = "1";//1 开启发送短信 0 关闭
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("ykSmsControl");
        if (wlyyHospitalSysDictDO!=null){
            sendMesControl = wlyyHospitalSysDictDO.getDictValue();
        }
        if("check_failed".equalsIgnoreCase(temlateCode)){
            wxPushLogDO = wxPushLogDao.findByTempNameAndOpenidAndReceiver(temlateCode,wlyyOutpatientDO.getId(),wlyyOutpatientDO.getPatient());
            wxPushLogDODoctor = wxPushLogDao.findByTempNameAndOpenidAndReceiver(temlateCode,wlyyOutpatientDO.getId(),wlyyOutpatientDO.getDoctor());
        }else {
            wxPushLogDO = wxPushLogDao.findByTempNameAndOpenid(temlateCode,wlyyOutpatientDO.getId());
        }
        if (wlyyOutpatientDO!=null){
            if (StringUtils.isNoneBlank(wlyyOutpatientDO.getIdcard())){
                String sexNo = IdCardUtil.getSexForIdcard_new(wlyyOutpatientDO.getIdcard());
                if ("1".equalsIgnoreCase(sexNo)){
                    sex = "先生";
                }else if ("2".equalsIgnoreCase(sexNo)){
                    sex = "女士";
                }
            }
            BasePatientDO basePatientDO = basePatientDao.findById(wlyyOutpatientDO.getPatient());
            if (basePatientDO!=null&&StringUtils.isNoneBlank(basePatientDO.getMobile())){
                mobile = basePatientDO.getMobile();
            }else {
                mobile=wlyyOutpatientDO.getMobile();
            }
        }
        logger.info("temlateCode"+temlateCode+"==mobile:"+mobile);
        try {
            if ("prescription_remind".equalsIgnoreCase(temlateCode)){//开具处方提醒
                smsTemplateDO = smsTemplateDao.findByClientId("prescription_remind");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}", DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
                            .replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);
                    if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                        ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                    }
                }
            }else if ("outpatient_remind".equalsIgnoreCase(temlateCode)){//患者发起复诊给医生发送消息
                smsTemplateDO = smsTemplateDao.findByClientId("outpatient_remind");
                if (smsTemplateDO!=null){
                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                        content = smsTemplateDO.getContent();
                        if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                            ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
                            wxPushLogDO = new WxPushLogDO();
                            wxPushLogDO.setTempName(temlateCode);
                            wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                            wxPushLogDO.setReceiver(wlyyOutpatientDO.getDoctor());
                            wxPushLogDO.setCreateTime(new Date());
                            wxPushLogDao.save(wxPushLogDO);
                        }
                    }else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                        content = smsTemplateDO.getContent().replace("图文","视频");
                        if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                            ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
                            wxPushLogDO = new WxPushLogDO();
                            wxPushLogDO.setTempName(temlateCode);
                            wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                            wxPushLogDO.setReceiver(wlyyOutpatientDO.getDoctor());
                            wxPushLogDO.setCreateTime(new Date());
                            wxPushLogDao.save(wxPushLogDO);
                        }
                    }
                }
            }else if ("message_remind_paitent".equalsIgnoreCase(temlateCode)){//医生发消息发送短信提醒
                smsTemplateDO = smsTemplateDao.findByClientId("message_remind_paitent");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
                    if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                        ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                    }
                }
            }else if ("oneself_pick".equalsIgnoreCase(temlateCode)){//病人自取
                smsTemplateDO = smsTemplateDao.findByClientId("oneself_pick");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime())).replace("{{门诊号码}}",wlyyOutpatientDO.getRealOrder())
                    .replace("{{性别}}",sex);
                    if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                        ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                    }
                }
            }else if("check_failed".equalsIgnoreCase(temlateCode)){//处方审核失败
                smsTemplateDO = smsTemplateDao.findByClientId("check_failed_patient");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
                    if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                        ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                    }
                }
                SmsTemplateDO smsTemplateDO1 = smsTemplateDao.findByClientId("check_failed_doctor");
                if (smsTemplateDO1!=null){
                    String contentDoctor = smsTemplateDO1.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
                            .replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder());
                    if (wxPushLogDODoctor==null&&"1".equalsIgnoreCase(sendMesControl)){
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getDoctor());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                        ykyySendSMS(doctorMobile,smsTemplateDO1.getHeader()+contentDoctor);
                    }
                }
            }else if ("check_success_patient".equalsIgnoreCase(temlateCode)){//处方审核通过
                smsTemplateDO = smsTemplateDao.findByClientId("check_success_patient");
                if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
                    if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                        ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                    }
                }
            }else if ("inspection_remind".equalsIgnoreCase(temlateCode)){//处方审核通过
                smsTemplateDO = smsTemplateDao.findByClientId("inspection_remind");
                if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
                    String medicard = "";
                    Integer brxb = 0;
                    String mzhm ="0";
                    //如果患者医保卡不为空则用社保卡 否则用mzhm
                    if(StringUtils.isNoneBlank(wlyyOutpatientDO.getCardNo())){
                        medicard = wlyyOutpatientDO.getCardNo();
                        JSONArray jsonArray3 = findHisPatient(medicard,false);
                        if(jsonArray3!=null&&jsonArray3.size()>0){
                            //获取居民信息
                            JSONObject json = jsonArray3.getJSONObject(0);
                            mzhm = json.getString("mzhm");
                        }else {
                            medicard="";
                        }
                    }else {
                        JSONArray jsonArray3 = findHisPatientByIdCard(wlyyOutpatientDO.getIdcard(),false);
                        if(jsonArray3!=null&&jsonArray3.size()>0){
                            //获取居民信息
                            JSONObject json = jsonArray3.getJSONObject(0);
                            mzhm = json.getString("mzhm");
                        }
                    }
                    List<WlyyInspectionDO> list = inspectionDao.findByOutpatientId(wlyyOutpatientDO.getId());
                    String createTime = "";
                    if (list!=null&&list.size()>0){
                        createTime = DateUtil.dateToStrLong(list.get(0).getCreateTime());
                    }
                    if (StringUtils.isNoneBlank(medicard)){
                        content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",createTime).replace("{{门诊号码}}",mzhm)
                        .replace("{{社保卡号}}","【凭社保卡/就诊卡"+medicard+"到院充值预缴金做检查】").replace("{{性别}}",sex).replace("{{时间}}",createTime);
                    }else {
                        content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",createTime).replace("{{门诊号码}}",mzhm)
                                .replace("{{社保卡号}}","【到收费处,凭此条短信中的门诊号码换卡充值预缴金做检查】").replace("{{性别}}",sex);;
                    }
                    if (wxPushLogDO==null&&"1".equalsIgnoreCase(sendMesControl)){
                        wxPushLogDO = new WxPushLogDO();
                        wxPushLogDO.setTempName(temlateCode);
                        wxPushLogDO.setOpenid(wlyyOutpatientDO.getId());
                        wxPushLogDO.setReceiver(wlyyOutpatientDO.getPatient());
                        wxPushLogDO.setCreateTime(new Date());
                        wxPushLogDao.save(wxPushLogDO);
                        ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                    }
                }
            }
            logger.info("发送后:temlateCode"+temlateCode+"==mobile:"+mobile+"content"+content+"doctorMobile"+doctorMobile);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(temlateCode+"模板发送失败");
        }
    }
    /**
     * 获取his病人信息
     * @param ssc
     * @return
     * @throws Exception
     */
    public JSONArray findHisPatient(String ssc,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.jzkh = '"+ssc+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }
    /**
     * 获取his病人信息
     * @param idcard
     * @return
     * @throws Exception
     */
    public JSONArray findHisPatientByIdCard(String idcard,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.sfzh = '"+idcard+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/utils/hibernate/HibenateUtils.java

@ -253,7 +253,7 @@ public class HibenateUtils {
                .registerStoredProcedureParameter("P_SFZH", String.class, ParameterMode.IN)
                .registerStoredProcedureParameter("P_ERRMSG", String.class, ParameterMode.INOUT)
                .setParameter("P_BRID", brid)
                .setParameter("P_YBKH", sfzh);
                .setParameter("P_SFZH", sfzh);
        query.execute();
        String priceStr = (String) query.getOutputParameterValue("P_ERRMSG"); // 获取存储过程中的返回值
        return priceStr;

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxPushLogDao.java

@ -2,10 +2,15 @@ package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2020/4/27.
 */
public interface WxPushLogDao extends PagingAndSortingRepository<WxPushLogDO, String>, JpaSpecificationExecutor<WxPushLogDO> {
    WxPushLogDO findByTempNameAndOpenid(String tempName,String openId);
    WxPushLogDO findByTempNameAndOpenidAndReceiver(String tempName,String openId,String reciver);
}

+ 266 - 0
business/sms-service/src/main/java/com/yihu/jw/sms/service/YkyyINSMSService.java

@ -0,0 +1,266 @@
package com.yihu.jw.sms.service;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.sms.util.ykyy.client.SmsClient;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Created by Trick on 2020/3/19.
 */
@Service
public class YkyyINSMSService {
    private static final Logger logger = LoggerFactory.getLogger(YkyyINSMSService.class);
    private final String usrCode ="300643";
    private final String pw ="T9IHN69DDF";
    private final String urlSms ="https://smsapp.wlwx.com";
    @Autowired
    private BaseSmsTemplateDao smsTemplateDao;
    /**
     * 发送短信验证码
     * @param mobile
     * @param content
     * @return
     */
    public ResultMsg ykyySendSMS(String mobile, String content){
        SmsClient smsClient = new SmsClient();
        return smsClient.sendSms("ykyy",usrCode, content,mobile,"yes","","8",urlSms,pw);
    }
   /* public void sendSmsByTempcode(String temlateCode, WlyyOutpatientDO wlyyOutpatientDO, WlyyPrescriptionDO wlyyPrescriptionDO,String doctorMobile){
        SmsTemplateDO smsTemplateDO =  null;
        String content="";
        String sex = "先生/女士";
        String mobile = "";
        if (wlyyOutpatientDO!=null){
            if (StringUtils.isNoneBlank(wlyyOutpatientDO.getIdcard())){
                String sexNo = IdCardUtil.getSexForIdcard_new(wlyyOutpatientDO.getIdcard());
                if ("1".equalsIgnoreCase(sexNo)){
                    sex = "先生";
                }else if ("2".equalsIgnoreCase(sexNo)){
                    sex = "女士";
                }
            }
            BasePatientDO basePatientDO = basePatientDao.findById(wlyyOutpatientDO.getPatient());
            if (basePatientDO!=null&&!StringUtils.isNoneBlank(basePatientDO.getMobile())){
                mobile = basePatientDO.getMobile();
            }else {
                mobile=wlyyOutpatientDO.getMobile();
            }
        }
        logger.info("temlateCode"+temlateCode+"==mobile:"+mobile);
        try {
            if ("prescription_remind".equalsIgnoreCase(temlateCode)){//开具处方提醒
                smsTemplateDO = smsTemplateDao.findByClientId("prescription_remind");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}", DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
                            .replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);
                    ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                }
            }else if ("outpatient_remind".equalsIgnoreCase(temlateCode)){//患者发起复诊给医生发送消息
                smsTemplateDO = smsTemplateDao.findByClientId("outpatient_remind");
                if (smsTemplateDO!=null){
                    if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                        content = smsTemplateDO.getContent();
                        ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
                    }else if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())&&"1".equalsIgnoreCase(wlyyOutpatientDO.getOutpatientType())){
                        content = smsTemplateDO.getContent().replace("图文","视频");
                        ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
                    }
                }
            }else if ("message_remind_paitent".equalsIgnoreCase(temlateCode)){//医生发消息发送短信提醒
                content = smsTemplateDO.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getDoctorName());
                ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
            }else if ("oneself_pick".equalsIgnoreCase(temlateCode)){//病人自取
                smsTemplateDO = smsTemplateDao.findByClientId("oneself_pick");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime())).replace("{{门诊号码}}",wlyyOutpatientDO.getRealOrder())
                    .replace("{{性别}}",sex);;
                    ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                }
            }else if("check_failed".equalsIgnoreCase(temlateCode)){//处方审核失败
                smsTemplateDO = smsTemplateDao.findByClientId("check_failed_patient");
                if (smsTemplateDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
                    ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                }
                SmsTemplateDO smsTemplateDO1 = smsTemplateDao.findByClientId("check_failed_doctor");
                if (smsTemplateDO1!=null){
                    content = smsTemplateDO.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()))
                            .replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder());
                    ykyySendSMS(doctorMobile,smsTemplateDO.getHeader()+content);
                }
            }else if ("check_success_patient".equalsIgnoreCase(temlateCode)){//处方审核通过
                smsTemplateDO = smsTemplateDao.findByClientId("check_success_patient");
                if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",wlyyPrescriptionDO.getRealOrder()).replace("{{性别}}",sex);;
                    ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                }
            }else if ("inspection_remind".equalsIgnoreCase(temlateCode)){//处方审核通过
                smsTemplateDO = smsTemplateDao.findByClientId("inspection_remind");
                if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
                    String medicard = "";
                    Integer brxb = 0;
                    String mzhm ="0";
                    //如果患者医保卡不为空则用社保卡 否则用mzhm
                    if(StringUtils.isNoneBlank(wlyyOutpatientDO.getCardNo())){
                        medicard = wlyyOutpatientDO.getCardNo();
                        JSONArray jsonArray3 = findHisPatient(medicard,false);
                        if(jsonArray3!=null&&jsonArray3.size()>0){
                            //获取居民信息
                            JSONObject json = jsonArray3.getJSONObject(0);
                            mzhm = json.getString("mzhm");
                        }else {
                            medicard="";
                        }
                    }else {
                        JSONArray jsonArray3 = findHisPatientByIdCard(wlyyOutpatientDO.getIdcard(),false);
                        if(jsonArray3!=null&&jsonArray3.size()>0){
                            //获取居民信息
                            JSONObject json = jsonArray3.getJSONObject(0);
                            mzhm = json.getString("mzhm");
                        }
                    }
                    List<WlyyInspectionDO> list = inspectionDao.findByOutpatientId(wlyyOutpatientDO.getId());
                    String createTime = "";
                    if (list!=null&&list.size()>0){
                        createTime = DateUtil.dateToStrLong(list.get(0).getCreateTime());
                    }
                    if (StringUtils.isNoneBlank(medicard)){
                        content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",createTime).replace("{{门诊号码}}",mzhm)
                        .replace("{{社保卡号}}","【凭社保卡"+medicard+"到院充值预缴金做检查】").replace("{{性别}}",sex);;
                    }else {
                        content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",createTime).replace("{{门诊号码}}",mzhm)
                                .replace("{{社保卡号}}","【到收费处,凭此条短信中的门诊号码换卡充值预缴金做检查】").replace("{{性别}}",sex);;
                    }
                    ykyySendSMS(mobile,smsTemplateDO.getHeader()+content);
                }
            }
            logger.info("发送后:temlateCode"+temlateCode+"==mobile:"+mobile+"content"+content);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(temlateCode+"模板发送失败");
        }
    }
    *//**
     * 获取his病人信息
     * @param ssc
     * @return
     * @throws Exception
     *//*
    public JSONArray findHisPatient(String ssc,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.jzkh = '"+ssc+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }
    *//**
     * 获取his病人信息
     * @param idcard
     * @return
     * @throws Exception
     *//*
    public JSONArray findHisPatientByIdCard(String idcard,boolean demoFlag) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
                "\tx.brxm AS \"brxm\",\n" +
                "\tx.sfzh AS \"sfzh\",\n" +
                "\tx.brxz AS \"brxz\",\n" +
                "\tx.brxb AS \"brxb\",\n" +
                "\tx.csny as \"csny\",\n" +
                "\tx.jzkh AS \"jzkh\",\n" +
                "\tx.jdsj AS \"jdsj\",\n" +
                "\tx.sjhm AS \"sjhm\",\n" +
                "\tx.fzxmc AS \"fzxmc\",\n" +
                "\tx.gzztmc AS \"gzztmc\",\n" +
                "\tx.lxdz AS \"lxdz\"\n" +
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.sfzh = '"+idcard+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("idcard:"+sql);
        if (demoFlag){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("brid","1168517");
            jsonObject.put("mzhm","0502452155");
            jsonObject.put("brxm","于小童");
            jsonObject.put("sfzh","450521199405092535");
            jsonObject.put("brxz","自费");
            jsonObject.put("brxb","男");
            jsonObject.put("csny","1994-05-09");
            jsonObject.put("jzkh","2396501");
            jsonObject.put("jdsj","2020-06-28 15:15:35");
            jsonObject.put("gzztmc","一般");
            jsonObject.put("lxdz","厦门市五缘湾");
            array.add(jsonObject);
        }else  {
            HttpResponse response = HttpUtils.doGet(url,params);
            String content = response.getContent();
            logger.info("response:"+content);
            JSONObject rs = JSON.parseObject(content);
            Integer status = rs.getInteger("status");
            if (status==200){
                array = rs.getJSONArray("detailModelList");
            }
        }
        return array;
    }*/
}

+ 0 - 29
business/sms-service/src/main/java/com/yihu/jw/sms/service/YkyySMSService.java

@ -1,29 +0,0 @@
package com.yihu.jw.sms.service;
import com.yihu.jw.sms.util.ykyy.client.SmsClient;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import org.springframework.stereotype.Service;
/**
 * Created by Trick on 2020/3/19.
 */
@Service
public class YkyySMSService {
    private final String usrCode ="300643";
    private final String pw ="T9IHN69DDF";
    private final String url ="https://smsapp.wlwx.com";
    /**
     * 发送短信验证码
     * @param mobile
     * @param content
     * @return
     */
    public ResultMsg ykyySendSMS(String mobile, String content){
        SmsClient smsClient = new SmsClient();
        return smsClient.sendSms("ykyy",usrCode, content,mobile,"yes","","8",url,pw);
    }
}

+ 0 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/AccountDO.java

@ -123,7 +123,6 @@ public class AccountDO extends UuidIdentityEntityWithOperator implements Seriali
        this.usedTotal = usedTotal;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPassword() {
        return password;
    }
@ -132,7 +131,6 @@ public class AccountDO extends UuidIdentityEntityWithOperator implements Seriali
        this.password = password;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getCardNumber() {
        return cardNumber;
    }

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskPatientDetailDO.java

@ -111,6 +111,7 @@ public class TaskPatientDetailDO extends UuidIdentityEntityWithOperator implemen
        this.patientId = patientId;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPatientIdcard() {
        return patientIdcard;
    }
@ -119,7 +120,6 @@ public class TaskPatientDetailDO extends UuidIdentityEntityWithOperator implemen
        this.patientIdcard = patientIdcard;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPatientOpenid() {
        return patientOpenid;
    }

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

@ -29,7 +29,7 @@ import com.yihu.jw.security.utils.AES;
import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.sms.service.YkyyINSMSService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
@ -139,7 +139,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @Autowired
    private OauthSsoService oauthSsoService;
    @Autowired
    private YkyySMSService ykyySMSService;
    private YkyyINSMSService ykyyINSMSService;
    @Autowired
    private RegisterService registerService;
    @Autowired
@ -805,9 +805,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                    }
                }else if("1".equals(type)){
                    result = ykyySMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
                    result = ykyyINSMSService.ykyySendSMS(username,"您好,您的手机登录短信验证码是:"+captcha+",5分钟内有效。");
                }else if("2".equals(type)) {
                    result = ykyySMSService.ykyySendSMS(username, "您好,您正在进行找回密码操作,您的短信验证码是:" + captcha + ",请勿将验证码告诉他人,5分钟内有效。");
                    result = ykyyINSMSService.ykyySendSMS(username, "您好,您正在进行找回密码操作,您的短信验证码是:" + captcha + ",请勿将验证码告诉他人,5分钟内有效。");
                }
                if (result.isSuccess()) {
                    Captcha _captcha = new Captcha();

+ 8 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/YkyyController.java

@ -409,4 +409,12 @@ public class YkyyController extends EnvelopRestEndpoint {
                              @RequestParam(value = "jzkh",required = false)String jzkh){
        return success(ykyyEntranceService.updateJzkh(brid,jzkh));
    }
    @GetMapping(value = "/updateSfzh")
    @ApiOperation(value = "更新患者身份证号")
    public Envelop updateSfzh(@ApiParam(name = "brid", value = "病人id", required = true)
                              @RequestParam(value = "brid",required = true)Float brid,
                              @ApiParam(name = "sfzh", value = "身份证号", required = false)
                              @RequestParam(value = "sfzh",required = false)String sfzh){
        return success(ykyyEntranceService.updateSfzh(brid,sfzh));
    }
}

+ 16 - 30
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -35,11 +35,11 @@ import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.sms.dao.BaseSmsTemplateDao;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.RSAEncrypt;
import com.yihu.jw.utils.YkyySMSService;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
@ -189,7 +189,7 @@ public class UnSettledHISPrescriptionService {
                    JSONObject json = jsonArray.getJSONObject(i);
                    String cfsb = json.getString("CFSB");
                    //查找对应的处方
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR,w.DOCTOR_NAME,to_char(w.CREATE_TIME,'YYYY-MM-DD hh24:mi:ss')  AS \"CREATE_TIME\" from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' and status <> 11 ORDER BY w.CREATE_TIME desc";
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' and status <> 11 ORDER BY w.CREATE_TIME desc";
                    List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                    if(pre!=null && pre.size()>0){
                        String prescriptionId = pre.get(0).get("ID").toString();
@ -209,17 +209,10 @@ public class UnSettledHISPrescriptionService {
                        System.out.println("发送诊断消息成功:"+immsg);
                        //发送短信提醒
                        String content = "";
                        SmsTemplateDO smsTemplateDO = smsTemplateDao.findByClientId("check_failed_patient");
                        if (smsTemplateDO!=null){
                            content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",cfsb);
                            ykyySMSService.ykyySendSMS(wlyyOutpatientDO.getConsumerMobile(),content);
                        }
                        SmsTemplateDO smsTemplateDO1 = smsTemplateDao.findByClientId("check_failed_doctor");
                        if (smsTemplateDO1!=null){
                            content = smsTemplateDO.getContent().replace("{{医生姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{时间}}",pre.get(0).get("CREATE_TIME").toString())
                                    .replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",cfsb);
                            ykyySMSService.ykyySendSMS(wlyyOutpatientDO.getConsumerMobile(),content);
                        }
                        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(cfsb);
                        BaseDoctorDO baseDoctorDO = doctorDao.findById(doctor);
                        ykyySMSService.sendSmsByTempcode("check_failed",wlyyOutpatientDO,prescriptionDO,baseDoctorDO.getMobile());
                    }
                }
            }
@ -268,16 +261,16 @@ public class UnSettledHISPrescriptionService {
                                        logger.info("=======setUrl========"+newConfig.getUrl());
                                        weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),newConfig);
                                    });
                                    //保存发送模板记录,
                                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                                    wxPushLogDO.setCreateTime(new Date());
                                    wxPushLogDO.setOpenid(prescriptionId);
                                    wxPushLogDO.setReceiver(patientDO.getId());
                                    wxPushLogDO.setWechatId(wechatId);
                                    wxPushLogDO.setReceiverName(patientDO.getName());
                                    wxPushLogDO.setScene("djsxxtz");
                                    wxPushLogDao.save(wxPushLogDO);
                                }
                                //保存发送模板记录,
                                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                                wxPushLogDO.setCreateTime(new Date());
                                wxPushLogDO.setOpenid(prescriptionId);
                                wxPushLogDO.setReceiver(patientDO.getId());
                                wxPushLogDO.setWechatId(wechatId);
                                wxPushLogDO.setReceiverName(patientDO.getName());
                                wxPushLogDO.setScene("djsxxtz");
                                wxPushLogDao.save(wxPushLogDO);
                                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
                                wlyyPrescriptionDO.setPrescribeTime(new Date());
                                wlyyPrescriptionDO.setCheckStatus(0);
@ -305,14 +298,7 @@ public class UnSettledHISPrescriptionService {
                                }
                                prescriptionVO.setDiagnosisVOs(wlyyPrescriptionDiagnosisVOS);
                                imService.pushPrescriptionImMessage(prescriptionVO);
                                //发送审核成功短信提醒
                                //发送短信提醒
                                String content = "";
                                SmsTemplateDO smsTemplateDO = smsTemplateDao.findByClientId("check_failed_patient");
                                if (smsTemplateDO!=null&&wlyyOutpatientDO!=null){
                                    content = smsTemplateDO.getContent().replace("{{病人姓名}}",wlyyOutpatientDO.getPatientName()).replace("{{处方编号}}",cfsb);
                                    ykyySMSService.ykyySendSMS(wlyyOutpatientDO.getConsumerMobile(),content);
                                }
                                ykyySMSService.sendSmsByTempcode("check_success_patient",wlyyOutpatientDO,wlyyPrescriptionDO,"");
                            }
                        }
                    }

+ 6 - 0
svr/svr-internet-hospital/pom.xml

@ -261,6 +261,12 @@
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>sms-service</artifactId>
            <version>2.0.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>

+ 3 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -15,7 +15,7 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.sms.service.YkyyINSMSService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
@ -55,7 +55,7 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private YkyySMSService ykyySMSService;
    private YkyyINSMSService ykyyINSMSService;
    private final String KEY_SUFFIX = ":code";
    @Autowired
    private ZhongShanSMSService zhongShanSMSService;
@ -195,7 +195,7 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            if("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                System.out.println("发送眼科验证码开始");
                ResultMsg result= null;
                result = ykyySMSService.ykyySendSMS(phoneNum, "您好,您的此次操作的验证码是:" + captcha + ",2分钟内有效。如非本人操作,请忽略");
                result = ykyyINSMSService.ykyySendSMS(phoneNum, "您好,您的此次操作的验证码是:" + captcha + ",2分钟内有效。如非本人操作,请忽略");
                if (result.isSuccess()){
                    this.store(client_id, phoneNum, captcha, 120);
                    mixEnvelop.setMessage("验证码发送成功");

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

@ -10,6 +10,7 @@ import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
@ -26,6 +27,7 @@ import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
import com.yihu.jw.hospital.httplog.service.WlyyHttpLogService;
import com.yihu.jw.hospital.message.service.BaseBannerDoctorService;
import com.yihu.jw.hospital.message.service.BaseUserMsgService;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
@ -35,6 +37,7 @@ import com.yihu.jw.hospital.service.consult.KnowledgeArticleService;
import com.yihu.jw.hospital.service.consult.KnowledgeCategoryService;
import com.yihu.jw.hospital.service.consult.QrcodeService;
import com.yihu.jw.hospital.service.consult.SysDictService;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
@ -49,7 +52,7 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.sms.service.YkyyINSMSService;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
@ -185,9 +188,13 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseNatAppointmentDao baseNatAppointmentDao;
    @Autowired
    private YkyySMSService ykyySMSService;
    private YkyyINSMSService ykyyINSMSService;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private SystemMessageService systemMessageService;
    @Autowired
    private ConsultDao consultDao;
    @GetMapping(value = BaseHospitalRequestMapping.PatientNoLogin.findDoctorByHospitalAndDiseaseAndDept)
    @ApiOperation(value = "根据疾病名称,热门部门查询医生", notes = "根据疾病名称,热门部门查询医生")
@ -1547,6 +1554,11 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    }
    @GetMapping("/testsms")
    public void testsms(String mobile ,String contet){
        ykyySMSService.ykyySendSMS(mobile,contet);
        ykyyINSMSService.ykyySendSMS(mobile,contet);
    }
    @GetMapping("/smsToDoctor")
    public Envelop sentMessageRemindSms(@RequestParam(value = "consult", required = true)String consult){
        ConsultDo consultDo = consultDao.findOne(consult);
        return  success(systemMessageService.sendDoctorRemindSms(consultDo));
    }
}

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

@ -2651,16 +2651,22 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @RequestParam(required = false) String payStatus,
            @ApiParam(name = "medicare", value = "医保卡号", required = false)
            @RequestParam(required = false) String medicare,
            @ApiParam(name = "createTime", value = "创建时间", required = false)
            @RequestParam(required = false) String createTime,
            @ApiParam(name = "appointmentTime", value = "预约时间", required = false)
            @RequestParam(required = false) String appointmentTime,
            @ApiParam(name = "createTimeStart", value = "创建时间", required = false)
            @RequestParam(required = false) String createTimeStart,
            @ApiParam(name = "createTimeEnd", value = "创建时间", required = false)
            @RequestParam(required = false) String createTimeEnd,
            @ApiParam(name = "appointmentTimeStart", value = "预约时间", required = false)
            @RequestParam(required = false) String appointmentTimeStart,
            @ApiParam(name = "appointmentTimeEnd", value = "预约时间", required = false)
            @RequestParam(required = false) String appointmentTimeEnd,
            @ApiParam(name = "isSuccess", value = "1成功  0失败")
            @RequestParam(value = "isSuccess", required = false) Integer isSuccess,
            @ApiParam(name = "page", value = "页数")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "pageSize", value = "每页大小")
            @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        try {
            return prescriptionService.getNatAppointmentList(realOrder, name, hospitalFlag, mobile, idcard, payStatus, medicare, createTime, appointmentTime, page, pageSize);
            return prescriptionService.getNatAppointmentList(realOrder, name, hospitalFlag, mobile, idcard, payStatus, medicare, createTimeStart, createTimeEnd, appointmentTimeStart,appointmentTimeEnd,isSuccess, page, pageSize);
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }

+ 1 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatCoreController.java

@ -156,6 +156,7 @@ public class WechatCoreController extends EnvelopRestEndpoint {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (validate(signature, timestamp, nonce)) {
                String xmlStr = weiXinCoreService.messageProcess(request, wxAccessTokenDO.getAccessToken());
                logger.info("返回xml:"+xmlStr);
                // 判断返回值是xml、json格式(取关是空串)
                Boolean flag = weiXinCoreService.isXML(xmlStr);
                if (xmlStr == "error") {

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/wechat/WeiXinEventProcess.java

@ -130,7 +130,7 @@ public class WeiXinEventProcess {
            String url = null;
            // 医生二维码跳转URL
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa67b466e6ab64bba&redirect_uri=https%3a%2f%2fintel.yanketong.com%2fims-wx%2f%23%2fpersonal%2ffamilyMember%2findex%3ftype%3dnucleicTest&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
                url = "https://intel.yanketong.com/ims-wx/redirect.html";
                picUrl = "https://intel.yanketong.com/group1/M00/00/13/wKghxmAZD-iAEyHgAAA-zHpYNyg537.png";
                article.put("Url", url);
                article.put("Title", "核酸检测预约");

+ 9 - 1
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/AccountDao.java

@ -3,11 +3,13 @@ package com.yihu.jw.dao;/**
 */
import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.ActivityRuleDO;
import com.yihu.jw.entity.health.bank.ActivityDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:15
@ -16,4 +18,10 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface AccountDao extends PagingAndSortingRepository<AccountDO,String>,JpaSpecificationExecutor<AccountDO> {
    @Query("select t from AccountDO t where t.patientId=?1 and t.status=1")
    AccountDO selectByPatientId(String patientId);
    @Query("select t from AccountDO t where t.patientId=?1 and t.status=1")
    List<AccountDO> selectsByPatientId(String patientId);
    @Query("select t from AccountDO t where t.patientId=?1")
    List<AccountDO> findByPatientId(String patientId);
}

+ 5 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskPatientDetailDao.java

@ -17,9 +17,14 @@ public interface TaskPatientDetailDao extends PagingAndSortingRepository<TaskPat
    @Query("select t from TaskPatientDetailDO t where taskId = ?1")
    List<TaskPatientDetailDO> selectByTaskId(String taskId);
    @Query("select t from TaskPatientDetailDO t where taskId = ?1 and patientOpenid = ?2")
    List<TaskPatientDetailDO> selectByTaskIdAndOpenid(String taskId,String openId);
    @Query("select t from TaskPatientDetailDO t where taskId = ?1 and patientId =?2")
    TaskPatientDetailDO selectByTaskIdAndPatientId(String taskId,String patientId);
    @Query("select t from TaskPatientDetailDO t where taskId = ?1 and patientId =?2")
    List<TaskPatientDetailDO> selectByTaskIdAndPatientId2(String taskId,String patientId);
    @Query("select t from TaskPatientDetailDO t where activityId = ?1 and patientId =?2")
    TaskPatientDetailDO selectByActivityIdAndPatientId(String activityId,String patientId);

+ 12 - 28
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/AccountService.java

@ -9,11 +9,11 @@ import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.TaskDO;
import com.yihu.jw.entity.health.bank.TaskPatientDetailDO;
import com.yihu.jw.entity.health.bank.TaskRuleDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -131,6 +131,7 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                buffer.deleteCharAt(buffer.length()-1);
                buffer.append(") ");
                String accountSql = "select * from wlyy_health_bank_account where patient_id in "+buffer;
                accountSql = TransforSqlUtl.wlyyHealthBankAccountAll(accountSql);
                List<AccountDO> accountDOSList = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper<>(AccountDO.class));
                if (accountDOSList != null && accountDOSList.size() !=0){
                    String sql2 = " SELECT " +
@ -171,19 +172,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                            " ( " +
                            " SELECT " +
                            " ba.id AS id, " +
                            " ba.total /*+ COALESCE (bacd1.sum, 0)*/ AS sum " +
                            " ba.total AS sum " +
                            " FROM " +
                            " wlyy_health_bank_account ba " +
                            /*" LEFT JOIN ( " +
                            " SELECT " +
                            " COALESCE (SUM(bacd.integrate), 0) AS sum, " +
                            " bacd.account_id " +
                            "  FROM " +
                            " wlyy_health_bank_credits_detail bacd " +
                            " WHERE " +
                            " bacd.trade_direction = - 1 " +
                            " GROUP BY " +
                            " bacd.account_id ) bacd1 ON ba.id = bacd1.account_id "+*/
                            " WHERE " +
                            " ba.id IN " +buffer1+
                            " )ba1 WHERE ba1.sum > "+accountDO1.getSum();
@ -204,19 +195,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                            " ( " +
                            " SELECT " +
                            " ba.id AS id, " +
                            " ba.total /*+ COALESCE (bacd1.sum, 0)*/ AS sum " +
                            " ba.total AS sum " +
                            " FROM " +
                            " wlyy_health_bank_account ba " +
                            /*" LEFT JOIN ( " +
                            " SELECT " +
                            " COALESCE (SUM(bacd.integrate), 0) AS sum, " +
                            " bacd.account_id " +
                            "  FROM " +
                            " wlyy_health_bank_credits_detail bacd " +
                            " WHERE " +
                            " bacd.trade_direction = - 1 " +
                            " GROUP BY " +
                            " bacd.account_id ) bacd1 ON ba.id = bacd1.account_id " +*/
                            " )ba1 WHERE ba1.sum > "+accountDO1.getSum();
                    List<Map<String,Object>> rstotal5 = jdbcTemplate.queryForList(sql4);
                    Integer Count2 = 0;
@ -251,8 +232,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
    public MixEnvelop<AccountDO, AccountDO> findByCondition1(JSONArray patients, String ruleId, Integer page, Integer size){
        for (int i=0;i<patients.size();i++){
            String patientId = patients.getJSONObject(i).getString("code");
            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(patientId);
            if (accountDOS == null || accountDOS.size() == 0) {
                AccountDO accountDO1 = new AccountDO();
                accountDO1.setPatientId(patientId);
@ -318,7 +300,7 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
        String sql =
                "SELECT ba1.patient_id AS patient_id," +
                        "AES_DECRYPT(from_base64(ba1.account_name,"+ AesEncryptUtils.KEY+") AS account_name," +
                        "ba1.account_name AS account_name," +
                        "ba1.hospital AS hospital," +
                        "ba1.total AS total," +
                        "ba1.create_time AS create_time," +
@ -349,6 +331,7 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                        "LIMIT "+(page-1)*size+","+size +")ba1" +
                        " ORDER BY " +
                        " ba1.sum DESC";
        sql = TransforSqlUtl.accountName(sql);
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        String sqlCount = "SELECT count(1) AS total"+
                " FROM " +
@ -384,8 +367,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
     */
    public MixEnvelop<AccountDO, AccountDO> selectByPatient(String patient,String name,String hospital,String hospitalName,String idcard){
        MixEnvelop<AccountDO,AccountDO> envelop = new MixEnvelop<>();
        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patient+"'";
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patient+"'";
//        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        List<AccountDO> accountDOS = accountDao.selectsByPatientId(patient);
        if (accountDOS == null || accountDOS.size()==0){
            AccountDO accountDO = new AccountDO();
            accountDO.setTotal(0);

+ 97 - 97
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java

@ -12,6 +12,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -170,75 +171,75 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            accountDO = accountDao.save(accountDO);
        }
        ActivityDO activityDO = activityDao.selectByTemplateIdAndType(planCode,"健康计划");
       if (activityDO==null){
           activityDO = new ActivityDO();
           activityDO.setStatus(1);
           activityDO.setSaasId("dev");
           activityDO.setCreateTime(new Date());
           activityDO.setUpdateTime(new Date());
           activityDO.setOrganizer("SYSTEM");
           activityDO.setTitle(templateName);
           activityDO.setType("健康计划");
           activityDO.setDescription(templateName);
           activityDO.setGlobelTemplate(planCode);
           activityDO.setIntroduction(templateName);
           activityDO.setIsFlag(-1);
           activityDO.setDelFlag(1);
           activityDO =  activityDao.save(activityDO);
           TaskDO taskDO = new TaskDO();
           taskDO.setSaasId("dev");
           taskDO.setCreateTime(new Date());
           taskDO.setUpdateTime(new Date());
           taskDO.setTitle(templateName);
           taskDO.setType("ACTIVITY_TASK");
           taskDO.setTaskCode("ACTIVITY_PLAN");
           taskDO.setTransactionId(activityDO.getId());
           taskDO.setContent(templateName);
           taskDO.setStatus(1);
           taskDO = taskDao.save(taskDO);
           TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
           if (taskPatientDetailDO==null){
               taskPatientDetailDO = new TaskPatientDetailDO();
               taskPatientDetailDO.setSaasId("dev");
               taskPatientDetailDO.setTaskId(taskDO.getId());
               taskPatientDetailDO.setActivityId(activityDO.getId());
               taskPatientDetailDO.setPatientIdcard(idcard);
               taskPatientDetailDO.setPatientId(patient);
               taskPatientDetailDO.setHospital(hospital);
               taskPatientDetailDO.setHospitalName(hospitalName);
               taskPatientDetailDO.setCreateTime(new Date());
               taskPatientDetailDO.setUpdateTime(new Date());
               taskPatientDetailDO.setTotal(0L);
               taskPatientDetailDO.setCouponTotal(0L);
               taskPatientDetailDO.setStatus(1);
               taskPatientDetailDao.save(taskPatientDetailDO);
           }
       }else {
           List<TaskDO> taskDOS = taskDao.selectByActivityId(activityDO.getId());
           if (taskDOS!=null&&taskDOS.size()!=0){
               TaskDO taskDO = taskDOS.get(0);
               TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
               if (taskPatientDetailDO==null){
                   taskPatientDetailDO = new TaskPatientDetailDO();
                   taskPatientDetailDO.setSaasId("dev");
                   taskPatientDetailDO.setTaskId(taskDO.getId());
                   taskPatientDetailDO.setActivityId(activityDO.getId());
                   taskPatientDetailDO.setPatientIdcard(idcard);
                   taskPatientDetailDO.setPatientId(patient);
                   taskPatientDetailDO.setHospital(hospital);
                   taskPatientDetailDO.setHospitalName(hospitalName);
                   taskPatientDetailDO.setCreateTime(new Date());
                   taskPatientDetailDO.setUpdateTime(new Date());
                   taskPatientDetailDO.setTotal(0L);
                   taskPatientDetailDO.setCouponTotal(0L);
                   taskPatientDetailDO.setStatus(1);
                   taskPatientDetailDao.save(taskPatientDetailDO);
               }
           }
        if (activityDO==null){
            activityDO = new ActivityDO();
            activityDO.setStatus(1);
            activityDO.setSaasId("dev");
            activityDO.setCreateTime(new Date());
            activityDO.setUpdateTime(new Date());
            activityDO.setOrganizer("SYSTEM");
            activityDO.setTitle(templateName);
            activityDO.setType("健康计划");
            activityDO.setDescription(templateName);
            activityDO.setGlobelTemplate(planCode);
            activityDO.setIntroduction(templateName);
            activityDO.setIsFlag(-1);
            activityDO.setDelFlag(1);
            activityDO =  activityDao.save(activityDO);
            TaskDO taskDO = new TaskDO();
            taskDO.setSaasId("dev");
            taskDO.setCreateTime(new Date());
            taskDO.setUpdateTime(new Date());
            taskDO.setTitle(templateName);
            taskDO.setType("ACTIVITY_TASK");
            taskDO.setTaskCode("ACTIVITY_PLAN");
            taskDO.setTransactionId(activityDO.getId());
            taskDO.setContent(templateName);
            taskDO.setStatus(1);
            taskDO = taskDao.save(taskDO);
            TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
            if (taskPatientDetailDO==null){
                taskPatientDetailDO = new TaskPatientDetailDO();
                taskPatientDetailDO.setSaasId("dev");
                taskPatientDetailDO.setTaskId(taskDO.getId());
                taskPatientDetailDO.setActivityId(activityDO.getId());
                taskPatientDetailDO.setPatientIdcard(idcard);
                taskPatientDetailDO.setPatientId(patient);
                taskPatientDetailDO.setHospital(hospital);
                taskPatientDetailDO.setHospitalName(hospitalName);
                taskPatientDetailDO.setCreateTime(new Date());
                taskPatientDetailDO.setUpdateTime(new Date());
                taskPatientDetailDO.setTotal(0L);
                taskPatientDetailDO.setCouponTotal(0L);
                taskPatientDetailDO.setStatus(1);
                taskPatientDetailDao.save(taskPatientDetailDO);
            }
        }else {
            List<TaskDO> taskDOS = taskDao.selectByActivityId(activityDO.getId());
            if (taskDOS!=null&&taskDOS.size()!=0){
                TaskDO taskDO = taskDOS.get(0);
                TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
                if (taskPatientDetailDO==null){
                    taskPatientDetailDO = new TaskPatientDetailDO();
                    taskPatientDetailDO.setSaasId("dev");
                    taskPatientDetailDO.setTaskId(taskDO.getId());
                    taskPatientDetailDO.setActivityId(activityDO.getId());
                    taskPatientDetailDO.setPatientIdcard(idcard);
                    taskPatientDetailDO.setPatientId(patient);
                    taskPatientDetailDO.setHospital(hospital);
                    taskPatientDetailDO.setHospitalName(hospitalName);
                    taskPatientDetailDO.setCreateTime(new Date());
                    taskPatientDetailDO.setUpdateTime(new Date());
                    taskPatientDetailDO.setTotal(0L);
                    taskPatientDetailDO.setCouponTotal(0L);
                    taskPatientDetailDO.setStatus(1);
                    taskPatientDetailDao.save(taskPatientDetailDO);
                }
            }
       }
       envelop.setObj(activityDO);
       return envelop;
        }
        envelop.setObj(activityDO);
        return envelop;
    }
@ -274,10 +275,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            activityDO1.setTotal(count);
            String taskSql1 = "select * from wlyy_health_bank_task_patient_detail btpd where activity_id = '"+activityDO1.getId()
                    +"' and (patient_idcard = '"+ AesEncryptUtils.encrypt(activityDO.getPatientIdcard())+"' OR union_id = '"+activityDO.getUnionId()+"')";
            taskSql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(taskSql1);
            List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
                taskPatientDetailDO.setPatientIdcard(AesEncryptUtils.decrypt(taskPatientDetailDO.getPatientIdcard()));
            }
            activityDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
            String tasksql = "select * from wlyy_health_bank_task where transaction_id = '"+activityDO1.getId()+"'";
            List<TaskDO> taskDOList = jdbcTemplate.query(tasksql,new BeanPropertyRowMapper(TaskDO.class));
@ -534,31 +534,31 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
     */
    public MixEnvelop<Boolean, Boolean> daleteActivity(String id){
        MixEnvelop<Boolean, Boolean> envelop = new MixEnvelop<>();
            List<TaskDO> taskDOList = taskDao.selectByActivityId(id);
            for (TaskDO taskDO:taskDOList){
                taskDO.setStatus(0);
                taskDO.setCreateTime(new Date());
                taskDO.setUpdateTime(new Date());
                taskDao.save(taskDO);
            }
            List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByActivityId(id);
            for(TaskPatientDetailDO taskPatientDetailDO:taskPatientDetailDOS){
                taskPatientDetailDO.setStatus(-1);
                taskPatientDetailDO.setCreateTime(new Date());
                taskPatientDetailDO.setUpdateTime(new Date());
                taskPatientDetailDao.save(taskPatientDetailDO);
            }
            ActivityRuleDO ruleDO = activityRuleDao.selectByActivityId(id);
            if(null!=ruleDO){
                ruleDO.setDelFlag(0);
                activityRuleDao.save(ruleDO);
            }
            ActivityDO activityDO = activityDao.findOne(id);
            activityDO.setStatus(-1);
            activityDO.setCreateTime(new Date());
            activityDO.setUpdateTime(new Date());
            activityDO.setDelFlag(0);
            activityDao.save(activityDO);
        List<TaskDO> taskDOList = taskDao.selectByActivityId(id);
        for (TaskDO taskDO:taskDOList){
            taskDO.setStatus(0);
            taskDO.setCreateTime(new Date());
            taskDO.setUpdateTime(new Date());
            taskDao.save(taskDO);
        }
        List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByActivityId(id);
        for(TaskPatientDetailDO taskPatientDetailDO:taskPatientDetailDOS){
            taskPatientDetailDO.setStatus(-1);
            taskPatientDetailDO.setCreateTime(new Date());
            taskPatientDetailDO.setUpdateTime(new Date());
            taskPatientDetailDao.save(taskPatientDetailDO);
        }
        ActivityRuleDO ruleDO = activityRuleDao.selectByActivityId(id);
        if(null!=ruleDO){
            ruleDO.setDelFlag(0);
            activityRuleDao.save(ruleDO);
        }
        ActivityDO activityDO = activityDao.findOne(id);
        activityDO.setStatus(-1);
        activityDO.setCreateTime(new Date());
        activityDO.setUpdateTime(new Date());
        activityDO.setDelFlag(0);
        activityDao.save(activityDO);
        return envelop;
    }
@ -795,7 +795,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                " wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
                "' GROUP BY patient_id )btpd1 " +
                "WHERE " +
                 " btpd1.sum >= (SELECT SUM(s.total) as total " +
                " btpd1.sum >= (SELECT SUM(s.total) as total " +
                "FROM  wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND  s.activity_id='"+activityId+"')" +
                " ORDER BY btpd1.sum desc "+
                " limit "+countTotal1+",1" ;

+ 142 - 299
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java

@ -11,6 +11,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.Logger;
@ -70,13 +71,13 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    @Value("${account.initPassword}")
    private String initPassword;
   /**
    /**
     *  find creditsLogInfo
     *
     * @return
     * @throws ParseException
     */
   public MixEnvelop<CreditsDetailDO, CreditsDetailDO> findByCondition(CreditsDetailDO creditsDetailDO, Integer page, Integer size) throws ParseException {
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> findByCondition(CreditsDetailDO creditsDetailDO, Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(creditsDetailDO,page,size,"*");
        List<CreditsDetailDO> creditsDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        for (CreditsDetailDO creditsDetailDO1 : creditsDetailDOS){
@ -248,20 +249,6 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        return MixEnvelop.getSuccess(HealthBankMapping.api_success,accountDO);
    }
    /*
    public Envelop<Boolean> exchangeGoods(GoodsDO goodsDO){
        CreditsDetailDO creditsLogDetailDO = new CreditsDetailDO();
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
*/
    public MixEnvelop<AccountDO, AccountDO> selectByRanking(List<String> patientIds, Integer page, Integer size){
        StringBuffer buffer = new StringBuffer();
        buffer.append(" ba.patient_id in(");
@ -276,7 +263,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        buffer.append(") ");
        String sql =
                "SELECT ba1.patient_id AS patient_id," +
                        "AES_DECRYPT(from_base64(ba1.account_name,"+ AesEncryptUtils.KEY+") AS account_name," +
                        "ba1.account_name AS account_name," +
                        "ba1.hospital AS hospital," +
                        "ba1.total AS total," +
                        "ba1.create_time AS create_time," +
@ -307,6 +294,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        " ORDER BY " +
                        " ba1.total DESC"+
                        " LIMIT "+(page-1)*size+","+size ;
        sql = TransforSqlUtl.accountName(sql);
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        String sqlCount = "SELECT count(1) AS total"+
                " FROM " +
@ -344,8 +332,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> insert(CreditsDetailDO creditsDetailDO){
        try {
            synchronized (creditsDetailDO.getPatientId()){
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0){
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }else {
@ -366,7 +355,8 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                    accountDO1.setCreateTime(new Date());
                    accountDO1.setUpdateTime(new Date());
                    accountDao.save(accountDO1);
                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    List<AccountDO> accountDOS = accountDao.findByPatientId(creditsDetailDO.getPatientId());
//                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    creditsDetailDO.setAccountId(accountDOS.get(0).getId());
                }
                TaskDO taskDO = new TaskDO();
@ -381,8 +371,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                TaskRuleDO taskRuleDO = taskRuleDOS.get(0);
                creditsDetailDO.setIntegrate(taskRuleDO.getIntegrate());
                creditsDetailDO.setTradeDirection(taskRuleDO.getTradeDirection());
                String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDOList.get(0).getId()+"' and patient_id = '" + creditsDetailDO.getPatientId() +"'";
                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
//                String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDOList.get(0).getId()+"' and patient_id = '" + creditsDetailDO.getPatientId() +"'";
//                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndPatientId2(taskDOList.get(0).getId(),creditsDetailDO.getPatientId());
                if (taskPatientDetailDOS == null || taskPatientDetailDOS.size() ==0){
                    TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
                    taskPatientDetailDO.setTaskId(creditsDetailDO.getTransactionId());
@ -400,6 +391,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                }else if (taskPatientDetailDOS != null && taskDOList.get(0).getPeriod() == 0){
                    String taskSql1 = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDOList.get(0).getId()+
                            "' and patient_id = '"+creditsDetailDO.getPatientId()+"' and create_time > '" + DateUtils.getDayBegin() +"' and create_time < '"+ DateUtils.getDayEnd() +"'";
                    taskSql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(taskSql1);
                    List<TaskPatientDetailDO> taskPatientDetailDOS1 = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                    if (taskPatientDetailDOS1 == null || taskPatientDetailDOS1.size() == 0){
                        TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
@ -508,8 +500,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                " ORDER BY btpd1.total DESC "+" LIMIT " + (page-1)*size+","+size;
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
//            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(taskPatientDetailDO.getPatientId());
            taskPatientDetailDO.setAccountDO(accountDOS.get(0));
        }
        String sqlCount =  "SELECT " +
@ -632,28 +625,10 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        logger.info(taskPatientDetailDOS.toString()+""+taskPatientDetailDOS.size());
        for (int i = 0;taskPatientDetailDOS != null&&taskPatientDetailDOS.size()!=0 && i<taskPatientDetailDOS.size();i++){
            TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDOS.get(i);
            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
//            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(taskPatientDetailDO.getPatientId());
            if (taskPatientDetailDOS.get(i).getPatientId().equalsIgnoreCase(patientId)){
                /*String taskSql = "select count(1)+1 as total from (" +
                        "select *  from (SELECT " +
                        " SUM(ptpd.total) AS total, " +
                        " ptpd.patient_openid AS patient_openid, " +
                        " ptpd.task_id AS task_id, " +
                        " ptpd.activity_id AS activity_id, " +
                        " ptpd.create_time as create_time, " +
                        " ptpd.patient_id AS patient_id " +
                        " FROM " +
                        " wlyy_health_bank_task_patient_detail ptpd " +
                        " WHERE " +
                        " activity_id = '" + activityId + "')ptpd1 where" +
                        " ptpd1.patient_id = '"+patientId+"' AND ptpd1.total > "+taskPatientDetailDOS.get(i).getTotal()+") ptpd2";
                List<Map<String,Object>> rstotal1 = jdbcTemplate.queryForList(taskSql);
                Long count = 0L;
                if(rstotal1!=null&&rstotal1.size()>0){
                    count = (Long) rstotal1.get(0).get("total");
                }
                accountDOS.get(0).setActivityRanking(count);*/
                taskPatientDetailDO.setIsFlag(1);
            }else {
                taskPatientDetailDO.setIsFlag(0);
@ -730,25 +705,28 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                taskDO1 = taskDOList.get(0);
            }
            if (taskRuleDO.getPeriod() == 1){
                    String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"'";
                    List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                    if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                        throw new Exception("已奖励过");
                    }
//                    String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"'";
//                    List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndPatientId2(taskDO1.getId(),patientId);
                if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                    throw new Exception("已奖励过");
                }
            }else if (taskRuleDO.getPeriod() == 0){
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    Date date = new Date();
                    String date1 = dateFormat.format(date);
                    String begin = DateUtils.getMinMonthDate(date1);
                    String end = DateUtils.getMaxMonthDate(date1);
                    String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"' AND create_time > '"+begin+"' AND create_time < '"+end+"'";
                    List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                    if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                        throw new Exception("已奖励过");
                    }
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                String date1 = dateFormat.format(date);
                String begin = DateUtils.getMinMonthDate(date1);
                String end = DateUtils.getMaxMonthDate(date1);
                String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"' AND create_time > '"+begin+"' AND create_time < '"+end+"'";
                sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                    throw new Exception("已奖励过");
                }
            }
            String sql1 = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+"' " +
                    "AND patient_idcard = '"+AesEncryptUtils.encrypt(idCard)+"' AND patient_openid = '"+openId+"' AND union_id = '"+unionId+"'";
                    "AND patient_idcard = '"+ AesEncryptUtils.decrypt(idCard) +"' AND patient_openid = '"+openId+"' AND union_id = '"+unionId+"'";
            sql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql1);
            List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            TaskPatientDetailDO taskPatientDetailDO1 = new TaskPatientDetailDO();
            if (taskPatientDetailDOS.isEmpty() && taskPatientDetailDOS.size() == 0){
@ -767,8 +745,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
            }else {
                taskPatientDetailDO1 = taskPatientDetailDOS.get(0);
            }
            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(patientId);
            if (taskRuleDO.getTradeDirection() == -1 && taskRuleDO.getIntegrate() == 0){
                String integrateSql = "select * from wlyy_health_bank_credits_detail where patient_id = '"+patientId+"' " +
                        "AND transaction_id IN (SELECT id FROM wlyy_health_bank_task WHERE task_code IN ('BP_BIND','GLU_BIND','BP_MEASURE','GLU_MEASURE','RULE'))";
@ -849,46 +828,12 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        return envelop;
    }
    /**
     * 固定数据
     *
     * @param
     * @return
     *//*
    public List<TaskDO> getTasks(String patientId){
        List<TaskDO> taskDOList = new ArrayList<>();
        TaskDO taskDO = new TaskDO();
        *//*taskDO.setPatientId(patientId);*//*
        taskDO.setTaskCode("BIND");
        taskDO.setPeriod(1);
        taskDO.setTaskTitle("首次绑定");
        taskDO.setTaskContent("(绑定社区登记发放的设备,可获得各类型设备的首绑奖励。)");
        taskDO.setTradeType("activity");
        taskDO.setTransactionId("402885e96324a409016324c0a45a0006");
        taskDO.setCreateTime(new Date());
        taskDO.setUpdateTime(new Date());
        taskDOList.add(taskDO);
        TaskDO taskDO1 = new TaskDO();
        *//*taskDO1.setPatientId(patientId);*//*
        taskDO1.setTaskCode("MEASURE");
        taskDO1.setPeriod(0);
        taskDO1.setTaskTitle("每日测量");
        taskDO1.setTaskContent("(使用社区发放的已关联您身份信息的设备,绑定后每天完成测量)");
        taskDO1.setTradeType("activity");
        taskDO1.setTransactionId("402885e96324a409016324c0a45a0006");
        taskDO1.setCreateTime(new Date());
        taskDO1.setUpdateTime(new Date());
        taskDOList.add(taskDO1);
        return taskDOList;
    }
*/
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> stepAddIntegrate(CreditsDetailDO creditsDetailDO){
        try {
            synchronized (creditsDetailDO.getPatientId()){
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0){
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }else {
@ -910,11 +855,13 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                    accountDO1.setCreateTime(new Date());
                    accountDO1.setUpdateTime(new Date());
                    accountDao.save(accountDO1);
                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    List<AccountDO> accountDOS = accountDao.findByPatientId(creditsDetailDO.getPatientId());
//                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    creditsDetailDO.setAccountId(accountDOS.get(0).getId());
                }
                String sql1 = "select *  from wlyy_health_bank_task_patient_detail where "+
                        " patient_idcard = '"+AesEncryptUtils.encrypt(creditsDetailDO.getIdCard())+"' AND union_id = '"+creditsDetailDO.getUnionId()+"' AND task_id = '"+creditsDetailDO.getTransactionId()+"'";
                        " patient_idcard = '"+ AesEncryptUtils.encrypt(creditsDetailDO.getIdCard()) +"' AND union_id = '"+creditsDetailDO.getUnionId()+"' AND task_id = '"+creditsDetailDO.getTransactionId()+"'";
                sql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql1);
                List<TaskPatientDetailDO> taskPatientDetailDOList = jdbcTemplate.query(sql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                if(taskPatientDetailDOList == null || taskPatientDetailDOList.size()==0){
                    throw new Exception("该居民参与活动查不到!");
@ -988,100 +935,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        }
                    }
                }
          /*  for (int i = 0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                if (creditsDetailDOS != null && creditsDetailDOS.size() != 0){
                    CreditsDetailDO creditsDetailDO1 = creditsDetailDOS.get(0);
                    TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO.getRuleCode());
                    if (creditsDetailDO.getStepNumber() < step1 && creditsDetailDO.getStepNumber() >0){
                        creditsDetailDO1.setIntegrate(0);
                        creditsDetailDO1.setTradeDirection(1);
                        CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                        AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                        accountDO.setTotal(accountDO.getTotal()+creditsDetailDO2.getIntegrate());
                        AccountDO accountDO1 = accountDao.save(accountDO);
                        creditsDetailDO2.setTotal(accountDO1.getTotal());
                        taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+creditsDetailDO2.getIntegrate());
                        taskPatientDetailDao.save(taskPatientDetailDO);
                        creditsDetailDOS.clear();
                        creditsDetailDOS.add(creditsDetailDO2);
                    }else if (creditsDetailDO.getStepNumber() >= step1 && creditsDetailDO.getStepNumber() < step2){
                        creditsDetailDO1.setIntegrate(creditsDetailDO1.getIntegrate()+1);
                        creditsDetailDO1.setTradeDirection(1);
                        CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                        AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                        accountDO.setTotal(accountDO.getTotal()+(creditsDetailDO2.getIntegrate()));
                        AccountDO accountDO1 = accountDao.save(accountDO);
                        creditsDetailDO2.setTotal(accountDO1.getTotal());
                        taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+(creditsDetailDO2.getIntegrate()));
                        taskPatientDetailDao.save(taskPatientDetailDO);
                        creditsDetailDOS.clear();
                        creditsDetailDOS.add(creditsDetailDO2);
                    }else if (creditsDetailDO.getStepNumber() >= step2){
                        if (creditsDetailDO1.getIntegrate() == 1){
                            creditsDetailDO1.setIntegrate(2);
                            creditsDetailDO1.setTradeDirection(1);
                            CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                            AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                            accountDO.setTotal(accountDO.getTotal()+(creditsDetailDO2.getIntegrate()-1));
                            AccountDO accountDO1 = accountDao.save(accountDO);
                            creditsDetailDO2.setTotal(accountDO1.getTotal());
                            taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+(creditsDetailDO2.getIntegrate()-1));
                            taskPatientDetailDao.save(taskPatientDetailDO);
                            creditsDetailDOS.clear();
                            creditsDetailDOS.add(creditsDetailDO2);
                        }*//*else if(creditsDetailDO1.getIntegrate() == 3){
                            creditsDetailDO1.setIntegrate(creditsDetailDO1.getIntegrate()+5);
                            creditsDetailDO1.setTradeDirection(1);
                            CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                            AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                            accountDO.setTotal(accountDO.getTotal()+(creditsDetailDO2.getIntegrate()-3));
                            AccountDO accountDO1 = accountDao.save(accountDO);
                            creditsDetailDO2.setTotal(accountDO1.getTotal());
                            taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+(creditsDetailDO2.getIntegrate()-3));
                            taskPatientDetailDao.save(taskPatientDetailDO);
                            creditsDetailDOS.clear();
                            creditsDetailDOS.add(creditsDetailDO2);
                        }*//*
                    }
                }else{
                    CreditsDetailDO creditsDetailDO1 = new CreditsDetailDO();
                    if (creditsDetailDO.getStepNumber() < step1 && creditsDetailDO.getStepNumber() >0){
                        creditsDetailDO1.setIntegrate(0);
                        creditsDetailDO1.setTradeDirection(1);
                    }else if (creditsDetailDO.getStepNumber() >= step1 && creditsDetailDO.getStepNumber() < step2){
                        creditsDetailDO1.setIntegrate(1);
                        creditsDetailDO1.setTradeDirection(1);
                    }else if (creditsDetailDO.getStepNumber() >=step2){
                        creditsDetailDO1.setIntegrate(2);
                        creditsDetailDO1.setTradeDirection(1);
                    }
                    creditsDetailDO1.setSaasId("dev");
                    creditsDetailDO1.setTradeType("ACTIVITY_TASK");
                    creditsDetailDO1.setPatientId(creditsDetailDO.getPatientId());
                    creditsDetailDO1.setHospital(creditsDetailDO.getHospital());
                    creditsDetailDO1.setHospitalName(creditsDetailDO.getHospitalName());
                    creditsDetailDO1.setAccountId(creditsDetailDO.getAccountId());
                    creditsDetailDO1.setStatus(1);
                    creditsDetailDO1.setCreateTime(new Date());
                    creditsDetailDO1.setUpdateTime(new Date());
                    creditsDetailDO1.setTransactionId(taskPatientDetailDO.getTaskId());
                    CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                    AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                    accountDO.setTotal(accountDO.getTotal()+creditsDetailDO2.getIntegrate());
                    taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+creditsDetailDO2.getIntegrate());
                    taskPatientDetailDao.save(taskPatientDetailDO);
                    creditsDetailDO2.setTotal(accountDO.getTotal());
                    creditsDetailDOS.add(creditsDetailDO2);
                }*/
              /*  String step = redisTemplate.opsForValue().get(STEP);
                if (StringUtils.isEmpty(step)){
                    throw new Exception("获取步数失败!");
                }
                JSONObject object = JSONObject.parseObject(step);
                int step1 = object.getInteger("step1");
                int step2 = object.getInteger("step2");
*/
                try{
                    activeRecordService.insert("dev",creditsDetailDOS.get(0).getTransactionId(),null,null,null,creditsDetailDOS.get(0).getPatientId());
                }catch (Exception e){
@ -1103,8 +957,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        MixEnvelop envelop = new MixEnvelop<>();
        envelop.setObj(true);
        TaskDO taskDO =  taskDao.selectByTaskRuleId(ruleId);
        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patientId+"'";
        List<AccountDO> accountDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patientId+"'";
//        List<AccountDO> accountDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        List<AccountDO> accountDOs = accountDao.findByPatientId(patientId);
        AccountDO accountDO = null;
        if("add".equals(type)&&(accountDOs==null||accountDOs.size()==0)){
            //新建账户
@ -1130,106 +985,91 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
            accountDO = accountDOs.get(0);
        }
       if (taskDO == null){
           TaskRuleDO taskRuleDO =  taskRuleDao.findByCode(ruleId);
           TaskDO  taskDO1 = new TaskDO();
           taskDO1.setTitle(taskRuleDO.getName());
           taskDO1.setContent(taskRuleDO.getDescription());
           taskDO1.setSaasId("dev");
           taskDO1.setTaskCode("RULE");
           taskDO1.setType("RULE_TASK");
           taskDO1.setTransactionId(ruleId);
           taskDO1.setCreateTime(new Date());
           taskDO1.setUpdateTime(new Date());
           taskDO1.setRuleCode(taskRuleDO.getId());
           taskDO1.setStatus(1);
           taskDO = taskDao.save(taskDO1);
       }
       TaskPatientDetailDO patientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patientId);
       if (patientDetailDO == null){
           TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
           taskPatientDetailDO.setSaasId("dev");
           taskPatientDetailDO.setTaskId(taskDO.getId());
           taskPatientDetailDO.setPatientId(patientId);
           taskPatientDetailDO.setDoctorId(doctorId);
           taskPatientDetailDO.setPatientIdcard(accountDO.getIdCard());
           taskPatientDetailDO.setCreateTime(new Date());
           taskPatientDetailDO.setUpdateTime(new Date());
           taskPatientDetailDO.setStatus(1);
           taskPatientDetailDao.save(taskPatientDetailDO);
       }
        if (taskDO == null){
            TaskRuleDO taskRuleDO =  taskRuleDao.findByCode(ruleId);
            TaskDO  taskDO1 = new TaskDO();
            taskDO1.setTitle(taskRuleDO.getName());
            taskDO1.setContent(taskRuleDO.getDescription());
            taskDO1.setSaasId("dev");
            taskDO1.setTaskCode("RULE");
            taskDO1.setType("RULE_TASK");
            taskDO1.setTransactionId(ruleId);
            taskDO1.setCreateTime(new Date());
            taskDO1.setUpdateTime(new Date());
            taskDO1.setRuleCode(taskRuleDO.getId());
            taskDO1.setStatus(1);
            taskDO = taskDao.save(taskDO1);
        }
        TaskPatientDetailDO patientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patientId);
        if (patientDetailDO == null){
            TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
            taskPatientDetailDO.setSaasId("dev");
            taskPatientDetailDO.setTaskId(taskDO.getId());
            taskPatientDetailDO.setPatientId(patientId);
            taskPatientDetailDO.setDoctorId(doctorId);
            taskPatientDetailDO.setPatientIdcard(accountDO.getIdCard());
            taskPatientDetailDO.setCreateTime(new Date());
            taskPatientDetailDO.setUpdateTime(new Date());
            taskPatientDetailDO.setStatus(1);
            taskPatientDetailDao.save(taskPatientDetailDO);
        }
       if("add".equals(type)){
           CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
           creditsDetailDO.setAccountId(accountDO.getId());
           creditsDetailDO.setIdCard(accountDO.getIdCard());
           creditsDetailDO.setSaasId("dev");
           creditsDetailDO.setTradeType("ACTIVITY_TASK");
           creditsDetailDO.setTradeDirection(1);
           creditsDetailDO.setIntegrate(integrate);
           creditsDetailDO.setDescription(reason);
           creditsDetailDO.setStatus(1);
           creditsDetailDO.setHospital(hospital);
           creditsDetailDO.setHospitalName(hospitalName);
           creditsDetailDO.setCreateTime(new Date());
           creditsDetailDO.setUpdateTime(new Date());
           creditsDetailDO.setTransactionId(taskDO.getId());
           creditsDetailDO.setPatientId(patientId);
           creditsDetailDO.setHospitalName(hospitalName);
           credittsLogDetailDao.save(creditsDetailDO);
           accountDO.setTotal(accountDO.getTotal()+integrate);
           accountDao.save(accountDO);
       }else{
           if (accountDO.getTotal().compareTo(integrate)>=0){
               CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
               creditsDetailDO.setAccountId(accountDO.getId());
               creditsDetailDO.setIdCard(accountDO.getIdCard());
               creditsDetailDO.setSaasId("dev");
               creditsDetailDO.setTradeType("ACTIVITY_TASK");
               creditsDetailDO.setTradeDirection(-1);
               creditsDetailDO.setIntegrate(integrate);
               creditsDetailDO.setDescription(reason);
               creditsDetailDO.setStatus(1);
               creditsDetailDO.setHospital(hospital);
               creditsDetailDO.setHospitalName(hospitalName);
               creditsDetailDO.setCreateTime(new Date());
               creditsDetailDO.setUpdateTime(new Date());
               creditsDetailDO.setTransactionId(taskDO.getId());
               creditsDetailDO.setPatientId(patientId);
               creditsDetailDO.setHospitalName(hospitalName);
               credittsLogDetailDao.save(creditsDetailDO);
               accountDO.setTotal(accountDO.getTotal()-integrate);
               accountDao.save(accountDO);
           }else {
               envelop.setMessage("积分不足!");
               throw new Exception("积分不足!");
           }
       }
       return envelop;
    }
    /*public JSONObject getStepNumber(){
        String step = redisTemplate.·().get(STEP);
        logger.info("redis数据:"+step);
        String sql = ""
        String step1 = systemDictDao.
        logger.info("数据库的数据:"+step1);
        if (step != null && step.equalsIgnoreCase(step1)){
            JSONObject jsonObject = JSONObject.parseObject(step);
            logger.info("数据不一致:"+jsonObject.toString());
            return jsonObject;
        }else {
            JSONObject jsonObject = JSONObject.parseObject(step);
            redisTemplate.opsForValue().set(STEP,step1);
            logger.info("数据一致:"+jsonObject.toString());
            return jsonObject;
        if("add".equals(type)){
            CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
            creditsDetailDO.setAccountId(accountDO.getId());
            creditsDetailDO.setIdCard(accountDO.getIdCard());
            creditsDetailDO.setSaasId("dev");
            creditsDetailDO.setTradeType("ACTIVITY_TASK");
            creditsDetailDO.setTradeDirection(1);
            creditsDetailDO.setIntegrate(integrate);
            creditsDetailDO.setDescription(reason);
            creditsDetailDO.setStatus(1);
            creditsDetailDO.setHospital(hospital);
            creditsDetailDO.setHospitalName(hospitalName);
            creditsDetailDO.setCreateTime(new Date());
            creditsDetailDO.setUpdateTime(new Date());
            creditsDetailDO.setTransactionId(taskDO.getId());
            creditsDetailDO.setPatientId(patientId);
            creditsDetailDO.setHospitalName(hospitalName);
            credittsLogDetailDao.save(creditsDetailDO);
            accountDO.setTotal(accountDO.getTotal()+integrate);
            accountDao.save(accountDO);
        }else{
            if (accountDO.getTotal().compareTo(integrate)>=0){
                CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
                creditsDetailDO.setAccountId(accountDO.getId());
                creditsDetailDO.setIdCard(accountDO.getIdCard());
                creditsDetailDO.setSaasId("dev");
                creditsDetailDO.setTradeType("ACTIVITY_TASK");
                creditsDetailDO.setTradeDirection(-1);
                creditsDetailDO.setIntegrate(integrate);
                creditsDetailDO.setDescription(reason);
                creditsDetailDO.setStatus(1);
                creditsDetailDO.setHospital(hospital);
                creditsDetailDO.setHospitalName(hospitalName);
                creditsDetailDO.setCreateTime(new Date());
                creditsDetailDO.setUpdateTime(new Date());
                creditsDetailDO.setTransactionId(taskDO.getId());
                creditsDetailDO.setPatientId(patientId);
                creditsDetailDO.setHospitalName(hospitalName);
                credittsLogDetailDao.save(creditsDetailDO);
                accountDO.setTotal(accountDO.getTotal()-integrate);
                accountDao.save(accountDO);
            }else {
                envelop.setMessage("积分不足!");
                throw new Exception("积分不足!");
            }
        }
    }*/
        return envelop;
    }
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> weekReward(CreditsDetailDO creditsDetailDO) {
        try {
            synchronized (creditsDetailDO.getPatientId()) {
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0) {
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }
@ -1460,8 +1300,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> shareIntegrate(CreditsDetailDO creditsDetailDO) {
        try {
            synchronized (creditsDetailDO.getPatientId()) {
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0) {
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }
@ -1530,8 +1371,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                Boolean isShare = jsonObject.getBoolean("isshare");
                if (isShare){
                    JSONObject object = jsonObject.getJSONObject("shareData");
                    String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
                    List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//                    String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//                    List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
                    List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                    CreditsDetailDO creditsDetailDO1 = new CreditsDetailDO();
                    if (accountDOList != null && accountDOList.size() != 0) {
                        creditsDetailDO1.setAccountId(accountDOList.get(0).getId());
@ -1667,8 +1509,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> weekRewardAndIntegrate(CreditsDetailDO creditsDetailDO,Integer flag) {
        synchronized (creditsDetailDO.getPatientId()) {
            MixEnvelop<CreditsDetailDO, CreditsDetailDO> envelop = new MixEnvelop<>();
            String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
            List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//            String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//            List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
            if (accountDOList != null && accountDOList.size() != 0) {
                creditsDetailDO.setAccountId(accountDOList.get(0).getId());
            }
@ -1804,7 +1647,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql1);
                String idcard = null;
                if (maps!=null&&maps.size()!=0){
                    idcard = AesEncryptUtils.decrypt(maps.get(0).get("idcard").toString());
                    idcard = maps.get(0).get("idcard").toString();
                    accountDO.setIdCard(idcard);
                }
                TaskDO taskDO = taskDao.selectById("5e5d857d684d77f201684d7f58b3000a132");

+ 7 - 2
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskPatientDtailService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -77,8 +78,9 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        taskPatientDetailDO.setCreateTime(new Date());
        taskPatientDetailDO.setUpdateTime(new Date());
        taskPatientDetailDO.setStatus(Integer.parseInt("0"));
        String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
        List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
//        String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
//        List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
        List<AccountDO> accountDOS = accountDao.findByPatientId(taskPatientDetailDO.getPatientId());
        if (accountDOS == null || accountDOS.size() ==0){
            AccountDO accountDO = new AccountDO();
            accountDO.setSaasId("dev");
@ -153,6 +155,7 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        String sql ="select * from wlyy_health_bank_task_patient_detail where " +
                " (patient_idcard = '"+ AesEncryptUtils.encrypt(idCard)+"' OR union_id ='"+unionId+"') AND task_id IN " +
                "(select id from wlyy_health_bank_task where task_code = '"+taskCode+"' )";
        sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        logger.info("参与信息:"+taskPatientDetailDOS);
        if (taskPatientDetailDOS!=null&&taskPatientDetailDOS.size()!=0){
@ -168,6 +171,7 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        String sql ="select * from wlyy_health_bank_task_patient_detail where " +
                " (patient_idcard = '"+AesEncryptUtils.encrypt(idCard)+"' OR union_id ='"+unionId+"') AND task_id = '"+taskId+"'" ;
        sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        logger.info("参与信息:"+taskPatientDetailDOS);
        return taskPatientDetailDOS.get(0);
@ -184,6 +188,7 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
    public List<TaskPatientDetailDO> select(Integer page,Integer size){
        String sql ="SELECT * FROM `wlyy_health_bank_task_patient_detail` btpd " +
                "GROUP BY btpd.activity_id, btpd.patient_id ORDER BY btpd.create_time limit "+(page-1)*size+","+size;
        sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
        for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
            ActivityDO activityDO = activityDao.selectById(taskPatientDetailDO.getActivityId());

+ 82 - 78
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskService.java

@ -13,6 +13,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -96,41 +97,42 @@ public class TaskService extends BaseJpaService<TaskDO,TaskDao> {
     * @param size 分页大小
     * @return
     */
   public MixEnvelop<TaskDO, TaskDO> selectByCondition(TaskDO taskDO, Integer page, Integer size){
       TaskDO taskDO2 = new TaskDO();
       String sql = new ISqlUtils().getSql(taskDO,page,size,"*");
       List<TaskDO> taskDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
       for (TaskDO taskDO1:taskDOS){
           if (taskDO1.getType()!= null && taskDO1.getType().equalsIgnoreCase("ACTIVITY_TASK")){
               ActivityDO activityDO = activityDao.findOne(taskDO1.getTransactionId());
               taskDO1.setActivityDO(activityDO);
           }
           TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO1.getRuleCode());
           taskDO1.setRuleName(taskRuleDO.getName());
           //参与活动的详情
           String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+
                   "' and patient_openid = '"+taskDO.getOpenId()+"'";
           List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
           taskDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
           //参与人数
           String taskSql1 = "select count(1) as total from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+"'";
           List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(taskSql1);
           Long count = 0L;
           if(rstotal!=null&&rstotal.size()>0){
               count = (Long) rstotal.get(0).get("total");
           }
           taskDO1.setTotal(count);
           taskDO1.setPatientId(taskDO.getPatientId());
    public MixEnvelop<TaskDO, TaskDO> selectByCondition(TaskDO taskDO, Integer page, Integer size){
        TaskDO taskDO2 = new TaskDO();
        String sql = new ISqlUtils().getSql(taskDO,page,size,"*");
        List<TaskDO> taskDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
        for (TaskDO taskDO1:taskDOS){
            if (taskDO1.getType()!= null && taskDO1.getType().equalsIgnoreCase("ACTIVITY_TASK")){
                ActivityDO activityDO = activityDao.findOne(taskDO1.getTransactionId());
                taskDO1.setActivityDO(activityDO);
            }
            TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO1.getRuleCode());
            taskDO1.setRuleName(taskRuleDO.getName());
            //参与活动的详情
//           String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+
//                   "' and patient_openid = '"+taskDO.getOpenId()+"'";
//           List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndOpenid(taskDO1.getId(),taskDO.getOpenId());
            taskDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
            //参与人数
            String taskSql1 = "select count(1) as total from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+"'";
            List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(taskSql1);
            Long count = 0L;
            if(rstotal!=null&&rstotal.size()>0){
                count = (Long) rstotal.get(0).get("total");
            }
            taskDO1.setTotal(count);
            taskDO1.setPatientId(taskDO.getPatientId());
       }
       String sqlcount = new ISqlUtils().getSql(taskDO,0,0,"count");
       List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
       Long count = 0L;
       if(rstotal!=null&&rstotal.size()>0){
           count = (Long) rstotal.get(0).get("total");
       }
       return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOS,page,size,count);
   }
        }
        String sqlcount = new ISqlUtils().getSql(taskDO,0,0,"count");
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOS,page,size,count);
    }
    /**
     * 查看当前的任务
@ -140,50 +142,52 @@ public class TaskService extends BaseJpaService<TaskDO,TaskDao> {
     * @param size 分页大小
     * @return
     */
   public MixEnvelop<TaskDO, TaskDO> selectByTask(JSONArray array, String patientId, Integer page, Integer size){
       StringBuffer buffer = new StringBuffer();
       List<String> taskCodes = new ArrayList<>();
       for (int i=0;i<array.size();i++){
           taskCodes.add(array.getString(i));
       }
       buffer.append(" bt.task_code in(");
       if (taskCodes == null || taskCodes.size() == 0){
           buffer.append("''");
       }else {
           for (int i=0;i<taskCodes.size();i++){
               buffer.append("'"+taskCodes.get(i)+"'").append(",");
           }
           buffer.deleteCharAt(buffer.length()-1);
       }
       buffer.append(") ");
       String sql = "select * from wlyy_health_bank_task bt where "+buffer +" ORDER BY update_time DESC LIMIT "+(page-1)*size+","+size;
       List<TaskDO> taskDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
       for (TaskDO taskDO:taskDOList){
           if (taskDO.getType().equalsIgnoreCase("ACTIVITY_TASK")){
               ActivityDO activityDO = activityDao.findOne(taskDO.getTransactionId());
               taskDO.setActivityDO(activityDO);
           }
           if (taskDO.getPeriod() == 1){
               String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
                       "' and patient_id = '"+patientId+"'";
               List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
               taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
           }else if (taskDO.getPeriod() == 0){
               String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
                       "' and patient_id = '"+patientId+"' and create_time > '" + DateUtils.getDayBegin() +"' and create_time < '"+ DateUtils.getDayEnd() +"'";
               List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
               taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
           }
           taskDO.setPatientId(patientId);
       }
       String sqlcount = "select COUNT(1) AS  total from wlyy_health_bank_task bt where "+buffer ;
       List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
       Long count = 0L;
       if(rstotal!=null&&rstotal.size()>0){
           count = (Long) rstotal.get(0).get("total");
       }
       return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOList,page,size,count);
   }
    public MixEnvelop<TaskDO, TaskDO> selectByTask(JSONArray array, String patientId, Integer page, Integer size){
        StringBuffer buffer = new StringBuffer();
        List<String> taskCodes = new ArrayList<>();
        for (int i=0;i<array.size();i++){
            taskCodes.add(array.getString(i));
        }
        buffer.append(" bt.task_code in(");
        if (taskCodes == null || taskCodes.size() == 0){
            buffer.append("''");
        }else {
            for (int i=0;i<taskCodes.size();i++){
                buffer.append("'"+taskCodes.get(i)+"'").append(",");
            }
            buffer.deleteCharAt(buffer.length()-1);
        }
        buffer.append(") ");
        String sql = "select * from wlyy_health_bank_task bt where "+buffer +" ORDER BY update_time DESC LIMIT "+(page-1)*size+","+size;
        List<TaskDO> taskDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
        for (TaskDO taskDO:taskDOList){
            if (taskDO.getType().equalsIgnoreCase("ACTIVITY_TASK")){
                ActivityDO activityDO = activityDao.findOne(taskDO.getTransactionId());
                taskDO.setActivityDO(activityDO);
            }
            if (taskDO.getPeriod() == 1){
//               String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
//                       "' and patient_id = '"+patientId+"'";
//               List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndPatientId2(taskDO.getId(),patientId);
                taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
            }else if (taskDO.getPeriod() == 0){
                String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
                        "' and patient_id = '"+patientId+"' and create_time > '" + DateUtils.getDayBegin() +"' and create_time < '"+ DateUtils.getDayEnd() +"'";
                taskSql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(taskSql);
                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
            }
            taskDO.setPatientId(patientId);
        }
        String sqlcount = "select COUNT(1) AS  total from wlyy_health_bank_task bt where "+buffer ;
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOList,page,size,count);
    }
   /* public List<TaskDO> getTasks(String patientId){
       List<TaskDO> taskDOList = new ArrayList<>();
       TaskDO taskDO = new TaskDO();

+ 21 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/TransforSqlUtl.java

@ -0,0 +1,21 @@
package com.yihu.jw.util;
/**
 * Created by yeshijie on 2021/2/4.
 */
public class TransforSqlUtl {
    public static String accountName(String sql){
        return sql.replaceAll("ba1.account_name","CAST(AES_DECRYPT(from_base64(ba1.account_name),'jkzl2021ZJXL*#%a')AS char)");
    }
    public static String wlyyHealthBankAccountAll(String sql){
        String str = "*,CAST(AES_DECRYPT(from_base64(account_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS account_name ";
        return sql.replace("*",str);
    }
    public static String wlyyHealthBankTaskPatientDetailAll(String sql){
        String str = "*,CAST(AES_DECRYPT(from_base64(patient_idcard),'jkzl2021ZJXL*#%a') AS CHAR ) AS patient_idcard ";
        return sql.replace("*",str);
    }
}