Explorar el Código

批量导入模板

qzyReal hace 3 años
padre
commit
ebf4d17928

+ 12 - 2
sp-admin/sa-view/tb-car/tb-car-list.html

@@ -40,12 +40,14 @@
 				</el-button>
 				<el-button type="primary" @click="importFn()" v-if="sa.isAuth('tb-car-import')">批量导入
 				</el-button>
+				<el-button type="primary" @click="importTemplate" v-if="sa.isAuth('tb-car-import')">导入模板
+				</el-button>
 				<!--				<el-button type="success" icon="el-icon-view" @click="getBySelect()">查看</el-button>-->
 				<el-button type="danger" icon="el-icon-delete" @click="deleteByIds()" v-if="sa.isAuth('tb-car-del')">删除
 				</el-button>
 				<el-button type="info" icon="el-icon-refresh" @click="sa.f5()">重置</el-button>
 				<!-- ------------- 数据列表 ------------- -->
-				<el-table class="data-table" ref="data-table" :data="dataList">
+				<el-table class="data-table" ref="data-table" :data="dataList" style="margin-top: 10px;">
 					<sa-td type="selection"></sa-td>
 					<sa-td name="归属" prop="customerName"></sa-td>
 					<sa-td name="车牌号" prop="cardNo"></sa-td>
@@ -105,6 +107,9 @@
 					}
 				},
 				methods: {
+					importTemplate(){
+						window.location.href='../../static/excel/批量导入车辆.xlsx';
+					},
 					importFn() {
 						Object.assign(this.modal, {
 							visible: true,
@@ -115,7 +120,12 @@
 						sa.loading('正在上传..')
 					},
 					successFn(res) {
-						sa.hideLoading()
+							sa.hideLoading();
+						if(res.code==200){
+							sa.alert('导入成功')	
+						}else{
+							sa.error(res.msg);
+						}
 					},
 					errorFn() {
 						sa.hideLoading()

BIN
sp-admin/static/excel/批量导入车辆.xlsx


+ 1 - 1
sp-server/app.pid

@@ -1 +1 @@
-9104
+17132

+ 3 - 2
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -65,6 +65,7 @@ public class OpenService {
         carNo = carNo.toUpperCase();
         TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
         Date now = new Date();
+        checkFree(carNo, 1, now);
         if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)) {
             tbBusinessCar = new TbBusinessCar();
             tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(3D).setIsLock(0).setInImage(image)
@@ -81,7 +82,7 @@ public class OpenService {
                 tbBusinessService.updateById(tbBusiness);
             }
         }
-        checkFree(carNo, 1, now);
+
     }
 
     private ResultJson handlerOut(String carNo, String channel, String image) {
@@ -146,7 +147,7 @@ public class OpenService {
             }
             tbCarService.updateById(tbCar);
         }
-        return tbCar != null && TbCar.CarTypeEnum.BUSINESS_CAR.getType().equals(tbCar.getCarType());
+        return tbCar != null && !TbCar.CarTypeEnum.BUSINESS_CAR.getType().equals(tbCar.getCarType());
     }
 
 

+ 8 - 4
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -435,10 +435,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         BigDecimal basePrice = businessCar ? partConfig.getBasePrice() : new BigDecimal("0");
         BigDecimal p = partConfig.getBasePrice();//乘积因子
         BigDecimal extraPrice = partConfig.getExtraPrice();
-       BigDecimal unit= new BigDecimal(hour / 24);
-       if (minutes>partConfig.getFreeMinutes()&&minutes<24*60){
-           unit=new BigDecimal("1");
-       }
+        BigDecimal unit = new BigDecimal(hour / 24);
+        if (minutes > partConfig.getFreeMinutes() && minutes < 24 * 60) {
+            unit = new BigDecimal("1");
+        }
         return basePrice.add(p.multiply(unit)).add(new BigDecimal(days).multiply(extraPrice));
     }
 
@@ -493,6 +493,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             carMap.put("id", tbBusinessCar.getId());
             carMap.put("carNo", tbBusinessCar.getCarNo());
             carMap.put("pay", tbBusinessCar.getPay());
+            TbCar tbCar = tbCarService.findByCardNo(tbBusinessCar.getCarNo());
+            if (tbCar != null && !TbCar.CarTypeEnum.BUSINESS_CAR.getType().equals(tbCar.getCarType())) {
+                carMap.put("price", 0);
+            }
             carsList.add(carMap);
         }
         result.put("carList", carsList);

+ 1 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml

@@ -37,6 +37,7 @@
             <if test=' this.has("realOutTime") '>and real_out_time = #{realOutTime}</if>
             <if test=' this.has("money") '>and money = #{money}</if>
             <if test=' this.has("driverPhone") '>and driver_phone = #{driverPhone}</if>
+            <if test=' this.has("pay") '>and pay = #{pay}</if>
         </where>
         order by
         <choose>

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_car/TbCarController.java

@@ -78,7 +78,7 @@ public class TbCarController {
 
 	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
 	@RequestMapping("importExcel")
-	public AjaxJson importExcel(MultipartFile file) {
+	public AjaxJson importExcel(MultipartFile file)throws Exception {
 		tbCarService.importExcel(file);
 		return AjaxJson.getSuccess();
 	}

+ 8 - 11
sp-server/src/main/java/com/pj/project/tb_car/TbCarService.java

@@ -83,17 +83,14 @@ public class TbCarService extends ServiceImpl<TbCarMapper, TbCar> implements ISe
         return getOne(ew);
     }
 
-    public void importExcel(MultipartFile file) {
+    public void importExcel(MultipartFile file) throws Exception {
         StaticLog.info("file size:{}", file.getSize());
-        try (InputStream is = file.getInputStream()) {
-            importCarListener.list.clear();
-            ExcelReader reader = EasyExcel.read(is, ImportCarBO.class,importCarListener).build();
-            ReadSheet readSheet = EasyExcel.readSheet(0).build();
-            reader.read(readSheet);
-            reader.finish();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
+        InputStream is = file.getInputStream();
+        importCarListener.list.clear();
+        ExcelReader reader = EasyExcel.read(is, ImportCarBO.class, importCarListener).build();
+        ReadSheet readSheet = EasyExcel.readSheet(0).build();
+        reader.read(readSheet);
+        reader.finish();
+        is.close();
     }
 }