Bladeren bron

添加医生信息管理模块。

lighter 4 jaren geleden
bovenliggende
commit
8506ec7654

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>3.3</version>
+    <version>3.4</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
 

+ 71 - 0
src/main/java/thyyxxk/webserver/controller/managedoctorinfo/ManageDoctorInfoController.java

@@ -0,0 +1,71 @@
+package thyyxxk.webserver.controller.managedoctorinfo;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import thyyxxk.webserver.pojo.ResultVo;
+import thyyxxk.webserver.pojo.dictionary.CodeNamePojo;
+import thyyxxk.webserver.pojo.dictionary.PureCodeName;
+import thyyxxk.webserver.pojo.mangedoctorinfo.DoctorPojo;
+import thyyxxk.webserver.service.managedoctorinfo.ManageDoctorInfoService;
+
+import java.util.List;
+
+
+@RestController
+@RequestMapping("/manageDoctorInfo")
+public class ManageDoctorInfoController {
+    private final ManageDoctorInfoService service;
+
+    @Autowired
+    public ManageDoctorInfoController(ManageDoctorInfoService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/getAllMzDept")
+    public ResultVo<List<CodeNamePojo>> getAllMzDept() {
+        return service.getAllMzDept();
+    }
+
+    @GetMapping("/getAllDoctors")
+    public ResultVo<List<DoctorPojo>> getAllDoctor() {
+        return service.getAllDoctors();
+    }
+
+    @GetMapping("/getAllTitles")
+    public ResultVo<List<PureCodeName>> getAllTitles() {
+        return service.getAllTitles();
+    }
+
+    @GetMapping("/getDoctorInfo")
+    public ResultVo<DoctorPojo> getDoctorInfo(@RequestParam("code") String code) {
+        return service.getDoctorInfo(code);
+    }
+
+    @PostMapping("/uploadPortrait")
+    public ResultVo<String> uploadPortrait(@RequestParam("code") String code, @RequestBody MultipartFile file) {
+        return service.uploadDoctorImg(code, file);
+    }
+
+    @PostMapping("/saveDoctorInfo")
+    public ResultVo<String> saveDoctorInfo(@RequestBody DoctorPojo param) {
+        return service.saveDoctorInfo(param);
+    }
+
+    @GetMapping("/updateDoctorWxHomepageFlag")
+    public ResultVo<String> updateDoctorWxHomepageFlag(@RequestParam("code") String code,
+                                                       @RequestParam("flag") Integer flag) {
+        return service.updateDoctorWxHomepageFlag(code, flag);
+    }
+
+    @GetMapping("/getAllRecommendDoctors")
+    public ResultVo<List<DoctorPojo>> getAllRecommendDoctors() {
+        return service.getAllRecommendDoctors();
+    }
+
+    @GetMapping("/updateWxHomepageOrder")
+    public ResultVo<String> updateWxHomepageOrder(@RequestParam("code") String code,
+                                                  @RequestParam("order") Integer order) {
+        return service.updateWxHomepageOrder(code, order);
+    }
+}

+ 82 - 0
src/main/java/thyyxxk/webserver/dao_his/managedoctorinfo/ManageDoctorInfoDao.java

@@ -0,0 +1,82 @@
+package thyyxxk.webserver.dao_his.managedoctorinfo;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.pojo.dictionary.CodeNamePojo;
+import thyyxxk.webserver.pojo.dictionary.PureCodeName;
+import thyyxxk.webserver.pojo.mangedoctorinfo.DoctorPojo;
+
+import java.util.List;
+
+@Mapper
+public interface ManageDoctorInfoDao {
+    @Select("select rtrim(code) code, rtrim(name) name, rtrim(py_code) pyCode from zd_unit_code where mz_flag=1")
+    List<CodeNamePojo> getAllMzDept();
+
+    @Select("select rtrim(b.name) titleName, " +
+            "rtrim(b.code) titleCode, " +
+            "rtrim(a.name) name, " +
+            "isnull(a.sex_code, 9) sex, " +
+            "rtrim(a.code) code, " +
+            "isnull(a.wx_homepage_flag, 0) wxHomepageFlag, " +
+            "rtrim(a.dept_code) deptCode, " +
+            "deptName=(select rtrim(name) from zd_unit_code where code=a.dept_code) " +
+            "from a_employee_mi a,zd_emp_title b " +
+            "where a.emp_tit_code=b.code " +
+            "and b.tit_grade =1 and a.code not in ('00000', '00026') " +
+            "and isnull(a.del_flag,0)<>1  order by a.code")
+    List<DoctorPojo> getAllDoctors();
+
+    @Select("select rtrim(code) code, rtrim(name) name " +
+            "from zd_emp_title where tit_grade=1 order by code")
+    List<PureCodeName> getAllTitles();
+
+    @Select("select name=rtrim(a.name), " +
+            "sex=isnull(a.sex_code, 9)," +
+            "rtrim(a.emp_tit_code) titleCode," +
+            "titleName=(select rtrim(name) from zd_emp_title where code=a.emp_tit_code), " +
+            "code=rtrim(a.code), " +
+            "rtrim(a.dept_code) deptCode," +
+            "deptName=(select rtrim(name) from zd_unit_code where code=a.dept_code), " +
+            "a.portrait, " +
+            "a.specialty, " +
+            "a.introduction " +
+            "from a_employee_mi a where a.code=#{code}")
+    DoctorPojo getDoctorInfo(@Param("code") String code);
+
+    @Update("update a_employee_mi set " +
+            "name=#{name}, " +
+            "sex_code=#{sex}, " +
+            "dept_code=#{deptCode}, " +
+            "emp_tit_code=#{titleCode}, " +
+            "introduction=#{introduction}, " +
+            "specialty=#{specialty} " +
+            "where code=#{code}")
+    void saveDoctorInfo(DoctorPojo param);
+
+    @Update("update a_employee_mi set portrait=#{imgBase64} where code=#{code}")
+    void updatePortraitUrl(@Param("imgBase64") String imgBase64, @Param("code") String code);
+
+    @Update("update a_employee_mi set wx_homepage_flag=#{flag} where code=#{code}")
+    void updateDoctorWxHomepageFlag(@Param("code") String code, @Param("flag") Integer flag);
+
+    @Select("select " +
+            "rtrim(b.name) titleName, " +
+            "rtrim(a.name) name, " +
+            "isnull(a.sex_code, 9) sex, " +
+            "rtrim(a.code) code, " +
+            "a.wx_homepage_flag," +
+            "a.wx_homepage_order, " +
+            "deptName=(select rtrim(name) from zd_unit_code where code=a.dept_code) " +
+            "from a_employee_mi a,zd_emp_title b " +
+            "where a.emp_tit_code=b.code " +
+            "and a.wx_homepage_flag=1 " +
+            "and b.tit_grade=1 " +
+            "and isnull(a.del_flag,0)<>1  order by a.wx_homepage_order")
+    List<DoctorPojo> getAllRecommendDoctors();
+
+    @Update("update a_employee_mi set wx_homepage_order=#{order} where code=#{code}")
+    void updateWxHomepageOrder(@Param("code") String code, @Param("order") Integer order);
+}

+ 1 - 1
src/main/java/thyyxxk/webserver/pojo/dictionary/CodeNamePojo.java

@@ -6,6 +6,6 @@ import lombok.Data;
 public class CodeNamePojo {
     private String code;
     private String name;
-    private boolean disabled;
     private String pyCode;
+    private boolean disabled;
 }

+ 33 - 0
src/main/java/thyyxxk/webserver/pojo/mangedoctorinfo/DoctorPojo.java

@@ -0,0 +1,33 @@
+package thyyxxk.webserver.pojo.mangedoctorinfo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+public class DoctorPojo {
+    @NotBlank(message = "医生姓名不能为空。")
+    private String name;
+    private String code;
+    private Integer sex;
+    private String sexName;
+    @NotBlank(message = "医生职称不能为空。")
+    private String titleCode;
+    private String titleName;
+    @NotBlank(message = "医生所属科室不能为空。")
+    private String deptCode;
+    private String deptName;
+    @NotBlank(message = "医生擅长不能为空。")
+    private String specialty;
+    private String introduction;
+    private String portrait;
+    private Integer wxHomepageFlag;
+    private Integer wxHomepageOrder;
+
+    public String getSexName() {
+        if (null == sex) {
+            return "未知";
+        }
+        return sex == 1 ? "男" : "女";
+    }
+}

+ 89 - 0
src/main/java/thyyxxk/webserver/service/managedoctorinfo/ManageDoctorInfoService.java

@@ -0,0 +1,89 @@
+package thyyxxk.webserver.service.managedoctorinfo;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import sun.misc.BASE64Encoder;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao_his.managedoctorinfo.ManageDoctorInfoDao;
+import thyyxxk.webserver.pojo.ResultVo;
+import thyyxxk.webserver.pojo.dictionary.CodeNamePojo;
+import thyyxxk.webserver.pojo.dictionary.PureCodeName;
+import thyyxxk.webserver.pojo.mangedoctorinfo.DoctorPojo;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+@Service
+public class ManageDoctorInfoService {
+    private final ManageDoctorInfoDao dao;
+
+    @Autowired
+    public ManageDoctorInfoService(ManageDoctorInfoDao dao) {
+        this.dao = dao;
+    }
+
+    public ResultVo<List<CodeNamePojo>> getAllMzDept() {
+        return ResultVoUtil.success(dao.getAllMzDept());
+    }
+
+    public ResultVo<List<DoctorPojo>> getAllDoctors() {
+        return ResultVoUtil.success(dao.getAllDoctors());
+    }
+
+    public ResultVo<List<PureCodeName>> getAllTitles() {
+        return ResultVoUtil.success(dao.getAllTitles());
+    }
+
+    public ResultVo<DoctorPojo> getDoctorInfo(String code) {
+        return ResultVoUtil.success(dao.getDoctorInfo(code));
+    }
+
+    public ResultVo<String> uploadDoctorImg(String code, MultipartFile img) {
+        log.info("上传医生头像,操作员:{},医生编码:{}", TokenUtil.getTokenUserId(), code);
+        dao.updatePortraitUrl(base64Encode(img), code);
+        return ResultVoUtil.success();
+    }
+
+    public ResultVo<String> saveDoctorInfo(DoctorPojo param) {
+        if (param.getSpecialty().trim().length() > 50) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医生擅长不能超过50个字!");
+        }
+        if (param.getIntroduction().trim().length() > 150) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医生简介不能超过150个字!");
+        }
+        dao.saveDoctorInfo(param);
+        return ResultVoUtil.success();
+    }
+
+    public ResultVo<String> updateDoctorWxHomepageFlag(String code, Integer flag) {
+        dao.updateDoctorWxHomepageFlag(code, flag);
+        return ResultVoUtil.success();
+    }
+
+    public ResultVo<List<DoctorPojo>> getAllRecommendDoctors() {
+        return ResultVoUtil.success(dao.getAllRecommendDoctors());
+    }
+
+    public ResultVo<String> updateWxHomepageOrder(String code, Integer order) {
+        dao.updateWxHomepageOrder(code, order);
+        return ResultVoUtil.success();
+    }
+
+    private String base64Encode(MultipartFile file){
+        String ret = null;
+        if (file == null)
+            return null;
+        try {
+            BASE64Encoder encoder = new BASE64Encoder();
+            ret = encoder.encode(file.getBytes());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return ret;
+    }
+}