Zimo 2 недель назад
Родитель
Сommit
1347be9e03
15 измененных файлов с 853 добавлено и 5 удалено
  1. 6 0
      yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java
  2. 20 1
      yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
  3. 5 0
      yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/Base64Util.java
  4. 98 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/EhrNoticeController.java
  5. 43 4
      yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/TodoController.java
  6. 67 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrNoticePageReqVO.java
  7. 83 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrNoticeRespVO.java
  8. 61 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrNoticeSaveReqVO.java
  9. 18 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrTodoVo.java
  10. 88 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/dal/dataobject/EhrNoticeDO.java
  11. 39 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/dal/mysql/EhrNoticeMapper.java
  12. 191 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/rest/EhrRest.java
  13. 55 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/ehr/EhrNoticeService.java
  14. 73 0
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/ehr/EhrNoticeServiceImpl.java
  15. 6 0
      yudao-server/src/main/resources/application-dev.yaml

+ 6 - 0
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java

@@ -99,6 +99,12 @@ public interface AdminAuthService {
      * @return token
      */
     String srmSsoToken(AuthOaLoginReqVO reqVO);
+
+    /**
+     * ehr token 获取
+     * @return token
+     */
+    String ehrSsoToken();
     /**
      * 免登录 pms
      *

+ 20 - 1
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.system.service.auth;
 
+import cn.hutool.core.codec.Base64Encoder;
 import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -101,7 +102,6 @@ public class AdminAuthServiceImpl implements AdminAuthService {
 
     @Value("${srm.ssoToken}")
     private String srmSsoTokenUrl;
-
     @Value("${pms.ssoToken}")
     private String pmsSsoToken;
 
@@ -121,6 +121,13 @@ public class AdminAuthServiceImpl implements AdminAuthService {
     private String ehrUrl;
     @Value("${ehr.home}")
     private String ehrHome;
+    @Value("${ehr.ssoToken}")
+    private String ehrSsoTokenUrl;
+    @Value("${ehr.appid}")
+    private String ehrAppid;
+    @Value("${ehr.appSecret}")
+    private String ehrAppSecret;
+
 
 
     @Value("${zentao.code}")
@@ -408,6 +415,18 @@ public class AdminAuthServiceImpl implements AdminAuthService {
         return result;
     }
 
+    @Override
+    public String ehrSsoToken() {
+        RestTemplate restTemplate = SslSkippingRestTemplate.createRestTemplate();
+        String encode = Base64Encoder.encode(ehrAppid+":"+ehrAppSecret);
+        HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.add("Authorization",  "Basic " + encode);
+        HttpEntity<MultiValueMap<String, String>> ehrRequestEntity = new HttpEntity<>(httpHeaders);
+        String result = restTemplate.postForObject(ehrUrl+ehrSsoTokenUrl+"?grant_type=client_credentials&scope=client", ehrRequestEntity, String.class);
+        System.out.println("result ehr token:" + result);
+        return result;
+    }
+
     @Override
     public ImmutableMap ehrLogin(AuthOaLoginReqVO reqVO) throws Exception {
         String workcode = reqVO.getUsername();

+ 5 - 0
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/util/Base64Util.java

@@ -1,5 +1,9 @@
 package cn.iocoder.yudao.module.system.util;
 
+import cn.hutool.core.codec.Base64Encoder;
+
+import java.util.Base64;
+
 public class Base64Util {
 
     static private final int BASE_LENGTH = 128;
@@ -270,4 +274,5 @@ public class Base64Util {
         }
         return newSize;
     }
+
 }

+ 98 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/EhrNoticeController.java

@@ -0,0 +1,98 @@
+package cn.iocoder.yudao.server.controller.admin;
+
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticePageReqVO;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticeRespVO;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticeSaveReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.EhrNoticeDO;
+import cn.iocoder.yudao.server.service.ehr.EhrNoticeService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import java.util.*;
+import java.io.IOException;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
+
+
+@Tag(name = "管理后台 - EHR消息通知")
+@RestController
+@RequestMapping("/rq/iot-ehr-notice")
+@Validated
+public class EhrNoticeController {
+
+    @Resource
+    private EhrNoticeService iotEhrNoticeService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建EHR消息通知")
+    @PreAuthorize("@ss.hasPermission('rq:iot-ehr-notice:create')")
+    public CommonResult<Long> createIotEhrNotice(@Valid @RequestBody EhrNoticeSaveReqVO createReqVO) {
+        return success(iotEhrNoticeService.createIotEhrNotice(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新EHR消息通知")
+    @PreAuthorize("@ss.hasPermission('rq:iot-ehr-notice:update')")
+    public CommonResult<Boolean> updateIotEhrNotice(@Valid @RequestBody EhrNoticeSaveReqVO updateReqVO) {
+        iotEhrNoticeService.updateIotEhrNotice(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除EHR消息通知")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-ehr-notice:delete')")
+    public CommonResult<Boolean> deleteIotEhrNotice(@RequestParam("id") Long id) {
+        iotEhrNoticeService.deleteIotEhrNotice(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得EHR消息通知")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-ehr-notice:query')")
+    public CommonResult<EhrNoticeRespVO> getIotEhrNotice(@RequestParam("id") Long id) {
+        EhrNoticeDO iotEhrNotice = iotEhrNoticeService.getIotEhrNotice(id);
+        return success(BeanUtils.toBean(iotEhrNotice, EhrNoticeRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得EHR消息通知分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-ehr-notice:query')")
+    public CommonResult<PageResult<EhrNoticeRespVO>> getIotEhrNoticePage(@Valid EhrNoticePageReqVO pageReqVO) {
+        PageResult<EhrNoticeDO> pageResult = iotEhrNoticeService.getIotEhrNoticePage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, EhrNoticeRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出EHR消息通知 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-ehr-notice:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotEhrNoticeExcel(@Valid EhrNoticePageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<EhrNoticeDO> list = iotEhrNoticeService.getIotEhrNoticePage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "EHR消息通知.xls", "数据", EhrNoticeRespVO.class,
+                        BeanUtils.toBean(list, EhrNoticeRespVO.class));
+    }
+
+}

+ 43 - 4
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/TodoController.java

@@ -11,12 +11,10 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oa.IotOaPersonDO;
 import cn.iocoder.yudao.module.system.dal.mysql.oa.IotOaPersonMapper;
 import cn.iocoder.yudao.module.system.oa.OaFlow;
 import cn.iocoder.yudao.module.system.util.DingtalkUtil;
-import cn.iocoder.yudao.server.dal.dataobject.CrmNoticeDO;
-import cn.iocoder.yudao.server.dal.dataobject.CrmPersonDO;
-import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
-import cn.iocoder.yudao.server.dal.dataobject.SrmNoticeDO;
+import cn.iocoder.yudao.server.dal.dataobject.*;
 import cn.iocoder.yudao.server.dal.mysql.*;
 import cn.iocoder.yudao.server.rest.CrmRest;
+import cn.iocoder.yudao.server.rest.EhrRest;
 import cn.iocoder.yudao.server.rest.SrmRest;
 import cn.iocoder.yudao.server.service.PortalOaFlow;
 import com.google.common.collect.ImmutableMap;
@@ -33,6 +31,7 @@ import javax.annotation.security.PermitAll;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Tag(name = "管理后台 - 待办接口")
@@ -61,7 +60,11 @@ public class TodoController {
     @Autowired
     private SrmRest srmRest;
     @Autowired
+    private EhrRest ehrRest;
+    @Autowired
     private SrmNoticeMapper srmNoticeMapper;
+    @Autowired
+    private EhrNoticeMapper ehrNoticeMapper;
 
     @GetMapping("/oa")
     @PermitAll
@@ -134,6 +137,13 @@ public class TodoController {
         return CommonResult.success(srmToDoList);
     }
 
+    @GetMapping("/ehr")
+    @PermitAll
+    public CommonResult<Map<String, Object>> ehrTodo(String workcode, Integer pageNo, Integer pageSize) throws Exception {
+        Map<String, Object> srmToDoList = ehrRest.getEhrToDoList(workcode, pageNo, pageSize);
+        return CommonResult.success(srmToDoList);
+    }
+
     @GetMapping("/crm/notice")
     @PermitAll
     public CommonResult<List> crmNotice(String workcode) throws Exception {
@@ -174,6 +184,16 @@ public class TodoController {
         return CommonResult.success(srmNotice);
     }
 
+    @GetMapping("/ehr/notice")
+    @PermitAll
+    public CommonResult<List> ehrNotice(String workcode) throws Exception {
+        List<EhrNoticeDO> srmNotices = ehrNoticeMapper.selectList("work_code", workcode);
+        EhrNoticeDO newestNoticeDO = srmNotices.stream().max(Comparator.comparing(EhrNoticeDO::getEhrCreateTime))
+                .orElse(null);
+        List ehrNotice = ehrRest.getEhrNotice(workcode, newestNoticeDO);
+        return CommonResult.success(ehrNotice);
+    }
+
     @GetMapping("/oa/notice")
     @PermitAll
     public CommonResult<List> oaNotice(String workcode) throws Exception {
@@ -214,6 +234,13 @@ public class TodoController {
         return CommonResult.success(workCode.stream().sorted(Comparator.comparing(SrmNoticeDO::getSrmCreateTime).reversed()).collect(Collectors.toList()));
     }
 
+    @GetMapping("/ehr/notice/self")
+    @PermitAll
+    public CommonResult<List> ehrNoticeSelfSystem(String workcode) throws Exception {
+        List<EhrNoticeDO> workCode = ehrNoticeMapper.selectList("work_code", workcode);
+        return CommonResult.success(workCode.stream().sorted(Comparator.comparing(EhrNoticeDO::getEhrCreateTime).reversed()).collect(Collectors.toList()));
+    }
+
     @GetMapping("/crm/notice/readed")
     @PermitAll
     public CommonResult<String> crmNoticeReaded(String workcode) throws Exception {
@@ -238,6 +265,18 @@ public class TodoController {
         return CommonResult.success("完成已读");
     }
 
+    @GetMapping("/ehr/notice/readed")
+    @PermitAll
+    public CommonResult<String> ehrNoticeReaded(String workcode) throws Exception {
+        List<EhrNoticeDO> workCode = ehrNoticeMapper.selectList("work_code", workcode);
+        workCode.forEach(item -> {
+            //设置为已读
+            item.setStatus("1");
+            ehrNoticeMapper.updateById(item);
+        });
+        return CommonResult.success("完成已读");
+    }
+
     @GetMapping("/oa/notice/readed")
     @PermitAll
     public CommonResult<String> oaNoticeReaded(String workcode) throws Exception {

+ 67 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrNoticePageReqVO.java

@@ -0,0 +1,67 @@
+package cn.iocoder.yudao.server.controller.admin.vo.ehr;
+
+import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - EHR消息通知分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class EhrNoticePageReqVO extends PageParam {
+
+    @Schema(description = "srm的创建人")
+    private String ehrCreator;
+
+    @Schema(description = "srm的创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private String[] ehrCreateTime;
+
+    @Schema(description = "srm的创建人", example = "芋艿")
+    private String ehrCreateName;
+
+    @Schema(description = "流程id", example = "13621")
+    private String processId;
+
+    @Schema(description = "消息标题")
+    private String title;
+
+    @Schema(description = "摘要内容")
+    private String abstractContent;
+
+    @Schema(description = "是否已读")
+    private String hasRead;
+
+    @Schema(description = "消息类型", example = "2")
+    private String messageType;
+
+    @Schema(description = "具体内容")
+    private String contentText;
+
+    @Schema(description = "消息大类")
+    private String messageCategory;
+
+    @Schema(description = "app详情地址")
+    private String appDetail;
+
+    @Schema(description = "web详情地址")
+    private String webDetail;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "工号")
+    private String workCode;
+
+    @Schema(description = "ehr的消息主键id", example = "24964")
+    private String ehrNoticeId;
+
+    @Schema(description = "状态", example = "2")
+    private String status;
+
+}

+ 83 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrNoticeRespVO.java

@@ -0,0 +1,83 @@
+package cn.iocoder.yudao.server.controller.admin.vo.ehr;
+
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - EHR消息通知 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class EhrNoticeRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15688")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "srm的创建人")
+    @ExcelProperty("srm的创建人")
+    private String ehrCreator;
+
+    @Schema(description = "srm的创建时间")
+    @ExcelProperty("srm的创建时间")
+    private String ehrCreateTime;
+
+    @Schema(description = "srm的创建人", example = "芋艿")
+    @ExcelProperty("srm的创建人")
+    private String ehrCreateName;
+
+    @Schema(description = "流程id", example = "13621")
+    @ExcelProperty("流程id")
+    private String processId;
+
+    @Schema(description = "消息标题", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("消息标题")
+    private String title;
+
+    @Schema(description = "摘要内容")
+    @ExcelProperty("摘要内容")
+    private String abstractContent;
+
+    @Schema(description = "是否已读")
+    @ExcelProperty("是否已读")
+    private String hasRead;
+
+    @Schema(description = "消息类型", example = "2")
+    @ExcelProperty("消息类型")
+    private String messageType;
+
+    @Schema(description = "具体内容")
+    @ExcelProperty("具体内容")
+    private String contentText;
+
+    @Schema(description = "消息大类")
+    @ExcelProperty("消息大类")
+    private String messageCategory;
+
+    @Schema(description = "app详情地址")
+    @ExcelProperty("app详情地址")
+    private String appDetail;
+
+    @Schema(description = "web详情地址")
+    @ExcelProperty("web详情地址")
+    private String webDetail;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "工号")
+    @ExcelProperty("工号")
+    private String workCode;
+
+    @Schema(description = "ehr的消息主键id", example = "24964")
+    @ExcelProperty("ehr的消息主键id")
+    private String ehrNoticeId;
+
+    @Schema(description = "状态", example = "2")
+    @ExcelProperty("状态")
+    private String status;
+
+}

+ 61 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrNoticeSaveReqVO.java

@@ -0,0 +1,61 @@
+package cn.iocoder.yudao.server.controller.admin.vo.ehr;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+import javax.validation.constraints.NotEmpty;
+
+@Schema(description = "管理后台 - EHR消息通知新增/修改 Request VO")
+@Data
+public class EhrNoticeSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15688")
+    private Long id;
+
+    @Schema(description = "srm的创建人")
+    private String ehrCreator;
+
+    @Schema(description = "srm的创建时间")
+    private String ehrCreateTime;
+
+    @Schema(description = "srm的创建人", example = "芋艿")
+    private String ehrCreateName;
+
+    @Schema(description = "流程id", example = "13621")
+    private String processId;
+
+    @Schema(description = "消息标题", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "消息标题不能为空")
+    private String title;
+
+    @Schema(description = "摘要内容")
+    private String abstractContent;
+
+    @Schema(description = "是否已读")
+    private String hasRead;
+
+    @Schema(description = "消息类型", example = "2")
+    private String messageType;
+
+    @Schema(description = "具体内容")
+    private String contentText;
+
+    @Schema(description = "消息大类")
+    private String messageCategory;
+
+    @Schema(description = "app详情地址")
+    private String appDetail;
+
+    @Schema(description = "web详情地址")
+    private String webDetail;
+
+    @Schema(description = "工号")
+    private String workCode;
+
+    @Schema(description = "ehr的消息主键id", example = "24964")
+    private String ehrNoticeId;
+
+    @Schema(description = "状态", example = "2")
+    private String status;
+
+}

+ 18 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/ehr/EhrTodoVo.java

@@ -0,0 +1,18 @@
+package cn.iocoder.yudao.server.controller.admin.vo.ehr;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class EhrTodoVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private String id;
+    private Long createTime;
+    private String initiator;
+    private String title;
+    private String content;
+    private String web_url;
+    private String h5_url;
+    private String staffId;
+}

+ 88 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/dal/dataobject/EhrNoticeDO.java

@@ -0,0 +1,88 @@
+package cn.iocoder.yudao.server.dal.dataobject;
+
+import lombok.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * EHR消息通知 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_ehr_notice")
+@KeySequence("rq_iot_ehr_notice_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class EhrNoticeDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * srm的创建人
+     */
+    private String ehrCreator;
+    /**
+     * srm的创建时间
+     */
+    private String ehrCreateTime;
+    /**
+     * srm的创建人
+     */
+    private String ehrCreateName;
+    /**
+     * 流程id
+     */
+    private String processId;
+    /**
+     * 消息标题
+     */
+    private String title;
+    /**
+     * 摘要内容
+     */
+    private String abstractContent;
+    /**
+     * 是否已读
+     */
+    private String hasRead;
+    /**
+     * 消息类型
+     */
+    private String messageType;
+    /**
+     * 具体内容
+     */
+    private String contentText;
+    /**
+     * 消息大类
+     */
+    private String messageCategory;
+    /**
+     * app详情地址
+     */
+    private String appDetail;
+    /**
+     * web详情地址
+     */
+    private String webDetail;
+    /**
+     * 工号
+     */
+    private String workCode;
+    /**
+     * ehr的消息主键id
+     */
+    private String ehrNoticeId;
+    /**
+     * 状态
+     */
+    private String status;
+
+}

