Sfoglia il codice sorgente

后端代码提交

mashengyi 3 anni fa
parent
commit
64c70dca59

+ 29 - 1
src/main/java/com/jkcredit/invoice/controller/localBussiness/NoCarController.java

@@ -1,5 +1,7 @@
 package com.jkcredit.invoice.controller.localBussiness;
 
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.annotation.LoginRequired;
 import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper;
@@ -12,6 +14,7 @@ import com.jkcredit.invoice.service.lowerService.NoCarService;
 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.ReadExcelUtil;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -19,8 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.File;
 import java.util.List;
 
 @Api(tags = "无车操作")
@@ -169,7 +175,29 @@ public class NoCarController {
             return new RespR(false,e.getMessage());
         }
     }
-
+    /**
+     * 批量运单导入
+     *
+     * @param file    参数集
+     * @return
+     */
+    @PostMapping("/batchImprotBillWay")
+    @ApiOperation(value="批量运单导入", notes="批量运单导入")
+    @LoginRequired
+    public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file) {
+        try {
+            ImportParams params = new ImportParams();
+            params.setTitleRows(1);
+            params.setHeadRows(1);
+            params.setKeyIndex(1);
+            List<NoCarWayBill> list = ExcelImportUtil.importExcel(file.getInputStream(), NoCarWayBill.class,params);
+            RespR respR = noCarBillWayService.batchBillWayStart(list);
+            return respR;
+        }catch (Exception e){
+            e.printStackTrace();
+            return new RespR(false,e.getMessage());
+        }
+    }
     /**
      * 分页查询无车计费信息
      *

+ 0 - 1
src/main/java/com/jkcredit/invoice/service/lowerService/NoCarService.java

@@ -79,5 +79,4 @@ public interface NoCarService {
      * @return
      */
     RespR monthAccQuery(MonthAccountQueryVo monthAccountQueryVo);
-
 }

+ 4 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/impl/NoCarServiceImpl.java

@@ -21,6 +21,7 @@ import com.jkcredit.invoice.service.lowerService.NoCarService;
 import com.jkcredit.invoice.service.lowerService.vo.HCInvoiceQueryVo;
 import com.jkcredit.invoice.service.lowerService.vo.MonthAccountQueryVo;
 import com.jkcredit.invoice.service.manager.ParamService;
+import com.jkcredit.invoice.service.nocar.NoCarRecService;
 import com.jkcredit.invoice.service.upService.NoCarInterface;
 import com.jkcredit.invoice.util.DateUtil;
 import com.jkcredit.invoice.util.MathUtil;
@@ -60,6 +61,9 @@ public class NoCarServiceImpl implements NoCarService{
     @Autowired
     ParamService paramService;
 
+    @Autowired
+    NoCarRecService noCarRecService;
+
     @Override
     public RespR customerCarRec(List<CustomerCarRec> customerCarRecs) {
         if(customerCarRecs== null || customerCarRecs.size()<=0){

+ 8 - 0
src/main/java/com/jkcredit/invoice/service/nocar/NoCarBillWayService.java

@@ -3,6 +3,7 @@ package com.jkcredit.invoice.service.nocar;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
+import com.jkcredit.invoice.util.RespR;
 
 import java.util.List;
 
@@ -22,4 +23,11 @@ public interface NoCarBillWayService {
      * @return
      */
     IPage<List<NoCarWayBill>> findByPageAndWayBillException(Page page, NoCarWayBill noCarWayBill);
+
+    /**
+     * 批量导入运单数据
+     * @param noCarWayBills
+     * @return
+     */
+    RespR batchBillWayStart(List<NoCarWayBill> noCarWayBills);
 }

+ 43 - 0
src/main/java/com/jkcredit/invoice/service/nocar/impl/NoCarBillWayServiceImpl.java

@@ -3,18 +3,29 @@ package com.jkcredit.invoice.service.nocar.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper;
 import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper;
+import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
+import com.jkcredit.invoice.service.lowerService.NoCarService;
 import com.jkcredit.invoice.service.nocar.NoCarBillWayService;
+import com.jkcredit.invoice.util.RespR;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 @Service
 public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCarWayBill> implements NoCarBillWayService{
     @Autowired
     NoCarWaybillMapper noCarWaybillMapper;
 
+    @Autowired
+    CustomerCarRecMapper customerCarRecMapper;
+
+    @Autowired
+    NoCarService noCarService;
     @Override
     public IPage<List<NoCarWayBill>> findByPageAndWayBill(Page page, NoCarWayBill noCarWayBill) {
         return noCarWaybillMapper.selectAllByPage(page,noCarWayBill);
@@ -24,4 +35,36 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
     public IPage<List<NoCarWayBill>> findByPageAndWayBillException(Page page, NoCarWayBill noCarWayBill) {
         return noCarWaybillMapper.selectAllByPageException(page,noCarWayBill);
     }
+
+    @Override
+    public RespR batchBillWayStart(List<NoCarWayBill> noCarWayBills) {
+        StringBuffer stringBuffer = new StringBuffer();
+        noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+            //1.查询是否有车辆备案
+            CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateColor());
+
+            //2.无车车辆备案时进行车辆备案
+            if(customerCarRec== null || customerCarRec.getRecStatus()!=1){
+                List<CustomerCarRec> customerCarRecs = new ArrayList<>();
+                customerCarRecs.add(customerCarRec);
+                RespR respR = noCarService.customerCarRec(customerCarRecs);
+                if(respR.getCode() ==1){
+                    return;
+                }else{
+                    stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                }
+            }
+
+            //3.进行上传
+            RespR respR = noCarService.noCarHisWaybillStart(noCarWayBill);
+            if (respR.getCode() == 1){
+                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+            }
+        });
+        if(StringUtils.isEmpty(stringBuffer.toString())){
+            return new RespR(false,stringBuffer.toString());
+        }
+        return new RespR(Boolean.TRUE);
+    }
+
 }

+ 6 - 3
src/main/resources/application.yml

@@ -43,9 +43,12 @@ mybatis-plus:
 spring:
   profiles: dev
   datasource:
-#    url: jdbc:mysql://172.31.1.10:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
-#    username: root
-#    password: Jkxy@mysql123
+    #url: jdbc:mysql://172.31.1.10:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
+    #username: root
+    # password: Jkxy@mysql123
+    #url: jdbc:mysql://127.0.0.1:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&allowPublicKeyRetrieval=true
+    #username: root
+    #password: root
     url: jdbc:mysql://192.168.50.88:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
     username: root
     password: jk@123