增加了医生白名单导入
This commit is contained in:
parent
e13129a171
commit
7d91e804a2
2
pom.xml
2
pom.xml
@ -24,7 +24,7 @@
|
||||
<mybatis-plus.version>3.5.2</mybatis-plus.version>
|
||||
<p6spy.version>3.8.6</p6spy.version>
|
||||
<swagger.version>2.7.0</swagger.version>
|
||||
<fastjson.version>2.0.16</fastjson.version>
|
||||
<fastjson.version>1.2.83</fastjson.version>
|
||||
<druid.version>1.2.14</druid.version>
|
||||
<google-linkedhashmap.version>1.4.2</google-linkedhashmap.version>
|
||||
<google-guava.version>20.0</google-guava.version>
|
||||
|
||||
@ -6,10 +6,13 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 专家表-白名单实体类
|
||||
*/
|
||||
@TableName("`t_caseplatform_expert_white`") // 指定数据库表名
|
||||
@Data
|
||||
public class ExpertWhiteEntity {
|
||||
/**
|
||||
* 主键
|
||||
@ -17,12 +20,6 @@ public class ExpertWhiteEntity {
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@ -30,16 +27,10 @@ public class ExpertWhiteEntity {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
* 手机号
|
||||
*/
|
||||
@TableField("photo")
|
||||
private String photo;
|
||||
|
||||
/**
|
||||
* 医院uuid
|
||||
*/
|
||||
@TableField("hospital_uuid")
|
||||
private String hospitalUuid;
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 医院名称
|
||||
@ -48,21 +39,33 @@ public class ExpertWhiteEntity {
|
||||
private String hospitalName;
|
||||
|
||||
/**
|
||||
* 省ID
|
||||
* 省(行政区划代码)
|
||||
*/
|
||||
@TableField("prov_id")
|
||||
private Integer provinceId;
|
||||
@TableField("prov")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 市ID
|
||||
* 科室
|
||||
*/
|
||||
@TableField("city_id")
|
||||
private Integer cityId;
|
||||
@TableField("department")
|
||||
private String department;
|
||||
|
||||
/**
|
||||
* 区ID
|
||||
* 职称
|
||||
*/
|
||||
@TableField("county_id")
|
||||
private Integer countyId;
|
||||
@TableField("title")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 导入的json数据
|
||||
*/
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package net.lab1024.sa.admin.module.business.caseplatformcase.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.service.CaseplatformCaseService;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcaseabstrac.service.CaseplatformCaseAbstracService;
|
||||
import net.lab1024.sa.common.common.domain.PageResult;
|
||||
import net.lab1024.sa.common.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.common.common.exception.BusinessException;
|
||||
import net.lab1024.sa.common.module.support.operatelog.annoation.OperateLog;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "")
|
||||
@OperateLog
|
||||
public class CaseplatformExpertWhiteController {
|
||||
|
||||
@Autowired
|
||||
private CaseplatformCaseService caseplatformCaseService;
|
||||
|
||||
|
||||
@ApiOperation("医生管理导入")
|
||||
@PostMapping("/caseplatformExpertWhite/import")
|
||||
public ResponseDTO<T> caseplatformExpertWhiteImport(@RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
caseplatformCaseService.importExperts(file);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}
|
||||
|
||||
return ResponseDTO.app_ok();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,15 @@
|
||||
package net.lab1024.sa.admin.module.business.caseplatformcase.service;
|
||||
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
// import com.alibaba.fastjson.JSON;
|
||||
// import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.lab1024.sa.admin.module.app.expert.admin.ExpertWhiteEntity;
|
||||
import net.lab1024.sa.admin.module.app.expert.dao.ExpertWhiteEntityDao;
|
||||
import net.lab1024.sa.admin.module.business.area.domain.vo.ProvVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.dao.CaseplatformCaseDao;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.entity.CaseplatformCaseEntity;
|
||||
@ -22,14 +30,24 @@ import net.lab1024.sa.admin.module.system.login.domain.LoginEmployeeDetail;
|
||||
import net.lab1024.sa.common.common.domain.PageResult;
|
||||
import net.lab1024.sa.common.common.domain.RequestUser;
|
||||
import net.lab1024.sa.common.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.common.common.exception.BusinessException;
|
||||
import net.lab1024.sa.common.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.common.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.common.common.util.SmartRequestUtil;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static net.lab1024.sa.common.common.code.UserErrorCode.NO_PERMISSION;
|
||||
|
||||
@ -56,6 +74,12 @@ public class CaseplatformCaseService {
|
||||
@Autowired
|
||||
private CaseplatformCaseCheckdataService checkdataService;
|
||||
|
||||
@Autowired
|
||||
private ExpertWhiteEntityDao expertWhiteDao;
|
||||
|
||||
// 创建 ObjectMapper 实例(建议使用 Spring 注入或静态常量)
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
@ -208,4 +232,122 @@ public class CaseplatformCaseService {
|
||||
return "解析失败";
|
||||
}
|
||||
}
|
||||
|
||||
public void importExperts(MultipartFile file) throws Exception {
|
||||
try (InputStream is = file.getInputStream();
|
||||
Workbook workbook = WorkbookFactory.create(is)) { // 自动识别 .xls 或 .xlsx
|
||||
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// 从第 1 行开始读取(跳过标题行)
|
||||
int rowNum = 0;
|
||||
for (Iterator<Row> it = sheet.rowIterator(); it.hasNext();) {
|
||||
Row row = it.next();
|
||||
|
||||
// 跳过第一行标题
|
||||
if (rowNum++ == 0) continue;
|
||||
|
||||
// 判断整行是否为空
|
||||
boolean isEmptyRow = true;
|
||||
for (Cell cell : row) {
|
||||
if (cell != null && cell.getCellType() != CellType.BLANK) {
|
||||
isEmptyRow = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEmptyRow) {
|
||||
continue; // 跳过空行
|
||||
}
|
||||
|
||||
String name = "";
|
||||
String prov = "";
|
||||
String hospitalName = "";
|
||||
String department = "";
|
||||
String title = "";
|
||||
String mobile = "";
|
||||
|
||||
DataFormatter dataFormatter = new DataFormatter();
|
||||
|
||||
Cell cell0 = row.getCell(0); if (cell0 != null) name = cell0.toString().trim();
|
||||
Cell cell1 = row.getCell(1); if (cell1 != null) prov = cell1.toString().trim();
|
||||
Cell cell2 = row.getCell(2); if (cell2 != null) hospitalName = cell2.toString().trim();
|
||||
Cell cell3 = row.getCell(3); if (cell3 != null) department = cell3.toString().trim();
|
||||
Cell cell4 = row.getCell(4); if (cell4 != null) title = cell4.toString().trim();
|
||||
Cell cell5 = row.getCell(5); if (cell5 != null) mobile = dataFormatter.formatCellValue(cell5).trim();
|
||||
|
||||
// 检测是否导入重复
|
||||
LambdaQueryWrapper<ExpertWhiteEntity> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ExpertWhiteEntity::getMobile, mobile);
|
||||
ExpertWhiteEntity expertWhite = expertWhiteDao.selectOne(queryWrapper);
|
||||
if (expertWhite != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
expertWhite = new ExpertWhiteEntity();
|
||||
expertWhite.setName(name);
|
||||
expertWhite.setProvince(prov);
|
||||
expertWhite.setHospitalName(hospitalName);
|
||||
expertWhite.setDepartment(department);
|
||||
expertWhite.setTitle(title);
|
||||
expertWhite.setMobile(mobile);
|
||||
expertWhite.setCreateTime(LocalDateTime.now());
|
||||
expertWhiteDao.insert(expertWhite);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("文件读取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 白名单专家导入
|
||||
*/
|
||||
// public void importExperts(MultipartFile file) throws Exception {
|
||||
// ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
||||
//
|
||||
// // 不读取表头(跳过第一行),直接读内容(按列索引)
|
||||
// List<List<Object>> rows = reader.read(1, reader.getRowCount());
|
||||
//
|
||||
// for (List<Object> row : rows) {
|
||||
// String name = !row.isEmpty() ? String.valueOf(row.get(0)).trim() : "";// 姓名
|
||||
// String prov = row.size() > 1 ? String.valueOf(row.get(1)).trim() : ""; // 省份
|
||||
// String hospitalName = row.size() > 1 ? String.valueOf(row.get(2)).trim() : ""; // 医院
|
||||
// String department = row.size() > 2 ? String.valueOf(row.get(3)).trim() : ""; // 科室
|
||||
// String title = row.size() > 3 ? String.valueOf(row.get(4)).trim() : ""; // 职称
|
||||
// String mobile = row.size() > 4 ? String.valueOf(row.get(5)).trim() : ""; // 手机号
|
||||
//
|
||||
// // 构造实体类
|
||||
//
|
||||
//
|
||||
// ExpertWhiteEntity expertWhite = new ExpertWhiteEntity();
|
||||
// expertWhite.setName(name);
|
||||
// expertWhite.setProvince(prov);
|
||||
// expertWhite.setHospitalName(hospitalName);
|
||||
// expertWhite.setDepartment(department);
|
||||
// expertWhite.setTitle(title);
|
||||
// expertWhite.setMobile(mobile);
|
||||
//
|
||||
// Map<String, Object> contentMap = new HashMap<>();
|
||||
// contentMap.put("name", name);
|
||||
// contentMap.put("hospital_name", hospitalName);
|
||||
// contentMap.put("department", department);
|
||||
// contentMap.put("title", title);
|
||||
// contentMap.put("mobile", mobile);
|
||||
// expertWhite.setContent(JSON.toJSONString(contentMap));
|
||||
//
|
||||
// // 构造 content 字段(json)
|
||||
//// JSONObject jsonObject = new JSONObject();
|
||||
//// jsonObject.put("name", name);
|
||||
//// jsonObject.put("hospital_name", hospitalName);
|
||||
//// jsonObject.put("aaa", department);
|
||||
//// jsonObject.put("title", title);
|
||||
//// jsonObject.put("mobile", mobile);
|
||||
//
|
||||
//// expertWhite.setContent(JSON.toJSONString(jsonObject));
|
||||
// expertWhite.setCreateTime(LocalDateTime.now());
|
||||
//
|
||||
// expertWhiteDao.insert(expertWhite);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
||||
import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@ -260,6 +260,12 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson JSON -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package net.lab1024.sa.common.common.util;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.common.common.domain.ResponseDTO;
|
||||
|
||||
|
||||
@ -29,7 +29,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 操作日志记录处理,对所有OperateLog注解的Controller进行操作日志监控
|
||||
@ -185,7 +187,17 @@ public abstract class OperateLogAspect {
|
||||
}
|
||||
|
||||
Object[] args = joinPoint.getArgs();
|
||||
String params = JSON.toJSONString(args);
|
||||
// 新增:处理MultipartFile参数
|
||||
Object[] filteredArgs = Arrays.stream(args)
|
||||
.map(arg -> {
|
||||
if (arg instanceof MultipartFile) {
|
||||
MultipartFile file = (MultipartFile) arg;
|
||||
return "上传文件: " + file.getOriginalFilename() + " (" + file.getSize() + " bytes)";
|
||||
}
|
||||
return arg;
|
||||
})
|
||||
.toArray();
|
||||
String params = JSON.toJSONString(filteredArgs);
|
||||
// 设置方法名称
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
String methodName = joinPoint.getSignature().getName();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user