|
@@ -1,5 +1,5 @@
|
|
|
package com.jkcredit.invoice.controller.business;
|
|
|
-
|
|
|
+import com.jkcredit.invoice.service.nocar.WayBillFileService;
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -22,12 +22,17 @@ import com.jkcredit.invoice.service.nocar.NoCarBillWayImportService;
|
|
|
import com.jkcredit.invoice.service.nocar.NoCarBillWayService;
|
|
|
import com.jkcredit.invoice.service.nocar.NoCarRecService;
|
|
|
import com.jkcredit.invoice.service.nocar.NocarInvoiceService;
|
|
|
+import com.jkcredit.invoice.util.Base64Utils;
|
|
|
+import com.jkcredit.invoice.util.DateUtil;
|
|
|
import com.jkcredit.invoice.util.RespR;
|
|
|
+import com.jkcredit.invoice.util.ZipUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.poi.util.IOUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -41,7 +46,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-
|
|
|
+import com.jkcredit.invoice.model.entity.waybill.NoCarWayBillFileInfo;
|
|
|
import static com.jkcredit.invoice.common.CommonConst.*;
|
|
|
|
|
|
@Api(tags = "无车操作")
|
|
@@ -83,6 +88,8 @@ public class NoCarController {
|
|
|
CustomerOperService customerOperService;
|
|
|
@Autowired
|
|
|
private CheckHasAuthRole checkHasAuthRole;
|
|
|
+ @Autowired
|
|
|
+ private WayBillFileService wayBillFileService;
|
|
|
|
|
|
/**
|
|
|
* 分页查询无车备案信息
|
|
@@ -218,6 +225,26 @@ public class NoCarController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询运单信息
|
|
|
+ *
|
|
|
+ * @param page 参数集
|
|
|
+ * @return 用户集合
|
|
|
+ */
|
|
|
+ @PostMapping("/findBatchFileList")
|
|
|
+ @ApiOperation(value = "分页查询运单协议上传", notes = "分页查询运单协议上传")
|
|
|
+ @LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
|
|
|
+ public RespR findBatchFileList(Page page, NoCarWayBillFileInfo noCarWayBillFileInfo, User user) {
|
|
|
+ try {
|
|
|
+ checkHasAuthRole.checkCustomerRole(user, noCarWayBillFileInfo.getCustomerId());
|
|
|
+ RespR respR = new RespR(wayBillFileService.selectAllFiles(page,noCarWayBillFileInfo));
|
|
|
+ return respR;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new RespR(false, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 重新获取发票并更新状态
|
|
|
*
|
|
@@ -421,7 +448,7 @@ public class NoCarController {
|
|
|
@PostMapping("/batchImprotBillWay")
|
|
|
@ApiOperation(value = "批量运单导入", notes = "批量运单导入")
|
|
|
@LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
|
|
|
- public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName, User user) {
|
|
|
+ public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName,String batchNum, User user) {
|
|
|
try {
|
|
|
|
|
|
if (null == file) {
|
|
@@ -435,14 +462,85 @@ public class NoCarController {
|
|
|
params.setKeyIndex(2);
|
|
|
List<NoCarWayBill> list = ExcelImportUtil.importExcel(file.getInputStream(), NoCarWayBill.class, params);
|
|
|
buildDate(list);
|
|
|
- RespR respR = noCarBillWayService.batchBillWayStart(list, customerName);
|
|
|
+ RespR respR = noCarBillWayService.batchBillWayStart(list, customerName,batchNum);
|
|
|
return respR;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return new RespR(false, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+ @Value("${param.fileTmp:/home/app/logs/temp}")
|
|
|
+ private String tempPath = "d:/log";
|
|
|
+ /**
|
|
|
+ * 批量运单导入
|
|
|
+ *
|
|
|
+ * @param file 参数集
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/batchImprotBillWayFile")
|
|
|
+ @ApiOperation(value = "批量文件导入", notes = "批量文件导入")
|
|
|
+ @LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
|
|
|
+ public RespR batchImprotBillWayFile(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName, User user) {
|
|
|
+ FileOutputStream fileOutputStream = null;
|
|
|
+ String realPath = "";
|
|
|
+ try {
|
|
|
+ log.info("开始导入文件{},{}M",file.getName(),file.getSize()/1024/1024);
|
|
|
+ if (null == file) {
|
|
|
+ return new RespR(false, "文件导入失败");
|
|
|
+ }
|
|
|
|
|
|
+ checkHasAuthRole.checkCustomerRole(user, customerName);
|
|
|
+ //将文件放到临时目录,
|
|
|
+ String batchNumber = "YDF" + System.currentTimeMillis();
|
|
|
+ realPath = tempPath+"/"+batchNumber+"/";
|
|
|
+ File file1 = new File(realPath);
|
|
|
+ file1.mkdirs();
|
|
|
+ fileOutputStream = new FileOutputStream(realPath+file.getOriginalFilename());
|
|
|
+ fileOutputStream.write(file.getBytes());
|
|
|
+ ZipUtils.unZipFiles(realPath+file.getOriginalFilename(),realPath+"out/");
|
|
|
+ File fileout = new File(realPath+"out/");
|
|
|
+ File [] files = fileout.listFiles();
|
|
|
+ while ( files.length>0&& files[0].isDirectory()){
|
|
|
+ files = fileout.listFiles()[0].listFiles();
|
|
|
+ }
|
|
|
+ for(int i=0;i<files.length;i++){
|
|
|
+ File fileTemp = files[i];
|
|
|
+ NoCarWayBillFileInfo noCarWayBillFileInfo = new NoCarWayBillFileInfo();
|
|
|
+ noCarWayBillFileInfo.setCustomerId(customerName);
|
|
|
+ noCarWayBillFileInfo.setBatchNum(batchNumber);
|
|
|
+ noCarWayBillFileInfo.setUpdateTime(DateUtil.getCurrentDateStr());
|
|
|
+ noCarWayBillFileInfo.setBase64Str( Base64Utils.fileToBase64Str(fileTemp));
|
|
|
+ noCarWayBillFileInfo.setWayBillNum(fileTemp.getName());
|
|
|
+ wayBillFileService.insert(noCarWayBillFileInfo);
|
|
|
+ }
|
|
|
+ return new RespR(true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return new RespR(false, e.getMessage());
|
|
|
+ }finally {
|
|
|
+ if(fileOutputStream !=null){
|
|
|
+ try {
|
|
|
+ fileOutputStream.close();
|
|
|
+ FileUtils.deleteDirectory(new File(realPath));
|
|
|
+ }catch (IOException e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deleteFile(File file){
|
|
|
+ if(file.isFile()){
|
|
|
+ file.delete();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File [] files = file.listFiles();
|
|
|
+ for(File file1:files){
|
|
|
+ deleteFile(file1);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 批量运单导入
|
|
|
*
|
|
@@ -452,7 +550,7 @@ public class NoCarController {
|
|
|
@PostMapping("/batchImprotHistoryBillWay")
|
|
|
@ApiOperation(value = "批量历史运单导入", notes = "批量历史运单导入")
|
|
|
@LoginRequired(role = AuthenticationInterceptor.AUTH_NOCAR)
|
|
|
- public RespR batchImprotHistoryBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName, User user) {
|
|
|
+ public RespR batchImprotHistoryBillWay(@RequestParam("file") MultipartFile file, @NotNull(message = "批量运单导入,客户名称不能为空") String customerName,String batchNum, User user) {
|
|
|
try {
|
|
|
|
|
|
if (null == file) {
|
|
@@ -467,7 +565,7 @@ public class NoCarController {
|
|
|
List<NoCarWayBill> list = ExcelImportUtil.importExcel(file.getInputStream(), NoCarWayBill.class, params);
|
|
|
log.info("batchImprotHistoryBillWay数量" + list.size());
|
|
|
buildDate(list);
|
|
|
- RespR respR = noCarBillWayService.batchHsitoryBillWay(list, customerName);
|
|
|
+ RespR respR = noCarBillWayService.batchHsitoryBillWay(list, customerName,batchNum);
|
|
|
return respR;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|