Browse Source

Merge branch 'baseCopy1' of wangjun/wlyy2.0 into dev

wangzhinan 3 năm trước cách đây
mục cha
commit
48b912602b

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

@ -1,13 +1,17 @@
package com.yihu.jw.hospital.message.service;
import com.alibaba.fastjson.JSONObject;
import com.google.j2objc.annotations.AutoreleasePool;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.score.BaseEvaluateDO;
import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
import com.yihu.jw.entity.base.words.BaseSensitiveDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.httplog.BaseOperateLogDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import com.yihu.jw.entity.hospital.message.BaseUserMessageDO;
@ -15,6 +19,7 @@ import com.yihu.jw.entity.hospital.message.BaseUserMsgContentDO;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateDao;
import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.httplog.dao.BaseOperateLogDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.hospital.message.dao.BaseUserMessageDao;
@ -80,6 +85,10 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
    private StringRedisTemplate redisTemplate;
    @Autowired
    private BaseBannerDoctorService baseBannerDoctorService;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseOperateLogDao baseOperateLogDao;
    @Value("${wechat.id}")
    private String wxId;
@ -269,6 +278,18 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
            if (map.get("type")!=null){
                baseUserMsgDO.setType(Integer.valueOf(map.get("type").toString()));
            }
            String reciveDoctor=null==map.get("receiver")?"":map.get("receiver").toString();
            List<BaseDoctorHospitalDO> baseDoctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(reciveDoctor);
            if (baseDoctorHospitalDOS!=null&&baseDoctorHospitalDOS.size()>0){
                returnMap.put("deptName",baseDoctorHospitalDOS.get(0).getDeptName());
            }
            BaseDoctorDO baseDoctorDO=baseDoctorDao.findById(reciveDoctor);
            if (baseDoctorDO!=null){
                returnMap.put("doctorName",baseDoctorDO.getName());
                returnMap.put("doctorPhoto",baseDoctorDO.getPhoto());
                returnMap.put("jobtitleName",baseDoctorDO.getJobTitleName());
            }
            baseUserMsgDO.setReceiver(null==map.get("receiver")?"":map.get("receiver").toString());
            baseUserMsgDO.setReceiverName(null==map.get("receiver_name")?"":map.get("receiver_name").toString());
            baseUserMsgDO.setSender(null==map.get("sender")?"":map.get("sender").toString());
@ -282,6 +303,7 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
                }
            }
            baseUserMsgDO.setContent(content);
            baseUserMsgDO.setRelationCode(null==map.get("relation_code")?"":map.get("relation_code").toString());
            baseUserMsgDO.setRelationType(null==map.get("relation_type")?0:Integer.valueOf(map.get("relation_type").toString()));
@ -534,14 +556,45 @@ public class BaseUserMsgService extends BaseJpaService<BaseUserMessageDO, BaseUs
        if ("1".equalsIgnoreCase(isDelParent)){
            BaseUserMessageDO baseUserMessageDO = baseUserMessageDao.findOne(msgId);
            if (baseUserMessageDO!=null){
                BaseOperateLogDO baseOperateLogDO = new BaseOperateLogDO();
                JSONObject jsonObject = new JSONObject();
                baseUserMessageDO.setDel(0);
                baseUserMessageDao.save(baseUserMessageDO);
            }
        }else {
            BaseUserMsgContentDO baseUserMsgContentDO = baseUserMsgContentDao.findOne(msgId);
            if (baseUserMsgContentDO!=null){
                baseUserMsgContentDO.setDel(0);
                baseUserMsgContentDao.save(baseUserMsgContentDO);
                baseOperateLogDO.setOperator(baseUserMessageDO.getSender());
                baseOperateLogDO.setIsDel("0");
                List<BaseBannerDoctorDO> ba =  baseBannerDoctorDao.getBanners(baseUserMessageDO.getReceiver(),baseUserMessageDO.getSender(),baseUserMessageDO.getRelationCode());
                if(ba!=null&&ba.size()>0){
                    jsonObject.put("banners",ba);
                    baseBannerDoctorDao.delete(ba);
                }
                List<BaseEvaluateScoreDO> scoreList= baseEvaluateScoreDao.findByRelationCode(baseUserMessageDO.getRelationCode());
                if (scoreList!=null&&scoreList.size()>0){
                    for (BaseEvaluateScoreDO baseEvaluateScoreDO:scoreList){
                        List<BaseEvaluateDO> baseEvaluateDO=baseEvaluateDao.findByRelationCode(baseEvaluateScoreDO.getId());
                        jsonObject.put(baseEvaluateScoreDO.getId(),baseEvaluateDO);
                        if (baseEvaluateDO!=null&&baseEvaluateDO.size()>0){
                            baseEvaluateDao.delete(baseEvaluateDO);
                        }
                    }
                    jsonObject.put("scoreList",scoreList);
                    baseEvaluateScoreDao.delete(scoreList);
                }
                baseOperateLogDO.setRelationCode(baseUserMessageDO.getId());
                baseOperateLogDO.setName("删除留言评价");
                baseOperateLogDO.setRelationType(jsonObject.toString());
                try {
                    baseOperateLogDao.save(baseOperateLogDO);
                }catch (Exception e){
                    e.printStackTrace();
                }
                List<BaseUserMsgContentDO> contentlist=baseUserMsgContentDao.getContentListByID(msgId);
                for (BaseUserMsgContentDO baseUserMsgContentDO:contentlist){
                    baseUserMsgContentDO.setDel(0);
                    baseUserMsgContentDao.save(baseUserMsgContentDO);
                }
            }
        }
    }