|
|
@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.iflytop.handacid.app.common.utils.UsbDriverUtil; |
|
|
|
import com.iflytop.handacid.common.base.BasePageQuery; |
|
|
|
import com.iflytop.handacid.common.model.entity.AuditRecord; |
|
|
|
import com.iflytop.handacid.common.model.entity.Formulation; |
|
|
|
import com.iflytop.handacid.common.result.PageResult; |
|
|
|
import com.iflytop.handacid.common.result.Result; |
|
|
|
import com.iflytop.handacid.common.service.AuditRecordService; |
|
|
@ -12,7 +11,6 @@ import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.usermodel.Cell; |
|
|
|
import org.apache.poi.ss.usermodel.Row; |
|
|
|
import org.apache.poi.ss.usermodel.Sheet; |
|
|
@ -22,11 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 审计 |
|
|
|
*/ |
|
|
@ -60,7 +58,7 @@ public class AuditRecordController { |
|
|
|
@PostMapping |
|
|
|
@Operation(summary = "增加记录") |
|
|
|
public Result<String> create(@RequestBody AuditRecord auditRecord) { |
|
|
|
boolean flag= auditRecordService.save(auditRecord); |
|
|
|
boolean flag = auditRecordService.save(auditRecord); |
|
|
|
return flag ? Result.success("添加成功") : Result.failed("添加失败"); |
|
|
|
} |
|
|
|
|
|
|
@ -68,7 +66,7 @@ public class AuditRecordController { |
|
|
|
@Operation(summary = "修改记录") |
|
|
|
public Result<String> update(@RequestBody AuditRecord auditRecord) { |
|
|
|
boolean flag = auditRecordService.updateById(auditRecord); |
|
|
|
return flag ? Result.success("修改成功"): Result.failed("修改失败"); |
|
|
|
return flag ? Result.success("修改成功") : Result.failed("修改失败"); |
|
|
|
} |
|
|
|
|
|
|
|
@DeleteMapping("/{ids}") |
|
|
@ -77,17 +75,17 @@ public class AuditRecordController { |
|
|
|
boolean success = auditRecordService.removeBatchByIds( |
|
|
|
Arrays.stream(ids.split(",")).map(Long::valueOf).toList() |
|
|
|
); |
|
|
|
return success ? Result.success("删除成功"): Result.failed("删除失败"); |
|
|
|
return success ? Result.success("删除成功") : Result.failed("删除失败"); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export") |
|
|
|
@Operation(summary = "导出记录") |
|
|
|
public Result<String> export() { |
|
|
|
String usbPath = UsbDriverUtil.findPath(); |
|
|
|
if(usbPath==null){ |
|
|
|
if (usbPath == null) { |
|
|
|
} |
|
|
|
List<AuditRecord> list= auditRecordService.list(); |
|
|
|
if(list.isEmpty()){ |
|
|
|
List<AuditRecord> list = auditRecordService.list(); |
|
|
|
if (list.isEmpty()) { |
|
|
|
return Result.failed("无审计记录"); |
|
|
|
} |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
@ -103,11 +101,11 @@ public class AuditRecordController { |
|
|
|
AuditRecord record = list.get(i); |
|
|
|
Row row = sheet.createRow(i + 1); |
|
|
|
row.createCell(0).setCellValue(record.getId()); |
|
|
|
row.createCell(1).setCellValue(record.getUserName()); |
|
|
|
row.createCell(1).setCellValue(record.getUserNickname()); |
|
|
|
row.createCell(2).setCellValue(record.getSolutionName()); |
|
|
|
row.createCell(3).setCellValue(record.getConcentration()); |
|
|
|
row.createCell(4).setCellValue(record.getChannelId() != null ? record.getChannelId() : 0); |
|
|
|
row.createCell(5).setCellValue(record.getVolume()); |
|
|
|
row.createCell(4).setCellValue(record.getChannelCode()); |
|
|
|
row.createCell(5).setCellValue(record.getUsedVolume()); |
|
|
|
row.createCell(6).setCellValue(record.getCreateTime() != null ? record.getCreateTime().toString() : ""); |
|
|
|
row.createCell(7).setCellValue(record.getUpdateTime() != null ? record.getUpdateTime().toString() : ""); |
|
|
|
} |
|
|
@ -125,7 +123,7 @@ public class AuditRecordController { |
|
|
|
return Result.success("导出成功,文件已保存到: " + filePath); |
|
|
|
} catch (IOException e) { |
|
|
|
log.error(e.getMessage()); |
|
|
|
return Result.failed("导出失败"+e.getMessage()); |
|
|
|
return Result.failed("导出失败" + e.getMessage()); |
|
|
|
//throw new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|