+ 39 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/dal/mysql/EhrNoticeMapper.java

@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.server.dal.mysql;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticePageReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.EhrNoticeDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * EHR消息通知 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface EhrNoticeMapper extends BaseMapperX<EhrNoticeDO> {
+
+    default PageResult<EhrNoticeDO> selectPage(EhrNoticePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<EhrNoticeDO>()
+                .eqIfPresent(EhrNoticeDO::getEhrCreator, reqVO.getEhrCreator())
+                .betweenIfPresent(EhrNoticeDO::getEhrCreateTime, reqVO.getEhrCreateTime())
+                .likeIfPresent(EhrNoticeDO::getEhrCreateName, reqVO.getEhrCreateName())
+                .eqIfPresent(EhrNoticeDO::getProcessId, reqVO.getProcessId())
+                .eqIfPresent(EhrNoticeDO::getTitle, reqVO.getTitle())
+                .eqIfPresent(EhrNoticeDO::getAbstractContent, reqVO.getAbstractContent())
+                .eqIfPresent(EhrNoticeDO::getHasRead, reqVO.getHasRead())
+                .eqIfPresent(EhrNoticeDO::getMessageType, reqVO.getMessageType())
+                .eqIfPresent(EhrNoticeDO::getContentText, reqVO.getContentText())
+                .eqIfPresent(EhrNoticeDO::getMessageCategory, reqVO.getMessageCategory())
+                .eqIfPresent(EhrNoticeDO::getAppDetail, reqVO.getAppDetail())
+                .eqIfPresent(EhrNoticeDO::getWebDetail, reqVO.getWebDetail())
+                .betweenIfPresent(EhrNoticeDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(EhrNoticeDO::getWorkCode, reqVO.getWorkCode())
+                .eqIfPresent(EhrNoticeDO::getEhrNoticeId, reqVO.getEhrNoticeId())
+                .eqIfPresent(EhrNoticeDO::getStatus, reqVO.getStatus())
+                .orderByDesc(EhrNoticeDO::getId));
+    }
+
+}

