Browse Source

量表新增

zhoutg 6 years ago
parent
commit
3c7881d6c1

+ 1 - 1
config-server/src/main/resources/shared/knowledgeman-service-dev.yml

@@ -7,7 +7,7 @@ spring:
     druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
       platform: mysql
-      url: jdbc:mysql://192.168.2.235:3306/diagbot-med?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
+      url: jdbc:mysql://192.168.2.235:3306/med-dev?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
       username: root
       password: diagbot@20180822
       # 连接池的配置信息

+ 1 - 1
config-server/src/main/resources/shared/knowledgeman-service-local.yml

@@ -7,7 +7,7 @@ spring:
     druid:
       driver-class-name: com.mysql.cj.jdbc.Driver
       platform: mysql
-      url: jdbc:mysql://192.168.2.235:3306/diagbot-med?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
+      url: jdbc:mysql://192.168.2.235:3306/med-dev?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
       username: root
       password: diagbot@20180822
       # 连接池的配置信息

+ 3 - 3
knowledgeman-service/src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -25,9 +25,9 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
         http
                 .csrf().disable()
                 .authorizeRequests()
-                .regexMatchers(".*swagger.*", ".*v2.*", ".*webjars.*", "/druid.*", "/actuator.*", "/hystrix.*").permitAll()
-                .antMatchers("/**").authenticated();
-//                .antMatchers("/**").permitAll();
+//                .regexMatchers(".*swagger.*", ".*v2.*", ".*webjars.*", "/druid.*", "/actuator.*", "/hystrix.*").permitAll()
+//                .antMatchers("/**").authenticated();
+                .antMatchers("/**").permitAll();
     }
 
 

+ 43 - 0
knowledgeman-service/src/main/java/com/diagbot/dto/ScaleContentPageDTO.java

@@ -0,0 +1,43 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2019/5/6 15:59
+ */
+@Getter
+@Setter
+public class ScaleContentPageDTO {
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 量表概念id
+     */
+    private Long conceptId;
+
+}

+ 83 - 0
knowledgeman-service/src/main/java/com/diagbot/entity/ScaleContent.java

@@ -0,0 +1,83 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 量表内容表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+@TableName("kl_scale")
+@Getter
+@Setter
+public class ScaleContent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 量表概念id
+     */
+    private Long conceptId;
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 0:文本,1:大数据接口填充
+     */
+    private Integer type;
+
+    /**
+     * 排序号
+     */
+    private Integer orderNo;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 134 - 0
knowledgeman-service/src/main/java/com/diagbot/facade/ScaleContentFacade.java

@@ -0,0 +1,134 @@
+/**
+ *
+ */
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.UserServiceClient;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.ScaleContentPageDTO;
+import com.diagbot.entity.ScaleContent;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.ScaleContentService;
+import com.diagbot.service.impl.ScaleContentServiceImpl;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.RespDTOUtil;
+import com.diagbot.util.UserUtils;
+import com.diagbot.vo.DeleteScaleVO;
+import com.diagbot.vo.ScaleContentPageVO;
+import com.diagbot.vo.ScaleContentSaveVO;
+import com.diagbot.vo.ScaleContentVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author zhoutg
+ * @Description
+ * @time 2018年12月5日下午4:53:59
+ */
+@Component
+public class ScaleContentFacade extends ScaleContentServiceImpl {
+
+    @Autowired
+    @Qualifier("scaleContentServiceImpl")
+    ScaleContentService scaleContentService;
+    @Autowired
+    UserServiceClient userServiceClient;
+
+    /**
+     * 量表内容新增或更新
+     *
+     * @param scaleContentSaveVO
+     */
+    public void insertOrUpdate(ScaleContentSaveVO scaleContentSaveVO) {
+        Long conceptId = scaleContentSaveVO.getConceptId();
+        Date now = DateUtil.now();
+        String userId = UserUtils.getCurrentPrincipleID();
+
+        // 删除原关联内容(物理删除)
+        if (conceptId != null) {
+            this.remove(new QueryWrapper<ScaleContent>()
+                    .eq("concept_id", conceptId));
+        }
+        // 新增关联内容
+        List<ScaleContent> list = new ArrayList<>();
+        List<ScaleContentVO> scaleContentVOS = scaleContentSaveVO.getContent();
+        for (ScaleContentVO scaleContentVO : scaleContentVOS) {
+            ScaleContent bean = new ScaleContent();
+            BeanUtil.copyProperties(scaleContentVO, bean);
+            bean.setConceptId(conceptId);
+            bean.setModifier(userId);
+            bean.setCreator(userId);
+            bean.setGmtCreate(now);
+            bean.setGmtModified(now);
+            list.add(bean);
+        }
+        scaleContentService.saveBatch(list);
+    }
+
+
+    /**
+     * 量表分页
+     *
+     * @param scaleContentPageVO
+     * @return
+     */
+    public IPage<ScaleContentPageDTO> getListFac(ScaleContentPageVO scaleContentPageVO) {
+        IPage<ScaleContentPageDTO> res = this.getList(scaleContentPageVO);
+        if (res.getTotal() <= 0) {
+            return res;
+        }
+        List<String> personIds = res.getRecords().stream().map(row -> row.getModifier()).collect(Collectors.toList());
+        RespDTO<Map<String, String>> mapRespDTO = userServiceClient.getUserInfoByIds(personIds);
+        RespDTOUtil.respNGDeal(mapRespDTO, "远程调用获取操作人失败");
+        for (ScaleContentPageDTO bean : res.getRecords()) {
+            bean.setModifier(mapRespDTO.data.get(bean.getModifier()));
+        }
+        return res;
+    }
+//
+//
+//    /**
+//     * 量表列表
+//     *
+//     * @param scaleId
+//     * @return
+//     */
+//    public List<ScaleContentDTO> getByParamFac(Long scaleId) {
+//        return this.getByParam(scaleId);
+//    }
+
+
+    /**
+     * 量表删除
+     *
+     * @param deleteScaleVO
+     * @return
+     */
+    public void delete(DeleteScaleVO deleteScaleVO) {
+        if (!(IsDeleteEnum.N.getKey().equals(deleteScaleVO.getStatus())
+                || IsDeleteEnum.Y.getKey().equals(deleteScaleVO.getStatus()))) {
+            throw new CommonException(CommonErrorCode.STATUS_IS_ERROR, "状态值错误【Y】或【N】");
+        }
+        String person = UserUtils.getCurrentPrincipleID();
+        List<Long> ids = deleteScaleVO.getIds();
+        Date now = DateUtil.now();
+        this.update(new ScaleContent(), new UpdateWrapper<ScaleContent>()
+                .in("concept_id", ids)
+                .set("gmt_modified", now)
+                .set("modifier", person)
+                .set("is_deleted", deleteScaleVO.getStatus()));
+    }
+}

