浏览代码

代码优化开发202110172

MSY 3 年之前
父节点
当前提交
618aff5ec2

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

@@ -209,7 +209,30 @@ public class NoCarController {
             return new RespR(false,e.getMessage());
         }
     }
+
     /**
+     * 批量查询无车发票信息
+     *
+     * @param file    参数集
+     * @return
+     */
+    @PostMapping("/batchImportNocarInvoices")
+    @ApiOperation(value="批量查询无车发票信息", notes="批量查询无车发票信息")
+    @LoginRequired
+    public RespR batchImportNocarInvoices(@RequestParam("file") MultipartFile file) {
+        try {
+            ImportParams params = new ImportParams();
+            params.setTitleRows(1);
+            params.setHeadRows(1);
+            params.setKeyIndex(2);
+            List<BillInvoice> list = ExcelImportUtil.importExcel(file.getInputStream(), BillInvoice.class,params) ;
+            RespR respR = nocarInvoiceService.findImportNocarInvoices(list);
+            return respR;
+        }catch (Exception e){
+            e.printStackTrace();
+            return new RespR(false,e.getMessage());
+        }
+    }    /**
      * 分页查询无车运单统计信息
      *
      * @param    billInvoice
@@ -366,11 +389,13 @@ public class NoCarController {
                 fileName = "运单结束模板.xlsx";
             }else if("3".equals(fileName)){
                 fileName = "历史运单模板.xlsx";
+            }else if("4".equals(fileName)){
+                fileName = "无车发票查询模板.xlsx";
             }
             OutputStream outputStream = null;
             InputStream inputStream = null;
             try {
-                File file = new File("/home/app/excel/"+fileName);
+                File file = new File("D:\\sys_invoice_tools\\"+fileName);
                 inputStream = new FileInputStream(file);
                 response.setHeader("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName, "UTF-8"));
                 outputStream = response.getOutputStream();

+ 1 - 0
src/main/java/com/jkcredit/invoice/credit/SimpleCORSFilter.java

@@ -129,6 +129,7 @@ public class SimpleCORSFilter implements Filter {
             "/noCar/findNocarInvoicesStatic",
             "/noCar/findNocarCalculateInfo",
             "/noCar/templateDownload",
+            "/noCar/batchImportNocarInvoices",
 
 
             "/selfCar/selfCarUnBind",

+ 2 - 0
src/main/java/com/jkcredit/invoice/mapper/Binvoce/BillInvoiceMapper.java

@@ -14,6 +14,8 @@ import java.util.Map;
 public interface BillInvoiceMapper extends BaseMapper<BillInvoice>{
     IPage<List<BillInvoice>> selectAllByPage(Page page, @Param("billInvoice") BillInvoice billInvoice);
 
+    BillInvoice selectAllByPageByBillInvoice( BillInvoice record);
+
     int insert(BillInvoice record);
 
     int updateByPrimaryKey(BillInvoice record);

+ 5 - 0
src/main/java/com/jkcredit/invoice/model/entity/invoice/BillInvoice.java

@@ -1,5 +1,7 @@
 package com.jkcredit.invoice.model.entity.invoice;
 
+import cn.afterturn.easypoi.excel.annotation.Excel;
+
 /**
  * 运单发票
  */
@@ -22,10 +24,12 @@ public class BillInvoice {
     /**
      * 发票号码
      */
+    @Excel(name = "发票号码")
     private String invoiceNum;
     /**
      * 发票代码
      */
+    @Excel(name = "发票代码")
     private String invoiceCode;
     /**
      *开票时间
@@ -82,6 +86,7 @@ public class BillInvoice {
     /**
      * 运单编号
      */
+    @Excel(name = "运单编号")
     private String waybillNum;
     /**
      * 运单状态  未结束	1

+ 10 - 0
src/main/java/com/jkcredit/invoice/service/nocar/NocarInvoiceService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
+import com.jkcredit.invoice.util.RespR;
 
 import java.util.List;
 import java.util.Map;
@@ -21,4 +22,13 @@ public interface NocarInvoiceService {
     IPage<List<BillInvoice>> findByPageAndInvoice(Page page, BillInvoice billInvoice);
 
     Map<String,String> findInvoiceStatics(BillInvoice billInvoice);
+
+
+
+    /**
+     * 批量查询所有发票接口
+     * @param billInvoices
+     * @return
+     */
+    RespR findImportNocarInvoices(List<BillInvoice> billInvoices);
 }

+ 16 - 0
src/main/java/com/jkcredit/invoice/service/nocar/impl/NocarInvoiceServiceImpl.java

@@ -6,9 +6,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jkcredit.invoice.mapper.Binvoce.BillInvoiceMapper;
 import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
 import com.jkcredit.invoice.service.nocar.NocarInvoiceService;
+import com.jkcredit.invoice.util.RespR;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -26,4 +29,17 @@ public class NocarInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper,BillI
     public Map<String, String> findInvoiceStatics(BillInvoice billInvoice) {
         return billInvoiceMapper.findInvoiceStatics(billInvoice);
     }
+
+    @Override
+    public RespR findImportNocarInvoices(List<BillInvoice> billInvoices) {
+        List<BillInvoice> billInvoicesTmp = new ArrayList<BillInvoice>();
+        for (BillInvoice billInvoice:billInvoices) {
+            if(StringUtils.isEmpty(billInvoice.getInvoiceNum()) || StringUtils.isEmpty(billInvoice.getInvoiceCode())){
+                return new RespR<>("失败","0");
+            }
+            BillInvoice bill =  billInvoiceMapper.selectAllByPageByBillInvoice(billInvoice);
+            billInvoicesTmp.add(bill);
+        }
+        return new RespR<>(billInvoicesTmp,"1");
+    }
 }

+ 19 - 0
src/main/resources/mapper/invoice/BillInvoiceMapper.xml

@@ -96,6 +96,25 @@
             </if>
         </where>
     </select>
+
+
+    <select id="selectAllByPageByBillInvoice" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice">
+        select
+        <include refid="baseSql" />
+        from t_billInvoice
+        <where>
+            <if test="waybillNum != null and waybillNum != ''">
+                and waybillNum = #{waybillNum}
+            </if>
+            <if test="invoiceCode != null and invoiceCode != ''">
+                and invoiceCode = #{invoiceCode}
+            </if>
+            <if test="invoiceNum != null and invoiceNum != ''">
+                and invoiceNum = #{invoiceNum}
+            </if>
+        </where>
+    </select>
+
     <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
         insert into t_billInvoice (
             companyNum,