소스 검색

模板引用记录

gaodm 5 년 전
부모
커밋
0914419482

+ 28 - 14
docs/029.20200109模板新需求/icss.sql

@@ -34,20 +34,34 @@ CREATE TABLE `icss_folder_mapping` (
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8  COMMENT='模板文件夹映射表';
 
 
-
-DROP TABLE IF EXISTS `icss_template_classify`;
-CREATE TABLE `icss_template_classify` (
+DROP TABLE IF EXISTS `icss_template_quote`;
+CREATE TABLE `icss_template_quote` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
-  `is_deleted` char(1)  NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
-  `gmt_create` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
-  `gmt_modified` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
-  `creator` varchar(20)  NOT NULL DEFAULT '' COMMENT '创建人姓名',
-  `modifier` varchar(20)  NOT NULL DEFAULT '' COMMENT '修改人姓名',
-  `name` varchar(300) NOT NULL DEFAULT '' COMMENT '名称',
-  `hospital_id` bigint(20) DEFAULT NULL COMMENT '医院id',
+  `is_deleted` char(3) DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
+  `gmt_create` datetime DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
+  `gmt_modified` datetime DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
+  `creator` varchar(60) DEFAULT '0' COMMENT '创建人,0表示无创建人值',
+  `modifier` varchar(60) DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
+  `template_id` bigint(20) DEFAULT NULL COMMENT '模板id',
   `doctor_id` bigint(20) DEFAULT NULL COMMENT '医生id',
-  `template_type` int(11) NOT NULL DEFAULT '1' COMMENT '模板类型(个人1,管理员2)',
-  `order_no` int(11) NOT NULL DEFAULT '1' COMMENT '排序号',
-  `remark` varchar(255)  NOT NULL DEFAULT '' COMMENT '备注',
+  `remark` varchar(384) DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8  COMMENT='模板分类表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='模板引用表';
+
+
+-- DROP TABLE IF EXISTS `icss_template_classify`;
+-- CREATE TABLE `icss_template_classify` (
+--   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
+--   `is_deleted` char(1)  NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
+--   `gmt_create` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
+--   `gmt_modified` datetime NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
+--   `creator` varchar(20)  NOT NULL DEFAULT '' COMMENT '创建人姓名',
+--   `modifier` varchar(20)  NOT NULL DEFAULT '' COMMENT '修改人姓名',
+--   `name` varchar(300) NOT NULL DEFAULT '' COMMENT '名称',
+--   `hospital_id` bigint(20) DEFAULT NULL COMMENT '医院id',
+--   `doctor_id` bigint(20) DEFAULT NULL COMMENT '医生id',
+--   `template_type` int(11) NOT NULL DEFAULT '1' COMMENT '模板类型(个人1,管理员2)',
+--   `order_no` int(11) NOT NULL DEFAULT '1' COMMENT '排序号',
+--   `remark` varchar(255)  NOT NULL DEFAULT '' COMMENT '备注',
+--   PRIMARY KEY (`id`)
+-- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8  COMMENT='模板分类表';

+ 9 - 0
icss-service/src/main/java/com/diagbot/client/TranServiceClient.java

@@ -70,6 +70,15 @@ public interface TranServiceClient {
     @PostMapping("/doctorInfo/doctorInfoMapByIds")
     RespDTO<Map<Long, DoctorInfo>> doctorInfoMapByIds(@RequestBody List<Long> ids);
 
+    /**
+     * 根据id获取医生信息
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/doctorInfo/doctorInfoById")
+    RespDTO<DoctorInfoDTO> getDoctorInfoById(@RequestBody Long id);
+
     /**
      * 根据ids获取科室信息map
      *

+ 12 - 0
icss-service/src/main/java/com/diagbot/client/hystrix/TranServiceHystrix.java

@@ -64,6 +64,18 @@ public class TranServiceHystrix implements TranServiceClient {
         return null;
     }
 
+    /**
+     * 根据id获取医生信息
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public RespDTO<DoctorInfoDTO> getDoctorInfoById(@RequestBody Long id) {
+        log.error("【hystrix】调用{}异常", "getDoctorInfoById");
+        return null;
+    }
+
     @Override
     public RespDTO<HospitalInfoDTO> getHospitalInfo(HospitalInfoVO hospitalInfoVO) {
         log.error("【hystrix】调用{}异常", "getHospitalInfo");

+ 54 - 2
icss-service/src/main/java/com/diagbot/facade/TemplateQuoteFacade.java

@@ -1,14 +1,66 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.client.TranServiceClient;
+import com.diagbot.dto.DoctorInfoDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.TemplateInfo;
+import com.diagbot.entity.TemplateQuote;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.TemplateQuoteServiceImpl;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.RespDTOUtil;
+import com.diagbot.vo.TemplateQuoteVO;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+
 /**
- * @author wangfeng
+ * @author gaodm
  * @Description:
  * @date 2020-01-09 18:29
  */
 @Component
-public class TemplateQuoteFacade {
+public class TemplateQuoteFacade extends TemplateQuoteServiceImpl {
+
+    @Autowired
+    private TemplateInfoFacade templateInfoFacade;
+    @Autowired
+    private TranServiceClient tranServiceClient;
+
+    /**
+     * 添加模板引用
+     *
+     * @param templateQuoteVO
+     * @return
+     */
+    public Boolean addTemplateQuote(TemplateQuoteVO templateQuoteVO) {
+        //模板存在性验证
+        QueryWrapper<TemplateInfo> templateInfoQuery = new QueryWrapper<>();
+        templateInfoQuery
+                .eq("id", templateQuoteVO.getTemplateId())
+                .eq("is_deleted", IsDeleteEnum.N.getKey());
+        if (templateInfoFacade.count(templateInfoQuery) < 1) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "该模板不存在!");
+        }
+        //医生存在性验证
+        RespDTO<DoctorInfoDTO> res
+                = tranServiceClient.getDoctorInfoById(templateQuoteVO.getDoctorId());
+        RespDTOUtil.respNGDeal(res, "该医生不存在!");
 
+        //引用模板
+        Date now = DateUtil.now();
+        TemplateQuote templateQuote = new TemplateQuote();
+        BeanUtil.copyProperties(templateQuoteVO, templateQuote);
+        templateQuote.setCreator(templateQuoteVO.getDoctorId().toString());
+        templateQuote.setModifier(templateQuoteVO.getDoctorId().toString());
+        templateQuote.setGmtCreate(now);
+        templateQuote.setGmtModified(now);
 
+        return this.save(templateQuote);
+    }
 }

+ 32 - 0
icss-service/src/main/java/com/diagbot/vo/TemplateQuoteVO.java

@@ -0,0 +1,32 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/1/13 13:30
+ */
+@Getter
+@Setter
+public class TemplateQuoteVO {
+    /**
+     * 模板id
+     */
+    @NotNull(message="请输入模板id")
+    private Long templateId;
+
+    /**
+     * 医生id
+     */
+    @NotNull(message="请输入医生id")
+    private Long doctorId;
+
+    /**
+     * 备注
+     */
+    private String remark;
+}

+ 28 - 10
icss-service/src/main/java/com/diagbot/web/TemplateQuoteController.java

@@ -1,20 +1,38 @@
 package com.diagbot.web;
 
-
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.TemplateQuoteFacade;
+import com.diagbot.vo.TemplateQuoteVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author wangfeng
- * @since 2020-01-09
+ * @Description: 模板引用
+ * @author: gaodm
+ * @time: 2020/1/13 13:28
  */
-@Controller
+@RestController
 @RequestMapping("/templateQuote")
+@Api(value = "模板引用API[by:gaodm]", tags = { "模板引用API" })
+@SuppressWarnings("unchecked")
 public class TemplateQuoteController {
+    @Autowired
+    private TemplateQuoteFacade templateQuoteFacade;
+
 
+    @ApiOperation(value = "添加模板引用[by:gaodm]")
+    @PostMapping("/addTemplateQuote")
+    @SysLogger("addTemplateQuote")
+    @Transactional
+    public RespDTO<Boolean> addTemplateQuote(@RequestBody @Validated TemplateQuoteVO templateQuoteVO) {
+        return RespDTO.onSuc(templateQuoteFacade.addTemplateQuote(templateQuoteVO));
+    }
 }

+ 25 - 10
tran-service/src/main/java/com/diagbot/facade/DoctorInfoFacade.java

@@ -1,18 +1,20 @@
 package com.diagbot.facade;
 
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
+import com.diagbot.dto.DoctorInfoDTO;
 import com.diagbot.dto.DoctorInfoFindDTO;
+import com.diagbot.entity.DoctorInfo;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.DoctorInfoServiceImpl;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.vo.DoctorInfoVO;
 import com.diagbot.vo.HospitalCodeSetVO;
 import org.springframework.stereotype.Component;
 
-import com.diagbot.dto.DoctorInfoDTO;
-import com.diagbot.entity.DoctorInfo;
-import com.diagbot.service.impl.DoctorInfoServiceImpl;
-import com.diagbot.vo.DoctorInfoVO;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description:
@@ -32,14 +34,15 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
         List<DoctorInfoDTO> doctorInfoDTOList = this.getDoctorInfos(doctorInfoVo.getDoctorCode(), doctorInfoVo.getHosptialCode(), doctorInfoVo.getDeptCode());
         return doctorInfoDTOList;
     }
-    
+
     /**
      * 根据ids获取医生信息map
+     *
      * @param ids 医生ids
      * @return 医生信息
      */
     public Map<Long, DoctorInfo> doctorInfoMapByIds(List<Long> ids) {
-    	Map<Long, DoctorInfo> doctorInfoMap
+        Map<Long, DoctorInfo> doctorInfoMap
                 = this.listByIds(ids).stream()
                 .filter(i -> i.getIsDeleted().equals(IsDeleteEnum.N.getKey()))
                 .collect(Collectors.toMap(DoctorInfo::getId, i -> i));
@@ -49,4 +52,16 @@ public class DoctorInfoFacade extends DoctorInfoServiceImpl {
     public DoctorInfoFindDTO findDoctorInfo(HospitalCodeSetVO hospitalCodeSetVO) {
         return this.baseMapper.findDoctorInfo(hospitalCodeSetVO);
     }
+
+
+    public DoctorInfoDTO getDoctorInfoById(Long id) {
+        DoctorInfo doctorInfo = this.getById(id);
+        if (null == doctorInfo
+                || doctorInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "该医生不存在!");
+        }
+        DoctorInfoDTO doctorInfoDTO = new DoctorInfoDTO();
+        BeanUtil.copyProperties(doctorInfo, doctorInfoDTO);
+        return doctorInfoDTO;
+    }
 }

+ 8 - 0
tran-service/src/main/java/com/diagbot/web/DoctorInfoController.java

@@ -60,4 +60,12 @@ public class DoctorInfoController {
         Map<Long, DoctorInfo> result = doctorInfoFacade.doctorInfoMapByIds(ids);
         return RespDTO.onSuc(result);
     }
+
+    @PostMapping(value = "/doctorInfoById")
+    @SysLogger("doctorInfoById")
+    @ApiOperation(value = "根据id获取医生信息[by:gaodm]")
+    @ApiIgnore
+    RespDTO<DoctorInfoDTO> getDoctorInfoById(@RequestBody Long id) {
+        return RespDTO.onSuc(doctorInfoFacade.getDoctorInfoById(id));
+    }
 }