package cn.besteam.modules.medical.controller; import cn.besteam.common.api.vo.Result; import cn.besteam.common.aspect.annotation.AutoLog; import cn.besteam.common.aspect.annotation.LogApi; import cn.besteam.common.aspect.annotation.OpenApi; import cn.besteam.common.constant.CommonConstant; import cn.besteam.common.constant.ErrorCode; import cn.besteam.common.constant.MedicalWasteEnum; import cn.besteam.common.dto.IdDTO; import cn.besteam.common.exception.BusinessException; import cn.besteam.common.util.DateUtil; import cn.besteam.modules.medical.dto.*; import cn.besteam.modules.medical.entity.MwCheckoutRecord; import cn.besteam.modules.medical.entity.MwCheckoutRecordItem; import cn.besteam.modules.medical.entity.MwCollectRecord; import cn.besteam.modules.medical.entity.MwCollectionAmendantRecord; import cn.besteam.modules.medical.service.IMwCheckoutRecordItemService; import cn.besteam.modules.medical.service.IMwCheckoutRecordService; import cn.besteam.modules.medical.service.IMwCollectRecordService; import cn.besteam.modules.medical.service.IMwCollectionAmendantRecordService; import cn.besteam.modules.medical.service.IMwWarningRecordService; import cn.besteam.modules.medical.vo.MwCollectCollectTrajectoryParamVO; import cn.besteam.modules.medical.vo.MwCollectCollectTrajectoryVO; import cn.besteam.modules.medical.vo.MwCollectRecordVO; import cn.besteam.modules.shiro.authc.util.EnvUtils; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.RoundingMode; 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-04-25 * @version: V1.0 */ @RestController @RequestMapping("/medical/mwCollectRecord") @Slf4j @Api(description = "收集记录表") public class MwCollectRecordController { @Autowired private IMwCollectRecordService mwCollectRecordService; @Autowired private IMwCheckoutRecordItemService mwCheckoutRecordItemService; @Autowired private IMwCheckoutRecordService mwCheckoutRecordService; @Autowired private IMwWarningRecordService mwWarningRecordService; @GetMapping(value = "/list") @ApiOperation(value = "获取收集记录数据列表", notes = "获取所有收集记录数据列表", produces = "application/json") public Result> list(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); // dto.setStatus(MedicalWasteEnum.MedicalWasteStatusEnum.COLLECT.getStatus()); // IPage pageList = mwCollectRecordService.queryPageCollectList(pageNo, pageSize, dto); return Result.ok(pageList); } /*=====收集记录导出--开始=======*/ private static Map headerMapList = new LinkedHashMap<>(); static { headerMapList.put("createTime", "收集时间"); headerMapList.put("code", "废物编号"); headerMapList.put("hospitalName", "医院名称"); headerMapList.put("departmentName", "科室名称"); headerMapList.put("wasteTypeStr", "废物类型"); headerMapList.put("weight", "重量(kg)"); headerMapList.put("departmentUserName", "科室人员"); headerMapList.put("creator", "收集人员"); headerMapList.put("description", "备注"); } @Data private static class MwCollectRecordExportListVO { private String createTime; private String code; private String hospitalName; private String departmentName; private String wasteTypeStr; private String weight; private String departmentUserName; private String creator; private String description; } @GetMapping("/listExport") @OpenApi @ApiOperation(value = "收集记录导出", notes = "收集记录导出", produces = "application/json") public void listExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); List list=mwCollectRecordService.queryPageCollectList( dto); List voList = new ArrayList<>(); for (MwCollectRecordVO collectRecordVO : list) { MwCollectRecordExportListVO vo=new MwCollectRecordExportListVO(); BeanUtils.copyProperties(collectRecordVO, vo); vo.setCreateTime(DateUtil.formatTime(collectRecordVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); if (collectRecordVO.getWeight() != null) { vo.setWeight(collectRecordVO.getWeight().setScale(2, RoundingMode.HALF_UP).toPlainString()); } 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.setColumnWidth(5, 30); writer.setColumnWidth(6, 30); writer.setColumnWidth(7, 30); writer.setColumnWidth(8, 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(); } /*=====收集记录导出--结尾=======*/ @GetMapping(value = "/listStore") @ApiOperation(value = "获取入库记录数据列表", notes = "获取入库记录数据列表", produces = "application/json") public Result> listStore(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); // dto.setStatus(MedicalWasteEnum.MedicalWasteStatusEnum.STORE.getStatus()); // IPage pageList = mwCollectRecordService.queryPageStoreList(pageNo, pageSize, dto); return Result.ok(pageList); } /*=====入库记录导出--开始=======*/ private static Map headerMapListStore = new LinkedHashMap<>(); static { headerMapListStore.put("storeTime", "入库时间"); headerMapListStore.put("code", "废物编号"); headerMapListStore.put("boxCode", "装箱编号"); headerMapListStore.put("hospitalName", "医院名称"); headerMapListStore.put("departmentName", "科室名称"); headerMapListStore.put("wasteTypeStr", "废物类型"); headerMapListStore.put("weight", "重量(kg)"); headerMapListStore.put("storeUser", "入库人员"); headerMapListStore.put("description", "备注"); } @Data private static class MwCollectRecordExportListStoreVO { private String storeTime; private String code; private String boxCode; private String hospitalName; private String departmentName; private String wasteTypeStr; private String weight; private String storeUser; private String description; } @GetMapping("/listStoreExport") @OpenApi @ApiOperation(value = "入库记录导出", notes = "入库记录导出", produces = "application/json") public void listStoreExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); List list=mwCollectRecordService.queryPageStoreList( dto); List voList = new ArrayList<>(); for (MwCollectRecordVO collectRecordVO : list) { MwCollectRecordExportListStoreVO vo=new MwCollectRecordExportListStoreVO(); BeanUtils.copyProperties(collectRecordVO, vo); vo.setStoreTime(DateUtil.formatTime(collectRecordVO.getStoreTime(), "yyyy-MM-dd HH:mm:ss")); if (collectRecordVO.getWeight() != null) { vo.setWeight(collectRecordVO.getWeight().setScale(2, RoundingMode.HALF_UP).toPlainString()); } 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.setColumnWidth(5, 30); writer.setColumnWidth(6, 30); writer.setColumnWidth(7, 30); writer.setColumnWidth(8, 30); writer.setHeaderAlias(headerMapListStore); 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(); } /*=====入库记录导出--结尾=======*/ @GetMapping(value = "/listCheckout") @ApiOperation(value = "获取出库记录数据列表", notes = "获取出库记录数据列表", produces = "application/json") public Result> listCheckout(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); // dto.setStatus(MedicalWasteEnum.MedicalWasteStatusEnum.CHECKOUT.getStatus()); // IPage pageList = mwCollectRecordService.queryPageCheckoutList(pageNo, pageSize, dto); return Result.ok(pageList); } /*=====出库记录导出--开始=======*/ private static Map headerMapListCheckout = new LinkedHashMap<>(); static { headerMapListCheckout.put("checkoutTime", "出库时间"); headerMapListCheckout.put("code", "废物编号"); headerMapListCheckout.put("boxCode", "装箱编号"); headerMapListCheckout.put("hospitalName", "医院名称"); headerMapListCheckout.put("departmentName", "科室名称"); headerMapListCheckout.put("wasteTypeStr", "废物类型"); headerMapListCheckout.put("weight", "重量(kg)"); headerMapListCheckout.put("checkoutUser", "出库人员"); headerMapListCheckout.put("engineDriver", "运输人员"); headerMapListCheckout.put("licensePlate", "车牌号"); headerMapListCheckout.put("transitCompany", "运输单位"); } @Data private static class MwCollectRecordExportListCheckoutVO { private String checkoutTime; private String code; private String boxCode; private String hospitalName; private String departmentName; private String wasteTypeStr; private String weight; private String checkoutUser; private String engineDriver; private String licensePlate; private String transitCompany; } @GetMapping("/listCheckoutExport") @OpenApi @ApiOperation(value = "出库记录导出", notes = "出库记录导出", produces = "application/json") public void listCheckoutExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); List list=mwCollectRecordService.queryPageCheckoutList( dto); List voList = new ArrayList<>(); for (MwCollectRecordVO collectRecordVO : list) { MwCollectRecordExportListCheckoutVO vo = new MwCollectRecordExportListCheckoutVO(); BeanUtils.copyProperties(collectRecordVO, vo); vo.setCheckoutTime(DateUtil.formatTime(collectRecordVO.getCheckoutTime(), "yyyy-MM-dd HH:mm:ss")); if (collectRecordVO.getWeight() != null) { vo.setWeight(collectRecordVO.getWeight().setScale(2, RoundingMode.HALF_UP).toPlainString()); } 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.setColumnWidth(5, 30); writer.setColumnWidth(6, 30); writer.setColumnWidth(7, 30); writer.setColumnWidth(8, 30); writer.setColumnWidth(9, 30); writer.setColumnWidth(10, 30); writer.setHeaderAlias(headerMapListCheckout); 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(); } /*=====出库记录导出--结尾=======*/ @GetMapping(value = "/listHistory") @ApiOperation(value = "医废追溯列表", notes = "医废追溯列表", produces = "application/json") public Result> listHistory(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); // IPage pageList = mwCollectRecordService.queryPageCollectList(pageNo, pageSize, dto); return Result.ok(pageList); } /*=====医废追溯导出--开始=======*/ private static Map headerMapListHistory = new LinkedHashMap<>(); static { headerMapListHistory.put("createTime", "收集时间"); headerMapListHistory.put("code", "废物编号"); headerMapListHistory.put("hospitalName", "医院名称"); headerMapListHistory.put("departmentName", "科室名称"); headerMapListHistory.put("wasteTypeStr", "废物类型"); headerMapListHistory.put("weight", "重量(kg)"); headerMapListHistory.put("departmentUserName", "科室人员"); headerMapListHistory.put("creator", "收集人员"); headerMapListHistory.put("description", "备注"); headerMapListHistory.put("statusName", "状态"); } @Data private static class MwCollectRecordExportListHistoryVO { private String createTime=""; private String code=""; private String hospitalName=""; private String departmentName=""; private String wasteTypeStr=""; private String weight=""; private String departmentUserName=""; private String creator=""; private String description=""; private String statusName=""; } @GetMapping("/listHistoryExport") @OpenApi @ApiOperation(value = "医废追溯导出", notes = "医废追溯导出", produces = "application/json") public void listHistoryExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); List list=mwCollectRecordService.queryPageCollectList( dto); List voList = new ArrayList<>(); for (MwCollectRecordVO collectRecordVO : list) { MwCollectRecordExportListHistoryVO vo=new MwCollectRecordExportListHistoryVO(); BeanUtils.copyProperties(collectRecordVO, vo); vo.setCreateTime(DateUtil.formatTime(collectRecordVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); //状态1新增 2已入库 3已出库 if (collectRecordVO.getStatus().equals(1)) { vo.setStatusName("未入库"); } else if (collectRecordVO.getStatus().equals(2)) { vo.setStatusName("已入库"); } else if (collectRecordVO.getStatus().equals(3)) { vo.setStatusName("已出库"); } if (collectRecordVO.getWeight() != null) { vo.setWeight(collectRecordVO.getWeight().setScale(2, RoundingMode.HALF_UP).toPlainString()); } voList.add(vo); } ExcelWriter writer = ExcelUtil.getWriter(true); String fileName = dto.getType() == 1 ? "医疗废物" : dto.getType() == 2 ? "可回收输液瓶袋" : "危险废物"; writer.renameSheet(fileName); writer.setColumnWidth(0, 30); writer.setColumnWidth(1, 30); writer.setColumnWidth(2, 30); writer.setColumnWidth(3, 30); writer.setColumnWidth(4, 30); writer.setColumnWidth(5, 30); writer.setColumnWidth(6, 30); writer.setColumnWidth(7, 30); writer.setColumnWidth(8, 30); writer.setColumnWidth(9, 30); writer.setHeaderAlias(headerMapListHistory); writer.write(voList); // response.setContentType("application/octet-stream;charset=utf-8"); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx"); //response.setContentType("application/octet-stream"); // 响应内容格式 writer.flush(response.getOutputStream()); writer.close(); } /*=====医废追溯导出--结尾=======*/ @GetMapping(value = "/listSupplement") @ApiOperation(value = "医废补录列表", notes = "医废补录列表", produces = "application/json") public Result> listSupplement(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setDelFlag(CommonConstant.DEL_FLAG_0); dto.setSource(MedicalWasteEnum.MedicalWasteSourceEnum.OPS.getType()); // IPage pageList = mwCollectRecordService.queryPageSupplyList(pageNo, pageSize, dto); return Result.ok(pageList); } /*=====医废补录导出--开始=======*/ private static Map headerMapListSupplement= new LinkedHashMap<>(); static { headerMapListSupplement.put("supplyTime", "补录时间"); headerMapListSupplement.put("createTime", "收集时间"); headerMapListSupplement.put("code", "废物编号"); headerMapListSupplement.put("hospitalName", "医院名称"); headerMapListSupplement.put("departmentName", "科室名称"); headerMapListSupplement.put("wasteTypeStr", "废物类型"); headerMapListSupplement.put("weight", "重量(kg)"); headerMapListSupplement.put("departmentUserName", "科室人员"); headerMapListSupplement.put("creator", "收集人员"); headerMapListSupplement.put("description", "备注"); headerMapListSupplement.put("statusName", "状态"); headerMapListSupplement.put("auditStatusName", "审核"); } @Data private static class MwCollectRecordExportListSupplementVO { private String supplyTime; private String createTime; private String code; private String hospitalName; private String departmentName; private String wasteTypeStr; private String weight; private String departmentUserName; private String creator; private String description; private String statusName; private String auditStatusName; } @GetMapping("/listSupplementExport") @OpenApi @ApiOperation(value = "医废补录导出", notes = "医废补录导出", produces = "application/json") public void listSupplementExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException { dto.setDelFlag(CommonConstant.DEL_FLAG_0); dto.setSource(MedicalWasteEnum.MedicalWasteSourceEnum.OPS.getType()); List list=mwCollectRecordService.queryPageSupplyList( dto); List voList = new ArrayList<>(); for (MwCollectRecordVO collectRecordVO : list) { MwCollectRecordExportListSupplementVO vo=new MwCollectRecordExportListSupplementVO(); BeanUtils.copyProperties(collectRecordVO, vo); vo.setCreateTime(DateUtil.formatTime(collectRecordVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); vo.setSupplyTime(DateUtil.formatTime(collectRecordVO.getSupplyTime(), "yyyy-MM-dd HH:mm:ss")); //状态1新增 2已入库 3已出库 if (collectRecordVO.getStatus().equals(1)) { vo.setStatusName("未入库"); } else if (collectRecordVO.getStatus().equals(2)) { vo.setStatusName("已入库"); } else if (collectRecordVO.getStatus().equals(3)) { vo.setStatusName("已出库"); } //审核状态 1待审核 2审核通过 3审核不通过 vo.setAuditStatusName("待审核"); if(collectRecordVO.getAuditStatus()!=null) { if (collectRecordVO.getAuditStatus().equals(1)) { vo.setAuditStatusName("未审核"); } else if (collectRecordVO.getAuditStatus().equals(2)) { vo.setAuditStatusName("已通过"); } else if (collectRecordVO.getAuditStatus().equals(3)) { vo.setAuditStatusName("未通过"); } } if (collectRecordVO.getWeight() != null) { vo.setWeight(collectRecordVO.getWeight().setScale(2, RoundingMode.HALF_UP).toPlainString()); } 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.setColumnWidth(5, 30); writer.setColumnWidth(6, 30); writer.setColumnWidth(7, 30); writer.setColumnWidth(8, 30); writer.setColumnWidth(9, 30); writer.setColumnWidth(10, 30); writer.setColumnWidth(11, 30); writer.setHeaderAlias(headerMapListSupplement); 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(); } /*=====医废补录记录导出--结尾=======*/ @GetMapping(value = "/listDelete") @ApiOperation(value = "医废删除列表", notes = "医废删除列表", produces = "application/json") public Result> listDelete(MwCollectRecordOpsDTO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setDelFlag(CommonConstant.DEL_FLAG_1); dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); // IPage pageList = mwCollectRecordService.queryPageDeleteList(pageNo, pageSize, dto); return Result.ok(pageList); } /*=====医废删除导出--开始=======*/ private static Map headerMapListDelete= new LinkedHashMap<>(); static { headerMapListDelete.put("deleteTime", "删除时间"); headerMapListDelete.put("createTime", "收集时间"); headerMapListDelete.put("code", "废物编号"); headerMapListDelete.put("hospitalName", "医院名称"); headerMapListDelete.put("departmentName", "科室名称"); headerMapListDelete.put("wasteTypeStr", "废物类型"); headerMapListDelete.put("weight", "重量(kg)"); headerMapListDelete.put("departmentUserName", "科室人员"); headerMapListDelete.put("creator", "收集人员"); headerMapListDelete.put("description", "备注"); headerMapListDelete.put("statusName", "状态"); } @Data private static class MwCollectRecordExportListDeleteVO { private String deleteTime; private String createTime; private String code; private String hospitalName; private String departmentName; private String wasteTypeStr; private String weight; private String departmentUserName; private String creator; private String description; private String statusName; } @GetMapping("/listDeleteExport") @OpenApi @ApiOperation(value = "医废删除导出", notes = "医废删除导出", produces = "application/json") public void listDeleteExport(HttpServletResponse response, MwCollectRecordOpsDTO dto) throws IOException { dto.setDelFlag(CommonConstant.DEL_FLAG_1); dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); List list=mwCollectRecordService.queryPageDeleteList( dto); List voList = new ArrayList<>(); for (MwCollectRecordVO collectRecordVO : list) { MwCollectRecordExportListDeleteVO vo = new MwCollectRecordExportListDeleteVO(); BeanUtils.copyProperties(collectRecordVO, vo); vo.setCreateTime(DateUtil.formatTime(collectRecordVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); vo.setDeleteTime(DateUtil.formatTime(collectRecordVO.getDeleteTime(), "yyyy-MM-dd HH:mm:ss")); //状态1新增 2已入库 3已出库 if (collectRecordVO.getStatus().equals(1)) { vo.setStatusName("未入库"); } else if (collectRecordVO.getStatus().equals(2)) { vo.setStatusName("已入库"); } else if (collectRecordVO.getStatus().equals(3)) { vo.setStatusName("已出库"); } if (collectRecordVO.getWeight() != null) { vo.setWeight(collectRecordVO.getWeight().setScale(2, RoundingMode.HALF_UP).toPlainString()); } 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.setColumnWidth(5, 30); writer.setColumnWidth(6, 30); writer.setColumnWidth(7, 30); writer.setColumnWidth(8, 30); writer.setColumnWidth(9, 30); writer.setColumnWidth(10, 30); writer.setHeaderAlias(headerMapListDelete); 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(); } /*=====数据恢复记录导出--结尾=======*/ @PostMapping(value = "/delete") @AutoLog(value = "删除收集记录") @ApiOperation(value = "删除收集记录", notes = "删除收集记录", produces = "application/json") public Result delete(@Validated @RequestBody IdDTO dto) { return Result.ok(mwCollectRecordService.delete(dto.getId())); } @GetMapping(value = "/queryById") @ApiOperation(value = "通过id查询收集记录", notes = "通过id查询收集记录", produces = "application/json") public Result queryById(@RequestParam(name = "id", required = true) String id) { MwCollectRecord mwCollectRecord = mwCollectRecordService.getById(id); if (mwCollectRecord == null) { throw new BusinessException(ErrorCode.ERR_500, "收集记录不存在"); } MwCollectRecordVO vo = new MwCollectRecordVO(); BeanUtils.copyProperties(mwCollectRecord, vo); MwCheckoutRecordItem mwCheckoutRecordItem=mwCheckoutRecordItemService.getOne(new QueryWrapper().eq("collect_record_id",id)); if(mwCheckoutRecordItem!=null){ MwCheckoutRecord mwCheckoutRecord=mwCheckoutRecordService.getById(mwCheckoutRecordItem.getCheckoutRecordId()); vo.setTransitCompany(mwCheckoutRecord.getTransitCompany()); vo.setEngineDriver(mwCheckoutRecord.getEngineDriver()); vo.setLicensePlate(mwCheckoutRecord.getLicensePlate()); } return Result.ok(vo); } @PostMapping(value = "/auditSupplement") @AutoLog(value = "审核补录记录") @ApiOperation(value = "审核补录记录", notes = "审核补录记录", produces = "application/json") public Result auditSupplement(@Validated @RequestBody MwCollectRecordAuditDTO dto) { return Result.ok(mwCollectRecordService.auditSupplement(dto)); } @PostMapping("/supply") @ApiOperation(value = "医废补录") @LogApi(value = "医废补录") public Result supply(@Validated @RequestBody MwCollectRecordSupplyDTO dto) { return Result.ok(mwCollectRecordService.supply(dto)); } @GetMapping(value = "/getRecordDetail") @ApiOperation(value = "获取流转过程", notes = "获取流转过程", produces = "application/json") public Result getRecordDetail(@RequestParam(name = "id") Integer id) { return Result.ok(mwCollectRecordService.getRecordDetail(id)); } @PostMapping(value = "/restore") @AutoLog(value = "恢复收集记录") @ApiOperation(value = "恢复收集记录", notes = "恢复收集记录", produces = "application/json") public Result restore(@Validated @RequestBody IdDTO dto) { return Result.ok(mwCollectRecordService.restore(dto.getId())); } @GetMapping(value = "/collectTrajectory") @ApiOperation(value = "获取收集轨迹数据列表", notes = "获取收集轨迹数据列表", produces = "application/json") public Result> collectTrajectory(MwCollectCollectTrajectoryParamVO dto, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { dto.setAuditStatus(MedicalWasteEnum.MedicalWasteAuditStatusEnum.PASS.getStatus()); dto.setDelFlag(CommonConstant.DEL_FLAG_0); // dto.setStatus(MedicalWasteEnum.MedicalWasteStatusEnum.COLLECT.getStatus()); // IPage pageList = mwCollectRecordService.getCollectTrajectory(pageNo, pageSize, dto); return Result.ok(pageList); } @GetMapping("/getBoxingList") @ApiOperation(value = "获取出库清单列表") @LogApi(value = "获取出库清单列表") public Result getBoxingListNew(@RequestParam Integer warehouseId,@RequestParam Integer hospitalId) { return Result.ok(mwCollectRecordService.getUnBoxingListNew(warehouseId, EnvUtils.getUser().getId(),hospitalId)); } @PostMapping("/checkoutBatch") @ApiOperation(value = "批量出库") @LogApi(value = "批量出库") public Result checkoutBatch(@Validated @RequestBody MwCheckoutRecordBatchDTO dto) { return Result.ok(mwCheckoutRecordService.checkoutBatchBackground(dto)); } @Autowired private IMwCollectionAmendantRecordService mwCollectionAmendantRecordService; @PostMapping(value = "/edit") @AutoLog(value = "编辑医废记录") @ApiOperation(value = "编辑医废记录", notes = "编辑医废记录", produces = "application/json") public Result edit(@RequestBody MwCollectRecord mwCollectRecord) { Result result = new Result(); MwCollectRecord mwCollectRecordEntity = mwCollectRecordService.getById(mwCollectRecord.getId()); if(mwCollectRecordEntity==null) { result.error500("未找到对应实体"); }else { MwCollectionAmendantRecord mwCollectionAmendantRecord = null; if(!mwCollectRecord.getWasteType().equals(mwCollectRecordEntity.getWasteType())){ mwCollectionAmendantRecord = new MwCollectionAmendantRecord(); mwCollectionAmendantRecord.setCollectCode(mwCollectRecordEntity.getCode()); mwCollectionAmendantRecord.setCollectId(mwCollectRecord.getId()); mwCollectionAmendantRecord.setContentAfter(mwCollectRecord.getWasteTypeStr()); mwCollectionAmendantRecord.setContentBefore(mwCollectRecordEntity.getWasteTypeStr()); mwCollectionAmendantRecord.setHospitalId(mwCollectRecordEntity.getHospitalId()); mwCollectionAmendantRecord.setOfficeId(mwCollectRecordEntity.getDepartmentId().toString()); mwCollectionAmendantRecord.setType(1); mwCollectionAmendantRecord.setDelFlag(0); mwCollectionAmendantRecordService.save(mwCollectionAmendantRecord); } if(!mwCollectRecord.getWeight().equals(mwCollectRecordEntity.getWeight())){ mwCollectionAmendantRecord = new MwCollectionAmendantRecord(); mwCollectionAmendantRecord.setCollectCode(mwCollectRecordEntity.getCode()); mwCollectionAmendantRecord.setCollectId(mwCollectRecord.getId()); mwCollectionAmendantRecord.setContentAfter(mwCollectRecord.getWeight().toString()); mwCollectionAmendantRecord.setContentBefore(mwCollectRecordEntity.getWeight().toString()); mwCollectionAmendantRecord.setHospitalId(mwCollectRecordEntity.getHospitalId()); mwCollectionAmendantRecord.setOfficeId(mwCollectRecordEntity.getDepartmentId().toString()); mwCollectionAmendantRecord.setType(2); mwCollectionAmendantRecord.setDelFlag(0); mwCollectionAmendantRecordService.save(mwCollectionAmendantRecord); } mwCollectRecordEntity.setWasteType(mwCollectRecord.getWasteType()); mwCollectRecordEntity.setWasteTypeStr(mwCollectRecord.getWasteTypeStr()); mwCollectRecordEntity.setWeight(mwCollectRecord.getWeight()); boolean ok = mwCollectRecordService.updateById(mwCollectRecordEntity); //TODO 返回false说明什么? if(ok) { result.success("修改成功!"); } } return result; } @PostMapping(value = "/deleteRecord") @AutoLog(value = "删除收集记录") @ApiOperation(value = "删除收集记录", notes = "删除收集记录", produces = "application/json") @Transactional(rollbackFor = Exception.class) public Result deleteRecord(@Validated @RequestBody IdDTO dto) { boolean ok = mwCollectRecordService.delete(dto.getId()); if(ok){ MwCollectRecord mwCollectRecordEntity = mwCollectRecordService.getById(dto.getId()); MwCollectionAmendantRecord mwCollectionAmendantRecord = null; mwCollectionAmendantRecord = new MwCollectionAmendantRecord(); mwCollectionAmendantRecord.setCollectCode(mwCollectRecordEntity.getCode()); mwCollectionAmendantRecord.setCollectId(dto.getId()); mwCollectionAmendantRecord.setHospitalId(mwCollectRecordEntity.getHospitalId()); mwCollectionAmendantRecord.setOfficeId(mwCollectRecordEntity.getDepartmentId().toString()); mwCollectionAmendantRecord.setType(3); mwCollectionAmendantRecord.setDelFlag(0); mwCollectionAmendantRecordService.save(mwCollectionAmendantRecord); //解除预警 mwWarningRecordService.handleDeleteCollectRecordWarning(mwCollectRecordEntity); } return Result.ok(ok); } }