Browse Source

留言修改

wangjun 4 năm trước cách đây
mục cha
commit
cc62a6d64b

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

@ -29,6 +29,8 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
import javax.imageio.ImageIO;
import javax.transaction.Transactional;
import javax.transaction.Transactional;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.core.ValueOperations;
@ -64,10 +66,12 @@ public class BaseBannerDoctorService
        ObjEnvelop objEnvelop = new ObjEnvelop();
        ObjEnvelop objEnvelop = new ObjEnvelop();
        BasePatientDO basePatientDO = this.patientDao.findById(patientId);
        BasePatientDO basePatientDO = this.patientDao.findById(patientId);
        boolean checkTimeOut = checkGiveTimeOut(patientId, doctor);
        boolean checkTimeOut = checkGiveTimeOut(patientId, doctor);
        boolean checkMessageTimeout = checkMessageTimeOut(patientId,doctor);
        if ((org.apache.commons.lang.StringUtils.isNotBlank(key)) && (org.apache.commons.lang.StringUtils.isNotBlank(value))) {
        if ((org.apache.commons.lang.StringUtils.isNotBlank(key)) && (org.apache.commons.lang.StringUtils.isNotBlank(value))) {
            if (verifyCaptcha(key, value))
            if (verifyCaptcha(key, value))
            {
            {
                checkTimeOut = true;
                checkTimeOut = true;
                checkMessageTimeout = true;
            }
            }
            else
            else
            {
            {
@ -118,6 +122,33 @@ public class BaseBannerDoctorService
                    baseUserMessageDO.setType(type);
                    baseUserMessageDO.setType(type);
                    baseUserMessageDO.setIsRead(Integer.valueOf(0));
                    baseUserMessageDO.setIsRead(Integer.valueOf(0));
                    this.baseUserMessageDao.save(baseUserMessageDO);
                    this.baseUserMessageDao.save(baseUserMessageDO);
                }else {
                    if(checkMessageTimes(patientId,doctor)){
                        if (checkMessageTimeout){
                            BaseUserMessageDO baseUserMessageDO = new BaseUserMessageDO();
                            baseUserMessageDO.setReceiver(doctor);
                            baseUserMessageDO.setContent(content);
                            baseUserMessageDO.setReceiverName(doctorName);
                            baseUserMessageDO.setRelationCode(relationCode);
                            baseUserMessageDO.setSender(patientId);
                            baseUserMessageDO.setSenderName(patientName);
                            baseUserMessageDO.setRelationName("赠送锦旗");
                            baseUserMessageDO.setRelationType(Integer.valueOf(2));
                            baseUserMessageDO.setStatus(Integer.valueOf(1));
                            baseUserMessageDO.setDel(Integer.valueOf(1));
                            baseUserMessageDO.setType(type);
                            baseUserMessageDO.setIsRead(Integer.valueOf(0));
                            objEnvelop.setMessage("success");
                        }else {
                            objEnvelop.setMessage("生成验证码");
                            objEnvelop.setObj(generateCaptcha());
                            return objEnvelop;
                        }
                    }else {
                        objEnvelop.setMessage("当天总送锦旗留言次数已达上限");
                        objEnvelop.setStatus(Integer.valueOf(77));
                        return objEnvelop;
                    }
                }
                }
            }
            }
            else
            else
@ -319,4 +350,52 @@ public class BaseBannerDoctorService
        }
        }
        return pass;
        return pass;
    }
    }
    public boolean checkMessageTimeOut(String sender, String reciver)
    {
        List<BaseUserMessageDO> baseBannerDoctorDOS = this.baseUserMessageDao.getMessageByPatientAndDoctor(reciver, sender);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("leave_message_timeout");
        if (null != baseBannerDoctorDOS)
        {
            BaseUserMessageDO lastOne = (BaseUserMessageDO)baseBannerDoctorDOS.get(0);
            Date lastDate = lastOne.getCreateTime();
            long timeOut = wlyyHospitalSysDictDO.getDictValue() != null ? Long.valueOf(wlyyHospitalSysDictDO.getDictValue()).longValue() : 5L;
            Date current = new Date();
            if (current.getTime() - lastDate.getTime() > timeOut * 1000L * 60L) {
                return true;
            }
            return false;
        }
        return true;
    }
    public boolean checkMessageTimes(String patientId, String doctorId)
    {
        StringBuffer sql = new StringBuffer();
        sql.append("select t.sender as \"sender\",t.receiver as \"receiver\" from base_user_message t");
        sql.append(" where 1=1 ");
        if (StringUtils.isNotBlank(patientId)) {
            sql.append(" and t.sender = '" + patientId + "'");
        }
        if (StringUtils.isNotBlank(doctorId)) {
            sql.append(" and t.receiver = '" + doctorId + "'");
        }
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String strDate = format.format(date);
        sql.append(" and t.create_time > '" + strDate + " 00:00:00' and t.create_time<'" + strDate + " 23:59:59'");
        List<Map<String, Object>> list = this.hibenateUtils.createSQLQuery(sql.toString());
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("leave_message_times");
        long countTimes = 5L;
        if (wlyyHospitalSysDictDO != null) {
            countTimes = wlyyHospitalSysDictDO.getDictValue() == null ? countTimes : Long.valueOf(wlyyHospitalSysDictDO.getDictValue()).longValue();
        }
        if (list.size() > countTimes) {
            return false;
        }
        return true;
    }
}
}