+ 191 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/rest/EhrRest.java

@@ -0,0 +1,191 @@
+package cn.iocoder.yudao.server.rest;
+
+import cn.hutool.core.date.DatePattern;
+import cn.hutool.core.date.DateUtil;
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.util.date.DateUtils;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthOaLoginReqVO;
+import cn.iocoder.yudao.module.system.oa.SslSkippingRestTemplate;
+import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
+import cn.iocoder.yudao.server.controller.admin.vo.crm.CrmTodoVo;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrTodoVo;
+import cn.iocoder.yudao.server.dal.dataobject.EhrNoticeDO;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
+import cn.iocoder.yudao.server.dal.dataobject.SrmNoticeDO;
+import cn.iocoder.yudao.server.dal.mysql.EhrNoticeMapper;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.ImmutableMap;
+import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.Resource;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+public class EhrRest {
+    @Resource
+    private AdminAuthService authService;
+    @Value("${ehr.todoUrl}")
+    private String ehrTodoUrl;
+    @Value("${ehr.url}")
+    private String ehrUrl;
+    @Value("${ehr.userInfo}")
+    private String ehrUserUrl;
+    @Value("${ehr.notice}")
+    private String ehrNoticeUrl;
+    @Resource
+    private RestTemplate restTemplate;
+    @Autowired
+    private AdminUserApi adminUserApi;
+    @Autowired
+    private EhrNoticeMapper ehrNoticeMapper;
+
+    /**
+     * 获取EHR的待办及已办的数量
+     * @param workcode
+     * @param pageNo
+     * @param pageSize
+     * @return
+     */
+    public Map<String, Object> getEhrToDoList(String workcode, Integer pageNo, Integer pageSize) {
+        Map<String, Object> params = new LinkedHashMap<>();
+        String tokenStr = authService.ehrSsoToken();
+        String token = String.valueOf(JSON.parseObject(tokenStr).get("access_token"));
+        if (Objects.isNull(token)||"null".equals(token)){
+            throw new ServiceException(new ErrorCode(3,"ehr获取token异常"));
+        }
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "Bearer "+token);
+        String todoStr = null;
+        HttpEntity<MultiValueMap<String, String>> ehrTodoEntity = new HttpEntity<>(headers);
+        String data = null;
+        String records = null;
+        AdminUserRespDTO userByUsername = adminUserApi.getUserByUsername(workcode);
+        if (Objects.isNull(userByUsername)){
+            throw new ServiceException(new ErrorCode(2, "系统不存在该用户"));
+        }
+        if (StringUtils.isBlank(userByUsername.getMobile())) {
+            throw new ServiceException(new ErrorCode(2, "不存在手机号,无法获取待办"));
+        }
+        //获取待办
+        try {
+            ResponseEntity<String> exchange = restTemplate.exchange(ehrUrl + ehrTodoUrl+"?mobileNo="+userByUsername.getMobile()+"&pageNo=1&pageSize=500", HttpMethod.GET, ehrTodoEntity, String.class);
+            String body = exchange.getBody();
+            data = JSON.parseObject(body).getString("data");
+            records = JSON.parseObject(data).getJSONArray("list").toJSONString();
+        } catch (RestClientException e) {
+            params.put("todoCount", 0);
+            params.put("todoList", new ArrayList<>());
+        }
+        List<EhrTodoVo> ehrTodoVos = JSON.parseArray(records, EhrTodoVo.class);
+        //返回待办
+        return ImmutableMap.of("todoList", ehrTodoVos, "todoCount", ehrTodoVos.size());
+
+    }
+
+
+
+    public List getEhrNotice(String workcode, EhrNoticeDO ehrNoticeDO) {
+        String tokenStr = authService.ehrSsoToken();
+        String token = String.valueOf(JSON.parseObject(tokenStr).get("access_token"));
+        if (Objects.isNull(token)||"null".equals(token)){
+            throw new ServiceException(new ErrorCode(3,"ehr获取token异常"));
+        }
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "Bearer "+token);
+        HttpEntity<MultiValueMap<String, String>> ehrTodoEntity = new HttpEntity<>(headers);
+        AdminUserRespDTO userByUsername = adminUserApi.getUserByUsername(workcode);
+        if (Objects.isNull(userByUsername)){
+            throw new ServiceException(new ErrorCode(2, "系统不存在该用户"));
+        }
+        if (StringUtils.isBlank(userByUsername.getMobile())) {
+            throw new ServiceException(new ErrorCode(2, "不存在手机号,无法获取待办"));
+        }
+        String userStr = null;
+        try {
+            ResponseEntity<String> exchange = restTemplate.exchange(ehrUrl + ehrUserUrl+"?mobileNo="+userByUsername.getMobile(),
+                    HttpMethod.GET, ehrTodoEntity, String.class);
+            userStr = exchange.getBody();
+            String staffId = String.valueOf(JSON.parseObject(JSON.toJSONString(JSON.parseObject(userStr).get("data"))).get("staffId"));
+            if (Objects.isNull(staffId)||StringUtils.isBlank(staffId)){
+                throw new ServiceException(new ErrorCode(3, "根据手机号获取EHR员工id异常"));
+            }
+            Map<String, Object> requestBody = new LinkedHashMap<>();
+
+            requestBody.put("pageNo", 1);
+            requestBody.put("pageSize", 100);
+            requestBody.put("hasRead", false);
+            requestBody.put("staffId", staffId);
+            if (ehrNoticeDO != null) {
+                if (StringUtils.isNotBlank(ehrNoticeDO.getEhrCreateTime())) {
+                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                    // 2. 字符串转时间对象
+                    LocalDateTime dateTime = LocalDateTime.parse(ehrNoticeDO.getEhrCreateTime(), formatter);
+                    // 3. 往前推 1 秒(核心)
+                    LocalDateTime newTime = dateTime.plusSeconds(1);
+                    // 4. 转回字符串输出
+                    String result = newTime.format(formatter);
+                    requestBody.put("fromDate", result);
+                    requestBody.put("endDate", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
+                }
+            }
+            System.out.println("==============================" + JSON.toJSONString(requestBody));
+            HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(requestBody, headers);
+            String noticeStr = restTemplate.postForObject(ehrUrl + ehrNoticeUrl, requestEntity, String.class);
+            JSONObject out1 = JSON.parseObject(noticeStr).getJSONObject("data");
+            //查询的某个日期后面的未读消息中心
+            String data1 = out1.getString("content");
+            List<EhrNoticeVO> ehrNoticeDOS = JSON.parseArray(data1, EhrNoticeVO.class);
+            List<EhrNoticeDO> collect = ehrNoticeDOS.stream().map(e -> {
+                EhrNoticeDO ehrNoticeDO1 = new EhrNoticeDO();
+                BeanUtils.copyProperties(e, ehrNoticeDO1);
+                ehrNoticeDO1.setEhrCreateTime(e.getCreatedDate());
+                ehrNoticeDO1.setEhrNoticeId(e.getId());
+                ehrNoticeDO1.setDeleted(false);
+                //未读
+                ehrNoticeDO1.setStatus("0");
+                ehrNoticeDO1.setWorkCode(workcode);
+                return ehrNoticeDO1;
+            }).collect(Collectors.toList());
+            ehrNoticeMapper.insertBatch(collect);
+            return collect;
+        } catch (RestClientException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Data
+    static class EhrNoticeVO {
+        private String id;
+        private String title;
+        private String processId;
+        private String createdDate;
+        private String abstractContent;
+        private boolean hasRead;
+        private String messageType;
+        private String contentText;
+        private String myMessageCategory;
+        private boolean appDetail;
+        private boolean webDetail;
+    }
+}

+ 55 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/service/ehr/EhrNoticeService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.server.service.ehr;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticePageReqVO;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticeSaveReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.EhrNoticeDO;
+
+import javax.validation.Valid;
+
+/**
+ * EHR消息通知 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface EhrNoticeService {
+
+    /**
+     * 创建EHR消息通知
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotEhrNotice(@Valid EhrNoticeSaveReqVO createReqVO);
+
+    /**
+     * 更新EHR消息通知
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotEhrNotice(@Valid EhrNoticeSaveReqVO updateReqVO);
+
+    /**
+     * 删除EHR消息通知
+     *
+     * @param id 编号
+     */
+    void deleteIotEhrNotice(Long id);
+
+    /**
+     * 获得EHR消息通知
+     *
+     * @param id 编号
+     * @return EHR消息通知
+     */
+    EhrNoticeDO getIotEhrNotice(Long id);
+
+    /**
+     * 获得EHR消息通知分页
+     *
+     * @param pageReqVO 分页查询
+     * @return EHR消息通知分页
+     */
+    PageResult<EhrNoticeDO> getIotEhrNoticePage(EhrNoticePageReqVO pageReqVO);
+
+}

