|
@ -7,10 +7,9 @@ import jakarta.servlet.http.HttpServletResponse; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.dromara.common.core.domain.R; |
|
|
import org.dromara.common.core.domain.R; |
|
|
import org.dromara.common.core.exception.ServiceException; |
|
|
import org.dromara.common.core.utils.file.FileUtils; |
|
|
import org.dromara.platform.domain.bo.PointInfoBo; |
|
|
import org.dromara.platform.domain.bo.PointInfoBo; |
|
|
import org.dromara.platform.domain.bo.WorkOrderInfoBo; |
|
|
import org.dromara.platform.domain.bo.WorkOrderInfoBo; |
|
|
import org.dromara.platform.domain.vo.DocumentTypeVo; |
|
|
|
|
|
import org.dromara.platform.domain.vo.PointInfoVo; |
|
|
import org.dromara.platform.domain.vo.PointInfoVo; |
|
|
import org.dromara.platform.domain.vo.WorkOrderInfoVo; |
|
|
import org.dromara.platform.domain.vo.WorkOrderInfoVo; |
|
|
import org.dromara.platform.listener.PointInfoListener; |
|
|
import org.dromara.platform.listener.PointInfoListener; |
|
@ -26,6 +25,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.net.URLEncoder; |
|
|
import java.net.URLEncoder; |
|
|
|
|
|
import java.rmi.ServerException; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
@ -101,10 +101,17 @@ public class ExcelController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 批量点位上报 |
|
|
|
|
|
* @param file |
|
|
|
|
|
* @param response |
|
|
|
|
|
* @return |
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
*/ |
|
|
@PostMapping("/uploadWorkOrderInfo") |
|
|
@PostMapping("/uploadWorkOrderInfo") |
|
|
public R<List<String>> uploadWorkOrderInfo(MultipartFile file, HttpServletResponse response) throws IOException { |
|
|
public R<List<String>> uploadWorkOrderInfo(MultipartFile file, HttpServletResponse response) throws IOException { |
|
|
long t1 = System.currentTimeMillis(); |
|
|
long t1 = System.currentTimeMillis(); |
|
|
|
|
|
// TODO 文件校验
|
|
|
|
|
|
|
|
|
WorkOrderInfoListener listener = new WorkOrderInfoListener(workOrderInfoService, contractInfoService); |
|
|
WorkOrderInfoListener listener = new WorkOrderInfoListener(workOrderInfoService, contractInfoService); |
|
|
|
|
|
|
|
@ -133,4 +140,32 @@ public class ExcelController { |
|
|
return R.fail("文件导入失败: " + e.getMessage()); |
|
|
return R.fail("文件导入失败: " + e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/checkFile") |
|
|
|
|
|
public void checkFile(MultipartFile file, String templateFileName,HttpServletResponse response) throws IOException { |
|
|
|
|
|
FileUtils.checkExcel(file, templateFileName); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void checkExcel(MultipartFile file, String templateFileName) throws ServerException { |
|
|
|
|
|
if (file == null || file.isEmpty()) { |
|
|
|
|
|
throw new ServerException("请选择要上传的文件"); |
|
|
|
|
|
} |
|
|
|
|
|
// ✅ 获取上传文件的原始名称
|
|
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
|
|
|
|
|
|
|
|
// 校验文件名称是否匹配模板
|
|
|
|
|
|
//templateFileName = "批量点位上报模板.xlsx";
|
|
|
|
|
|
if (!templateFileName.contains(originalFilename)){ |
|
|
|
|
|
throw new ServerException("请检查上传的文件名称!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (originalFilename == null || !(originalFilename.endsWith(".xls") || originalFilename.endsWith(".xlsx"))) { |
|
|
|
|
|
throw new ServerException("请上传正确的文件格式"); |
|
|
|
|
|
} |
|
|
|
|
|
// 打印文件名(例如:test.xlsx)
|
|
|
|
|
|
log.info("上传的文件名是:" + originalFilename); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|