+ 35 - 0
knowledgeman-service/src/main/java/com/diagbot/mapper/ScaleContentMapper.java

@@ -0,0 +1,35 @@
+package com.diagbot.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.dto.ScaleContentPageDTO;
+import com.diagbot.entity.ScaleContent;
+import com.diagbot.vo.ScaleContentPageVO;
+
+/**
+ * <p>
+ * 量表内容表 Mapper 接口
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+public interface ScaleContentMapper extends BaseMapper<ScaleContent> {
+
+    /**
+     * 获取量表分页
+     *
+     * @param scaleContentPageVO
+     * @return
+     */
+    public IPage<ScaleContentPageDTO> getList(ScaleContentPageVO scaleContentPageVO);
+//
+//
+//    /**
+//     * 返回量表内容
+//     *
+//     * @param scaleId
+//     * @return
+//     */
+//    public List<ScaleContentDTO> getByParam(Long scaleId);
+}

+ 35 - 0
knowledgeman-service/src/main/java/com/diagbot/service/ScaleContentService.java

@@ -0,0 +1,35 @@
+package com.diagbot.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.ScaleContentPageDTO;
+import com.diagbot.entity.ScaleContent;
+import com.diagbot.vo.ScaleContentPageVO;
+
+/**
+ * <p>
+ * 量表内容表 服务类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+public interface ScaleContentService extends IService<ScaleContent> {
+
+    /**
+     * 获取量表分页
+     *
+     * @param scaleContentPageVO
+     * @return
+     */
+    IPage<ScaleContentPageDTO> getList(ScaleContentPageVO scaleContentPageVO);
+//
+//
+//    /**
+//     * 返回量表内容
+//     *
+//     * @param scaleId
+//     * @return
+//     */
+//    public List<ScaleContentDTO> getByParam(Long scaleId);
+}

+ 33 - 0
knowledgeman-service/src/main/java/com/diagbot/service/impl/ScaleContentServiceImpl.java

@@ -0,0 +1,33 @@
+package com.diagbot.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.ScaleContentPageDTO;
+import com.diagbot.entity.ScaleContent;
+import com.diagbot.mapper.ScaleContentMapper;
+import com.diagbot.service.ScaleContentService;
+import com.diagbot.vo.ScaleContentPageVO;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 量表内容表 服务实现类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+@Service
+public class ScaleContentServiceImpl extends ServiceImpl<ScaleContentMapper, ScaleContent> implements ScaleContentService {
+
+    @Override
+    public IPage<ScaleContentPageDTO> getList(ScaleContentPageVO scaleContentPageVO) {
+        return baseMapper.getList(scaleContentPageVO);
+    }
+
+//
+//    @Override
+//    public List<ScaleContentDTO> getByParam(Long scaleId) {
+//        return baseMapper.getByParam(scaleId);
+//    }
+}

