任务清单导入、导出pdf

master
hcy 2 years ago
parent 3b539ddd2b
commit e1c4655c9a

@ -603,4 +603,15 @@ public class FontController {
public String batchExportPdf(int taskId) throws Exception { public String batchExportPdf(int taskId) throws Exception {
return batchExportService.batchExportPdf(taskId); return batchExportService.batchExportPdf(taskId);
} }
/**
* pdf
* @param taskId
* @param response
*/
@ResponseBody
@RequestMapping(value = "downloadPdfZip", produces = {"text/json;charset=UTF-8"}, method = RequestMethod.POST)
public String downloadPdfZip(int taskId,HttpServletResponse response) throws IOException {
return batchExportService.downloadPdfZip(taskId,response);
}
} }

@ -0,0 +1,128 @@
package com.emr.controller.exportTask;
import com.alibaba.fastjson.JSON;
import com.emr.annotation.OptionalLog;
import com.emr.dao.ExportTaskDetailsMapper;
import com.emr.dao.ExportTaskMapper;
import com.emr.entity.ExportTask;
import com.emr.entity.ExportTaskDetails;
import com.emr.service.ImportExcel.ImportExcelEntity;
import com.emr.service.ImportExcel.ImportExcelUtil;
import com.emr.util.ExceptionPrintUtil;
import com.emr.vo.ExportTaskDetailsVo;
import com.emr.vo.ExportTaskVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.Charset;
import java.util.List;
/**
*
*/
@Controller
@RequestMapping("exportTask/")
public class ExportTaskController {
@Autowired
private ExportTaskMapper exportTaskMapper;
@Autowired
private ExportTaskDetailsMapper exportTaskDetailsMapper;
/*@RequiresPermissions("/exportTask/exportTaskList")*/
@OptionalLog(module = "任务清单列表", methods = "任务清单列表页面")
@RequestMapping("exportTaskList")
public String exportTaskList() {
return "recordManage/exportTask/exportTaskList";
}
@OptionalLog(module = "任务清单列表", methods = "任务清单列表页面")
@RequestMapping("getExportTaskList")
@ResponseBody
public String getExportTaskList(Integer page, Integer limit, ExportTask exportTask,String startTime,String endTime) {
if (null != page && null != limit) {
PageHelper.startPage(page, limit);
}
try {
List<ExportTaskVo> list = exportTaskMapper.getExportTaskList(exportTask,startTime,endTime);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
//根据taskid查询所有需要导出病历的住院号出院日期
List<ExportTaskDetailsVo> taskList = exportTaskDetailsMapper.selectAllByTaskId(list.get(i).getTaskId());
if (taskList != null && taskList.size() > 0) {
list.get(i).setState(0);
}else{
list.get(i).setState(1);
}
}
}
PageInfo pageInfo = new PageInfo<>(list);
return JSON.toJSONString(pageInfo);
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
return null;
}
}
@RequiresPermissions("/exportTask/impExcelTask")
@RequestMapping(value = "impExcelTask", method = {RequestMethod.POST})
@ResponseBody
public ResponseEntity<String> impExcelTask(HttpServletRequest request) {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(new MediaType("text", "html", Charset.forName("UTF-8")));
try {
//读取文件
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) (request);
MultipartFile multipartFile = multiRequest.getFile("upfile");
//属性名
String[] fieldNames = {"inpno", "dischargedatetime"};
//判断集中类中的方法名
String[] judgeMethods = {"judgeInpNo", "judgeDischargeDateTime"};
ExportTaskDetails exportTaskDetails = new ExportTaskDetails();
exportTaskDetails.setState(0);
//实例化
ImportExcelUtil.newInstance("exportTaskDetailsMapper", exportTaskDetails, ExportTaskDetails.class);
//导入excel的操作
ImportExcelEntity excelEntity = ImportExcelUtil.fileImport1(multipartFile, fieldNames, judgeMethods, "");
if (excelEntity.getSuccessCount() == 0 && excelEntity.getWrongCount() == 0) {
//无数据
return new ResponseEntity<String>("无数据!", responseHeaders, HttpStatus.OK);
}
if (excelEntity.getWrongCount() == 0) {
//成功
return new ResponseEntity<String>(null, responseHeaders, HttpStatus.OK);
} else {
//有出错数据
String msgStr = excelEntity.getWorkBookKey() + "@已成功导入" + excelEntity.getSuccessCount() + "条,失败" + excelEntity.getWrongCount() + "条,随后将导出错误记录!";
return new ResponseEntity<String>(msgStr, responseHeaders, HttpStatus.OK);
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
//抛异常
return new ResponseEntity<String>(e.getMessage(), responseHeaders, HttpStatus.OK);
}
}
}

@ -0,0 +1,61 @@
package com.emr.controller.exportTaskDetails;
import com.alibaba.fastjson.JSON;
import com.emr.annotation.OptionalLog;
import com.emr.dao.ExportTaskDetailsMapper;
import com.emr.dao.ExportTaskMapper;
import com.emr.entity.ExportTask;
import com.emr.entity.ExportTaskDetails;
import com.emr.util.ExceptionPrintUtil;
import com.emr.vo.ExportTaskDetailsVo;
import com.emr.vo.ExportTaskVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
*
*/
@Controller
@RequestMapping("exportTaskDetails/")
public class ExportTaskDetailsController {
@Autowired
private ExportTaskMapper exportTaskMapper;
@Autowired
private ExportTaskDetailsMapper exportTaskDetailsMapper;
@OptionalLog(module = "任务清单明细查询", methods = "任务清单明细查询页面")
@RequestMapping("exportTaskDetailsList")
public String exportTaskDetailsList() {
return "recordManage/exportTaskDetails/exportTaskDetailsList";
}
@OptionalLog(module = "任务清单明细列表", methods = "任务清单明细列表页面")
@RequestMapping("getExportTaskDetailsList")
@ResponseBody
public String getExportTaskDetailsList(Integer page, Integer limit, ExportTaskDetails exportTaskDetails,String startTime,String endTime) {
if (null != page && null != limit) {
PageHelper.startPage(page, limit);
}
try {
List<ExportTaskDetailsVo> list = exportTaskDetailsMapper.getExportTaskDetailsList(exportTaskDetails,startTime,endTime);
PageInfo pageInfo = new PageInfo<>(list);
return JSON.toJSONString(pageInfo);
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
return null;
}
}
}

@ -1,5 +1,6 @@
package com.emr.dao; package com.emr.dao;
import com.emr.entity.ExportTaskDetails;
import com.emr.vo.ExportDetailsVo; import com.emr.vo.ExportDetailsVo;
import com.emr.vo.ExportTaskDetailsVo; import com.emr.vo.ExportTaskDetailsVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -20,4 +21,23 @@ public interface ExportTaskDetailsMapper {
List<ExportDetailsVo> getfilePath(@Param("inpNo") String inpNo, @Param("dischargeDateTime") String dischargeDateTime); List<ExportDetailsVo> getfilePath(@Param("inpNo") String inpNo, @Param("dischargeDateTime") String dischargeDateTime);
int upStatc(@Param("state") int state,@Param("id") int id); int upStatc(@Param("state") int state,@Param("id") int id);
int deleteByPrimaryKey(Integer id);
int insert(ExportTaskDetails record);
int insertSelective(ExportTaskDetails record);
ExportTaskDetails selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ExportTaskDetails record);
int updateByPrimaryKey(ExportTaskDetails record);
int SimpleInsert(List<ExportTaskDetails> list);
ExportTaskDetails selectExportTaskDetailsByInpNo(@Param("inpNo") String inpNo);
List<ExportTaskDetailsVo> getExportTaskDetailsList(@Param("record") ExportTaskDetails exportTaskDetails,@Param("startTime") String startTime,@Param("endTime") String endTime);
} }

