陈昶聿
2 天以前 5e0e7ad230dfba76d00e224e27c8488383396e0e
【景宁】定时发送异常信息-景宁配置
已修改4个文件
已添加1个文件
183 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-ls.yml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/TemplateUtils.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -960,6 +960,13 @@
        ryTask.dealSubtaskDeadline(orgid, day);
        return AjaxResult.success("【dealSubtaskDeadline】同步任务已启动,天数为" + day + "天,请稍后查看结果");
    }
    @PostMapping("/sendExceptInfo")
    public AjaxResult sendExceptInfo() throws Exception {
        ryTask.sendExceptInfo();
        return AjaxResult.success("sendExceptInfo");
    }
    /**
     * å¸¦Redis缓存的统计查询,供patItem和patItemCount共用,条件不变时直接命中缓存
     */
ruoyi-admin/src/main/resources/application-ls.yml
@@ -257,7 +257,9 @@
isEncryp: 0
#文件上传地址
fileUpload: https://9.208.2.190:8092
#fileUpload: https://9.208.2.190:8092
#profile: /profile-api
fileUpload: https://221.12.19.26:8093
profile: /profile-api
# é¡¹ç›®ç›¸å…³é…ç½® ä¸½æ°´
ruoyi-common/src/main/java/com/ruoyi/common/utils/TemplateUtils.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,104 @@
package com.ruoyi.common.utils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TemplateUtils {
    private static final Pattern PATTERN = Pattern.compile("\\$\\{([^}]+)\\}");
    private static final ObjectMapper OM = new ObjectMapper();
    public static String render(String template, Object bean) {
        if (template == null || bean == null) {
            return template;
        }
        Matcher matcher = PATTERN.matcher(template);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            String exp = matcher.group(1);
            Object val = getValueByExp(bean, exp);
            String strVal = val == null ? "" : val.toString();
            matcher.appendReplacement(sb, Matcher.quoteReplacement(strVal));
        }
        matcher.appendTail(sb);
        return sb.toString();
    }
    private static Object getValueByExp(Object root, String exp) {
        try {
            Object curr = root;
            if (exp.contains("#json.")) {
                String[] parts = exp.split("#json\\.", 2);
                String beanField = parts[0];
                String jsonPath = parts[1];
                Object jsonStrObj = getBeanField(curr, beanField);
                // ========== Java8 å…¼å®¹ä¿®æ”¹ç‚¹ ==========
                if (!(jsonStrObj instanceof String)) {
                    return null;
                }
                String jsonStr = (String) jsonStrObj;
                if (jsonStr.trim().isEmpty()) {
                    return null;
                }
                JsonNode node = OM.readTree(jsonStr);
                return getJsonNode(node, jsonPath);
            }
            String[] props = exp.split("\\.");
            for (String p : props) {
                curr = getBeanField(curr, p);
                if (curr == null) {
                    break;
                }
            }
            return curr;
        } catch (Exception e) {
            return null;
        }
    }
    private static Object getBeanField(Object bean, String fieldName)
            throws IntrospectionException, InvocationTargetException, IllegalAccessException {
        if (bean == null) {
            return null;
        }
        PropertyDescriptor pd = new PropertyDescriptor(fieldName, bean.getClass());
        Method getter = pd.getReadMethod();
        return getter.invoke(bean);
    }
    private static Object getJsonNode(JsonNode node, String path) {
        String[] arr = path.split("\\.");
        JsonNode curr = node;
        for (String k : arr) {
            curr = curr.get(k);
            if (curr == null) {
                return null;
            }
        }
        return curr.isValueNode() ? curr.asText() : curr.toString();
    }
    // æµ‹è¯•
    public static void main(String[] args) {
        class User {
            private String name = "张三";
            private Integer age = 25;
            private String ext = "{\"phone\":\"13800138000\",\"addr\":{\"city\":\"杭州\"}}";
            public String getName() { return name; }
            public Integer getAge() { return age; }
            public String getExt() { return ext; }
        }
        User u = new User();
        String tpl = "姓名:${name},年龄:${age},手机号:${ext#json.phone},城市:${ext#json.addr.city}";
        System.out.println(render(tpl, u));
    }
}
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -8,6 +8,7 @@
import com.google.gson.Gson;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.service.IDingTalkService;
import com.ruoyi.common.dx.MessageSend;
@@ -23,6 +24,7 @@
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.smartor.common.LSHospTokenUtil;
import com.smartor.common.MtSubmitSmUtil;
import com.smartor.common.QwenLLMUtil;
@@ -108,6 +110,9 @@
    @Autowired
    private IDingTalkService dingTalkService;
    @Autowired
    private ISysUserService userService;
    @Value("${localIP}")