+ 13 - 13
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseUserMsgService.java

@ -473,22 +473,22 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        return sql.toString();
        return sql.toString();
    }
    }
    public boolean checkGiveTimeOut(String sender, String reciver)
    public boolean checkGiveTimeOut(String sender, String reciver)
{
    List<BaseUserMessageDO> baseBannerDoctorDOS = this.baseUserMessageDao.getMessageByPatientAndDoctor(reciver, sender);
    WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("leave_message_timeout");
    if (null != baseBannerDoctorDOS)
    {
    {
        List<BaseUserMessageDO> baseBannerDoctorDOS = this.baseUserMessageDao.getMessageByPatientAndDoctor(reciver, sender);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = this.wlyyHospitalSysDictDao.findById("leave_message_timeout");
        if (null != baseBannerDoctorDOS)
        {
            BaseUserMessageDO lastOne = (BaseUserMessageDO)baseBannerDoctorDOS.get(0);
            Date lastDate = lastOne.getCreateTime();
            long timeOut = wlyyHospitalSysDictDO.getDictValue() != null ? Long.valueOf(wlyyHospitalSysDictDO.getDictValue()).longValue() : 5L;
            Date current = new Date();
            if (current.getTime() - lastDate.getTime() > timeOut * 1000L * 60L) {
                return true;
            }
            return false;
        BaseUserMessageDO lastOne = (BaseUserMessageDO)baseBannerDoctorDOS.get(0);
        Date lastDate = lastOne.getCreateTime();
        long timeOut = wlyyHospitalSysDictDO.getDictValue() != null ? Long.valueOf(wlyyHospitalSysDictDO.getDictValue()).longValue() : 5L;
        Date current = new Date();
        if (current.getTime() - lastDate.getTime() > timeOut * 1000L * 60L) {
            return true;
        }
        }
        return true;
        return false;
    }
    }
    return true;
}
    public boolean checkGiveTimes(String patientId, String doctorId)
    public boolean checkGiveTimes(String patientId, String doctorId)
    {
    {

+ 4 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/message/BannerDoctorController.java

@ -45,13 +45,13 @@ public class BannerDoctorController extends EnvelopRestEndpoint {
                                  @RequestParam(value = "key", required = false)String key,
                                  @RequestParam(value = "key", required = false)String key,
                                 @ApiParam(name = "value", value = "value", required = false)
                                 @ApiParam(name = "value", value = "value", required = false)
                                  @RequestParam(value = "value", required = false)String value) throws Exception{
                                  @RequestParam(value = "value", required = false)String value) throws Exception{
        List<BaseBannerDoctorDO> resultList = new ArrayList<>();
        ObjEnvelop objEnvelop = new ObjEnvelop();
        ObjEnvelop objEnvelop = new ObjEnvelop();
        List<String> list = new ArrayList<>();
        if(StringUtils.isNotEmpty(bannerIds)){
        if(StringUtils.isNotEmpty(bannerIds)){
            List<String> list =  Arrays.asList(bannerIds.split(","));
            String patientId= getUID();
            objEnvelop = baseBannerDoctorService.bannerGive(patientId,list,content,doctor,doctorName,type,key,value);
            list =  Arrays.asList(bannerIds.split(","));
        }
        }
        String patientId= getUID();
        objEnvelop = baseBannerDoctorService.bannerGive(patientId,list,content,doctor,doctorName,type,key,value);
    return objEnvelop;
    return objEnvelop;
    }
    }
    @ApiOperation("查询赠送锦旗")
    @ApiOperation("查询赠送锦旗")