+ 73 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/service/ehr/EhrNoticeServiceImpl.java

@@ -0,0 +1,73 @@
+package cn.iocoder.yudao.server.service.ehr;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticePageReqVO;
+import cn.iocoder.yudao.server.controller.admin.vo.ehr.EhrNoticeSaveReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.EhrNoticeDO;
+import cn.iocoder.yudao.server.dal.mysql.EhrNoticeMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * EHR消息通知 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class EhrNoticeServiceImpl implements EhrNoticeService {
+
+    @Resource
+    private EhrNoticeMapper iotEhrNoticeMapper;
+
+    @Override
+    public Long createIotEhrNotice(EhrNoticeSaveReqVO createReqVO) {
+        // 插入
+        EhrNoticeDO iotEhrNotice = BeanUtils.toBean(createReqVO, EhrNoticeDO.class);
+        iotEhrNoticeMapper.insert(iotEhrNotice);
+        // 返回
+        return iotEhrNotice.getId();
+    }
+
+    @Override
+    public void updateIotEhrNotice(EhrNoticeSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotEhrNoticeExists(updateReqVO.getId());
+        // 更新
+        EhrNoticeDO updateObj = BeanUtils.toBean(updateReqVO, EhrNoticeDO.class);
+        iotEhrNoticeMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotEhrNotice(Long id) {
+        // 校验存在
+        validateIotEhrNoticeExists(id);
+        // 删除
+        iotEhrNoticeMapper.deleteById(id);
+    }
+
+    private void validateIotEhrNoticeExists(Long id) {
+        if (iotEhrNoticeMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(2, "不存咋"));
+        }
+    }
+
+    @Override
+    public EhrNoticeDO getIotEhrNotice(Long id) {
+        return iotEhrNoticeMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<EhrNoticeDO> getIotEhrNoticePage(EhrNoticePageReqVO pageReqVO) {
+        return iotEhrNoticeMapper.selectPage(pageReqVO);
+    }
+
+}

+ 6 - 0
yudao-server/src/main/resources/application-dev.yaml

@@ -283,6 +283,12 @@ ehr:
   company_id: c7f474d57ec74a8cb10561b14c272e67
   url: https://ehr.deepoil.cc
   home: /proxy/hr/home
+  todoUrl: /openapi/thirdparty/api/v1/todos/bymobile
+  ssoToken: /openapi/oauth/token
+  appid: c8ca38ae-c9bb-46e4-b4da-e20514917195
+  appSecret: 66963782-8d04-4625-81ec-cffe27dbddbb
+  userInfo: /openapi/thirdparty/api/staff/v1/staffs/getStaffIdByMobileNo
+  notice: /openapi/thirdparty/api/message/v1/get/by/company/staff
 pms:
   secret: cc99d802-ce5c-5f62-b037-9a00726e7109
   ssoToken: https://iot.deepoil.cc/admin-api/system/auth/ssoLogin/getToken