@ -0,0 +1,25 @@
package com.emr.dao;
import com.emr.entity.ExportTask;
import com.emr.vo.ExportTaskVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExportTaskMapper {
int deleteByPrimaryKey(Integer taskId);
int insert(ExportTask record);
int insertSelective(ExportTask record);
ExportTask selectByPrimaryKey(Integer taskId);
int updateByPrimaryKeySelective(ExportTask record);
int updateByPrimaryKey(ExportTask record);
ExportTask getExportTaskByName(@Param("taskName") String taskName);
List<ExportTaskVo> getExportTaskList(@Param("record") ExportTask exportTask,@Param("startTime") String startTime,@Param("endTime") String endTime);
}

@ -0,0 +1,46 @@
package com.emr.entity;
import java.util.Date;
public class ExportTask {
private Integer taskId;
private String taskName;
private Integer state;
private Date createDate;
public Integer getTaskId() {
return taskId;
}
public void setTaskId(Integer taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName == null ? null : taskName.trim();
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}

@ -0,0 +1,56 @@
package com.emr.entity;
import java.util.Date;
public class ExportTaskDetails {
private Integer id;
private Integer taskid;
private String inpno;
private Date dischargedatetime;
private Integer state;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getTaskid() {
return taskid;
}
public void setTaskid(Integer taskid) {
this.taskid = taskid;
}
public String getInpno() {
return inpno;
}
public void setInpno(String inpno) {
this.inpno = inpno == null ? null : inpno.trim();
}
public Date getDischargedatetime() {
return dischargedatetime;
}
public void setDischargedatetime(Date dischargedatetime) {
this.dischargedatetime = dischargedatetime;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
}

@ -1,16 +1,21 @@
package com.emr.service.ImportExcel; package com.emr.service.ImportExcel;
import com.emr.dao.CommomMapper; import com.emr.dao.CommomMapper;
import com.emr.dao.ExportTaskMapper;
import com.emr.dao.approve.Emr_Apply_ApproveMapper; import com.emr.dao.approve.Emr_Apply_ApproveMapper;
import com.emr.entity.ExportTask;
import com.emr.entity.ExportTaskDetails;
import com.emr.entity.Power_User; import com.emr.entity.Power_User;
import com.emr.entity.ResultUtil; import com.emr.entity.ResultUtil;
import com.emr.entity.approve.Emr_Apply_Approve; import com.emr.entity.approve.Emr_Apply_Approve;
import com.emr.vo.commomSearch.CommomVo; import com.emr.vo.commomSearch.CommomVo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.ContextLoader; import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
@ -20,6 +25,7 @@ import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -44,6 +50,9 @@ public class ImportExcelJudgeMethod {
@Autowired @Autowired
private Emr_Apply_ApproveMapper applyApproveMapper; private Emr_Apply_ApproveMapper applyApproveMapper;
@Autowired
private ExportTaskMapper exportTaskMapper;
/****************************************导入公共判断******************************************************/ /****************************************导入公共判断******************************************************/
/** /**
* *
@ -58,6 +67,52 @@ public class ImportExcelJudgeMethod {
Method method = cls.getDeclaredMethod(SIMPLEINSERT,List.class); Method method = cls.getDeclaredMethod(SIMPLEINSERT,List.class);
return (int)method.invoke(bean,list); return (int)method.invoke(bean,list);
} }
/**
*
*/
public int SimpleInsert1(List<Object> list, String mapperName, String value) throws Exception {
int t = 0;
String taskName = value.replaceAll(".xls", "").replaceAll(".xlsx", "");
ExportTask task = null;
task = exportTaskMapper.getExportTaskByName(taskName);
if (list != null && list.size() > 0) {
ExportTask exportTask = new ExportTask();
exportTask.setTaskName(taskName);
exportTask.setState(0);
exportTask.setCreateDate(new Date());
if (ObjectUtils.isEmpty(task)) {
//任务清单主表插入
exportTaskMapper.insertSelective(exportTask);
//根据任务名称查找任务清单id
task = exportTaskMapper.getExportTaskByName(taskName);
}else{
exportTask.setTaskId(task.getTaskId());
exportTaskMapper.updateByPrimaryKeySelective(exportTask);
}
for (int i = 0; i < list.size(); i++) {
ExportTaskDetails exportTaskDetails = (ExportTaskDetails) list.get(i);
exportTaskDetails.setTaskid(task.getTaskId());
}
//注入判断方法集中类
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
//获取类实例
Object bean = wac.getBean(mapperName);
Class<?> cls = bean.getClass();
//获取执行方法
Method method = cls.getDeclaredMethod(SIMPLEINSERT, List.class);
t = (int) method.invoke(bean, list);
}
return t;
}
/****************************************自定义验证记录合法******************************************************/ /****************************************自定义验证记录合法******************************************************/
public String judgeRecord(String fieldName, String value, Field f, Object object, String head)throws Exception{ public String judgeRecord(String fieldName, String value, Field f, Object object, String head)throws Exception{
Emr_Apply_Approve applyApprove = (Emr_Apply_Approve)object; Emr_Apply_Approve applyApprove = (Emr_Apply_Approve)object;
@ -199,4 +254,80 @@ public class ImportExcelJudgeMethod {
} }
return ""; return "";
} }
/**
* taskId
*
* @param fieldName
* @param value
* @param f
* @param object
* @param head
* @return
*/
public String judgeTaskId(String fieldName, String value, Field f, Object object, String head) throws Exception {
if ("taskid".equals(fieldName)) {
if (StringUtils.isBlank(value)) {
return "\"" + head + "\"不能为空,";
}
f.set(object, Integer.valueOf(value));
}
return "";
}
/**
*
*
* @param fieldName
* @param value
* @param f
* @param object
* @param head
* @return
*/
public String judgeInpNo(String fieldName, String value, Field f, Object object, String head) throws Exception {
if ("inpno".equals(fieldName)) {
if (StringUtils.isBlank(value)) {
return "\"" + head + "\"不能为空,";
}
//判断长度
if (value.length() > 30) {
return "\"" + head + "\"输入内容太长,长度为30,";
}
//判断当前行病案号是否已经存在
/*ExportTaskDetails exportTaskDetails = exportTaskDetailsMapper.selectExportTaskDetailsByInpNo(value);
if (exportTaskDetails != null) {
return "\"" + head + "\"已存在,";
}*/
f.set(object, value);
}
return "";
}
/**
*
*
* @param fieldName
* @param value
* @param f
* @param object
* @param head
* @return
*/
public String judgeDischargeDateTime(String fieldName, String value, Field f, Object object, String head) throws Exception {
if ("dischargedatetime".equals(fieldName)) {
if (StringUtils.isBlank(value)) {
return "\"" + head + "\"不能为空,";
}
f.set(object, DateUtil.parseYYYYMMDDDate(value));
}
return "";
}
} }

