|
package org.springblade.mdm.machinefile.controller;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.servlet.http.HttpServletResponse;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springblade.core.excel.util.ExcelUtil;
|
import org.springblade.core.tenant.annotation.NonDS;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.utils.DateUtil;
|
import org.springblade.mdm.basesetting.machine.entity.Machine;
|
import org.springblade.mdm.basesetting.machine.service.MachineService;
|
import org.springblade.mdm.basesetting.producedivision.entity.MdmDept;
|
import org.springblade.mdm.basesetting.producedivision.service.MdmDeptService;
|
import org.springblade.mdm.commons.service.OssFileCommonService;
|
import org.springblade.mdm.machinefile.entity.FileSendRecord;
|
import org.springblade.mdm.machinefile.entity.MachineFile;
|
import org.springblade.mdm.machinefile.service.FileSendRecordService;
|
import org.springblade.mdm.machinefile.service.MachineFileChangeHisService;
|
import org.springblade.mdm.machinefile.service.MachineFileService;
|
import org.springblade.mdm.machinefile.vo.*;
|
import org.springblade.mdm.program.vo.CompareDataVO;
|
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.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.io.IOException;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* 文件下发记录
|
*
|
* @author yangys
|
*/
|
@NonDS
|
@RestController
|
@RequestMapping("/machinefile/sendrecord")
|
@Tag(name = "文件下发记录", description = "文件下发记录")
|
@Slf4j
|
public class FileSendRecordController {
|
@Autowired
|
private OssFileCommonService ossFileCommonService;
|
@Autowired
|
private FileSendRecordService fileSendRecordService;
|
|
@GetMapping("/page")
|
@Operation(summary = "下发文件记录列表", description = "下发文件记录列表")
|
public R<IPage<FileSendRecordVO>> page(FileSendRecordQueryVO query) {
|
if(query.getCreateTimeEnd()!=null){
|
query.setCreateTimeEnd(query.getCreateTimeEnd().plusDays(1));
|
}
|
return R.data(fileSendRecordService.pageQuery(query));
|
}
|
|
@GetMapping("/download-by-id")
|
@Operation(summary = "下发文件记录列表", description = "下发文件记录列表")
|
public void downloadByRecordId(Long id,HttpServletResponse response) throws IOException {
|
FileSendRecord record = fileSendRecordService.getById(id);
|
ossFileCommonService.download(record.getOssName(),record.getName(),response);
|
}
|
|
|
@GetMapping("/export-excel")
|
@Operation(summary = "下发文件记录表导出", description = "下发文件记录表导出")
|
public void export(FileSendRecordQueryVO query, HttpServletResponse response) {
|
query.setCurrent(1);
|
query.setSize(Integer.MAX_VALUE);
|
|
//IPage<MachineBackFileVO> pages = service.pageQuery(query);
|
IPage<FileSendRecordVO> pages = fileSendRecordService.pageQuery(query);
|
List<FileSendRecordExcelVO> list = new ArrayList<>();
|
pages.getRecords().forEach(m ->{
|
FileSendRecordExcelVO excelVO = new FileSendRecordExcelVO();
|
BeanUtils.copyProperties(m, excelVO);
|
list.add(excelVO);
|
});
|
ExcelUtil.export(response, "下发文件记录表" + DateUtil.time(), "下发文件记录表", list, FileSendRecordExcelVO.class);
|
}
|
|
}
|