@@ -283,31 +288,67 @@
        subtaskDetailTraceVO.setHandleFlag("0");
        List<ServiceSubtaskDetailTrace> serviceSubtaskDetailTraces =
                serviceSubtaskDetailTraceService.selectServiceSubtaskDetailTtraceList(subtaskDetailTraceVO);
        // æŠŠ dutyDeptPersonCode æ•´ç†åˆ° list ä¸­ï¼ˆå¦‚果多个人用逗号分割,则展开并去重)
        List<String> dutyDeptPersonCodeList = serviceSubtaskDetailTraces.stream()
                .map(ServiceSubtaskDetailTrace::getDutyDeptPersonCode)
                .filter(StringUtils::isNotBlank)
                .flatMap(code -> Arrays.stream(code.split(",")))
                .map(String::trim)
                .filter(StringUtils::isNotBlank).distinct()  // åŽ»é‡
                .collect(Collectors.toList());
        // èŽ·å–â€œå¼‚å¸¸å†…å®¹æé†’"
        SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("send.except.content");
        String exceptContent = sysConfig.getConfigValue();
        // èŽ·å–â€œå†…å®¹æé†’æµ‹è¯•äººå·¥å·â€
        String testPerson = sysConfigMapper.checkConfigKeyUnique("send.test.person").getConfigValue();
        SysConfig testPersonConfig = sysConfigMapper.checkConfigKeyUnique("send.test.person");
        String testPerson = ObjectUtils.isNotEmpty(testPersonConfig) ? testPersonConfig.getConfigValue() : "";
        if(CollectionUtils.isNotEmpty(serviceSubtaskDetailTraces)){
            for (ServiceSubtaskDetailTrace serviceSubtaskDetailTrace : serviceSubtaskDetailTraces) {
                List<String> dutyDeptPersonCodeList = new ArrayList<>();
                        // æŠŠ dutyDeptPersonCode æ•´ç†åˆ° list ä¸­ï¼ˆå¦‚果多个人用逗号分割,则展开并去重)
                String dutyDeptPersonCodeStr = serviceSubtaskDetailTrace.getDutyDeptPersonCode();
                if(StringUtils.isNotEmpty(dutyDeptPersonCodeStr)){
                    String[] dutyDeptPersonCodeSplit = dutyDeptPersonCodeStr.split(",");
                    if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) {
                        dutyDeptPersonCodeList = new ArrayList<>(Arrays.asList(dutyDeptPersonCodeSplit));
                    } else {
                        dutyDeptPersonCodeList.addAll(Arrays.asList(dutyDeptPersonCodeSplit));
                    }
                }
        if (StringUtils.isNotBlank(testPerson)) {
            String[] split = testPerson.split(",");
            if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) dutyDeptPersonCodeList = Arrays.asList(split);
            else dutyDeptPersonCodeList.addAll(Arrays.asList(split));
                    if (CollectionUtils.isEmpty(dutyDeptPersonCodeList)) {
                        dutyDeptPersonCodeList = new ArrayList<>(Arrays.asList(split));
                    } else {
                        dutyDeptPersonCodeList.addAll(Arrays.asList(split));
                    }
        }
        if (CollectionUtils.isNotEmpty(dutyDeptPersonCodeList)) {
            for (String dutyDeptPersonCode : dutyDeptPersonCodeList) {
                log.info("【sendExceptInfo】发送人工号:{}", dutyDeptPersonCode);
                String dutyDeptPerson = dingTalkService.getDingTalkUserByMobile(dutyDeptPersonCode);
                dingTalkService.sendDingTalkText(exceptContent, dutyDeptPerson);
                        SysUser sysUser = new SysUser();
                        SysUser sysUserVo = new SysUser();
                        sysUserVo.setUserCode(dutyDeptPersonCode);
//                        sysUserVo.setOrgid(serviceSubtaskDetailTrace.getOrgid());
                        List<SysUser> users = userService.getUserList(sysUserVo);
                        String phoneNumber = "";
                        if(ObjectUtils.isNotEmpty(users)){
                            sysUser = users.get(0);
                            phoneNumber = sysUser.getPhonenumber();
                        }else {
                            continue;
                        }
                        if(StringUtils.isEmpty(phoneNumber)){
                            continue;
                        }
                        String dutyDeptPerson = dingTalkService.getDingTalkUserByMobile(phoneNumber);
                        if(StringUtils.isNotBlank(dutyDeptPerson)){
                            String context = TemplateUtils.render(exceptContent, serviceSubtaskDetailTrace);
                            dingTalkService.sendDingTalkText(context, dutyDeptPerson);
                            //更新状态
                            serviceSubtaskDetailTrace.setHandleFlag("1");
                            serviceSubtaskDetailTrace.setUpdateTime(new Date());
                            serviceSubtaskDetailTraceService.updateServiceSubtaskDetailTtrace(serviceSubtaskDetailTrace);
                        }
                    }
                }
            }
        }
    }
smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -260,6 +260,7 @@
        pmks.setDeptcheckFlag("0");
        pmks.setInhospstate("1");
        pmks.setFuflag("1");
        pmks.setPatid(16685L);
        List<PatMedInhosp> patMedInhosps = patMedInhospMapper.selectPatMedInhospList(pmks);
        //1.入院宣教