@ -41,6 +41,8 @@ public class ImportExcelUtil {
//公共批量插入方法 //公共批量插入方法
private static final String SIMPLEINSERT = "SimpleInsert"; private static final String SIMPLEINSERT = "SimpleInsert";
private static final String SIMPLEINSERT1 = "SimpleInsert1";
public static void newInstance(String mapperName,Object o,Class oClass){ public static void newInstance(String mapperName,Object o,Class oClass){
MAPPERNAME = mapperName; MAPPERNAME = mapperName;
object = o; object = o;
@ -150,6 +152,109 @@ public class ImportExcelUtil {
return excelEntity; return excelEntity;
} }
/**
*
*
* @param multipartFile
* @return
*/
public static ImportExcelEntity fileImport1(MultipartFile multipartFile, String[] fieldNames, String[] judgeMethods, String jedgeMethod) {
Workbook workbook = null;
int successCount = 0;
int wrongCount = 0;
String workBookKey = "";
//正确行数下角标
List<Integer> wrongRowIndex = new ArrayList<>();
try {
/*把文件流copy读取到文件中*/
workbook = WorkbookFactory.create(multipartFile.getInputStream());
/*遍历sheet页*/
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
Sheet sheet = workbook.getSheetAt(i);
if (sheet == null) {
continue;
}
//获取表头行
Row head = sheet.getRow(0);
/*遍历行这里j的初始值取1是因为我的表格里第一行是表头*/
List<Object> list = new ArrayList<>();
for (int j = 1; j < sheet.getPhysicalNumberOfRows(); j++) {
Row row = sheet.getRow(j);
boolean flag = isRowEmpty(row);
if (!flag) {
if (row.getPhysicalNumberOfCells() != 0) {
StringBuilder wrongStr = new StringBuilder();
for (int k = 0; k < fieldNames.length; k++) {
//对象赋值后返回错误对象
wrongStr.append(getValueByField(object, fieldNames[k], getCellValue(row.getCell(k)), getCellValue(head.getCell(k)), judgeMethods[k]));
}
//有错误信息在行尾创建cell并标红提示文字
if (StringUtils.isBlank(wrongStr)) {
Constructor constructor = ObjectClass.getDeclaredConstructor();
Object obj = (Object) constructor.newInstance();
//判断是否有自定义条件
if (StringUtils.isNotBlank(jedgeMethod)) {
//判断是否有报错信息,有报错信息添加到报错信息
String valueByField = judgeMethod(jedgeMethod);
if (StringUtils.isNotBlank(valueByField)) {
wrongStr.append(valueByField);
} else {
successCount++;
wrongRowIndex.add(j);
//复制
copy(object, obj);
list.add(obj);
}
} else {
successCount++;
wrongRowIndex.add(j);
//复制
copy(object, obj);
list.add(obj);
}
}
if (StringUtils.isNotBlank(wrongStr)) {
//设置错误信息字体为红色加粗
Font font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setColor(HSSFColor.RED.index);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
Cell cell = row.createCell(fieldNames.length);
cell.setCellStyle(cellStyle);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
wrongStr = new StringBuilder(wrongStr.substring(0, wrongStr.length() - 1));
cell.setCellValue(wrongStr.toString());
wrongCount++;
}
}
}
}
//批量新增成功记录
SimpleInsert1(list, multipartFile.getOriginalFilename());
//删除正确行
if (!wrongRowIndex.isEmpty()) {
//定义删除次数,对应后方下角标都要减去删除次数
int deleteCount = 0;
//递归删除
removeSheet(sheet, deleteCount, wrongRowIndex);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException();
}
//错误excel加入缓存
if (wrongCount != 0) {
workBookKey = UUIDUtils.getUUID();
workBookMap.put(workBookKey, workbook);
}
ImportExcelEntity excelEntity = new ImportExcelEntity();
excelEntity.setSuccessCount(successCount);
excelEntity.setWrongCount(wrongCount);
excelEntity.setWorkBookKey(workBookKey);
return excelEntity;
}
//批量新增成功数据方法 //批量新增成功数据方法
private static int SimpleInsert(List<Object> list)throws Exception{ private static int SimpleInsert(List<Object> list)throws Exception{
if(null != list && !list.isEmpty()){ if(null != list && !list.isEmpty()){
@ -170,6 +275,26 @@ public class ImportExcelUtil {
} }
} }
//批量新增成功数据方法
private static int SimpleInsert1(List<Object> list, String value) throws Exception {
if (null != list && !list.isEmpty()) {
//注入判断方法集中类
//插入数据库
//反射执行插入方法
//获取当前上下文环境spring容器
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
//获取类实例
Object bean = wac.getBean(IMPORTEXCELJUDGEMETHOD);
Class<?> cls = bean.getClass();
//获取执行方法
Method method = cls.getDeclaredMethod(SIMPLEINSERT1, List.class, String.class, String.class);
return (int) method.invoke(bean, list, MAPPERNAME, value);
//执行方法
} else {
return 0;
}
}
//判断空行 //判断空行
private static boolean isRowEmpty(Row row) { private static boolean isRowEmpty(Row row) {
for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) { for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
@ -286,7 +411,7 @@ public class ImportExcelUtil {
if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式 if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式
SimpleDateFormat sdf = null; SimpleDateFormat sdf = null;
// 验证short值 // 验证short值
if (cell.getCellStyle().getDataFormat() == 14) { if (cell.getCellStyle().getDataFormat() == 14 || cell.getCellStyle().getDataFormat() == 176) {
sdf = new SimpleDateFormat("yyyy/MM/dd"); sdf = new SimpleDateFormat("yyyy/MM/dd");
} else if (cell.getCellStyle().getDataFormat() == 21) { } else if (cell.getCellStyle().getDataFormat() == 21) {
sdf = new SimpleDateFormat("HH:mm:ss"); sdf = new SimpleDateFormat("HH:mm:ss");

@ -1,5 +1,7 @@
package com.emr.service.batchExport; package com.emr.service.batchExport;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List; import java.util.List;
/** /**
@ -14,4 +16,6 @@ public interface BatchExportService {
//批量导出 //批量导出
String batchExportPdf(int taskId)throws Exception; String batchExportPdf(int taskId)throws Exception;
String downloadPdfZip(int taskId, HttpServletResponse response) throws IOException;
} }

@ -1,9 +1,11 @@
package com.emr.service.batchExport; package com.emr.service.batchExport;
import com.emr.dao.ExportTaskDetailsMapper; import com.emr.dao.ExportTaskDetailsMapper;
import com.emr.dao.emrPdfWaterSet.EmrPdfWaterSetMapper;
import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet; import com.emr.entity.emrPdfWaterSet.EmrPdfWaterSet;
import com.emr.util.ExceptionPrintUtil; import com.emr.util.ExceptionPrintUtil;
import com.emr.util.Logger; import com.emr.util.Logger;
import com.emr.util.img2PdfUtil;
import com.emr.vo.ExportDetailsVo; import com.emr.vo.ExportDetailsVo;
import com.emr.vo.ExportTaskDetailsVo; import com.emr.vo.ExportTaskDetailsVo;
import com.emr.vo.commomSearch.ScanPathVo; import com.emr.vo.commomSearch.ScanPathVo;
@ -17,12 +19,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static com.emr.util.img2PdfUtil.addWaterMark; import static com.emr.util.img2PdfUtil.addWaterMark;
@ -35,10 +40,17 @@ import static com.emr.util.img2PdfUtil.addWaterMark;
*/ */
@Service @Service
public class BatchExportServiceImpl implements BatchExportService { public class BatchExportServiceImpl implements BatchExportService {
private static Logger logger = new Logger(); //private static Logger logger = new Logger();
@Resource
private Logger logger;
@Autowired @Autowired
ExportTaskDetailsMapper exportTaskDetailsMapper; ExportTaskDetailsMapper exportTaskDetailsMapper;
@Autowired
private EmrPdfWaterSetMapper pdfWaterSetMapper;
@Value("${export_pdf_hospital_info}") @Value("${export_pdf_hospital_info}")
private String flieName; private String flieName;
@ -189,4 +201,201 @@ public class BatchExportServiceImpl implements BatchExportService {
String formattedDate = targetFormat.format(date); String formattedDate = targetFormat.format(date);
return flieName + "_" + dto.getInpNo() + "_" + formattedDate; return flieName + "_" + dto.getInpNo() + "_" + formattedDate;
} }
@Override
public String downloadPdfZip(int taskId, HttpServletResponse response) throws IOException {
//是否存在目录不存在创建
File file = new File(exportPdfPath);
if (!file.isDirectory()) {
file.mkdirs();
}
//根据taskid查询所有需要导出病历的住院号出院日期
List<ExportTaskDetailsVo> taskList = exportTaskDetailsMapper.selectAllByTaskId(taskId);
if (taskList == null) {
return "没有任务";
}
response.reset();
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
ZipOutputStream zos = null;
BufferedOutputStream bos = null;
ByteArrayOutputStream out = null;
BufferedInputStream bis = null;
try {
String zipName = "任务清单pdf压缩包";
zipName = java.net.URLEncoder.encode(zipName, "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + zipName + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ").zip");
zos = new ZipOutputStream(response.getOutputStream());
bos = new BufferedOutputStream(zos);
EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1);
for (ExportTaskDetailsVo list : taskList) {
//根据住院号出院日期查询需要导出病历路径
List<ExportDetailsVo> filePathList = exportTaskDetailsMapper.getfilePath(list.getInpNo(), list.getDischargeDateTime());
if (filePathList == null || filePathList.size() == 0) {
exportTaskDetailsMapper.upStatc(2, list.getId());
logger.log("病案号为:" + list.getInpNo() + "出院时间为:" + list.getDischargeDateTime() + "的病历找不到。");
continue;
}
//组织导出文件名
//fileName = exportFlieName(list);
out = new ByteArrayOutputStream();
Boolean aBoolean = imageToPdf1(filePathList, out, emrPdfWaterSet);
//Boolean aBoolean = imageToPdf(filePathList, fileName,exportPdfPath);
//为true时修改任务状态1完成2失败
if (aBoolean) {
exportTaskDetailsMapper.upStatc(1, list.getId());
String inpNo = list.getInpNo();
String dischargeDateTime = list.getDischargeDateTime();
//格式化日期
String disDateStr = dischargeDateTime.substring(0, 4) + dischargeDateTime.substring(5, 7) + dischargeDateTime.substring(8, 10);
String pdfNameStr = inpNo + "_" + disDateStr;
//每个文件名
String filePdfName = flieName + "_" + pdfNameStr;
zos.putNextEntry(new ZipEntry(filePdfName + ".pdf"));
byte[] file1 = out.toByteArray(); //这个zip文件的字节
bis = new BufferedInputStream(new ByteArrayInputStream(file1));
//输出
int len = 0;
byte[] buf = new byte[1024 * 1024];
while ((len = bis.read(buf, 0, buf.length)) != -1) {
bos.write(buf, 0, len);
}
} else {
exportTaskDetailsMapper.upStatc(2, list.getId());
logger.log("病案号为:" + list.getInpNo() + "出院时间为:" + list.getDischargeDateTime() + "的病历保存失败。");
}
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
e.printStackTrace();
} finally {
try {
if (null != bos) {
bos.flush();
bos.close();
}
if (null != bis) {
bis.close();
}
out.flush();
out.close();
if (null != zos) {
zos.flush();
zos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return "下载完成";
}
public Boolean imageToPdf1(List<ExportDetailsVo> scanPathVos, ByteArrayOutputStream bos, EmrPdfWaterSet pdfWaterSet) {
//ByteArrayOutputStream bos = null;
FileOutputStream fileOutputStream = null;
PdfWriter writer = null;
try {
//bos = new ByteArrayOutputStream();
Document document = new Document(PageSize.A4, 0, 0, 0, 0); //创建文档容器
//fileOutputStream = new FileOutputStream(exportPdfPath + fileName + ".pdf");
//writer = PdfWriter.getInstance(document, fileOutputStream);//创建编写器PDF类型
//是否启用水印
writer = PdfWriter.getInstance(document, bos);
//上一个目录名称
String lastOutline = null;
//是否增加标签
boolean outFlag = true;
//标签顺序
Integer outNum = 1;
// 添加目录
document.open(); //打开容器
float w, h;
PdfContentByte cb = writer.getDirectContent();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), 12);
cb.beginText();
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "目录", 300, 780, 0);
cb.endText();
// 创建目录
PdfOutline root = cb.getRootOutline();
// 添加图片到PDF
for (int i = 0; i < scanPathVos.size(); i++) {
try {
String assortName = scanPathVos.get(i).getAssortName();
if (StringUtils.isNotBlank(lastOutline) && lastOutline.equals(assortName)) {
outFlag = false;
}
if (StringUtils.isBlank(lastOutline)) {
lastOutline = assortName;
outFlag = true;
}
if (!lastOutline.equals(assortName)) {
lastOutline = assortName;
outFlag = true;
}
String imagePath = scanPathVos.get(i).getFilePath();
Image image = Image.getInstance(imagePath);
/*处理图片缩放比例*/
w = image.getWidth();
h = image.getHeight();
image.setAlignment(com.lowagie.text.Image.ALIGN_CENTER);
image.scaleAbsolute(PageSize.A4.getWidth(), PageSize.A4.getWidth() * (h / w));
// 创建新页面并添加图片
if (i != 0) {
document.newPage();
}
document.add(image);
if (outFlag) {
System.out.println();
//目录跳转页面内容设置。
PdfAction action = PdfAction.gotoLocalPage(i + 1, new PdfDestination(PdfDestination.FIT), writer);
//标题目录
String title = outNum + "." + scanPathVos.get(i).getAssortName();
new PdfOutline(root, action, title, false);
outNum++;
}
} catch (Exception e) {
logger.log("导出失败" + scanPathVos.get(i).getFilePath() + e.getMessage());
e.printStackTrace();
}
}
document.close();
//是否启用水印
Short effective = pdfWaterSet.getDownloadEffective();
Short isImg = pdfWaterSet.getDownloadIsImg();
if (effective == 1 || isImg == 1) {
img2PdfUtil.addWaterMark(bos, null, pdfWaterSet.getUpOrUnder(), pdfWaterSet.getTransparent(),
pdfWaterSet.getText(), pdfWaterSet.getTextX(), pdfWaterSet.getTextY(),
pdfWaterSet.getTextColor(), pdfWaterSet.getTextSize(), pdfWaterSet.getTextRotation(),
effective, isImg, pdfWaterSet.getImgFile(), pdfWaterSet.getImgWidth(),
pdfWaterSet.getImgHeight(), pdfWaterSet.getImgX(), pdfWaterSet.getImgY());
}
} catch (Exception e) {
logger.log(e + "");
ExceptionPrintUtil.printException(e);
e.printStackTrace();
return false;
} finally {
try {
if (writer != null) {
writer.close();
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
if (bos != null) {
bos.flush();
bos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
} }

@ -1,6 +1,7 @@
package com.emr.util; package com.emr.util;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -8,7 +9,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@Component
public class Logger { public class Logger {
@Value("${export_pdf_path}") @Value("${export_pdf_path}")

@ -0,0 +1,15 @@
package com.emr.vo;
import lombok.Data;
/**
*
*/
@Data
public class ExportInpVo {
private String inpatientNo;//病案号
private String disDate; //出院日期
}

@ -21,4 +21,8 @@ public class ExportTaskDetailsVo {
//出院日期 //出院日期
private String dischargeDateTime; private String dischargeDateTime;
private Integer state;
private String createDate;
} }

@ -0,0 +1,43 @@
package com.emr.vo;
public class ExportTaskVo {
private Integer taskId;
private String taskName;
private Integer state;
private String createDate;
public Integer getTaskId() {
return taskId;
}
public void setTaskId(Integer taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName == null ? null : taskName.trim();
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
}

@ -32,4 +32,135 @@
</select> </select>
<resultMap id="BaseResultMap" type="com.emr.entity.ExportTaskDetails">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="taskId" jdbcType="INTEGER" property="taskid" />
<result column="inpNo" jdbcType="VARCHAR" property="inpno" />
<result column="dischargeDateTime" jdbcType="TIMESTAMP" property="dischargedatetime" />
<result column="state" jdbcType="INTEGER" property="state" />
</resultMap>
<sql id="Base_Column_List">
id, taskId, inpNo, dischargeDateTime, state
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from Export_Task_Details
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectExportTaskDetailsByInpNo" resultType="com.emr.entity.ExportTaskDetails">
select <include refid="Base_Column_List" /> from Export_Task_Details where inpNo =#{inpNo}
</select>
<select id="getExportTaskDetailsList" resultType="com.emr.vo.ExportTaskDetailsVo">
select
a.id,
a.taskId,
a.inpNo,
a.dischargeDateTime,
a.state,
b.create_date as createDate
from Export_Task_Details a
left join export_task b on a.taskId = b.task_id
where 1 = 1
<if test="record.taskid != null and record.taskid != ''">
and a.taskId= #{record.taskid}
</if>
<if test="record.state != null">
and a.state= #{record.state}
</if>
<if test="startTime != '' and startTime != null">
AND CONVERT ( VARCHAR ( 100 ), b.create_date, 23 ) &gt;= #{startTime}
<if test="endTime != '' and endTime != null">
AND CONVERT ( VARCHAR ( 100 ), b.create_date, 23 ) &lt;= #{endTime}
</if>
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from Export_Task_Details
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.emr.entity.ExportTaskDetails">
insert into Export_Task_Details (id, taskId, inpNo,
dischargeDateTime, state)
values (#{id,jdbcType=INTEGER}, #{taskid,jdbcType=INTEGER}, #{inpno,jdbcType=VARCHAR},
#{dischargedatetime,jdbcType=TIMESTAMP}, #{state,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.emr.entity.ExportTaskDetails">
insert into Export_Task_Details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="taskid != null">
taskId,
</if>
<if test="inpno != null">
inpNo,
</if>
<if test="dischargedatetime != null">
dischargeDateTime,
</if>
<if test="state != null">
state,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="taskid != null">
#{taskid,jdbcType=INTEGER},
</if>
<if test="inpno != null">
#{inpno,jdbcType=VARCHAR},
</if>
<if test="dischargedatetime != null">
#{dischargedatetime,jdbcType=TIMESTAMP},
</if>
<if test="state != null">
#{state,jdbcType=INTEGER},
</if>
</trim>
</insert>
<insert id="SimpleInsert" parameterType="java.util.List">
INSERT INTO Export_Task_Details(taskId,inpNo,dischargeDateTime,state)
VALUES
<foreach collection ="list" item="item" index= "index" separator =",">
(
#{item.taskid,jdbcType=INTEGER},
#{item.inpno,jdbcType=VARCHAR},
#{item.dischargedatetime,jdbcType=TIMESTAMP},
#{item.state,jdbcType=INTEGER}
)
</foreach >
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.ExportTaskDetails">
update Export_Task_Details
<set>
<if test="taskid != null">
taskId = #{taskid,jdbcType=INTEGER},
</if>
<if test="inpno != null">
inpNo = #{inpno,jdbcType=VARCHAR},
</if>
<if test="dischargedatetime != null">
dischargeDateTime = #{dischargedatetime,jdbcType=TIMESTAMP},
</if>
<if test="state != null">
state = #{state,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.emr.entity.ExportTaskDetails">
update Export_Task_Details
set taskId = #{taskid,jdbcType=INTEGER},
inpNo = #{inpno,jdbcType=VARCHAR},
dischargeDateTime = #{dischargedatetime,jdbcType=TIMESTAMP},
state = #{state,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper> </mapper>

@ -0,0 +1,106 @@
<?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.emr.dao.ExportTaskMapper">
<resultMap id="BaseResultMap" type="com.emr.entity.ExportTask">
<id column="task_id" jdbcType="INTEGER" property="taskId" />
<result column="task_name" jdbcType="VARCHAR" property="taskName" />
<result column="state" jdbcType="INTEGER" property="state" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
</resultMap>
<sql id="Base_Column_List">
task_id, task_name, state,create_date
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from Export_Task
where task_id = #{taskId,jdbcType=INTEGER}
</select>
<select id="getExportTaskByName" resultType="com.emr.entity.ExportTask">
select
<include refid="Base_Column_List" />
from Export_Task
where task_name = #{taskName}
</select>
<select id="getExportTaskList" resultType="com.emr.vo.ExportTaskVo">
select
task_id as taskId,
task_name as taskName,
state,
create_date as createDate
from Export_Task
where 1 =1
<if test="record.taskName != null and record.taskName != ''">
and task_name like '%${record.taskName}%'
</if>
<if test="startTime != '' and startTime != null">
AND CONVERT ( VARCHAR ( 100 ), create_date, 23 ) &gt;= #{startTime}
<if test="endTime != '' and endTime != null">
AND CONVERT ( VARCHAR ( 100 ), create_date, 23 ) &lt;= #{endTime}
</if>
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from Export_Task
where task_id = #{taskId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.emr.entity.ExportTask">
insert into Export_Task (task_id, task_name, state,create_date
)
values (#{taskId,jdbcType=INTEGER}, #{taskName,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.emr.entity.ExportTask">
insert into Export_Task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">
task_id,
</if>
<if test="taskName != null">
task_name,
</if>
<if test="state != null">
state,
</if>
<if test="state != null">
create_date,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">
#{taskId,jdbcType=INTEGER},
</if>
<if test="taskName != null">
#{taskName,jdbcType=VARCHAR},
</if>
<if test="state != null">
#{state,jdbcType=INTEGER},
</if>
<if test="createDate != null">
#{createDate,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.ExportTask">
update Export_Task
<set>
<if test="taskName != null">
task_name = #{taskName,jdbcType=VARCHAR},
</if>
<if test="state != null">
state = #{state,jdbcType=INTEGER},
</if>
<if test="state != null">
create_date = #{createDate,jdbcType=INTEGER},
</if>
</set>
where task_id = #{taskId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.emr.entity.ExportTask">
update Export_Task
set task_name = #{taskName,jdbcType=VARCHAR},
state = #{state,jdbcType=INTEGER}
where task_id = #{taskId,jdbcType=INTEGER}
</update>
</mapper>

@ -0,0 +1,95 @@
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<style>
.loading {
width: 160px;
height: 56px;
position: absolute;
top: 50%;
left: 50%;
line-height: 56px;
color: #fff;
padding-left: 60px;
font-size: 15px;
background: #000;
opacity: 0.7;
z-index: 9999;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
</style>
<!--导入加载-->
<div id="loadingModel" class="modal fade" data-keyboard="false"
data-backdrop="static" data-role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div id="loading" class="loading">加载中。。。</div>
</div>
<script>
//导入按钮
function importBtn(){
$("#myModalLabel3").text('导入');
$('#myModal3').modal('show')
}
//导入excel
//url:导入请求的相对路径exportFileName导出出错数据的关键字
function importExcel(url,exportFileName){
var fileDir = $("#upfile").val();
var suffix = fileDir.substr(fileDir.lastIndexOf("."));
if ("" == fileDir) {
toastr.warning("选择需要导入的Excel文件!")
return false;
}
if (".xls" != suffix && ".xlsx" != suffix) {
toastr.warning("文件格式有误!选择Excel格式的文件导入!")
return false;
}
$("#form1").attr('disabled', 'disabled');
var url = path + url;
$('#loadingModel').modal('show');
$("#loading").css("background","url("+path+"/static/img/load.gif) no-repeat 10px 50%");
$('#form1').ajaxSubmit({
type:'POST',
url : url,
dataType : 'text',//服务器返回的数据类型 可选XML ,Json jsonp script html text等
data:{upfile:$("#upfile").val()},
error : function() {
$("#form1").removeAttr('disabled');
toastr.warning("导入excel出错!")
},
success : function(data) {
$('#loadingModel').modal('hide');
if(data == null || data == ''){
toastr.success("全部导入成功!");
setTimeout(function(){
window.location.reload();
},1000)
}else{
if(data.indexOf("@") != -1){
var datas = data.split("@");
var workBookKey = datas[0];
debugger;
data = datas[1];
Common.confirm({
title: "提示",
message: data,
operate: function (reselt) {
if (reselt) {
var url = path + "/exportWrongExcel?fileName="+exportFileName+"&workBookKey=" + workBookKey;
window.location.href = url;
}
}
})
}else{
toastr.error(data);
}
}
$("#upfile").val("");
$("#form1").removeAttr('disabled');
}
});
}
</script>

@ -0,0 +1,86 @@
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<style>
.loading {
width: 160px;
height: 56px;
position: absolute;
top: 50%;
left: 50%;
line-height: 56px;
color: #fff;
padding-left: 60px;
font-size: 15px;
background: #000;
opacity: 0.7;
z-index: 9999;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
</style>
<!--导入加载-->
<div id="loadingModel" class="modal fade" data-keyboard="false"
data-backdrop="static" data-role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div id="loading" class="loading">加载中。。。</div>
</div>
<script>
//导入按钮
function uploadBtn() {
$("#myModalLabel3").text('上传');
$('#myModal3').modal('show')
}
//导入excel
//url:导入请求的相对路径exportFileName导出出错数据的关键字
function uploadCostList() {
var fileDir = $("#upfile").val();
var suffix = fileDir.substr(fileDir.lastIndexOf("."));
if ("" == fileDir) {
toastr.warning("选择需要导入的压缩包文件!")
return false;
}
if (".zip" != suffix) {
toastr.warning("文件格式有误!选择zip格式的文件导入!")
return false;
}
$("#form1").attr('disabled', 'disabled');
$('#loadingModel').modal('show');
$("#loading").css("background", "url(" + path + "/static/img/load.gif) no-repeat 10px 50%");
$('#form1').ajaxSubmit({
type: 'POST',
url: path + '/commom/uploadCostList',
dataType: 'text',//服务器返回的数据类型 可选XML ,Json jsonp script html text等
data: {upfile: $("#upfile").val()},
error: function () {
$("#form1").removeAttr('disabled');
toastr.warning("上传文件出错!")
},
success: function (data) {
$('#loadingModel').modal('hide');
var dataObj = eval("(" + data + ")");
if (dataObj.code == 0) {
var dataExcel = dataObj.data;
toastr.success("费用清单上传成功");
if (dataExcel.workBookKey != null && dataExcel.workBookKey != '') {
var exportFileName = "费用清单";
window.location.href = path + "/exportWrongExcel1?fileName=" + exportFileName + "&workBookKey=" + dataExcel.workBookKey;
} else {
setTimeout(function () {
window.location.reload();
}, 1000)
}
} else {
toastr.error("费用清单上传失败");
}
$("#upfile").val("");
$("#form1").removeAttr('disabled');
}
});
}
</script>

@ -0,0 +1,230 @@
<%@ page import="java.util.Date" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<%@ include file="/WEB-INF/jspf/common.jspf" %>
<%@ include file="/WEB-INF/jspf/importExcelJsp.jspf" %>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>任务清单列表</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv=X-UA-Compatible IE=EmulateIE7>
<!--[if lt IE 9]>
<script type="text/javascript" src="${path}/static/js/html5shiv.min.js"></script>
<script type="text/javascript" src="${path}/static/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="${path}/static/js/respond.min.js"></script>
<![endif]-->
<script>
var path = "${path}";
</script>
<style type="text/css">
.mainDiv{
background-color: #fff;
}
/**搜索区*/
.searchDiv{
padding-top:5px;
height: 30px;
}
.searchDiv1{
height: 30px;
}
.tableDiv{
width: 100%;
background-color: #fff;
margin-left: 1%;
margin-top:-10px;
}
.dateSearchDiv{
width:29%;
}
.dateSearchInput{
width:30%;
margin-left:3%;
}
.dateLabelDiv{
width: 30%;
text-align: right;
}
.searchInput{
width:20%;
}
.searchElement{
width: 40%;
}
.searchInputElement{
width: 60%;
}
.labelDiv{
padding-top:4%;
margin-left: 5px;
}
/**查询按钮组*/
.btnsDiv{
text-align: right;
height:30px;
margin-right: 25px;
}
.btn{
margin-left: 1%;
}
.modelBtns{
/*text-align: center;*/
margin-left: 40%;
}
.control-label1{
width:30%;
text-align: right;
padding-top:2px;
font-weight: 700;
}
.warningLabel{
margin-left:102px;
font-weight: 700;
}
.warningDiv{
margin-left: 134px;
margin-top: -20px;
}
/**级联病案号内容*/
.mouseOver{
background-color: #708090;
color:#FFFAFA;
}
.mouseOut{
background-color: #FFFAFA;
color:#000000;
}
/*模态框头*/
.modal-header{
background-color: #199ED8;
text-align: center;
}
.loading {
width: 160px;
height: 56px;
position: absolute;
top: 50%;
left: 50%;
line-height: 56px;
color: #fff;
padding-left: 60px;
font-size: 15px;
background: #000;
opacity: 0.7;
z-index: 9999;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
</style>
</head>
<body>
<input type="hidden" id="checks">
<div class="main">
<div class="headDiv">
<div class="headSpanDiv">
<span class="headspan">
任务清单列表
</span>
</div>
</div>
<div class="mainDiv">
<!--搜索区-->
<div class="searchDiv">
<div class="searchInput left">
<div class="searchElement left">
<label class="labelDiv">任务名称:</label>
</div>
<div class="searchInputElement left">
<input type="test" class="form-control input-sm" id="searchName" maxlength="16">
</div>
</div>
<div class="dateSearchDiv left">
<div class="dateLabelDiv left">
<label class="labelDiv">操作日期:</label>
</div>
<div class="dateSearchInput left">
<input type="text" class="form-control input-sm" id="startTime1" placeholder="开始时间" maxlength="10" autocomplete="off">
</div>
<div class="dateSearchInput left">
<input type="text" class="form-control input-sm" id="endTime1" placeholder="结束时间" maxlength="10" autocomplete="off">
</div>
</div>
<div class="searchDiv1">
<div class="searchInput left" style="margin-left: 2%">
<button type="button" class="btn btn-sm btn-primary" onclick="refreshTable()">查询</button>
</div>
</div>
</div>
<div class="btnsDiv">
<shiro:hasPermission name="/exportTask/impExcelTask">
<button type="button" class="btn btn-sm btn-warning btns" onclick="importBtn()" >导入excel</button>
</shiro:hasPermission>
</div>
<!--数据表格-->
<div id="tableDiv" class="tableDiv table-responsive">
<table id="mytab" class="table text-nowrap table-bordered">
</table>
</div>
</div>
</div>
<!-- 模态框Modal3 导入-->
<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel3">导入信息</h4>
</div>
<div class="modal-body" style="height:380px">
<form method="POST" enctype="multipart/form-data"
id="form1">
<div class="formDiv">
<label class="control-label1 left">下载模板:</label>
<input class="btn btn-primary btn-sm" onclick="window.open('${path }/static/js/template/任务清单模板.xls');" type="button" value="下载模板">
</div>
<div class="formDiv">
<label class="control-label1 left">选择文件:</label>
<input id="upfile" type="file" name="upfile" calss="layui-btn">
</div>
<div class="modelBtns">
<input class="btn btn-primary btn-sm" type="button" value="批量导入Excel数据"
onclick="importExcel('/exportTask/impExcelTask','任务清单')">
</div>
<div class="formDiv">
<label class="warningLabel">友情提醒:</label>
<div class="warningDiv">
<span style="color: red"></br>1、病案号不能为空,内容最多30个字</span></br>
<span style="color: red">2、出院日期不能为空</span></br>
</div>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<script>
var time = new Date().getTime();
document.write('<script src="${path}/static/js/recordManage/exportTask/exportTaskList.js?t=' + time + '"><\/script>')
document.write('<script src="${path}/static/js/dateUtil.js?t=' + time + '"><\/script>')
document.write('<script src="${path}/static/js/commom.js?t=' + time + '"><\/script>')
</script>
<%--<script src="${path}/static/js/approveManage/approveList/approveList.js?t=" +<%=new Date().getTime() %> type="text/javascript"></script>
<script src="${path}/static/js/approveManage/approveList/approveDateCommmomMethod.js"></script>
<script src="${path}/static/js/approveManage/approveList/approveSaveCommomMethod.js?t=2"></script>
<script src="${path}/static/js/dateUtil.js"></script>--%>
</body>
</html>

@ -0,0 +1,229 @@
<%@ page import="java.util.Date" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<%@ include file="/WEB-INF/jspf/common.jspf" %>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>任务清单明细列表</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv=X-UA-Compatible IE=EmulateIE7>
<!--[if lt IE 9]>
<script type="text/javascript" src="${path}/static/js/html5shiv.min.js"></script>
<script type="text/javascript" src="${path}/static/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="${path}/static/js/respond.min.js"></script>
<![endif]-->
<script>
var path = "${path}";
</script>
<style type="text/css">
.mainDiv {
background-color: #fff;
}
/**搜索区*/
.searchDiv {
padding-top: 5px;
height: 30px;
}
.searchDiv1 {
height: 30px;
}
.tableDiv {
width: 100%;
background-color: #fff;
margin-left: 1%;
margin-top: -10px;
}
.dateSearchDiv {
width: 29%;
}
.dateSearchInput {
width: 30%;
margin-left: 3%;
}
.dateLabelDiv {
width: 30%;
text-align: right;
}
.searchInput {
width: 20%;
}
.searchElement {
width: 40%;
}
.searchInputElement {
width: 60%;
}
.labelDiv {
padding-top: 4%;
margin-left: 5px;
}
/**查询按钮组*/
.btnsDiv {
text-align: right;
height: 30px;
margin-right: 25px;
}
.btn {
margin-left: 1%;
}
.modelBtns {
/*text-align: center;*/
margin-left: 40%;
}
.control-label1 {
width: 30%;
text-align: right;
padding-top: 2px;
font-weight: 700;
}
.warningLabel {
margin-left: 102px;
font-weight: 700;
}
.warningDiv {
margin-left: 134px;
margin-top: -20px;
}
/**级联病案号内容*/
.mouseOver {
background-color: #708090;
color: #FFFAFA;
}
.mouseOut {
background-color: #FFFAFA;
color: #000000;
}
/*模态框头*/
.modal-header {
background-color: #199ED8;
text-align: center;
}
.loading {
width: 160px;
height: 56px;
position: absolute;
top: 50%;
left: 50%;
line-height: 56px;
color: #fff;
padding-left: 60px;
font-size: 15px;
background: #000;
opacity: 0.7;
z-index: 9999;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
</style>
</head>
<body>
<input type="hidden" id="checks">
<div class="main">
<div class="headDiv">
<div class="headSpanDiv">
<span class="headspan">
任务清单明细列表
</span>
</div>
</div>
<div class="mainDiv">
<!--搜索区-->
<div class="searchDiv">
<div class="searchInput left">
<div class="searchElement left">
<label class="labelDiv">任务ID</label>
</div>
<div class="searchInputElement left">
<input type="text" class="form-control input-sm" id="taskid" maxlength="16">
</div>
</div>
<div class="dateSearchDiv left">
<div class="dateLabelDiv left">
<label class="labelDiv">操作日期:</label>
</div>
<div class="dateSearchInput left">
<input type="text" class="form-control input-sm" id="startTime1" placeholder="开始时间"
maxlength="10" autocomplete="off">
</div>
<div class="dateSearchInput left">
<input type="text" class="form-control input-sm" id="endTime1" placeholder="结束时间" maxlength="10"
autocomplete="off">
</div>
</div>
<div class="searchInput left" style="margin-left: 10px;">
<div class="searchElement left">
<label class="labelDiv">申请状态:</label>
</div>
<div class="searchInputElement left">
<select class="form-control input-sm" id="state">
<option value="">请选择</option>
<option value="0">未开始</option>
<option value="1">完成</option>
<option value="2">失败</option>
</select>
</div>
</div>
<div class="searchDiv1">
<div class="searchInput left" style="margin-left: 2%">
<button type="button" class="btn btn-sm btn-primary" onclick="refreshTable()">查询</button>
</div>
</div>
</div>
<%--<div class="btnsDiv">
<shiro:hasPermission name="/exportTask/impExcelTask">
<button type="button" class="btn btn-sm btn-warning btns" onclick="importBtn()" >导入excel</button>
</shiro:hasPermission>
</div>--%>
<!--数据表格-->
<div id="tableDiv" class="tableDiv table-responsive">
<table id="mytab" class="table text-nowrap table-bordered">
</table>
</div>
</div>
</div>
<script>
var time = new Date().getTime();
document.write('<script src="${path}/static/js/recordManage/exportTaskDetails/exportTaskDetailsList.js?t=' + time + '"><\/script>')
document.write('<script src="${path}/static/js/dateUtil.js?t=' + time + '"><\/script>')
document.write('<script src="${path}/static/js/commom.js?t=' + time + '"><\/script>')
</script>
<%--<script src="${path}/static/js/approveManage/approveList/approveList.js?t=" +<%=new Date().getTime() %> type="text/javascript"></script>
<script src="${path}/static/js/approveManage/approveList/approveDateCommmomMethod.js"></script>
<script src="${path}/static/js/approveManage/approveList/approveSaveCommomMethod.js?t=2"></script>
<script src="${path}/static/js/dateUtil.js"></script>--%>
</body>
</html>

@ -0,0 +1,209 @@
$(function () {
initDateInput(1);
})
var pageNumber;
/**
* 加载数据表格
*/
$('#mytab').bootstrapTable({
height: 5000,
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true, //是否显示分页(*
sidePagination: "server", //分页方式client客户端分页server服务端分页*
paginationPreText: '上一页',
paginationNextText: '下一页',
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*
pageList: [10, 20, 30, 40, 50],//可供选择的每页的行数(*
height: $(window).height() - 134, //行高如果没有设置height属性表格自动根据记录条数觉得表格高度
columns: [
/*{
title: '全选',
field: 'select',
checkbox: true,
width: 25,
align: 'center',
valign: 'middle'
},*/
{
field: 'no',
title: '序号',
sortable: true,
formatter: function (value, row, index) {
//获取每页显示的数量
var pageSize = $('#mytab').bootstrapTable('getOptions').pageSize;
//获取当前是第几页
var pageNumber = $('#mytab').bootstrapTable('getOptions').pageNumber;
//返回序号注意index是从0开始的所以要加上1
return pageSize * (pageNumber - 1) + index + 1;
}
},
{
title: '任务ID',
field: 'taskId',
},
{
title: '任务名称',
field: 'taskName',
},
{
title: '操作日期',
field: 'createDate',
formatter: function(value,row,index){
return covertDate(value);
}
},
/*{
title: '任务状态',
field: 'state',
formatter: function (value, row, index) {
var spanValue;
if (value == '0') {
spanValue = '<p class="text-danger">未完成</p>';
} else if (value == '1') {
spanValue = '<p style="color:green">已完成</p>';
}
return spanValue;
}
},*/
{
title: '操作',
formatter: function (value, row, index) {
var editanddrop = '';
if (row.state == 0 || row.state == 1) {
editanddrop += '<button type="button" onclick="exportExcel(' + row.taskId + ')" class="btn btn-sm btn-info TableView btn-sm" >导出PDF</button>';
}
return editanddrop;
}
}
],
locale: 'zh-CN',//中文支持,
url: path + '/exportTask/getExportTaskList',//排序方式
queryParams: function (params) {
return {
limit: params.limit, // 每页显示数量
offset: params.offset, // SQL语句起始索引
page: (params.offset / params.limit) + 1, //当前页码,
taskName: $("#searchName").val(),
startTime: $("#startTime1").val(),
endTime:$("#endTime1").val(),
}
},
responseHandler: function (res) {
//在ajax获取到数据渲染表格之前修改数据源
var nres = [];
nres.push({total: res.total, rows: res.list});
return nres[0];
},
onLoadSuccess: function () {
$(".page-list").show();
$(".fixed-table-body").css("overflow", "auto");
},
//监听分页点击事件
onPageChange: function (num, type) {
pageNumber = num;
},
//选中单个复选框
onCheck: function (row) {
var checks = $("#checks").val();
$("#checks").val(checks += "'" + row.id + "',");
},
//取消单个复选框
onUncheck: function (row) {
var checks = $("#checks").val();
checks = checks.replace("'" + row.id + "',", "");
$("#checks").val(checks);
},
//全选
onCheckAll: function (rows) {
$("#checks").val("");
var checks = '';
for (var i = 0; i < rows.length; i++) {
checks += "'" + rows[i].id + "',"
}
$("#checks").val(checks);
},
//全不选
onUncheckAll: function (rows) {
$("#checks").val("");
}
})
/**
* 查询按钮
*/
function refreshTable() {
$("#checks").val("");
$('#mytab').bootstrapTable('refresh', {
url: path + '/exportTask/getExportTaskList'
})
}
/**
* 显示申请信息详情
* @param id
*/
function showApprove(id) {
loadSelect(path + '/approve/loadType', null, 'applyType1');
//加载申请原因模板
loadSelect(path + '/approve/loadReasonModle', null, 'parentId1');
$.ajax({
type: 'get',
url: path + '/approve/getApproveById',
data: {id: id},
dataType: 'json',
success: function (data) {
if (null != data) {
$("#approveId1").val(data.id);
$("#effeTime1").val(data.effeTime);
$("#effeDays1").val(data.effeDays);
$("#applyType1").val(data.applyType);
$("#parentId1").val(data.reasonParentId);
$("#applyReason1").val(data.applyReason);
$("#inpatientNo1").val(data.inpatientNo);
$("#admissTimes1").val(data.admissTimes);
$("#name1").val(data.name);
$("#startTime3").val(data.disTime);
}
}
})
}
/**
* 导出excel功能
*/
function exportExcel(taskId) {
//var checks = $("#checks").val();
Common.confirm({
title: "提示",
message: "您确定要导出PDF吗?",
operate: function (reselt) {
if (reselt) {
post(path + '/font/downloadPdfZip', {"taskId": taskId,
});
/*$.ajax({
type: 'post',
url: path + '/font/downloadPdfZip?taskId=' +taskId,
dataType: 'text',
success: function (data) {
toastr.success("下载成功!");
//refreshTable();
//$('#mytab').bootstrapTable('selectPage', pageNumber);
}
})*/
}
}
})
}

@ -0,0 +1,158 @@
$(function () {
initDateInput(1);
})
var pageNumber;
/**
* 加载数据表格
*/
$('#mytab').bootstrapTable({
height: 5000,
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true, //是否显示分页(*
sidePagination: "server", //分页方式client客户端分页server服务端分页*
paginationPreText: '上一页',
paginationNextText: '下一页',
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*
pageList: [10, 20, 30, 40, 50],//可供选择的每页的行数(*
height: $(window).height() - 134, //行高如果没有设置height属性表格自动根据记录条数觉得表格高度
columns: [
/*{
title: '全选',
field: 'select',
checkbox: true,
width: 25,
align: 'center',
valign: 'middle'
},*/
{
field: 'no',
title: '序号',
sortable: true,
formatter: function (value, row, index) {
//获取每页显示的数量
var pageSize = $('#mytab').bootstrapTable('getOptions').pageSize;
//获取当前是第几页
var pageNumber = $('#mytab').bootstrapTable('getOptions').pageNumber;
//返回序号注意index是从0开始的所以要加上1
return pageSize * (pageNumber - 1) + index + 1;
}
},
{
title: '任务ID',
field: 'taskId',
},
{
title: '病案号',
field: 'inpNo',
},
{
title: '出院日期',
field: 'dischargeDateTime',
formatter: function (value, row, index) {
return value.substring(0,10);
}
},
{
title: '操作日期',
field: 'createDate',
formatter: function(value,row,index){
return covertDate(value);
}
},
{
title: '状态',
field: 'state',
formatter: function (value, row, index) {
var spanValue;
if (value == '0') {
spanValue = '<p class="text-danger">未开始</p>';
} else if (value == '1') {
spanValue = '<p style="color:green">完成</p>';
}else if (value == '2') {
spanValue = '<p style="color:green">失败</p>';
}
return spanValue;
}
}
/*{
title: '操作',
formatter: function (value, row, index) {
var editanddrop = '';
if (row.state == 0) {
editanddrop += '<button type="button" onclick="exportExcel(' + row.taskId + ')" class="btn btn-sm btn-info TableView btn-sm" >导出PDF</button>';
}
return editanddrop;
}
}*/
],
locale: 'zh-CN',//中文支持,
url: path + '/exportTaskDetails/getExportTaskDetailsList',//排序方式
queryParams: function (params) {
return {
limit: params.limit, // 每页显示数量
offset: params.offset, // SQL语句起始索引
page: (params.offset / params.limit) + 1, //当前页码,
taskid: $("#taskid").val(),
state:$("#state").val(),
startTime: $("#startTime1").val(),
endTime:$("#endTime1").val(),
}
},
responseHandler: function (res) {
//在ajax获取到数据渲染表格之前修改数据源
var nres = [];
nres.push({total: res.total, rows: res.list});
return nres[0];
},
onLoadSuccess: function () {
$(".page-list").show();
$(".fixed-table-body").css("overflow", "auto");
},
//监听分页点击事件
onPageChange: function (num, type) {
pageNumber = num;
},
//选中单个复选框
onCheck: function (row) {
var checks = $("#checks").val();
$("#checks").val(checks += "'" + row.id + "',");
},
//取消单个复选框
onUncheck: function (row) {
var checks = $("#checks").val();
checks = checks.replace("'" + row.id + "',", "");
$("#checks").val(checks);
},
//全选
onCheckAll: function (rows) {
$("#checks").val("");
var checks = '';
for (var i = 0; i < rows.length; i++) {
checks += "'" + rows[i].id + "',"
}
$("#checks").val(checks);
},
//全不选
onUncheckAll: function (rows) {
$("#checks").val("");
}
})
/**
* 查询按钮
*/
function refreshTable() {
// $("#checks").val("");
$('#mytab').bootstrapTable('refresh', {
url: path + '/exportTaskDetails/getExportTaskDetailsList'
})
}
Loading…
Cancel
Save