package cn.besteam.modules.medical.controller;
|
|
import cn.besteam.common.api.vo.Result;
|
import cn.besteam.common.aspect.annotation.OpenApi;
|
import cn.besteam.common.util.DateUtil;
|
import cn.besteam.modules.medical.service.IMwDeviceValidateRecordService;
|
import cn.besteam.modules.medical.vo.MwDeviceValidateRecordVO;
|
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelWriter;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.net.URLEncoder;
|
import java.util.ArrayList;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* @Title: Controller
|
* @Description: 设备特征码校验记录
|
* @author: besteam
|
* @date: 2020-05-09
|
* @version: V1.0
|
*/
|
@RestController
|
@RequestMapping("/medical/mwDeviceValidateRecord")
|
@Slf4j
|
@Api(description = "设备特征码记录")
|
public class MwDeviceValidateRecordController {
|
|
@Autowired
|
private IMwDeviceValidateRecordService mwDeviceValidateRecordService;
|
|
/**
|
* 分页列表查询
|
*
|
* @param sn
|
* @param pageNo
|
* @param pageSize
|
* @return
|
*/
|
@GetMapping(value = "/list")
|
@ApiOperation(value = "登录记录", notes = "登录记录", produces = "application/json")
|
public Result<IPage<MwDeviceValidateRecordVO>> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, String sn) {
|
|
return Result.ok(mwDeviceValidateRecordService.queryPageList(pageNo, pageSize, sn));
|
}
|
|
/*=====登录记录导出--开始=======*/
|
private static Map<String, String> headerMapList = new LinkedHashMap<>();
|
|
static {
|
headerMapList.put("departmentName", "医院名称");
|
headerMapList.put("account", "用户名");
|
headerMapList.put("userName", "姓名");
|
headerMapList.put("sn", "设备特征码");
|
headerMapList.put("createTime", "登录时间");
|
}
|
|
@Data
|
private static class MwDeviceValidateRecordExportListVO {
|
|
private String departmentName;
|
|
private String account;
|
|
private String userName;
|
|
private String sn;
|
|
private String createTime;
|
|
}
|
|
@GetMapping("/listExport")
|
@OpenApi
|
@ApiOperation(value = "登录记录导出", notes = "登录记录导出", produces = "application/json")
|
public void listExport(HttpServletResponse response, String sn) throws IOException {
|
List<MwDeviceValidateRecordVO> list=mwDeviceValidateRecordService.queryPageList(sn);
|
List<MwDeviceValidateRecordExportListVO> voList = new ArrayList<>();
|
for (MwDeviceValidateRecordVO collectRecordVO : list) {
|
MwDeviceValidateRecordExportListVO vo=new MwDeviceValidateRecordExportListVO();
|
BeanUtils.copyProperties(collectRecordVO, vo);
|
vo.setCreateTime(DateUtil.formatTime(collectRecordVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
voList.add(vo);
|
}
|
ExcelWriter writer = ExcelUtil.getWriter(true);
|
writer.renameSheet("登录记录");
|
writer.setColumnWidth(0, 30);
|
writer.setColumnWidth(1, 30);
|
writer.setColumnWidth(2, 30);
|
writer.setColumnWidth(3, 30);
|
writer.setColumnWidth(4, 30);
|
writer.setHeaderAlias(headerMapList);
|
writer.write(voList);
|
//
|
String fileName = "登录记录";
|
response.setContentType("application/octet-stream;charset=utf-8");
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
|
writer.flush(response.getOutputStream());
|
writer.close();
|
|
}
|
/*====登录记录导出--结尾=======*/
|
// /**
|
// * 添加
|
// *
|
// * @param mwDeviceValidateRecord
|
// * @return
|
// */
|
// @PostMapping(value = "/add")
|
// @AutoLog(value = "添加设备特征码校验记录")
|
// @ApiOperation(value = "添加设备特征码校验记录", notes = "添加设备特征码校验记录", produces = "application/json")
|
// public Result<MwDeviceValidateRecord> add(@RequestBody MwDeviceValidateRecord mwDeviceValidateRecord) {
|
//
|
// Result<MwDeviceValidateRecord> result = new Result<MwDeviceValidateRecord>();
|
// try {
|
// mwDeviceValidateRecordService.save(mwDeviceValidateRecord);
|
// result.success("添加成功!");
|
// } catch (Exception e) {
|
// log.error("", e);
|
// result.error500("操作失败");
|
// }
|
// return result;
|
// }
|
//
|
// /**
|
// * 编辑
|
// *
|
// * @param mwDeviceValidateRecord
|
// * @return
|
// */
|
// @PostMapping(value = "/edit")
|
// @AutoLog(value = "编辑设备特征码校验记录")
|
// @ApiOperation(value = "编辑设备特征码校验记录", notes = "编辑设备特征码校验记录", produces = "application/json")
|
// public Result<MwDeviceValidateRecord> edit(@RequestBody MwDeviceValidateRecord mwDeviceValidateRecord) {
|
//
|
// Result<MwDeviceValidateRecord> result = new Result<MwDeviceValidateRecord>();
|
// MwDeviceValidateRecord mwDeviceValidateRecordEntity = mwDeviceValidateRecordService.getById(mwDeviceValidateRecord.getId());
|
// if (mwDeviceValidateRecordEntity == null) {
|
// result.error500("未找到对应实体");
|
// } else {
|
// boolean ok = mwDeviceValidateRecordService.updateById(mwDeviceValidateRecord);
|
// //TODO 返回false说明什么?
|
// if (ok) {
|
// result.success("修改成功!");
|
// }
|
// }
|
// return result;
|
// }
|
//
|
// /**
|
// * 通过id删除
|
// *
|
// * @param id
|
// * @return
|
// */
|
// @PostMapping(value = "/delete")
|
// @AutoLog(value = "删除设备特征码校验记录")
|
// @ApiOperation(value = "删除设备特征码校验记录", notes = "删除设备特征码校验记录", produces = "application/json")
|
// public Result<MwDeviceValidateRecord> delete(@RequestParam(name = "id", required = true) String id) {
|
//
|
// Result<MwDeviceValidateRecord> result = new Result<MwDeviceValidateRecord>();
|
// MwDeviceValidateRecord mwDeviceValidateRecord = mwDeviceValidateRecordService.getById(id);
|
// if (mwDeviceValidateRecord == null) {
|
// result.error500("未找到对应实体");
|
// } else {
|
// boolean ok = mwDeviceValidateRecordService.removeById(id);
|
// if (ok) {
|
// result.success("删除成功!");
|
// }
|
// }
|
// return result;
|
// }
|
//
|
// /**
|
// * 批量删除
|
// *
|
// * @param ids
|
// * @return
|
// */
|
// @PostMapping(value = "/deleteBatch")
|
// @AutoLog(value = "批量删除设备特征码校验记录")
|
// @ApiOperation(value = "批量删除设备特征码校验记录", notes = "批量删除设备特征码校验记录", produces = "application/json")
|
// public Result<MwDeviceValidateRecord> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
//
|
// Result<MwDeviceValidateRecord> result = new Result<MwDeviceValidateRecord>();
|
// if (ids == null || "".equals(ids.trim())) {
|
// result.error500("参数不识别!");
|
// } else {
|
// this.mwDeviceValidateRecordService.removeByIds(Arrays.asList(ids.split(",")));
|
// result.success("删除成功!");
|
// }
|
// return result;
|
// }
|
//
|
// /**
|
// * 通过id查询
|
// *
|
// * @param id
|
// * @return
|
// */
|
// @GetMapping(value = "/queryById")
|
// @ApiOperation(value = "通过id查询设备特征码校验记录", notes = "通过id查询设备特征码校验记录", produces = "application/json")
|
// public Result<MwDeviceValidateRecord> queryById(@RequestParam(name = "id", required = true) String id) {
|
//
|
// Result<MwDeviceValidateRecord> result = new Result<MwDeviceValidateRecord>();
|
// MwDeviceValidateRecord mwDeviceValidateRecord = mwDeviceValidateRecordService.getById(id);
|
// if (mwDeviceValidateRecord == null) {
|
// result.error500("未找到对应实体");
|
// } else {
|
// result.setResult(mwDeviceValidateRecord);
|
// result.setSuccess(true);
|
// }
|
// return result;
|
// }
|
}
|