+ 22 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/DeleteScaleVO.java

@@ -0,0 +1,22 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: ztg
+ * @time: 2019/1/28 15:45
+ */
+@Getter
+@Setter
+public class DeleteScaleVO {
+    @NotNull(message="量表概念id不能为空")
+    private List<Long> ids;
+    @NotBlank(message="状态值不能为空")
+    private String status;
+}

+ 17 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/ScaleContentPageVO.java

@@ -0,0 +1,17 @@
+package com.diagbot.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @description:
+ * @author: ztg
+ * @date: 2019/5/9 11:27
+ */
+@Getter
+@Setter
+public class ScaleContentPageVO extends Page {
+    private String status; //状态值
+    private String name;   //量表名称
+}

+ 27 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/ScaleContentSaveVO.java

@@ -0,0 +1,27 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 量表内容表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+@Getter
+@Setter
+public class ScaleContentSaveVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long conceptId; //量表概念id
+    private List<ScaleContentVO> content = new ArrayList<>();
+
+}

+ 43 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/ScaleContentVO.java

@@ -0,0 +1,43 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 量表内容表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+@Getter
+@Setter
+public class ScaleContentVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 0:文本,1:大数据接口填充
+     */
+    private Integer type;
+
+    /**
+     * 排序号
+     */
+    private Integer orderNo;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 69 - 0
knowledgeman-service/src/main/java/com/diagbot/web/ScaleContentController.java

@@ -0,0 +1,69 @@
+package com.diagbot.web;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.dto.ScaleContentPageDTO;
+import com.diagbot.facade.ScaleContentFacade;
+import com.diagbot.vo.DeleteScaleVO;
+import com.diagbot.vo.ScaleContentPageVO;
+import com.diagbot.vo.ScaleContentSaveVO;
+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.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+/**
+ * <p>
+ * 量表内容表 前端控制器
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2019-04-08
+ */
+@RestController
+@RequestMapping("/scaleContent")
+@Api(value = "量表内容相关API", tags = { "知识库标准化-量表内容相关API" })
+public class ScaleContentController {
+
+    @Autowired
+    ScaleContentFacade scaleContentFacade;
+
+    @ApiOperation(value = "知识库标准化-量表内容新增或更新[by:zhoutg]")
+    @PostMapping("/insertOrUpdate")
+    @SysLogger("insertOrUpdate")
+    @Transactional
+    public RespDTO<Boolean> insertOrUpdate(@RequestBody ScaleContentSaveVO scaleContentSaveVO) {
+        scaleContentFacade.insertOrUpdate(scaleContentSaveVO);
+        return RespDTO.onSuc(true);
+    }
+
+
+    @ApiOperation(value = "知识库标准化-量表内容分页[by:zhoutg]",
+            notes = "")
+    @PostMapping("/list")
+    @SysLogger("list")
+    public RespDTO<IPage<ScaleContentPageDTO>> list(@RequestBody ScaleContentPageVO questionPageVO) {
+        IPage<ScaleContentPageDTO> data = scaleContentFacade.getListFac(questionPageVO);
+        return RespDTO.onSuc(data);
+    }
+
+
+    @ApiOperation(value = "知识库标准化-量表内容删除|恢复[by:zhoutg]",
+            notes = "ids:量表概念id<br>" +
+                    "status: 删除传值'Y'<br>" +
+                    "        恢复传值'N'")
+    @PostMapping("/delete")
+    @SysLogger("delete")
+    public  RespDTO<Boolean> delete(@Valid @RequestBody DeleteScaleVO deleteScaleVO) {
+        scaleContentFacade.delete(deleteScaleVO);
+        return RespDTO.onSuc(true);
+    }
+}

+ 27 - 0
knowledgeman-service/src/main/resources/mapper/ScaleContentMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.ScaleContentMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.ScaleContent">
+        <result column="content" property="content" />
+        <result column="type" property="type" />
+    </resultMap>
+
+    <select id="getList" resultType="com.diagbot.dto.ScaleContentPageDTO">
+        SELECT DISTINCT b.lib_name name, b.id concept_id, a.gmt_modified, a.modifier, a.is_deleted
+        FROM `kl_scale` a, kl_concept b
+        where a.concept_id = b.id
+        and b.is_deleted = 'N'
+        <if test="status != null and status != ''">
+            and a.is_deleted = #{status}
+        </if>
+        <if test="name != null and name != ''">
+            and b.lib_name like concat('%',#{name} ,'%' )
+        </if>
+        and b.lib_type = 48
+        ORDER BY a.is_deleted, a.gmt_modified
+    </select>
+
+
+</mapper>