Browse Source

手动绑定车辆

qzyReal 2 years ago
parent
commit
6bc80b3d73

+ 1 - 1
app/manifest.json

@@ -85,7 +85,7 @@
     "vueVersion" : "2",
     "h5" : {
         "router" : {
-            "base" : "/h5/",
+            "base" : "/test/",
             "mode" : "history"
         },
         "devServer" : {

+ 1 - 1
app/pages/wx/pay.vue

@@ -213,7 +213,7 @@
 				} else if (type == 1) {
 					let itemSelect = this.itemSelect;
 					let itemStr = this.item.list
-						.filter(obj => itemSelect.indexOf(obj.id) !== -1).map(obj => obj.name)
+						.filter(obj => itemSelect.indexOf(obj.id) !== -1).map(obj => obj.name.substr(0,obj.name.indexOf('(')))
 						.join('、');
 					console.log(itemStr)
 					con = 'A1-' + itemStr;

+ 2 - 2
app/utils/request.js

@@ -1,5 +1,5 @@
-const server = 'http://127.0.0.1:8099/pro';
-// const server = 'https://pco.aseanbusiness.cn/pro';
+// const server = 'http://127.0.0.1:8099/pro';
+const server = 'https://pco.aseanbusiness.cn/pro';
 // const server = 'https://dxkaa1.bgigc.com/pro';
 
 import common from '../common/js/common.js';

+ 7 - 0
sp-admin/sa-frame/menu-list.js

@@ -339,6 +339,12 @@ var menuList = [{
 						isShow: false
 					},
 					{
+					
+						id: 'tb-business-car-bind',
+						name: '车辆绑定',
+						isShow: false
+					},
+					{
 						id: 'tb-flex-business-confirm',
 						name: '账单确认',
 						isShow: false
@@ -456,6 +462,7 @@ var menuList = [{
 					name: '修改记录',
 					isShow: false
 				},
+				
 				{
 
 					id: 'tb-business-car-del',

+ 172 - 0
sp-admin/sa-view/tb-business-car/tb-business-car-business-add.html

@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>入境登记-列表</title>
+		<meta charset="utf-8">
+		<meta name="viewport"
+			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+		<!-- 所有的 css & js 资源 -->
+		<link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
+		<link rel="stylesheet" href="../../static/sa.css">
+		<script src="../../static/kj/vue.min.js"></script>
+		<script src="../../static/kj/element-ui/index.js"></script>
+		<script src="../../static/kj/httpVueLoader.js"></script>
+		<script src="../../static/kj/jquery.min.js"></script>
+		<script src="../../static/kj/layer/layer.js"></script>
+		<script src="../../static/sa.js"></script>
+		<script src="../../static/kj/upload-util.js"></script>
+	</head>
+	<style>
+		.complete-modal .c-label,
+		.confirm-in .c-label,
+		.confirm-info .c-label {
+			width: 290px;
+		}
+	</style>
+	<body>
+		<div class="vue-box" style="display: none;" :style="'display: block;'">
+			<div class="c-panel">
+
+				<el-form ref="form" :model='p' @submit.native.prevent>
+					<sa-item type="text" name="订单号" placeholder="订单号" v-model="p.no"></sa-item>
+						<sa-item type="text" name="车牌号" placeholder="车牌号" v-model="p.carNo"></sa-item>
+					<div class="c-item">
+						<label class="c-label">录入日期:</label>
+						<el-date-picker :clearable="false"  value-format="yyyy-MM-dd" v-model="p.createTime" type="date">
+						</el-date-picker>
+					</div>
+					<el-button size="mini" type="primary" @click="f5()">
+						搜索</el-button>
+					<el-button type="info" icon="el-icon-search"
+						@click="p.cardNo = '';p.no = '';p.createTime = '';p.adminConfirmInput=-1; f5()">重置
+					</el-button>
+				</el-form>
+				<!-- ------------- 数据列表 ------------- -->
+				<el-table class="data-table" ref="data-table" :data="dataList">
+					<sa-td type="selection"></sa-td>
+					<sa-td name="业务单号" prop="no" width="160"></sa-td>
+					<sa-td name="车辆类型" prop="goodsName"></sa-td>
+					<sa-td name="业务项" prop="itemTypeName" width="160"></sa-td>
+					<el-table-column label="车牌号" width="120px">
+						<template slot-scope="s">
+							<label v-if="s.row.cardNo">{{s.row.cardNo}}</label>
+							<label v-else>{{s.row.chinaCarNo}}</label>
+						</template>
+					</el-table-column>
+					<sa-td name="作业时间" prop="operateTime" width="160"></sa-td>
+					<sa-td name="已支付(元)" prop="payMoney" width="140"></sa-td>
+					<sa-td name="业务费用(元)" prop="itemPrice" width="120"></sa-td>
+					<sa-td width="160" name="创建时间" prop="createTime"></sa-td>
+					</sa-td>
+					<el-table-column label="操作" width="120px" fixed="right">
+						<template slot-scope="s">
+							<el-button class="c-btn" type="primary" @click="sureFn(s.row)">选择
+							</el-button>
+						</template>
+					</el-table-column>
+				</el-table>
+				<!-- ------------- 分页 ------------- -->
+				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
+				</sa-item>
+			</div>
+		</div>
+		<script>
+			var app = new Vue({
+				components: {
+					"sa-info": httpVueLoader('../../sa-frame/com/sa-info.vue'),
+					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
+					"sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
+				},
+				el: '.vue-box',
+				data: {
+					carNo: sa.p('carNo', ''),
+					businessCarId: sa.p('businessCarId', -1),
+					p: { // 查询参数  
+						no: '', // 编号 
+						businessType: 1,
+						carNo: '', // 车牌号 
+						createTime: '', // 离境时间 
+						no: '', // 编号 
+						pageNo: 1, // 当前页 
+						pageSize: 10, // 页大小 
+						sortType: 0 // 排序方式 
+					},
+					dataCount: 0,
+					dataList: [], // 数据集合 
+				},
+				methods: {
+					getCurrendCustomer() {
+						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
+							this.currentCustomerId = resp.data;
+						}.bind(this));
+					},
+					sureFn(data) {
+						let carNo=data.cardNo?data.cardNo:data.chinaCarNo;
+						let obj = {
+							id: data.id,
+							businessCarId: this.businessCarId
+						};
+						let content = '是否将[' + this.carNo + ']绑定到此业务';
+						if (data.businessCarId && data.businessCarId !== this.businessCarId) {
+							content = '此业务已绑定车辆【' + carNo + '】,是否覆盖?';
+						}
+						if (data.businessCarId === this.businessCarId) {
+							sa.error('该车已绑定此业务,无需绑定');
+							return;
+						}
+						sa.confirm(content, function() {
+							sa.ajax('/TbBusiness/bindCar', obj, function(resp) {
+								sa.alert('绑定成功');
+								setTimeout(() => {
+									sa.closeCurrIframe(); // 关闭本页 
+									parent.app.f5(); // 刷新父页面列表
+								}, 1000)
+							}.bind(this))
+						}.bind(this));
+
+					},
+					// 查看
+					get: function(data) {
+						sa.showIframe('数据详情', 'tb-car-disincle-info.html?id=' + data.id, '1050px', '90%');
+					},
+					add: function(data) {
+						sa.showIframe('新增数据', 'tb-car-disincle-add.html?id=-1', '1080px', '90%');
+					},
+					update(data) {
+						sa.showIframe('修改数据', 'tb-car-disincle-edit.html?id=' + data.id, '1080px', '90%');
+					},
+					getPcodeByCurrRid() {
+						sa.ajax('/SpRolePermission/getPcodeByCurrRid', function(resp) {
+							this.perCode = resp.data;
+						}.bind(this))
+					},
+					// 刷新
+					f5: function() {
+						sa.ajax('/TbBusiness/getList', sa.removeNull(this.p), function(res) {
+							let list = res.data;
+							this.dataList = list; // 数据
+							this.dataCount = res.dataCount; // 数据总数 
+							let businessCarId = this.businessCarId;
+							list.forEach(row => {
+								if (businessCarId == row.businessCarId) {
+									this.$nextTick(() => {
+										this.$refs['data-table'].toggleRowSelection(row,
+											true)
+									})
+								}
+							})
+							sa.f5TableHeight(); // 刷新表格高度 
+						}.bind(this));
+					},
+				},
+				created: function() {
+					sa.onInputEnter();
+				},
+				mounted() {
+					this.getCurrendCustomer();
+					this.f5();
+				},
+			})
+		</script>
+	</body>
+</html>

+ 182 - 0
sp-admin/sa-view/tb-business-car/tb-business-car-business.html

@@ -0,0 +1,182 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>-列表</title>
+		<meta charset="utf-8">
+		<meta name="viewport"
+			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+		<!-- 所有的 css & js 资源 -->
+		<link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
+		<link rel="stylesheet" href="../../static/sa.css">
+		<script src="../../static/kj/vue.min.js"></script>
+		<script src="../../static/kj/element-ui/index.js"></script>
+		<script src="../../static/kj/httpVueLoader.js"></script>
+		<script src="../../static/kj/jquery.min.js"></script>
+		<script src="../../static/kj/layer/layer.js"></script>
+		<script src="../../static/sa.js"></script>
+	</head>
+	<body>
+		<div class="vue-box" style="display: none;" :style="'display: block;'">
+			<div class="c-panel">
+				<el-form ref="form" :model='p' @submit.native.prevent>
+					<sa-item type="text" name="车牌号" v-model="p.carNo"></sa-item>
+					<div class="c-item">
+						<label class="c-label">入场时间:</label>
+						<el-date-picker :clearable="false" v-model="inTime" type="datetimerange" range-separator="至"
+							start-placeholder="开始日期" end-placeholder="结束日期">
+						</el-date-picker>
+					</div>
+					<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
+					<el-button size="mini" type="info" @click="sa.f5()">重置</el-button>
+				</el-form>
+				<!-- ------------- 数据列表 ------------- -->
+				<el-table class="data-table" ref="data-table" :data="dataList">
+					<sa-td type="selection"></sa-td>
+					<sa-td name="车牌号" prop="carNo" width=120></sa-td>
+					<el-table-column label="车牌颜色">
+						<template slot-scope="s">
+							<label v-if="!s.row.color">-</label>
+							<label v-else>{{s.row.color}}</label>
+						</template>
+					</el-table-column>
+					<sa-td name="入场通道" prop="inChannel"></sa-td>
+					<sa-td name="入场时间" prop="realInTime"></sa-td>
+					<sa-td name="离场时间" prop="realOutTime"></sa-td>
+					<el-table-column label="停车费">
+						<template slot-scope="s">
+							<label v-if="s.row.money">{{s.row.money}}</label>
+							<label v-else>-</label>
+						</template>
+					</el-table-column>
+					<sa-td name="支付状态" prop="payType">
+						<template slot-scope="s">
+							<label v-if="s.row.payType.indexOf('免')!==-1">{{s.row.payType}}</label>
+							<label v-else>
+								<label v-if="s.row.money">已支付</label>
+								<label v-else>未支付</label>
+							</label>
+						</template>
+					</sa-td>
+					<el-table-column label="操作"  fixed="right">
+						<template slot-scope="s">
+							<el-button class="c-btn" type="primary" @click="sureFn(s.row)">选择
+							</el-button>
+						</template>
+					</el-table-column>
+				</el-table>
+				<!-- ------------- 分页 ------------- -->
+				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
+				</sa-item>
+			</div>
+		</div>
+		<script>
+			var app = new Vue({
+				components: {
+					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
+					"sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
+				},
+				el: '.vue-box',
+				data: {
+					leveTime: [],
+					inTime: [],
+					businessId:sa.p('id','-1'),
+					businessCarId:sa.p('businessCarId',''),
+					carNo:sa.p('carNo',''),
+					p: { // 查询参数
+						carNo: '', //  
+						inStart:'',
+						inEnd:'',
+						pageNo: 1, // 当前页 
+						pageSize: 10, // 页大小 
+						sortType: 10 ,// 排序方式
+					},
+					dataCount: 0,
+					dataList: [], // 数据集合 
+					colorList: []
+				},
+				methods: {
+					sureFn(data) {
+						let id=data.id;
+						let businessCarId=this.businessCarId;
+						let content = '是否将[' + data.carNo + ']绑定到此业务';
+						if (businessCarId&&id!=businessCarId) {
+							content = '此业务已绑定车辆【' + decodeURIComponent(this.carNo) + '】,是否覆盖?';
+						}
+						if (id === businessCarId) {
+							sa.error('该车已绑定此业务,无需绑定');
+							return;
+						}
+						let obj = {
+							id: this.businessId,
+							businessCarId: id
+						};
+						sa.confirm(content, function() {
+							sa.ajax('/TbBusiness/bindCar', obj, function(resp) {
+								sa.alert('绑定成功');
+								setTimeout(() => {
+									sa.closeCurrIframe(); // 关闭本页 
+									parent.app.f5(); // 刷新父页面列表
+								}, 1000)
+							}.bind(this))
+						}.bind(this));
+					
+					},
+					// 刷新
+					f5: function() {
+						if (this.inTime && this.inTime.length > 0) {
+							this.p.inStart = sa.forDatetime(this.inTime[0]);
+							this.p.inEnd = sa.forDatetime(this.inTime[1]);
+						} else {
+							this.p.inStart = '';
+							this.p.inEnd = '';
+						}
+						sa.ajax('/TbBusinessCar/getList', sa.removeNull(this.p), function(res) {
+							let list = res.data;
+							this.dataList = list; // 数据
+							this.dataCount = res.dataCount; // 数据总数 
+							let businessCarId = this.businessCarId;
+							list.forEach(row => {
+								if (businessCarId == row.id) {
+									this.$nextTick(() => {
+										this.$refs['data-table'].toggleRowSelection(row,
+											true)
+									})
+								}
+							})
+							sa.f5TableHeight(); // 刷新表格高度 
+						}.bind(this));
+					},
+					// 查看
+					get: function(data) {
+						sa.showIframe('数据详情', 'tb-business-car-info.html?id=' + data.id + '&businessId=' + this.p
+							.businessId, '800px', '80%');
+					},
+					// 修改
+					update: function(data) {
+						sa.showIframe('修改数据', 'tb-business-car-add.html?id=' + data.id + '&businessId=' + this.p
+							.businessId, '500px', '80%');
+					},
+					// 新增
+					add: function(data) {
+						sa.showIframe('新增数据', 'tb-business-car-add.html?id=-1' + '&businessId=' + this.p.businessId,
+							'550px', '80%');
+					},
+					// 删除
+					del: function(data) {
+						sa.confirm('是否删除,此操作不可撤销', function() {
+							sa.ajax('/TbBusinessCar/deleteRecord?id=' + data.id, function(res) {
+								sa.arrayDelete(this.dataList, data);
+								sa.ok('删除成功');
+								sa.f5TableHeight(); // 刷新表格高度 
+							}.bind(this))
+						}.bind(this));
+					},
+				},
+				created: function() {
+					this.f5();
+					sa.onInputEnter();
+				}
+			})
+		</script>
+	</body>
+</html>

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

@@ -106,16 +106,16 @@
 								<label v-if="s.row.money">已支付</label>
 								<label v-else>未支付</label>
 							</label>
-							
 						</template>
 					</sa-td>
-					<el-table-column label="操作" width="200px">
+					<el-table-column label="操作" width="280px" fixed="right">
 						<template slot-scope="s">
 							<el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看
 							</el-button>
 							<el-button v-if="sa.isAuth('tb-business-car-edit')" class="c-btn" type="primary"
 								icon="el-icon-edit" @click="update(s.row)">修改
 							</el-button>
+							
 							<el-button v-if="sa.isAuth('tb-business-car-del')&&s.row.money==0" class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除</el-button>
 						</template>
 					</el-table-column>
@@ -153,6 +153,7 @@
 					colorList: []
 				},
 				methods: {
+					
 					getCarColor() {
 						sa.ajax('/TbCarNoColor/getList', {
 							pageNo: 1,

+ 6 - 2
sp-admin/sa-view/tb-business/tb-business-info.html

@@ -20,6 +20,10 @@
 			.c-panel .c-label {
 				width: 8em;
 			}
+			.c-item {
+			    min-width: 270px;
+			    padding-right: 10px;
+			}
 		</style>
 	</head>
 	<body>
@@ -37,7 +41,7 @@
 									<div>
 										<el-row>
 											<el-col span="12">
-												<sa-info name="客户名称" br>{{m.customerName}}</sa-info>
+												<sa-info  name="客户名称" br>{{m.customerName}}</sa-info>
 												<sa-info name="业务编号" br>{{m.no}}</sa-info>
 												<sa-info name="境外车牌号" br>{{m.cardNo}}</sa-info>
 												<sa-info name="境外车规格" br>{{m.cardSize}}(米)</sa-info>
@@ -118,7 +122,7 @@
 										<sa-td width="120" name="支付状态" prop="payStatus" type="enum"
 											:jv="{0: '未支付[#ff0000]', 1: '已支付[#005500]'}">
 										</sa-td>
-										<el-table-column prop="payTime" label="支付时间">
+										<el-table-column prop="payTime" label="支付时间" width=180>
 										</el-table-column>
 										<sa-td type="img-list" name="凭据" prop="ticket"></sa-td>
 										<el-table-column label="其他凭据">

+ 8 - 2
sp-admin/sa-view/tb-business/tb-car-disincle-list.html

@@ -39,7 +39,7 @@
 						</el-select>
 					</div>
 					<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
-					<el-button type="info" icon="el-icon-search" @click="p.cardNo = '';p.adminConfirmInput=-1; f5()">重置</el-button>
+					<el-button type="info" icon="el-icon-search" @click="p.carNo = '';p.adminConfirmInput=-1; f5()">重置</el-button>
 					<el-button v-if="sa.isAuth('tb-flex-business-add')" size="mini" type="primary" @click="add()">
 						新增</el-button>
 					<br />
@@ -54,7 +54,7 @@
 					<sa-td name="作业时间" prop="operateTime" width="160"></sa-td>
 					<sa-td name="确认" prop="adminConfirmInput" type="enum" :jv="{1: '已确认', 0: '未确认'}"></sa-td>
 					<sa-td name="已支付(元)" prop="payMoney" width="140"></sa-td>
-					<sa-td name="业务费用(元)" prop="totalMoney" width="120"></sa-td>
+					<sa-td name="业务费用(元)" prop="itemPrice" width="120"></sa-td>
 					<sa-td name="入场时间" prop="realInTime" width="140"></sa-td>
 					<sa-td name="离场时间" prop="realOutTime" width="140"></sa-td>
 					<sa-td width="160" name="创建时间" prop="createTime"></sa-td>
@@ -74,6 +74,9 @@
 								&&s.row.payStatus!=='3'"
 									@click="handlerPay(s.row)">
 									线下收费</el-button>
+									<el-button v-if="sa.isAuth('tb-business-car-bind')" class="c-btn" type="primary"
+										 @click="businessFn(s.row)">绑定车辆
+									</el-button>
 							<el-button class="c-btn" type="danger"
 								v-if="sa.isAuth('tb-flex-business-del')&&s.row.adminConfirmInput==0&&s.row.payMoney==0"
 								@click="del(s.row)">删除
@@ -146,6 +149,9 @@
 					}
 				},
 				methods: {
+					businessFn(data){
+						sa.showIframe('绑定车辆', '../tb-business-car/tb-business-car-business.html?id=' + data.id+'&businessCarId='+data.businessCarId+'&carNo='+data.carNo, '90%',"90%");
+					},
 					handlerPay(data){
 						sa.showIframe('人工收费', 'tb-car-disincle-pay.html?id=' + data.id, '1050px', '90%');
 					},

+ 0 - 1
sp-server/app.pid

@@ -1 +0,0 @@
-4976

+ 8 - 5
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -95,7 +95,11 @@ public class OpenService {
         TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
         Date now = new Date();
         TbCar tbCar = tbCarService.findByCardNo(carNo);
-        if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null) || tbBusinessCar.getPay() == 1) {
+        boolean bindBusiness = false;
+        if (tbBusinessCar != null) {
+            bindBusiness = tbBusinessService.findOtherBusinessByCarId(tbBusinessCar.getId()).size() > 0;
+        }
+        if (tbBusinessCar == null || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null && bindBusiness) || tbBusinessCar.getPay() == 1) {
             tbBusinessCar = new TbBusinessCar();
             tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(0D).setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时")
                     .setInChannel(channel).setRealInTime(now).setBasePartMoney(new BigDecimal("0")).setTimeUpdate(now)
@@ -125,11 +129,10 @@ public class OpenService {
         taskService.addTask(new CoverBase64ToImageTask("=======" + carId + "", 2000, carId, base64image, inOrOut));
 
     }
-
     private ResultJson handlerOut(String carNo, String channel, String image) {
         carNo = carNo.toUpperCase();
         TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
-        if (tbBusinessCar == null || tbBusinessCar.getRealInTime() == null||tbBusinessCar.getRealOutTime()!=null) {
+        if (tbBusinessCar == null || tbBusinessCar.getRealInTime() == null || tbBusinessCar.getRealOutTime() != null) {
             log.error("请求返回【未查询到入场记录】:{}", carNo);
             return ResultJson.error("未查询到入场记录");
         }
@@ -165,7 +168,7 @@ public class OpenService {
         }
         String carNoStr = carNo.substring(0, 1);
         Date inTime = tbBusinessCar.getRealInTime();
-        if (tbBusinessCar.getPay() == 1&&tbBusinessCar.getRealOutTime()==null&&tbBusinessCar.getPayTime()!=null) {
+        if (tbBusinessCar.getPay() == 1 && tbBusinessCar.getRealOutTime() == null && tbBusinessCar.getPayTime() != null) {
             inTime = tbBusinessCar.getPayTime();
         }
         BigDecimal price = tbBusinessService.calculationPartMoney(inTime, now);
@@ -176,7 +179,7 @@ public class OpenService {
         double dif = price.doubleValue();
         if (dif > 0) {
             RedisUtil.setByMINUTES(channel, carNo, 1);
-            log.error("请求返回:请缴停车费:{},{}元", carNo,dif);
+            log.error("请求返回:请缴停车费:{},{}元", carNo, dif);
             return ResultJson.error("请缴停车费" + dif + "元");
         }
         //无业务费用车辆===

+ 23 - 13
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java

@@ -163,9 +163,9 @@ public class TbBusinessController {
         List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
         items.forEach(tbBusinessItem -> tbBusinessItem.setGoodsName(t.getGoodsName()).setCardNo(t.getCardNo()).setChinaCarNo(t.getChinaCarNo()));
         t.setItems(items);
-        if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(t.getBusinessType())){
-           t.setCars(Collections.singletonList( tbBusinessCarService.getById(t.getBusinessCarId())));
-        }else {
+        if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(t.getBusinessType())) {
+            t.setCars(Collections.singletonList(tbBusinessCarService.getById(t.getBusinessCarId())));
+        } else {
             List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(id);
             t.setCars(cars);
         }
@@ -173,7 +173,6 @@ public class TbBusinessController {
     }
 
 
-
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
@@ -313,32 +312,43 @@ public class TbBusinessController {
         tbBusinessService.uploadReport(tbBusiness);
         return AjaxJson.getSuccess();
     }
+
     @RequestMapping("getOtherBusinessById")
     public AjaxJson getOtherBusinessById(String id) {
         return AjaxJson.getSuccessData(tbBusinessService.getOtherBusinessById(id));
     }
 
     @RequestMapping("deleteOtherBusiness")
-    public AjaxJson deleteOtherBusiness(String id,String businessCarId) {
+    public AjaxJson deleteOtherBusiness(String id, String businessCarId) {
         tbBusinessService.deleteOtherBusiness(id);
         return AjaxJson.getSuccess();
     }
+
     @RequestMapping("manualConfirm")
     @SaCheckPermission(TbBusiness.PERMISSION_MANUAL_PAY)
     public AjaxJson manualConfirm() {
         SoMap so = SoMap.getRequestSoMap();
-       String id= so.getString("id");
-      String remark=  so.getString("remark");
-        String inChannel=   so.getString("inChannel");
-        String outChannel=    so.getString("outChannel");
-        Date realInTime=    so.getDateTime("realInTime");
-        Date realOutTime=    so.getDateTime("realOutTime");
-        tbBusinessService.manualConfirmPay(id,inChannel,realInTime,outChannel,realOutTime,remark);
+        String id = so.getString("id");
+        String remark = so.getString("remark");
+        String inChannel = so.getString("inChannel");
+        String outChannel = so.getString("outChannel");
+        Date realInTime = so.getDateTime("realInTime");
+        Date realOutTime = so.getDateTime("realOutTime");
+        tbBusinessService.manualConfirmPay(id, inChannel, realInTime, outChannel, realOutTime, remark);
         return AjaxJson.getSuccess();
     }
 
 
-
+    @RequestMapping(value = "unBindCar")
+    public AjaxJson unBindCar(String id, String businessCarId) {
+        tbBusinessService.unBindCar(id,businessCarId);
+        return AjaxJson.getSuccess();
+    }
+    @RequestMapping(value = "bindCar")
+    public AjaxJson bindCar(String id, String businessCarId) {
+        tbBusinessService.bindCar(id,businessCarId);
+        return AjaxJson.getSuccess();
+    }
 
 
     // ------------------------- 前端接口 -------------------------

+ 2 - 0
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.java

@@ -34,4 +34,6 @@ public interface TbBusinessMapper extends BaseMapper<TbBusiness> {
     int checkCarBusinessTypeByTime(@Param("typeId") String typeId, @Param("carNo") String carNo,
                                           @Param("timeStart")String timeStart,
                                           @Param("timeEnd") String timeEnd,  @Param("businessId")String businessId);
+
+    void unBindCar(String id);
 }

+ 12 - 0
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.xml

@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.pj.project.tb_business.TbBusinessMapper">
+    <update id="unBindCar">
+        update tb_business set card_no='',china_car_no='',business_car_id=null  where id=#{id}
+    </update>
 
     <!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
     <select id="getList" resultType="com.pj.project.tb_business.TbBusiness">
@@ -28,6 +31,9 @@
             <if test=' this.has("outDayTime") '>and out_day_time = #{outDayTime}</if>
             <if test=' this.has("partMoney") '>and part_money = #{partMoney}</if>
             <if test=' this.has("partTime") '>and part_time = #{partTime}</if>
+            <if test=' this.has("createTime") '>and date_format(create_time,'%Y-%m-%d') = #{createTime}</if>
+            <if test=' this.has("businessType") '>and business_type = #{businessType}</if>
+            <if test=' this.has("businessCarId") '>and business_car_id = #{businessCarId}</if>
             <if test='isCar==0'>
                 and declare_no is not null
             </if>
@@ -80,12 +86,18 @@
             <if test="cardNo !='' and cardNo !=null">
                 and b.car_no like concat('%',#{cardNo},'%')
             </if>
+        <if test="no !='' and no !=null">
+            and a.no like concat('%',#{no},'%')
+        </if>
         <if test="adminConfirmInput !='-1'">
             and a.admin_confirm_input=#{adminConfirmInput}
         </if>
         <if test="customerId !=null and customerId !=''">
             and a.customer_id=#{customerId}
         </if>
+        <if test="businessCarId !=null and businessCarId !=''">
+            and a.business_car_id=#{businessCarId}
+        </if>
         <if test="carNo !=null and carNo !=''">
             and b.car_no like concat ('%',#{carNo},'%')
         </if>

+ 48 - 9
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -476,10 +476,13 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     }
 
     public BigDecimal calculationPartMoney(Date iTime, Date oTime) {
+        BigDecimal zero = new BigDecimal("0");
+        if (iTime == null || oTime == null) {
+            return zero;
+        }
         LocalDateTime inDayTime = iTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
         LocalDateTime outDayTime = oTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
         long minutes = ChronoUnit.MINUTES.between(inDayTime, outDayTime);
-        BigDecimal zero = new BigDecimal("0");
         if (minutes < 0) {
             return zero;
         }
@@ -647,23 +650,59 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 
     public void manualConfirmPay(String id, String inChannel, Date realInTime, String outChannel, Date realOutTime, String remark) {
         TbBusiness db = this.getById(id);
-        if (db==null){
+        if (db == null) {
             throw new BusinessException("业务不存在");
         }
         db.setPayStatus(3).setPayMoney(db.getItemPrice());
         this.updateById(db);
-       TbBusinessCar tbBusinessCar= tbBusinessCarService.getById(db.getBusinessCarId());
-       if (realInTime!=null&&realOutTime!=null){
-         BigDecimal price=  calculationPartMoney(realInTime,realOutTime);
-         tbBusinessCar.setMoney(price).setPay(1);
-       }
+        TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(db.getBusinessCarId());
+        if (realInTime != null && realOutTime != null) {
+            BigDecimal price = calculationPartMoney(realInTime, realOutTime);
+            tbBusinessCar.setMoney(price).setPay(1);
+        }
         tbBusinessCar.setInChannel(inChannel)
                 .setOutChannel(outChannel)
                 .setRealOutTime(realOutTime)
                 .setRealInTime(realInTime);
         tbBusinessCarService.updateById(tbBusinessCar);
-        List<TbBusinessItem>items=tbBusinessItemService.findByBusinessId(id);
-        items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setRemark(StrUtil.isEmpty(remark)?"手动确认":remark));
+        List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
+        items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setRemark(StrUtil.isEmpty(remark) ? "手动确认" : remark));
         tbBusinessItemService.updateBatchById(items);
     }
+
+    public void unBindCar(String id, String businessCarId) {
+        QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
+        ew.eq("id", id).eq("business_car_id", businessCarId);
+        TbBusiness db = getOne(ew);
+        if (db == null) {
+            throw new BusinessException("业务单不存在");
+        }
+        tbBusinessMapper.unBindCar(id);
+    }
+
+    public void bindCar(String id, String businessCarId) {
+        TbBusiness db = this.getById(id);
+        if (!TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(db.getBusinessType())) {
+            throw new BusinessException("业务类型不正确");
+        }
+        TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(businessCarId);
+        if (tbBusinessCar == null) {
+            throw new BusinessException("车辆记录不存在");
+        }
+        List<TbBusiness> list = this.findOtherBusinessByCarId(businessCarId);
+        int count = (int) list.stream().filter(tbBusiness -> !tbBusiness.getId().equals(id) && tbBusiness.getItemTypeId().equals(db.getItemTypeId())).count();
+        if (count>0){
+            throw new BusinessException("同一车辆请勿绑定多个相同业务");
+        }
+        String carNo = tbBusinessCar.getCarNo();
+        String carNoStr = StrUtil.sub(carNo, 0, 1);
+        //中国车
+        if (CAR_LIST.contains(carNoStr)) {
+            db.setChinaCarNo(carNo);
+        } else {
+            db.setCardNo(carNo);
+        }
+        db.setBusinessCarId(businessCarId);
+        this.updateById(db);
+    }
 }

+ 109 - 78
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarController.java

@@ -1,7 +1,10 @@
 package com.pj.project.tb_business_car;
 
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 
+import cn.hutool.core.util.StrUtil;
 import com.pj.constants.UserTypeEnum;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_costomer.TbCostomer;
@@ -18,111 +21,139 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 
 
 /**
- * Controller: tb_business_car -- 
- * @author qzy 
+ * Controller: tb_business_car --
+ *
+ * @author qzy
  */
 @RestController
 @RequestMapping("/TbBusinessCar/")
 public class TbBusinessCarController {
 
-	/** 底层 Service 对象 */
-	@Autowired
-	TbBusinessCarService tbBusinessCarService;
-
-	/** 查 - 根据id */
-	@RequestMapping("add")
-	@SaCheckPermission(TbBusiness.PERMISSION_CODE)
-	public AjaxJson add(TbBusinessCar t) throws Exception{
-		tbBusinessCarService.add(t);
-		return AjaxJson.getSuccess();
-	}
-	/** 查 - 根据id */
-	@RequestMapping("delete")
-	@SaCheckPermission(TbBusiness.PERMISSION_CODE)
-	public AjaxJson delete(String id) {
-		return tbBusinessCarService.deleteCar(id);
-	}
-
-	/** 查 - 根据id */
-	@RequestMapping("deleteRecord")
-	@SaCheckPermission(TbBusinessCar.PERMISSION_DEL)
-	public AjaxJson deleteRecord(String id) {
-		return tbBusinessCarService.deleteRecord(id);
-	}
-
-	@RequestMapping(value = "findInAndNoBusinessCar")
-	public AjaxJson findInAndNoBusinessCar(){
-		List<TbBusinessCar>list=tbBusinessCarService.findInAndNoBusinessCar();
-		return AjaxJson.getSuccessData(list);
-	}
-
-	/** 查 - 根据id */
-	@RequestMapping("update")
-	@SaCheckPermission(TbBusiness.PERMISSION_CODE)
-	public AjaxJson update(TbBusinessCar t){
-		tbBusinessCarService.updateCar(t);
-		return AjaxJson.getSuccess();
-	}
-	/** 查 - 根据id */
-	@RequestMapping("getById")
-	public AjaxJson getById(Long id){
-		TbBusinessCar t = tbBusinessCarService.getById(id);
-		return AjaxJson.getSuccessData(t);
-	}
-	/** 改 - 状态(0=否,1=是) */
-	@RequestMapping("updateStatus")
-	@SaCheckPermission(TbBusiness.PERMISSION_CODE)
-	public AjaxJson updateStatus(String id, int value){
-		TbBusinessCar t=tbBusinessCarService.getById(id);
-		t.setIsLock(value);
-		tbBusinessCarService.updateById(t);
-		return AjaxJson.getByLine(1);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	@RequestMapping("getList")
-	public AjaxJson getList() { 
-		SoMap so = SoMap.getRequestSoMap();
+    /**
+     * 底层 Service 对象
+     */
+    @Autowired
+    TbBusinessCarService tbBusinessCarService;
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("add")
+    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    public AjaxJson add(TbBusinessCar t) throws Exception {
+        tbBusinessCarService.add(t);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("delete")
+    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    public AjaxJson delete(String id) {
+        return tbBusinessCarService.deleteCar(id);
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("deleteRecord")
+    @SaCheckPermission(TbBusinessCar.PERMISSION_DEL)
+    public AjaxJson deleteRecord(String id) {
+        return tbBusinessCarService.deleteRecord(id);
+    }
+
+    @RequestMapping(value = "findInAndNoBusinessCar")
+    public AjaxJson findInAndNoBusinessCar() {
+        List<TbBusinessCar> list = tbBusinessCarService.findInAndNoBusinessCar();
+        return AjaxJson.getSuccessData(list);
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("update")
+    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    public AjaxJson update(TbBusinessCar t) {
+        tbBusinessCarService.updateCar(t);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("getById")
+    public AjaxJson getById(Long id) {
+        TbBusinessCar t = tbBusinessCarService.getById(id);
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 改 - 状态(0=否,1=是)
+     */
+    @RequestMapping("updateStatus")
+    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    public AjaxJson updateStatus(String id, int value) {
+        TbBusinessCar t = tbBusinessCarService.getById(id);
+        t.setIsLock(value);
+        tbBusinessCarService.updateById(t);
+        return AjaxJson.getByLine(1);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getList")
+    public AjaxJson getList() {
+        SoMap so = SoMap.getRequestSoMap();
         String currentCustomerId = StpUserUtil.getCustomerId();
         if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
-            so.put("customerId",currentCustomerId);
+            so.put("customerId", currentCustomerId);
         }
-		List<TbBusinessCar> list = tbBusinessCarService.getList(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
+        String limitDay = so.getString("limitDay");
+        if (StrUtil.isNotEmpty(limitDay)){
+            LocalDate now=LocalDate.now();
+            LocalDate startDay=now.minusMonths(1);
+            DateTimeFormatter formatter=DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            String startDayStr=startDay.format(formatter);
+            String endDayStr=now.format(formatter);
+            so.put("startDay",startDayStr);
+            so.put("endDay",endDayStr);
+        }
+        List<TbBusinessCar> list = tbBusinessCarService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
 
-    /** 手动添加放行记录*/
+    /**
+     * 手动添加放行记录
+     */
     @RequestMapping("addCarRecord")
     @SaCheckPermission(TbBusinessCar.PERMISSION_ADD)
-    public AjaxJson addManualCar(TbBusinessCar t) throws Exception{
+    public AjaxJson addManualCar(TbBusinessCar t) throws Exception {
         tbBusinessCarService.addCarRecord(t);
         return AjaxJson.getSuccess();
     }
 
     @RequestMapping("updateCarRecord")
     @SaCheckPermission(TbBusinessCar.PERMISSION_EDIT)
-    public AjaxJson updateCarRecord(TbBusinessCar t) throws Exception{
+    public AjaxJson updateCarRecord(TbBusinessCar t) throws Exception {
         tbBusinessCarService.updateCarRecord(t);
         return AjaxJson.getSuccess();
     }
+
     @RequestMapping("export")
     @SaCheckPermission(TbBusinessCar.PERMISSION_EXPORT)
     public AjaxJson export() {
-    	SoMap soMap=SoMap.getRequestSoMap();
-        return AjaxJson.getSuccessData( tbBusinessCarService.export(soMap));
+        SoMap soMap = SoMap.getRequestSoMap();
+        return AjaxJson.getSuccessData(tbBusinessCarService.export(soMap));
     }
+
     @RequestMapping("searchInNotOutCar")
     public AjaxJson searchInNotOutCar() {
-		SoMap soMap=SoMap.getRequestSoMap();
-		String carNo=soMap.getString("carNo");
-        return AjaxJson.getSuccessData( tbBusinessCarService.findNotOutCarLike(carNo));
+        SoMap soMap = SoMap.getRequestSoMap();
+        String carNo = soMap.getString("carNo");
+        return AjaxJson.getSuccessData(tbBusinessCarService.findNotOutCarLike(carNo));
     }
 
 
-	
-	
-	
-	
-	
-
 }

+ 4 - 2
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml

@@ -40,6 +40,8 @@
             <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("startDay") '>and date_format(time_update,'%Y-%m-%d') &gt;= #{startDay}</if>
+            <if test=' this.has("endDay") '>and date_format(time_update,'%Y-%m-%d') &lt;= #{endDay}</if>
             <if test=' this.has("pay") '>and pay = #{pay}</if>
             <if test='leave==2 '>
               and   real_out_time is not null
@@ -120,7 +122,7 @@
         SELECT a.* from tb_business_car a,tb_business b, tb_business_item c
          where a.id=b.business_car_id
          and b.id=c.business_id
-         and DATE_FORMAT(c.create_time,'%y-%m-%d')=DATE_FORMAT(now(),'%y-%m-%d')
+         and DATE_FORMAT(c.create_time,'%Y-%m-%d')=DATE_FORMAT(now(),'%Y-%m-%d')
          and a.car_no=#{carNo}
          and c.item_id=#{itemId};
 
@@ -137,7 +139,7 @@
             AND b.id = c.business_id
         AND a.car_no=#{carNo}
         and c.business_type=#{typeId}
-        and DATE_FORMAT(b.operate_time,'%y-%m-%d %H:%i:%s') &gt;#{timeEnd}
+        and DATE_FORMAT(b.operate_time,'%Y-%m-%d %H:%i:%s') &gt;#{timeEnd}
     </select>
 
 

+ 3 - 3
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -140,11 +140,11 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
     public void removeByBusinessId(String businessId) {
         QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
         ew.eq("business_id", businessId);
-        List<TbBusinessCar>list=list(ew);
+        List<TbBusinessCar> list = list(ew);
         list.forEach(tbBusinessCar -> {
-            if (tbBusinessCar.getRealInTime()==null){
+            if (tbBusinessCar.getRealInTime() == null) {
                 this.removeById(tbBusinessCar.getId());
-            }else {
+            } else {
                 tbBusinessCarMapper.removeBusinessId(tbBusinessCar.getId());
             }
         });

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_item_type/TbItemTypeController.java

@@ -72,7 +72,7 @@ public class TbItemTypeController {
      */
     @RequestMapping("update")
     public AjaxJson update(TbItemType t) {
-        tbItemTypeService.updateById(t);
+        tbItemTypeService.updateItemType(t);
         return AjaxJson.getSuccess();
     }
 

+ 8 - 1
sp-server/src/main/java/com/pj/project/tb_item_type/TbItemTypeService.java

@@ -64,7 +64,7 @@ public class TbItemTypeService extends ServiceImpl<TbItemTypeMapper, TbItemType>
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
-  public   List<TbItemType> getList(SoMap so) {
+    public List<TbItemType> getList(SoMap so) {
         List<TbItemType> list = tbItemTypeMapper.getList(so);
         String customerId = StpUserUtil.getCustomerId();
         if (!UserTypeEnum.PLATFORM_ADMIN.getCustomerId().equals(customerId)) {
@@ -88,4 +88,11 @@ public class TbItemTypeService extends ServiceImpl<TbItemTypeMapper, TbItemType>
         tbItemType.setItems(items);
         return tbItemType;
     }
+
+    public void updateItemType(TbItemType t) {
+        List<RelationTypeItem> relationTypeItems = relationTypeItemService.findByTypeId(t.getId());
+        relationTypeItems.forEach(relationTypeItem -> {relationTypeItem.setTypeName(t.getName());relationTypeItemService.updateById(relationTypeItem);});
+
+        super.updateById(t);
+    }
 }