|
@ -0,0 +1,613 @@
|
|
|
package com.yihu.wlyy.controller.manager.hos;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
import com.yihu.wlyy.entity.Doctor;
|
|
|
import com.yihu.wlyy.entity.WlyyAdminTeam;
|
|
|
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
|
|
|
import com.yihu.wlyy.service.manager.team.WlyyAdminTeamService;
|
|
|
import com.yihu.wlyy.util.IdcardValidator;
|
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
import jxl.Sheet;
|
|
|
import jxl.Workbook;
|
|
|
import jxl.read.biff.BiffException;
|
|
|
import jxl.write.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by yww on 2016/9/28.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/admin/hos/doctor")
|
|
|
public class HosDoctorController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private HosDoctorService doctorService;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyAdminTeamService wlyyAdminTeamService;
|
|
|
|
|
|
//跳转到医生列表页
|
|
|
@RequestMapping(value = "initial", method = RequestMethod.GET)
|
|
|
public String list(Model model, @RequestParam(required = true) String orgId, String doctorName, @RequestParam String orgCode, @RequestParam String orgName) {
|
|
|
model.addAttribute("orgId", orgId);
|
|
|
model.addAttribute("doctorName", doctorName);
|
|
|
model.addAttribute("orgCode", orgCode);
|
|
|
model.addAttribute("orgName", orgName);
|
|
|
return "hos/doctor/doctor_list";
|
|
|
}
|
|
|
|
|
|
|
|
|
//进入人员添加界面
|
|
|
@RequestMapping(value = "createInit", method = RequestMethod.GET)
|
|
|
public String add() {
|
|
|
String orgCode = request.getParameter("orgCode");
|
|
|
request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
|
|
|
request.setAttribute("orgCode", orgCode);
|
|
|
return "hos/doctor/doctor_modify";
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "create")
|
|
|
@ResponseBody
|
|
|
public String createDoctor(String jsonData) {
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Doctor doctor = objectMapper.readValue(jsonData, Doctor.class);
|
|
|
doctorService.saveDoctor(doctor);
|
|
|
return success("操作成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//进入人员查看、编辑界面
|
|
|
@RequestMapping(value = "updateInit/{id}", method = RequestMethod.GET)
|
|
|
public String update(@PathVariable("id") Long id) {
|
|
|
try {
|
|
|
request.setAttribute("doctorId", id);
|
|
|
request.setAttribute("type", request.getParameter("type"));
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
}
|
|
|
return "hos/doctor/doctor_modify";
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "update")
|
|
|
@ResponseBody
|
|
|
public String updateDoctor(String jsonData) {
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Doctor doctor = objectMapper.readValue(jsonData, Doctor.class);
|
|
|
doctorService.updateDoctor(doctor);
|
|
|
return success("操作成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除用户
|
|
|
*
|
|
|
* @param id
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "delete")
|
|
|
@ResponseBody
|
|
|
public String deleteDoctor(
|
|
|
@RequestParam(value = "id", required = true) Long id,
|
|
|
@RequestParam(value = "code", required = true) String code) {
|
|
|
try {
|
|
|
doctorService.deleteDoctorByid(id, code);
|
|
|
return success("操作成功!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查找用户列表
|
|
|
*
|
|
|
* @param page
|
|
|
* @param rows
|
|
|
* @param hospital 医院标识
|
|
|
* @param deptName 科室标识
|
|
|
* @param jobName 职称标识
|
|
|
* @param status 状态
|
|
|
* @param name 姓名
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "doctorList")
|
|
|
@ResponseBody
|
|
|
public String doctorList(
|
|
|
@RequestParam(value = "page", required = true) int page,
|
|
|
@RequestParam(value = "rows", required = true) int rows,
|
|
|
@RequestParam(value = "hospital", required = true) String hospital,
|
|
|
@RequestParam(value = "deptName", required = false) String deptName,
|
|
|
@RequestParam(value = "jobName", required = false) String jobName,
|
|
|
@RequestParam(value = "status", required = false) String status,
|
|
|
@RequestParam(value = "mobile", required = false) String mobile,
|
|
|
@RequestParam(value = "name", required = false) String name) {
|
|
|
try {
|
|
|
if (StringUtils.isEmpty(hospital)) {
|
|
|
return error(-1, "所属机构编码不能为空!");
|
|
|
}
|
|
|
Page<Doctor> doctors = doctorService.getDoctorList(page, rows, hospital, deptName, jobName, status, mobile, name);
|
|
|
return write(200, "", page, rows, doctors);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查找单个用户
|
|
|
*
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "findOneDoctor")
|
|
|
@ResponseBody
|
|
|
public String findOneDoctor(
|
|
|
@RequestParam(value = "id", required = true) Long id) {
|
|
|
try {
|
|
|
Doctor doctor = doctorService.getDoctor(id);
|
|
|
return write(200, "操作成功!", "doc", doctor);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查找单个用户
|
|
|
*
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "findDoctor")
|
|
|
@ResponseBody
|
|
|
public String findDoctor(
|
|
|
@RequestParam(value = "code", required = true) String code) {
|
|
|
try {
|
|
|
|
|
|
Doctor doctor = doctorService.getDoctorByCode(code);
|
|
|
List<WlyyAdminTeam> wlyyAdminTeams = wlyyAdminTeamService.getTeamsByDoctor(doctor.getCode());
|
|
|
JSONObject object = new JSONObject(doctor);
|
|
|
String teamName = "";
|
|
|
for(WlyyAdminTeam wlyyAdminTeam:wlyyAdminTeams){
|
|
|
teamName=teamName+wlyyAdminTeam.getName()+",";
|
|
|
}
|
|
|
if(teamName.lastIndexOf(",")>=0){
|
|
|
teamName = teamName.substring(0,teamName.lastIndexOf(","));
|
|
|
}
|
|
|
object.put("teamName",teamName.toString());
|
|
|
return write(200, "操作成功!", "doc", object);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "sign")
|
|
|
public String sign(@RequestParam(value = "doctorIdList", required = true) String ids) {
|
|
|
request.setAttribute("doctorIdList", ids);
|
|
|
return "hos/doctor/sign_modify";
|
|
|
}
|
|
|
|
|
|
// @RequestMapping(value = "updateStatus",method = RequestMethod.POST)
|
|
|
// @ResponseBody
|
|
|
// public String updateSign(
|
|
|
// @RequestParam(value = "doctorIdList", required = true) String ids,
|
|
|
// @RequestParam(value = "status", required = true) String status) {
|
|
|
// try {
|
|
|
// doctorService.updateStatus(ids, status);
|
|
|
// return write(200, "操作成功!");
|
|
|
// } catch (Exception e) {
|
|
|
// error(e);
|
|
|
// return error(-1, "操作失败!");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
@RequestMapping(value = "updateStatus", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String updateStatus(
|
|
|
@RequestParam(value = "doctorId", required = true) Long doctorId,
|
|
|
@RequestParam(value = "mobile", required = true) String mobile,
|
|
|
@RequestParam(value = "status", required = true) Integer status) {
|
|
|
try {
|
|
|
if (doctorId == null) {
|
|
|
return error(-1, "医生id不能为空!!");
|
|
|
}
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
return error(-1, "电话号码不能为空!");
|
|
|
}
|
|
|
if (status == null) {
|
|
|
return error(-1, "状态不能为空!!");
|
|
|
}
|
|
|
//生失效前判断是否有同手机号的生效数据(有则不允许生效)
|
|
|
//因为基卫导入时,手机号码为空的情况下都是设置为1,所以对该部分数据允许进行生效
|
|
|
boolean existMobile = false;
|
|
|
if(!mobile.equals("1")){
|
|
|
if (status == 1) {
|
|
|
existMobile = doctorService.isExistMobile(mobile);
|
|
|
}
|
|
|
if (existMobile) {
|
|
|
return error(-1, "同个手机号只能有一条生效医生信息!");
|
|
|
}
|
|
|
}
|
|
|
boolean res = doctorService.updateDel(status, doctorId);
|
|
|
return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//跳转上传结果页面
|
|
|
@RequestMapping("/importResult")
|
|
|
public String importResult() {
|
|
|
return "hos/doctor/doctor_import_result";
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/importFromExcel", produces = "application/json;charset=UTF-8")
|
|
|
@ResponseBody
|
|
|
public String importFromExcel(HttpServletRequest request, @RequestParam(value = "orgCode", required = true) String orgCode, @RequestParam(value = "orgName", required = true) String orgName) {
|
|
|
List errorLs = new ArrayList<>();
|
|
|
List correctLs = new ArrayList<>();
|
|
|
IdcardValidator idcardValidator = new IdcardValidator();
|
|
|
//判断表中数据是否重复
|
|
|
//名字、手机号、身份证号
|
|
|
Set<String> nameSet = new HashSet<>(); //存放表中名字
|
|
|
Set<String> mobileSet = new HashSet<>();//存放表中手机号
|
|
|
try {
|
|
|
request.setCharacterEncoding("UTF-8");
|
|
|
InputStream inputStream = request.getInputStream();
|
|
|
Workbook rwb = Workbook.getWorkbook(inputStream);
|
|
|
Sheet[] sheets = rwb.getSheets();
|
|
|
int rows;
|
|
|
int row;
|
|
|
List<Doctor> doctorList = new ArrayList<>();
|
|
|
String name = null;// 姓名
|
|
|
Integer sex = null;// 性别(1男,2女)
|
|
|
String birthday = null;// 生日
|
|
|
String mobile = null;// 手机号
|
|
|
String password = null;// 登录密码 ---默认值手机后六位
|
|
|
Integer status = 1;// 状态(1正常,0禁用)
|
|
|
String province = null;// 省
|
|
|
String city = null; // 市
|
|
|
String town = null;// 區縣代碼
|
|
|
String hospital = orgCode;// 医院标识
|
|
|
String hospitalName = null;// 医院名称
|
|
|
String deptName = null;// 科室名
|
|
|
String jobName = null;// 职称名
|
|
|
String expertise = null;// 医生专长
|
|
|
String introduce = null;// 医生介绍
|
|
|
Integer level = 0;// 类型:1专科医生,2全科医生,3健康管理师 默认0
|
|
|
String idCard = null;//身份证号
|
|
|
String isFamous = "0";//是否名医
|
|
|
String shequType = null; //社区内类型
|
|
|
|
|
|
Sheet sheet = sheets[0]; //第一张表
|
|
|
rows = sheet.getRows();
|
|
|
for (int j = 1; j < rows; j++) {
|
|
|
if (sheet.getRow(j).length == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
String errorMsg = "";
|
|
|
Doctor doctor = new Doctor();
|
|
|
Map<String, String> errorMsgMap = doctor.getErrorMsgMap();
|
|
|
row = j;
|
|
|
name = sheet.getCell(0, row).getContents().trim(); // 0 姓名
|
|
|
idCard = sheet.getCell(1, row).getContents().trim(); //1 身份证号
|
|
|
mobile = sheet.getCell(2, row).getContents().trim(); //2 手机号
|
|
|
//3 人员类型(对应字段?)
|
|
|
jobName = sheet.getCell(4, row).getContents().trim(); //4 临床职称
|
|
|
//5 行政职称(对应字段?)
|
|
|
expertise = sheet.getCell(6, row).getContents().trim(); //6 人员专长
|
|
|
hospitalName = sheet.getCell(7, row).getContents().trim(); //7 机构名称
|
|
|
deptName = sheet.getCell(8, row).getContents().trim(); //8 科室
|
|
|
introduce = sheet.getCell(9, row).getContents().trim();//9 医生简介
|
|
|
String levelName = sheet.getCell(10, row).getContents().trim();//10 三师类型
|
|
|
shequType = sheet.getCell(11, row).getContents().trim();//11 社区内类型
|
|
|
if (
|
|
|
StringUtils.isEmpty(name) && StringUtils.isEmpty(idCard)
|
|
|
&& StringUtils.isEmpty(mobile) && StringUtils.isEmpty(jobName)
|
|
|
&& StringUtils.isEmpty(expertise) && StringUtils.isEmpty(hospitalName)
|
|
|
&& StringUtils.isEmpty(deptName) && StringUtils.isEmpty(introduce)
|
|
|
&& StringUtils.isEmpty(levelName) && StringUtils.isEmpty(shequType)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
doctor.setName(name);
|
|
|
doctor.setIdCard(idCard);
|
|
|
doctor.setMobile(mobile);
|
|
|
doctor.setJobName(jobName);
|
|
|
doctor.setExpertise(expertise);
|
|
|
doctor.setHospitalName(hospitalName);
|
|
|
doctor.setDeptName(deptName);
|
|
|
doctor.setIntroduce(introduce);
|
|
|
doctor.setLevelName(levelName);
|
|
|
doctor.setShequType(shequType);
|
|
|
|
|
|
boolean isRepeatFlag = false;//表中姓名、手机号、身份证号是否重复(有重复保存第一个,其余返回)
|
|
|
|
|
|
//表中的机构名不能为空,且需与机构列表传递过来的一致
|
|
|
if (StringUtils.isEmpty(hospitalName)) {
|
|
|
errorMsgMap.put("hospitalName", "表中的机构名称不能为空!;");
|
|
|
errorMsg += "表中的机构名称不能为空!;";
|
|
|
} else if (!StringUtils.equals(hospitalName, orgName)) {
|
|
|
errorMsgMap.put("hospitalName", "表中的机构名称与已建立的机构名称不一致!!");
|
|
|
errorMsg += "表中的机构名称与已建立的机构名称不一致!;";
|
|
|
}
|
|
|
//手机号不能为空、唯一性
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
errorMsgMap.put("mobile", "手机号码不能为空;");
|
|
|
errorMsg += "手机号码不能为空!;";
|
|
|
} else {
|
|
|
//手机格式判断
|
|
|
//
|
|
|
boolean flag = doctorService.isExistMobile(mobile);
|
|
|
if (!mobile.matches("^[0-9]{11}$")) {
|
|
|
errorMsgMap.put("mobile", "手机格式不正确;");
|
|
|
errorMsg += "手机格式不正确;";
|
|
|
} else if (flag) {
|
|
|
errorMsgMap.put("mobile", "手机号已注册;");
|
|
|
errorMsg += "手机号已注册;";
|
|
|
} else if (mobileSet.contains(mobile)) {
|
|
|
errorMsgMap.put("mobile", "-表中存在重复电话号码,只导入第一条;");
|
|
|
errorMsg += "表中存在重复电话号码;";
|
|
|
isRepeatFlag = true;
|
|
|
} else {
|
|
|
mobileSet.add(mobile);
|
|
|
}
|
|
|
}
|
|
|
//唯一性验证
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
errorMsgMap.put("name", "医生姓名不能为空!;");
|
|
|
errorMsg += "医生姓名不能为空!;";
|
|
|
} else {
|
|
|
boolean flag = doctorService.findByNameHospital(name, orgCode);
|
|
|
if (flag) {
|
|
|
errorMsgMap.put("name", "该机构下该医生姓名已存在,请确认!!");
|
|
|
errorMsg += "该机构下该医生姓名已存在,请确认,若是存在同名情况,请手工新增!;";
|
|
|
}
|
|
|
if (nameSet.contains(name)) {
|
|
|
errorMsgMap.put("name", errorMsg.indexOf("name") + "-表中存在重复人名,只导入第一条;");
|
|
|
errorMsg += "表中存在重复人名;";
|
|
|
isRepeatFlag = true;
|
|
|
} else {
|
|
|
nameSet.add(name);
|
|
|
}
|
|
|
}
|
|
|
//判断身份证是否为空,取相关信息
|
|
|
if (!StringUtils.isEmpty(idCard)) {
|
|
|
if (!idcardValidator.isValidatedAllIdcard(idCard)) {
|
|
|
errorMsgMap.put("idCard", "身份证格式有误;");
|
|
|
errorMsg += "身份证格式有误;";
|
|
|
} else if (doctorService.isExistIdCard(idCard)) {
|
|
|
errorMsgMap.put("idCard", "医生身份证已存在,请确认!;");
|
|
|
errorMsg += "医生身份证已存在,请确认!;";
|
|
|
} else {
|
|
|
sex = doctorService.getGenderByIdCard(idCard);
|
|
|
birthday = doctorService.getBirthdayByIdCard(idCard);
|
|
|
}
|
|
|
}
|
|
|
//三师类型不能为空
|
|
|
if (StringUtils.isEmpty(levelName)) {
|
|
|
errorMsgMap.put("levelName", "三师类型不能为空!;");
|
|
|
errorMsg += "三师类型不能为空!;";
|
|
|
}
|
|
|
if (StringUtils.equals(levelName, "专科医生")) {
|
|
|
level = 1;
|
|
|
} else if (StringUtils.equals(levelName, "全科医生")) {
|
|
|
level = 2;
|
|
|
} else if (StringUtils.equals(levelName, "健康管理师")) {
|
|
|
level = 3;
|
|
|
} else if (StringUtils.equals(levelName, "管理员")) {
|
|
|
level = 10;
|
|
|
} else {
|
|
|
errorMsgMap.put("levelName", "三师类型不正确!;");
|
|
|
errorMsg += "三师类型不正确!;";
|
|
|
}
|
|
|
|
|
|
if (!StringUtils.isEmpty(errorMsg.trim())) {
|
|
|
doctor.setErrorMsg(errorMsg);
|
|
|
errorLs.add(doctor);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//插入数据集信息
|
|
|
|
|
|
doctor.setCode(UUID.randomUUID().toString().replace("-", ""));
|
|
|
doctor.setBirthday(StringUtils.isEmpty(birthday) == true ? null : DateUtils.parseDate(birthday, "yyyy-MM-dd"));
|
|
|
doctor.setSex(sex);
|
|
|
|
|
|
//初始密码、salt值
|
|
|
String subMobile = mobile.substring(5);
|
|
|
String salt = UUID.randomUUID().toString().replace("-", "");
|
|
|
doctor.setSalt(salt);
|
|
|
doctor.setPassword(MD5.GetMD5Code(subMobile + salt));
|
|
|
|
|
|
doctor.setStatus(status);
|
|
|
doctor.setHospital(hospital);
|
|
|
doctor.setIscertified(0);
|
|
|
doctor.setCzrq(new Date());
|
|
|
doctor.setLevel(level);
|
|
|
doctor.setShequType(shequType);
|
|
|
doctor.setIsFamous(isFamous);
|
|
|
doctor.setErrorMsgMap(errorMsgMap);
|
|
|
doctor.setPhoto("../../../images/d-male.png");
|
|
|
correctLs.add(doctor);
|
|
|
}
|
|
|
|
|
|
doctorService.saveDoctorList(correctLs);
|
|
|
//包装导入结果(导入成功数量、错误对象集合)
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("successNum", correctLs.size());
|
|
|
map.put("failedNum", errorLs.size());
|
|
|
map.put("errorData", errorLs);
|
|
|
return write(200, "操作成功", "data", map);
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/importData", produces = "application/json;charset=UTF-8")
|
|
|
@ResponseBody
|
|
|
public String importData(HttpServletRequest request) {
|
|
|
try {
|
|
|
request.setCharacterEncoding("UTF-8");
|
|
|
InputStream inputStream = request.getInputStream();
|
|
|
Workbook workbook = Workbook.getWorkbook(inputStream);
|
|
|
|
|
|
doctorService.importData(workbook);
|
|
|
|
|
|
return write(200, "操作成功");
|
|
|
|
|
|
} catch (IOException | BiffException | ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//导入失败数据生成Excel表
|
|
|
@RequestMapping(value = "toExcel", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
|
|
public void errorDataToExcel(@RequestParam(value = "errorData") String errorData, HttpServletResponse response) {
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, Doctor.class);
|
|
|
List<Doctor> lst = (List<Doctor>) objectMapper.readValue(errorData, javaType);
|
|
|
response.setContentType("octets/stream");
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + new String("errorTable.xls"));
|
|
|
OutputStream os = response.getOutputStream();
|
|
|
this.write(os, lst);
|
|
|
} catch (Exception ex) {
|
|
|
error(ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void addHeader(WritableSheet ws) throws WriteException {
|
|
|
String[] header = {"姓名", "身份证号", "手机号", "人员类型", "临床职称", "行政职称", "人员专长", "机构名称", "科室", "医生简介", "三师类型", "社区内类型"};
|
|
|
int i = 0;
|
|
|
for (String h : header) {
|
|
|
addCell(ws, 0, i, h);//表名,行,列,header
|
|
|
i++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void write(WritableWorkbook wwb, List ls) throws Exception {
|
|
|
try {
|
|
|
WritableSheet ws;
|
|
|
ws = wwb.createSheet("sheet", 1);
|
|
|
addHeader(ws);
|
|
|
int i = 1;
|
|
|
for (Doctor doc : (List<Doctor>) ls) {
|
|
|
Map<String, String> map = doc.getErrorMsgMap();
|
|
|
|
|
|
addCell(ws, i, 0, doc.getName(), map.get("name"));
|
|
|
addCell(ws, i, 1, doc.getIdCard(), map.get("idCard"));
|
|
|
addCell(ws, i, 2, doc.getMobile(), map.get("mobile"));
|
|
|
addCell(ws, i, 3, "", "");
|
|
|
addCell(ws, i, 4, doc.getJobName(), map.get("jobName"));
|
|
|
addCell(ws, i, 5, "", "");
|
|
|
addCell(ws, i, 6, doc.getExpertise(), map.get("expertise"));
|
|
|
addCell(ws, i, 7, doc.getHospitalName(), map.get("hospitalName"));
|
|
|
addCell(ws, i, 8, doc.getDeptName(), map.get("deptName"));
|
|
|
addCell(ws, i, 9, doc.getIntroduce(), map.get("introduce"));
|
|
|
addCell(ws, i, 10, doc.getLevelName(), map.get("levelName"));
|
|
|
addCell(ws, i, 11, doc.getShequType(), map.get("shequType"));
|
|
|
i++;
|
|
|
}
|
|
|
wwb.write();
|
|
|
wwb.close();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
if (wwb != null) wwb.close();
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void write(OutputStream os, List ls) throws Exception {
|
|
|
write(Workbook.createWorkbook(os), ls);
|
|
|
}
|
|
|
|
|
|
;
|
|
|
|
|
|
//添加单元格内容
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
//添加单元格内容
|
|
|
public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
|
|
|
Label label = new Label(column, row, data);
|
|
|
if (!org.springframework.util.StringUtils.isEmpty(memo)) {
|
|
|
WritableCellFeatures cellFeatures = new WritableCellFeatures();
|
|
|
cellFeatures.setComment(memo);
|
|
|
label.setCellFeatures(cellFeatures);
|
|
|
}
|
|
|
ws.addCell(label);
|
|
|
}
|
|
|
|
|
|
//初始化密码
|
|
|
@RequestMapping(value = "initPassword")
|
|
|
@ResponseBody
|
|
|
public String initPassword(
|
|
|
@RequestParam(value = "doctorId", required = true) Long doctorId,
|
|
|
@RequestParam(value = "mobile", required = true) String mobile) {
|
|
|
try {
|
|
|
boolean res = doctorService.initPassword(doctorId, mobile);
|
|
|
return res == true ? write(200, "操作成功!") : error(-1, "操作失败!");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "操作失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//电话号码唯一性验证
|
|
|
@RequestMapping(value = "isExistMobile")
|
|
|
@ResponseBody
|
|
|
public String isExistMobile(@RequestParam(value = "mobile", required = true) String mobile) {
|
|
|
if (doctorService.isExistMobile(mobile)) {
|
|
|
return "true";
|
|
|
}
|
|
|
return "false";
|
|
|
}
|
|
|
|
|
|
//身份证号唯一性验证
|
|
|
@RequestMapping(value = "isExistIdCard")
|
|
|
@ResponseBody
|
|
|
public String isExistIdCard(@RequestParam(value = "idCard", required = true) String idCard) {
|
|
|
if (doctorService.isExistIdCard(idCard)) {
|
|
|
return "true";
|
|
|
}
|
|
|
return "false";
|
|
|
}
|
|
|
|
|
|
}
|