소스 검색

业务日志添加

lyr 8 년 전
부모
커밋
85bc1d92ad

+ 22 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/logs/BusinessLogs.java

@ -1,12 +1,13 @@
package com.yihu.wlyy.logs;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * 业务日志输出
 *
 * <p>
 * Created by lyr-pc on 2017/1/19.
 */
public class BusinessLogs {
@ -18,12 +19,8 @@ public class BusinessLogs {
     * 业务类型
     */
    public enum BusinessType {
        //注册
        register
        //签约
        , sign
        //咨询
        , consult
        consult
        //指导
        , guidance
        //健康教育
@ -42,9 +39,25 @@ public class BusinessLogs {
     * @param type 业务类别
     * @param info 日志信息
     */
    public static void info(BusinessType type, JSONObject info) {
        logger.info(type.ordinal() + " - " + info.toString());
    public static void info(BusinessType type, String user, JSONObject info) {
        try {
            logger.info(type.ordinal() + " - " + user + " - " + info.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 业务日志输出
     *
     * @param type 业务类别
     * @param info 日志信息
     */
    public static void info(BusinessType type, String user, JSONArray info) {
        try {
            logger.info(type.ordinal() + " - " + user + " - " + info.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -255,7 +255,7 @@ public class FollowUpService extends BaseService {
     * 新增随访计划(批量)
     */
    @Transactional
    public void addFollowupPlan(String doctorCode, String patientCode, String data) throws Exception {
    public Iterable<Followup> addFollowupPlan(String doctorCode, String patientCode, String data) throws Exception {
        //批量随访计划
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
@ -299,8 +299,10 @@ public class FollowUpService extends BaseService {
                followupPlan.add(followup);
            }
            followupDao.save(followupPlan);
            return followupDao.save(followupPlan);
        }
        return null;
    }

+ 9 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
@ -954,6 +955,7 @@ public class SignPatientLabelInfoService extends BaseService {
            }
        }
        JSONArray logArray = new JSONArray();
        JSONArray teams = adminTeamService.findPatientDoctorTeam(patient, doctor);
        List<String> teamCodes = new ArrayList<>();
@ -991,6 +993,7 @@ public class SignPatientLabelInfoService extends BaseService {
                healthLabel.setCzrq(new Date());
                labelInfoDao.save(healthLabel);
                logArray.put(new JSONObject(label));
            }
        } else {
            return -2;
@ -1034,6 +1037,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    disLabel.setCzrq(new Date());
                    labelInfoDao.save(disLabel);
                    logArray.put(new JSONObject(label));
                }
            }
        } else {
@ -1081,6 +1085,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    cusLabel.setCzrq(new Date());
                    labelInfoDao.save(cusLabel);
                    logArray.put(new JSONObject(label));
                }
            }
        }
@ -1103,6 +1108,7 @@ public class SignPatientLabelInfoService extends BaseService {
                disLabel.setCzrq(new Date());
                labelInfoDao.save(disLabel);
                logArray.put(new JSONObject("{\"labelCode\":\"1\",\"labelName\":\"慢病人群\",\"labelType\":\"1\"}"));
            }
        } else {
            int age = IdCardUtil.getAgeForIdcard(idcard);
@ -1131,9 +1137,12 @@ public class SignPatientLabelInfoService extends BaseService {
                disLabel.setLabelName(lbName);
                labelInfoDao.save(disLabel);
                logArray.put(new JSONObject("{\"labelCode\":\"" + lbCode + "\",\"labelName\":\"" + lbName + "\",\"labelType\":\"1\"}"));
            }
        }
        BusinessLogs.info(BusinessLogs.BusinessType.label, patient, logArray);
        return 1;
    }

+ 8 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.followup;
import java.util.*;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.service.app.followup.FollowUpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -116,7 +117,13 @@ public class DoctorFollowUpController extends BaseController {
                                  @ApiParam(name = "data", value = "随访计划列表json", defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
                                  @RequestParam(value = "data", required = true) String data) {
        try {
            followUpService.addFollowupPlan(getUID(), patient, data);
            Iterable<Followup> followups = followUpService.addFollowupPlan(getUID(), patient, data);
            if (followups != null) {
                for (Followup followup : followups) {
                    BusinessLogs.info(BusinessLogs.BusinessType.followup, followup.getPatientCode(), new JSONObject(followup));
                }
            }
            return write(200, "新增随访计划成功!");
        } catch (Exception e) {

+ 11 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -5,6 +5,7 @@ import java.util.*;
import com.yihu.wlyy.entity.education.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.health.*;
@ -75,6 +76,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    @Autowired
    ConsultService consultService;
    /**
     * 查询
     *
@ -383,7 +385,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                    // 行政团队
                    heap.setAdminTeamCode(signFamily.getAdminTeamId());
                    list.add(heap);
                    consultService.sendMucMessageBySingnType(doctor.getCode(),doctor.getName(), p, "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4","医生:"+doctor.getName()+"给患者:"+patientTemp.getName()+"发送了健康教育文章!");
                    consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", "医生:" + doctor.getName() + "给患者:" + patientTemp.getName() + "发送了健康教育文章!");
                    if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
                        // 推送消息给微信端
                        JSONObject json = new JSONObject();
@ -408,11 +410,16 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                return error(-1, "发送失败!");
            } else {
                for (String key : msgs.keySet()) {
                    Map<String,Object> map = msgs.get(key);
                    Map<String, Object> map = msgs.get(key);
                    PushMsgTask.getInstance().putWxMsg(getAccessToken(), 9,
                            map.get("openid") == null ? "":map.get("openid").toString(),
                            map.get("name") == null ? "":map.get("name").toString(),
                            map.get("openid") == null ? "" : map.get("openid").toString(),
                            map.get("name") == null ? "" : map.get("name").toString(),
                            (JSONObject) map.get("json"));
                    JSONObject json = (JSONObject) map.get("json");
                }
                for (HealthEduArticlePatient heap : list) {
                    BusinessLogs.info(BusinessLogs.BusinessType.article, heap.getPatient(), new JSONObject(heap));
                }
                // 推送消息给患者

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
@ -98,6 +99,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				Patient p = patientService.findByCode(patient);
				consultService.sendMucMessageBySingnType(getUID(),doctor.getName(),patient,content,"1","医生:"+doctor.getName()+"给患者:"+p.getName()+"发送了健康指导!");
				BusinessLogs.info(BusinessLogs.BusinessType.guidance, patient, new JSONObject(guidance));
				return success("保存成功!");
			} else {
				return error(-1, "保存失败!");

+ 15 - 13
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.util.*;
@ -326,7 +327,7 @@ public class ConsultController extends WeixinBaseController {
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);
        } catch (Exception ex) {
            error(ex);
@ -398,6 +399,7 @@ public class ConsultController extends WeixinBaseController {
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);
        } catch (Exception ex) {
            error(ex);
@ -591,7 +593,7 @@ public class ConsultController extends WeixinBaseController {
     */
    @RequestMapping(value = "append")
    @ResponseBody
    public String append(@RequestParam String consult, @RequestParam String content, @RequestParam int type,@RequestParam(required = false,defaultValue = "0") Integer times) {
    public String append(@RequestParam String consult, @RequestParam String content, @RequestParam int type, @RequestParam(required = false, defaultValue = "0") Integer times) {
        try {
            List<ConsultTeamLog> logs = new ArrayList<ConsultTeamLog>();
            ConsultTeam consultModel = consultTeamService.findByCode(consult);
@ -605,14 +607,14 @@ public class ConsultController extends WeixinBaseController {
            }
            String[] arr = null;
            if(type==3){
               String path =  fetchWxVoices();
               JSONObject obj = new JSONObject();
            if (type == 3) {
                String path = fetchWxVoices();
                JSONObject obj = new JSONObject();
                // 将临时语音拷贝到正式存储路径下
                if (StringUtils.isNotEmpty(path)) {
                    content = CommonUtil.copyTempVoice(path);
                    obj.put("path",content);
                    obj.put("times",times);
                    obj.put("path", content);
                    obj.put("times", times);
                    content = obj.toString();
                }
                ConsultTeamLog log = new ConsultTeamLog();
@ -622,9 +624,9 @@ public class ConsultController extends WeixinBaseController {
                log.setChatType(type);
                log.setType(3);
                logs.add(log);
            }else if (type == 2) {
            } else if (type == 2) {
                // 图片消息
                content =  fetchWxImages();
                content = fetchWxImages();
                // 将临时图片拷贝到正式存储路径下
                if (StringUtils.isNotEmpty(content)) {
                    content = CommonUtil.copyTempImage(content);
@ -658,11 +660,11 @@ public class ConsultController extends WeixinBaseController {
            List<String> failed = new ArrayList<>();
            for (ConsultTeamLog log : logs) {
                String response = ImUtill.sendTopicIM(getUID(),patient.getName(),consult,String.valueOf(log.getType()),log.getContent());
                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
                if (StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = new JSONObject(response);
                    if(resObj.getInt("status")==-1){
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!"+resObj.getString("message"));
                    if (resObj.getInt("status") == -1) {
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                }
@ -690,7 +692,7 @@ public class ConsultController extends WeixinBaseController {
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            JSONObject messageObj =  ImUtill.getTopicMessage(consultModel.getConsult(),consultModel.getStartMsgId(),consultModel.getEndMsgId(),page,pagesize,getUID());
            JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getUID());
            return write(200, "查询成功", "list", messageObj);
        } catch (Exception e) {
            error(e);

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.web.third;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
@ -296,6 +297,7 @@ public class BookingController extends WeixinBaseController {
//				} else {
//					//发送成功,保存到数据库
//				}
                BusinessLogs.info(BusinessLogs.BusinessType.appointment, p.getCode(), new JSONObject(obj));
                return write(200, "创建挂号单成功!");
            } else {
                return error(-1, "创建挂号单失败!");
@ -421,6 +423,7 @@ public class BookingController extends WeixinBaseController {
                    else{
                        des +=" 微信提醒失败,患者无绑定微信!";
                    }
                    BusinessLogs.info(BusinessLogs.BusinessType.appointment, p.getCode(), new JSONObject(obj));
                }
                catch (Exception ex)
                {