Forráskód Böngészése

其他业务设置

qzyReal 3 éve
szülő
commit
5941ee8ad1
46 módosított fájl, 2043 hozzáadás és 1415 törlés
  1. 1 0
      sp-admin/sa-view/tb-business/tb-business-add.html
  2. 27 15
      sp-admin/sa-view/tb-business/tb-business-car-business.html
  3. 6 4
      sp-admin/sa-view/tb-business/tb-business-edit.html
  4. 2 1
      sp-admin/sa-view/tb-business/tb-business-list.html
  5. 312 355
      sp-admin/sa-view/tb-business/tb-car-disincle-add.html
  6. 571 199
      sp-admin/sa-view/tb-business/tb-car-disincle-edit.html
  7. 12 24
      sp-admin/sa-view/tb-business/tb-car-disincle-info.html
  8. 44 31
      sp-admin/sa-view/tb-business/tb-car-disincle-list.html
  9. 18 20
      sp-admin/sa-view/tb-business/tb-car-disincle-pay.html
  10. 48 28
      sp-admin/sa-view/tb-goods/tb-goods-add.html
  11. 47 15
      sp-admin/sa-view/tb-goods/tb-goods-list.html
  12. 2 16
      sp-admin/sa-view/tb-item-type/tb-item-type-add.html
  13. 0 1
      sp-admin/sa-view/tb-item-type/tb-item-type-list.html
  14. 0 23
      sp-server/src/main/java/com/pj/api/h5/ApiController.java
  15. 16 7
      sp-server/src/main/java/com/pj/api/open/service/OpenService.java
  16. 29 162
      sp-server/src/main/java/com/pj/api/service/ApiService.java
  17. 21 24
      sp-server/src/main/java/com/pj/api/wx/service/WxService.java
  18. 1 2
      sp-server/src/main/java/com/pj/project/relation_business_car/RelationBusinessCar.java
  19. 19 1
      sp-server/src/main/java/com/pj/project/relation_business_car/RelationBusinessCarService.java
  20. 0 49
      sp-server/src/main/java/com/pj/project/relation_business_car/RelationBusinessCarUtil.java
  21. 1 1
      sp-server/src/main/java/com/pj/project/relation_goods_type/RelationGoodsType.java
  22. 1 1
      sp-server/src/main/java/com/pj/project/relation_goods_type/RelationGoodsTypeController.java
  23. 2 2
      sp-server/src/main/java/com/pj/project/relation_goods_type/RelationGoodsTypeService.java
  24. 32 0
      sp-server/src/main/java/com/pj/project/tb_business/OtherBusinessBO.java
  25. 5 1
      sp-server/src/main/java/com/pj/project/tb_business/TbBusiness.java
  26. 52 21
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java
  27. 4 0
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.java
  28. 67 32
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.xml
  29. 366 124
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java
  30. 14 1
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCar.java
  31. 17 9
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarController.java
  32. 2 0
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.java
  33. 12 1
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml
  34. 61 70
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java
  35. 1 1
      sp-server/src/main/java/com/pj/project/tb_business_item/PayTask.java
  36. 4 0
      sp-server/src/main/java/com/pj/project/tb_business_item/TbBusinessItemService.java
  37. 1 1
      sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareController.java
  38. 2 0
      sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareMapper.java
  39. 3 0
      sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareMapper.xml
  40. 4 0
      sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareService.java
  41. 1 6
      sp-server/src/main/java/com/pj/project/tb_fee_statistics/TbFeeStatisticsService.java
  42. 50 9
      sp-server/src/main/java/com/pj/project/tb_goods/TbGoods.java
  43. 142 111
      sp-server/src/main/java/com/pj/project/tb_goods/TbGoodsController.java
  44. 3 18
      sp-server/src/main/java/com/pj/project/tb_item_type/TbItemType.java
  45. 2 5
      sp-server/src/main/java/com/pj/project/tb_item_type/TbItemTypeController.java
  46. 18 24
      sp-server/src/main/java/com/pj/project/tb_item_type/TbItemTypeService.java

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

@@ -425,6 +425,7 @@
 						if(currentCustomerId!='1'){
 							this.declare.p.customerId=this.currentCustomerId;
 						}
+							this.declare.p.declareNo=this.m.declareNo;
 						sa.ajax('/TbDeclare/getNotBindList', sa.removeNull(this.declare.p), function(resp) {
 							let list = resp.data;
 							this.declare.list = list;

+ 27 - 15
sp-admin/sa-view/tb-business-car/tb-business-car-business.html → sp-admin/sa-view/tb-business/tb-business-car-business.html

@@ -28,6 +28,7 @@
 					</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-button size="mini" type="primary" @click="confirmSelectFn">确定</el-button>
 				</el-form>
 				<!-- ------------- 数据列表 ------------- -->
 				<el-table class="data-table" ref="data-table" :data="dataList">
@@ -57,12 +58,12 @@
 							</label>
 						</template>
 					</sa-td>
-					<el-table-column label="操作"  fixed="right">
+					<!-- <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-column> -->
 				</el-table>
 				<!-- ------------- 分页 ------------- -->
 				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()">
@@ -80,7 +81,7 @@
 					leveTime: [],
 					inTime: [],
 					businessId:sa.p('id','-1'),
-					businessCarId:sa.p('businessCarId',''),
+					businessCarIds:sa.p('businessCarIds',''),
 					carNo:sa.p('carNo',''),
 					p: { // 查询参数
 						carNo: decodeURIComponent(sa.p('carNo','')), //  
@@ -122,6 +123,27 @@
 						}.bind(this));
 					
 					},
+					
+					confirmSelectFn(){
+						let selection = this.$refs['data-table'].selection;
+						if (selection.length == 0) {
+							return sa.msg('至少选择一条记录')
+						}
+						let ids = sa.getArrayField(selection, 'id');
+						let obj={
+							businessId:this.businessId,
+							businessCarIds:ids.join(',')
+						}
+						sa.confirm('是否确认绑定选中车辆?', function() {
+							sa.ajax('/TbBusiness/bindOtherBusinessCar', 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) {
@@ -135,9 +157,9 @@
 							let list = res.data;
 							this.dataList = list; // 数据
 							this.dataCount = res.dataCount; // 数据总数 
-							let businessCarId = this.businessCarId;
+							let businessCarIdList = this.businessCarIds.split(',');
 							list.forEach(row => {
-								if (businessCarId == row.id) {
+								if (businessCarIdList.indexOf(row.id) !==-1 ) {
 									this.$nextTick(() => {
 										this.$refs['data-table'].toggleRowSelection(row,
 											true)
@@ -162,16 +184,6 @@
 						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();

+ 6 - 4
sp-admin/sa-view/tb-business/tb-business-edit.html

@@ -77,7 +77,8 @@
 												</el-option>
 											</el-select>
 										</div>
-										<sa-item type="num" name="载重(kg)" placeholder="请输入车辆载重" v-model="m.netWeight" br>
+										<sa-item type="num" name="载重(kg)" placeholder="请输入车辆载重" v-model="m.netWeight"
+											br>
 										</sa-item>
 
 										<div class="c-item">
@@ -448,9 +449,10 @@
 						this.declare.visible = false;
 					},
 					getDeclareList() {
-						if(currentCustomerId!='1'){
-							this.declare.p.customerId=this.currentCustomerId;
+						if (currentCustomerId != '1') {
+							this.declare.p.customerId = this.currentCustomerId;
 						}
+						this.declare.p.declareNo = this.m.declareNo;
 						sa.ajax('/TbDeclare/getNotBindList', sa.removeNull(this.declare.p), function(resp) {
 							let list = resp.data;
 							this.declare.list = list;
@@ -647,7 +649,7 @@
 						sa.ajax('/TbGoods/getList', {
 							pageNo: 1,
 							pageSize: 10,
-							businessType:2
+							businessType: 2
 						}, function(resp) {
 							this.goodsList = resp.data;
 						}.bind(this))

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

@@ -234,7 +234,8 @@
 						partTime: '', // 停车时常(分) 
 						pageNo: 1, // 当前页 
 						pageSize: 10, // 页大小 
-						sortType: 0 // 排序方式 
+						sortType: 0 ,// 排序方式 
+						businessType:2,
 					},
 					dataCount: 0,
 					dataList: [], // 数据集合 

+ 312 - 355
sp-admin/sa-view/tb-business/tb-car-disincle-add.html

@@ -25,7 +25,7 @@
 			}
 
 			.item-num .el-input__inner {
-				width: 100px;
+				width: 130px;
 			}
 
 			.xj {
@@ -48,12 +48,11 @@
 		</style>
 	</head>
 	<body>
-		<div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
+		<div class="vue-box sbot" style="display: none;" :style="'display: block;'">
 			<!-- ------- 内容部分 ------- -->
 			<div class="s-body">
 				<div class="c-panel">
-					<div class="c-title" v-if="id == 0">数据添加</div>
-					<div class="c-title" v-else>数据修改</div>
+					<div class="c-title">数据添加</div>
 					<el-form v-if="m" label-position="left">
 						<el-row>
 							<el-card class="box-card">
@@ -61,61 +60,50 @@
 									<span>基本资料</span>
 								</div>
 								<div>
-									<div class="c-item">
-										<label class="c-label"><span style="color: red;">*</span>业务项目:</label>
-										<el-select v-model="m.goodsId" placeholder="请选择" @change="goodsChange">
-											<el-option v-for="item in goodsList" :key="item.id" :label="item.name"
-												:value="item.id">
-											</el-option>
-										</el-select>
-									</div>
-									<div class="c-item">
-										<label class="c-label">
-											<span style="color: red;" v-if="goods.needDeclare==1">*</span>
-											申报单号:</label>
-										<el-input v-model="m.declareNo" placeholder="选择申报单" readonly>
-											<div slot="suffix" style="cursor: pointer;color: blue;"
-												@click="handlerDeclare">
-												<i class="el-icon-folder-add"></i>
+									<el-row>
+										<el-col span=8>
+											<div class="c-item">
+												<label class="c-label"><span style="color: red;">*</span>业务项目:</label>
+												<el-select v-model="m.goodsId" placeholder="请选择" @change="goodsChange">
+													<el-option v-for="item in goodsList" :key="item.id"
+														:label="item.name" :value="item.id">
+													</el-option>
+												</el-select>
 											</div>
-										</el-input>
-									</div>
-									<div class="c-item" v-if="currentCustomerId=='1'">
-										<label class="c-label"><span style="color: red;">*</span>客户:</label>
-										<el-select v-model="m.customerId" placeholder="请选择">
-											<el-option v-for="item in customerList" :key="item.id" :label="item.name"
-												:value="item.id">
-											</el-option>
-										</el-select>
-									</div>
-									<sa-item type="num" name="载重(kg)" placeholder="请输入车辆载重" v-model="m.netWeight" br>
-									</sa-item>
-									</sa-item>
-									<div class="c-item">
-										<label class="c-label"><span style="color: red;">*</span>境外车牌号:</label>
-										<el-autocomplete v-model="m.cardNo" placeholder="请输入境外车牌号"
-											@select="handleSelectCar" value-key='carNo'
-											:fetch-suggestions="queryCarAsync">
-										</el-autocomplete>
-									</div>
-									<div class="c-item">
-										<label class="c-label">
-											<span style="color: red;" v-if="goods.needCarSize==1">*</span>
-											车俩规格:</label>
-										<el-autocomplete v-model="m.cardSize" placeholder="请输入车规格"
-											@select="handleSelectCarSize" value-key='unit'
-											:fetch-suggestions="queryCaSizerAsync">
-										</el-autocomplete>
-									</div>
-									<div class="c-item">
-										<label class="c-label">中国车:</label>
-										<el-input v-model="china.list.map(obj=>obj.carNo).join('、')" placeholder="添加中国车"
-											readonly>
-											<div slot="suffix" style="cursor: pointer;color: blue;" @click="addCar">
-												<i class="el-icon-folder-add"></i>
+											<sa-item name="作业人员" placeholder="请输入作业人员" v-model="m.operator" br>
+											</sa-item>
+										</el-col>
+										<el-col span=8>
+											<div class="c-item" v-if="goods.needDeclare==1">
+												<label class="c-label">
+													<span style="color: red;" >*</span>
+													申报单号:</label>
+												<el-input v-model="m.declareNo" placeholder="选择申报单" :readonly="goods.needDeclare==1" clearable>
+												</el-input>
+												<div style="cursor: pointer;color: blue;display: inline;"
+													@click="handlerDeclare">
+													<i class="el-icon-folder-add"></i>
+												</div>
 											</div>
-										</el-input>
-									</div>
+											<div class="c-item">
+												<label class="c-label"><span style="color: red;"
+														v-if="goods.needOperateTime==1">*</span>作业时间:</label>
+												<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
+													v-model="m.operateTime"></el-date-picker>
+											</div>
+										</el-col>
+										<el-col span=8>
+											<div class="c-item" v-if="currentCustomerId=='1'">
+												<label class="c-label"><span style="color: red;">*</span>客户:</label>
+												<el-select :disabled="goods.needDeclare||m.declareNo" v-model="m.customerId"
+													placeholder="请选择">
+													<el-option v-for="item in customerList" :key="item.id"
+														:label="item.name" :value="item.id">
+													</el-option>
+												</el-select>
+											</div>
+										</el-col>
+									</el-row>
 								</div>
 							</el-card>
 						</el-row>
@@ -124,17 +112,22 @@
 								<div slot="header" class="clearfix">
 									<span>车辆</span>
 									<el-button style="float: right;" icon="el-icon-plus" type="primary"
-										@click="showAddModal" v-if="modal.list.length<modal.num">添加
+										@click="showAddModal">添加
 									</el-button>
 								</div>
-								<el-table :data="modal.list">
-									<el-table-column prop="name" label="姓名">
+								<el-table :data="car.list">
+									<el-table-column type="index" width="50" label="序号">
 									</el-table-column>
-									<el-table-column prop="phone" label="联系号码">
+									<el-table-column prop="carNo" label="车牌号">
+									</el-table-column>
+									<el-table-column prop="carSize" label="规格(米)">
+									</el-table-column>
+									<el-table-column prop="carType" label="类型">
+									</el-table-column>
+									<el-table-column prop="netWeight" label="载重(kg)">
 									</el-table-column>
 									<el-table-column label="操作">
 										<template slot-scope="s">
-											<!-- <el-button class="c-btn" type="primary" @click="uploadFn(s.row)">上传</el-button> -->
 											<el-button class="c-btn" type="info" @click="editFn(s.row)">修改</el-button>
 											<el-button class="c-btn" type="danger" @click="deleteFn(s.row)">删除
 											</el-button>
@@ -149,23 +142,35 @@
 									<span>业务项</span>
 								</div>
 								<div>
-									<el-form-item v-for="(type,index) in itemTypeList" style="display: flex;">
-										<label style="color: red;">*</label>{{type.name}}</label>
-										<el-select v-model="type.itemId" style="width: 120px;" @change="itemChange"
-											placeholder="请选择">
-											<el-option v-for="item in type.items" :key="item.id" :label="item.itemName"
-												:value="item.id">
-											</el-option>
-										</el-select>
-										<el-input-number style="margin-left: 60px;" class="item-num" v-model="type.num"
-											:min="1" :max="10" size="mini" :disabled="type.inc==0"></el-input-number>
-										<div class="xj" v-if="type.itemId">
-											{{type.items.filter(obj=>obj.id==type.itemId)[0].price*type.num}}元
-											<label @click="cleanItem(type)" style="margin-left: 5px;cursor: pointer">(<i
-													class="el-icon-delete"></i>)</label>
-										</div>
-										<el-button v-if="type.code=='p09'&&type.itemId"
-											@click="addPeopleFn(type.itemId,type.num)">操作</el-button>
+									<el-form-item v-for="(type,index) in itemTypeList">
+										<el-row>
+											<el-col span="9">
+												<label style="color: red;"
+													v-if="type.need==1">*</label>{{type.name}}</label>
+												<el-select v-model="type.itemId" style="width: 120px;"
+													@change="itemChange(type)" placeholder="请选择">
+													<el-option v-for="item in type.items" :key="item.id"
+														:label="item.itemName" :value="item.id">
+													</el-option>
+												</el-select>
+											</el-col>
+											<el-col span="7">
+												<el-input-number style="margin-left: 60px;" class="item-num"
+													v-model="type.num" :min="1" :max="10" size="mini"
+													:disabled="type.inc==0"></el-input-number>
+												<div class="xj" v-if="type.itemId">
+													{{type.price*type.num}}元
+													<label @click="cleanItem(type)"
+														style="margin-left: 5px;cursor: pointer">(<i
+															class="el-icon-delete"></i>)</label>
+												</div>
+											</el-col>
+											<el-col span="8">
+												<sa-item type="textarea" name="备注" placeholder="请输入备注"
+													v-model="type.remark"></sa-item>
+											</el-col>
+										</el-row>
+										<el-divider></el-divider>
 									</el-form-item>
 									<div class="hj" v-if="totalPrice>0">
 										合计费用:{{totalPrice}}<label>元</label>
@@ -178,107 +183,44 @@
 			</div>
 			<!-- ------- 底部按钮 ------- -->
 			<div class="s-foot">
-				<el-button type="primary" @click="ok()" v-if="sa.isAuth('tb-business-add')">确定</el-button>
+				<el-button type="primary" @click="ok()">确定</el-button>
 				<el-button @click="closeFn()">取消</el-button>
 			</div>
-			<el-dialog title="人员核酸检测" :visible.sync="modal.visible" width="80%">
-				<el-card class="box-card">
-					<div slot="header">
-						<span>列表</span>
-						<el-button style="float: right;" icon="el-icon-plus" type="primary" @click="showAddModal"
-							v-if="modal.list.length<modal.num">添加
-						</el-button>
-					</div>
-					<el-table :data="modal.list">
-						<el-table-column prop="name" label="姓名">
-						</el-table-column>
-						<el-table-column prop="phone" label="联系号码">
-						</el-table-column>
-						<el-table-column label="操作">
-							<template slot-scope="s">
-								<!-- <el-button class="c-btn" type="primary" @click="uploadFn(s.row)">上传</el-button> -->
-								<el-button class="c-btn" type="info" @click="editFn(s.row)">修改</el-button>
-								<el-button class="c-btn" type="danger" @click="deleteFn(s.row)">删除</el-button>
-							</template>
-						</el-table-column>
-					</el-table>
-				</el-card>
-				<span slot="footer" class="dialog-footer">
-					<el-button @click="cancelAdd">取 消</el-button>
-					<el-button type="primary" @click="modal.visible=false">确 定</el-button>
-				</span>
-			</el-dialog>
-			<el-dialog title="人员核酸检测" :visible.sync="addModal.visible" width="400">
-				<span>
-					<el-form label-position="left">
-						<sa-item type="text" name="姓名" placeholder="姓名" v-model="addModal.form.name" br></sa-item>
-						<sa-item type="text" name="联系号码" placeholder="联系号码" v-model="addModal.form.phone" br></sa-item>
-					</el-form>
-				</span>
-				<span slot="footer" class="dialog-footer">
-					<el-button @click="addModal.visible = false">取 消</el-button>
-					<el-button type="primary" @click="confirmAdd">确 定</el-button>
-				</span>
-			</el-dialog>
-			<el-dialog title="添加中国车" :visible.sync="china.visible" width="80%">
-				<el-card class="box-card">
-					<div slot="header">
-						<span>列表</span>
-						<el-button style="float: right;" icon="el-icon-plus" type="primary" @click="addChinaCarFn">添加
-						</el-button>
-					</div>
-					<el-table :data="china.list">
-						<el-table-column prop="carNo" label="车牌号">
-						</el-table-column>
-						<el-table-column prop="driverName" label="联系人">
-						</el-table-column>
-						<el-table-column prop="driverPhone" label="联系号码">
-						</el-table-column>
-						<el-table-column prop="carSize" label="车辆规格">
-						</el-table-column>
-						<el-table-column label="操作">
-							<template slot-scope="s">
-								<el-button class="c-btn" type="info" @click="editChinaCarFn(s.row)">修改</el-button>
-								<el-button class="c-btn" type="danger" @click="deleteChinaCarFn(s.row)">删除</el-button>
-							</template>
-						</el-table-column>
-					</el-table>
-				</el-card>
-				<span slot="footer" class="dialog-footer">
-					<el-button @click="china.visible=false">关 闭</el-button>
-					<el-button type="primary" @click="china.visible=false">确 定</el-button>
-				</span>
-			</el-dialog>
-			<el-dialog title="添加中国车" :visible.sync="car.visible" width="300">
+			<el-dialog title="车辆录入" :visible.sync="car.visible" width="400">
 				<span>
 					<el-form label-position="left">
 						<div class="c-item">
 							<label class="c-label"><span style="color: red;">*</span>车牌号:</label>
-							<el-autocomplete v-model="car.form.carNo" placeholder="请输入车牌号"
-								@select="handleSelectChinaCar" value-key='carNo'
-								:fetch-suggestions="queryChinaCarAsync">
+							<el-autocomplete v-model="car.form.carNo" placeholder="请输入车牌号" value-key='carNo'
+								:fetch-suggestions="queryCarAsync">
 							</el-autocomplete>
 						</div>
 						<div class="c-item">
-							<label class="c-label"><span style="color: red;">*</span>车辆规格:</label>
-							<el-input-number class="china-car-size" v-model="car.form.carSize" controls-position="right"
-								:min="4.2" :max="50"></el-input-number>
+							<label class="c-label">车辆类型:</label>
+							<el-select v-model="car.form.carType" placeholder="请选择" @change="carTypeChange">
+								<el-option :label="item.name" :value="item.name" v-for="(item,index) in carTypeList">
+								</el-option>
+							</el-select>
 						</div>
 						<div class="c-item">
-							<label class="c-label">联系人:</label>
-							<el-input v-model="car.form.driverName" placeholder="联系人">
-							</el-input>
+							<label class="c-label">
+								<span style="color: red;" v-if="goods.needCarSize==1">*</span>
+								规格(米):</label>
+							<el-input-number class="item-num" v-model="car.form.carSize" :min="1" :max="50">
+							</el-input-number>
 						</div>
-						<div class="c-item">
-							<label class="c-label">联系号码:</label>
-							<el-input v-model="car.form.driverPhone" placeholder="联系号码">
-							</el-input>
+						<div class="c-item" v-if="car.form.carType.indexOf('空')==-1">
+							<label class="c-label">
+								<span style="color: red;" v-if="goods.needCarSize==1">*</span>
+								载重(kg):</label>
+							<el-input-number class="item-num" v-model="car.form.netWeight" :min="1" :max="999999">
+							</el-input-number>
 						</div>
 					</el-form>
 				</span>
 				<span slot="footer" class="dialog-footer">
 					<el-button @click="car.visible = false">取 消</el-button>
-					<el-button type="primary" @click="confirmAddCar">确 定</el-button>
+					<el-button type="primary" @click="confirmAdd">确 定</el-button>
 				</span>
 			</el-dialog>
 			<el-dialog title="申报单" :visible.sync="declare.visible" width="90%">
@@ -298,9 +240,9 @@
 						</el-table-column>
 						<el-table-column prop="declarePeople" label="申报人">
 						</el-table-column>
-						<el-table-column prop="customerName" label="申报公司">
+						<el-table-column prop="customerName" label="申报公司" width=200>
 						</el-table-column>
-						<el-table-column prop="declarePhone" label="申报电话">
+						<el-table-column prop="createTime" width="140" label="申报时间">
 						</el-table-column>
 						<el-table-column prop="declareNo" width="180" label="申报单号">
 						</el-table-column>
@@ -310,11 +252,9 @@
 						</el-table-column>
 						<el-table-column prop="grossWeight" label="毛重(kg)">
 						</el-table-column>
-						<el-table-column prop="createTime" width="140" label="申报时间">
-						</el-table-column>
 					</el-table>
 					<div class="block">
-						<el-pagination layout="prev, pager, next" @current-change="getDeclareList"
+						<el-pagination layout="prev, pager, next" @current-change="currentPageChange"
 							:page-size="declare.p.pageSize" :total="declare.p.dataCount"
 							:current-page="declare.p.pageNo">
 						</el-pagination>
@@ -334,63 +274,29 @@
 				},
 				el: '.vue-box',
 				data: {
-					id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改) 
 					m: {
 						id: '', // 主键 
 						customerId: '', // 客户id 
 						customerName: '', // 客户名称 
-						no: '', // 编号 
-						cardNo: '', // 车牌号 
-						countryName: '越南车',
-						cardSize: '', // 车规格 
-						netWeight: '', // 载重(kg) 
+						operateTime: '',
+						no: '', // 编号
+						goodsId: '',
 						goodsName: '', // 商品 
-						chinaCarNo: '',
-						expectInDay: '',
-						driverName: '', // 司机名称 
-						driverPhone: '', // 司机联系号码 
-						driverIdCard: '', // 司机身份证 
-						payTicket: '', // 支付凭证 
 					}, // 实体对象 
 					customerList: [],
 					carList: [],
 					currentCustomerId: 1,
 					itemTypeList: [],
 					filterTypeList: [],
-					typeList: [],
 					goodsList: [],
-					countryList: [{
-						name: '越南车'
-					}, {
-						name: '中国车'
-					}],
 					tableData: [],
-					modal: {
-						visible: false,
-						itemId: 4,
-						num: 1,
-						list: []
-					},
-					addModal: {
-						visible: false,
-						form: {
-							name: '',
-							phone: '',
-							itemId: 4,
-							ticket: ''
-						}
-					},
-					unitList: [],
-					china: {
-						visible: false,
-						list: []
-					},
 					car: {
 						visible: false,
+						list: [],
 						form: {
 							carNo: '',
-							driverName: '',
-							driverPhone: '',
+							carType: '',
+							netWeight: '',
 							carSize: ''
 						}
 					},
@@ -415,7 +321,8 @@
 						needOperateTime: 1,
 						chinaCarPay: 1,
 						vietnamCarPay: 1,
-					}
+					},
+					carTypeList: []
 				},
 				computed: {
 					totalPrice() {
@@ -446,7 +353,10 @@
 					},
 					handlerDeclare() {
 						this.declare.visible = true;
-
+						this.getDeclareList();
+					},
+					currentPageChange(page){
+						this.declare.p.pageNo=page;
 						this.getDeclareList();
 					},
 					getDeclareList() {
@@ -460,7 +370,7 @@
 							this.declare.p.pageNo = resp.pageNo;
 							this.declare.p.dataCount = resp.dataCount;
 							list.forEach(row => {
-								if (row.declareNo == this.m.declareNo) {
+								if (row.declareNo == this.m.declareNo&&this.m.declareNo) {
 									this.$nextTick(() => {
 										this.$refs['declareTable'].toggleRowSelection(row, true)
 									})
@@ -479,10 +389,26 @@
 							return sa.msg('只能选择一条数据')
 						}
 						let declare = selection[0];
-						if (this.m.declareNo !== declare.declareNo) {
+						let oldNo = this.m.declareNo;
+						if (oldNo && oldNo !== declare.declareNo) {
+							this.car.list = [];
+						}
+						if (oldNo !== declare.declareNo) {
 							this.m.declareNo = declare.declareNo;
 							this.m.customerId = declare.customerId;
 							this.m.customerName = declare.customerName;
+							let carNo = declare.carNo;
+							let grossWeight = declare.grossWeight;
+							let carList = this.car.list;
+							let exit = carList.filter(obj => obj.carNo == carNo).pop();
+							if (!exit) {
+								let car = {
+									carNo: carNo,
+									netWeight: grossWeight,
+									carType: '载重'
+								}
+								this.car.list.push(car)
+							}
 							this.m.cardNo = declare.carNo;
 							this.m.chinaCarNo = declare.chinaCarNo;
 							this.m.netWeight = declare.grossWeight;
@@ -490,162 +416,122 @@
 							if (chinaCarNo) {
 								let list = [];
 								chinaCarNo.replace(",", ",").split(",").forEach(carNo => {
-									let obj = {
-										carNo: carNo
+									let exit = carList.filter(obj => obj.carNo == carNo).pop();
+									if (!exit) {
+										let car = {
+											carNo: carNo,
+											carType: '空车'
+										}
+										this.car.list.push(car)
 									}
-									list.push(obj);
-									this.china.list = list;
 								})
 							}
+							this.filterItems();
 						}
 						this.declare.visible = false;
 					},
-					findInAndNoBusinessCar() {
-						sa.ajax('/TbBusinessCar/findInAndNoBusinessCar', function(resp) {
-							this.carList = resp.data;
-						}.bind(this))
-					},
-					handleSelectCar(data) {
-						this.m.cardNo = data.carNo;
-					},
-					queryCarAsync(queryStr, cb) {
-						let list = this.carList;
-						let filterList = list.filter(obj => obj.carNo.indexOf(queryStr) !== -1);
-						cb(filterList)
-					},
-					handleSelectChinaCar(data) {
-						this.car.form.carNo = data.carNo;
-					},
-					queryChinaCarAsync(queryStr, cb) {
-						let list = this.carList;
-						let filterList = list.filter(obj => obj.carNo.indexOf(queryStr) !== -1 && obj.carNo !== this.m
-							.cardNo);
-						cb(filterList)
-					},
 					cleanItem(type) {
 						type.itemId = '';
-						let typeName = type.name;
-						if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
-							this.checkItem = '';
+						type.itemName = '';
+						type.price = '';
+					},
+					itemChange(type) {
+						let itemId = type.itemId;
+						let item = type.items.filter(obj => obj.id == itemId).pop();
+						if (item) {
+							type.inc = item.inc;
+							type.price = item.price;
 						}
 					},
-					itemChange(itemId) {
-
-					},
-					addCar() {
-						this.china.visible = true;
-					},
-					addChinaCarFn() {
-						Object.assign(this.car, {
-							visible: true,
-							form: {
-								carNo: '',
-								driverName: '',
-								driverPhone: '',
-								carSize: ''
-							}
-						})
-					},
-					confirmAddCar() {
+					confirmAdd() {
 						let carNo = this.car.form.carNo;
-						if (!sa.isCarNo(carNo)) {
-							sa.error('请填入正确的车牌号')
+						let netWeight = this.car.form.netWeight;
+						let goods = this.goods;
+						let form = this.car.form;
+						let carType = form.carType;
+						if (!carNo) {
+							sa.error('请录入车牌号')
 							return false;
 						}
-						if (!this.car.form.carSize) {
+						if (!form.carSize && goods.needCarSize == 1) {
 							sa.error('请填入车辆规格')
 							return false;
 						}
-						let phone = this.car.form.phone;
-						if (phone && !sa.isPhone(phone)) {
-							sa.error('联系号码不正确')
-							return false;
+						if(carType.indexOf('空')!==-1){
+							netWeight=0;
 						}
-						let list = this.china.list;
+						let list = this.car.list;
 						let index = list.map(obj => obj.carNo).indexOf(carNo);
 						if (index > -1) {
 							list.splice(index, 1);
 						}
-						this.china.list.push(this.car.form);
+						let carSize = form.carSize;
+						let car = {
+							id: form.id,
+							carNo: form.carNo.toUpperCase(),
+							carType: carType,
+							carSize: carSize,
+							netWeight: netWeight
+						}
+						this.car.list.push(car);
 						this.car.visible = false;
-
-					},
-					editChinaCarFn(data) {
-						Object.assign(this.car, {
-							visible: true,
-							form: data
-						})
-					},
-					deleteChinaCarFn(data) {
-						this.china.list.splice(this.china.list.indexOf(data), 1)
-					},
-
-					getUnitList() {
-						sa.ajax('/TbUnit/getList', {
-							pageNo: 1,
-							pageSize: 50
-						}, function(resp) {
-							this.unitList = resp.data;
-						}.bind(this))
-					},
-					addPeopleFn(itemId, num) {
-						this.modal.itemId = itemId;
-						this.modal.num = num;
-						this.modal.visible = true;
-
-					},
-					showAddModal() {
-						Object.assign(this.addModal, {
-							visible: true,
-							form: {
-								index: -1,
-								name: '',
-								phone: '',
-								itemId: this.modal.itemId,
-								ticket: ''
-							}
-						})
-					},
-					cancelAdd() {
-						this.modal.list = [];
-						this.modal.visible = false;
-
-					},
-					confirmAdd() {
-						if (!this.addModal.form.name) {
-							sa.error('请输入检测人姓名')
-							return false;
+						this.filterItems();
+					},
+					filterItems() {
+						let carList = this.car.list;
+						let filterTypeList = JSON.parse(JSON.stringify(this.filterTypeList));
+						if (carList.length == 0) {
+							this.itemTypeList = filterTypeList;
+							return;
 						}
-						let phone = this.addModal.form.phone;
-						if (phone && !sa.isPhone(phone)) {
-							sa.error('检测人联系号码不正确')
-							return false;
+						let car = carList[0];
+						let checkCarList = carList.filter(car => car.carType.indexOf('空') == -1);
+						if(checkCarList.length>0){
+							car=checkCarList[0];
 						}
-						let dbIndex = this.addModal.form.index;
-						if (dbIndex >= 0) {
-							this.modal.list[dbIndex].name = this.addModal.form.name;
-							this.modal.list[dbIndex].phone = this.addModal.form.phone;
-						} else {
-							this.addModal.form.index = this.modal.list.length;
-							this.modal.list.push(this.addModal.form);
+						let carSize = car.carSize;
+						let carType = car.carType;
+						let netWeight = car.netWeight;
+						let tempList = [];
+						for (let i in filterTypeList) {
+							let type = filterTypeList[i];
+							let items = type.items;
+							if (carType) {
+								items = items.filter(item => item.itemType&& item.itemType.indexOf(carType) !== -1);
+								console.log(items)
+							}
+							if (carSize && carSize > 1) {
+								items = items.filter(item => item.minLength <= carSize && item.carLength >= carSize);
+								console.log(items)
+							}
+							if (netWeight && netWeight > 1 && carType.indexOf('空') == -1) {
+								items = items.filter(item => item.minWeight <= netWeight && item.maxWeight >= netWeight);
+								console.log(items)
+							}
+							let itemIds = items.map(item => item.id);
+							if (itemIds.indexOf(type.itemId) == -1) {
+								this.cleanItem(type);
+							}
+							type.items = items;
+							tempList.push(type);
 						}
-						this.addModal.visible = false;
+						this.itemTypeList = tempList;
+					},
+					showAddModal() {
+						this.car.visible = true;
+						this.car.form.carNo = '';
+						this.car.form.carSize = '';
+						this.car.form.netWeight = '';
 					},
 					editFn(data) {
-						Object.assign(this.addModal, {
+						Object.assign(this.car, {
 							visible: true,
 							form: data
 						})
 					},
 					deleteFn(data) {
-						this.modal.list.splice(data.index, 1);
-						if (data.id) {
-							sa.ajax('/TbBusinessPeople/deleteById', {
-								id: data.id
-							}, function(resp) {
-
-							}.bind(this))
-						}
+						this.car.list.splice(this.car.list.indexOf(data), 1);
+						this.filterItems();
 					},
 					getGoods() {
 						sa.ajax('/TbGoods/getList', {
@@ -676,17 +562,46 @@
 						sa.ajaxNoLoading('/TbItemType/getTypeByGoodsId', {
 							goodsId: this.m.goodsId
 						}, function(resp) {
-							this.itemTypeList = resp.data;
+							let list = resp.data;
+							this.itemTypeList = list;
+							this.filterTypeList = JSON.parse(JSON.stringify(this.itemTypeList));
+							this.filterItems();
 						}.bind(this))
 					},
-					queryCaSizerAsync(queryStr, cb) {
-						let list = this.unitList;
-						let filterList = list.filter(obj => obj.unit.indexOf(queryStr) !== -1);
-						cb(filterList)
+					getItemType() {
+						sa.ajax('/TbItem/getItemType', function(resp) {
+							let list = resp.data;
+							if (list.length > 0) {
+								this.car.form.carType = list[0].name;
+							}
+							this.carTypeList = list;
+						}.bind(this))
 					},
+					carTypeChange(v) {
 
-					handleSelectCarSize(item) {
-						this.m.cardSize = item.unit;
+					},
+					getCustomerList() {
+						sa.ajax('/TbCostomer/getList', {
+							pageNo: 1,
+							pageSize: 30,
+							sortType: 20,
+							judgeStatus: 2
+						}, function(res) {
+							let list = res.data;
+							if (list.length > 0) {
+								let customer = list[0];
+								this.m.customerId = customer.id;
+								this.m.customerName = customer.name;
+							}
+							this.customerList = list;
+						}.bind(this));
+					},
+					queryCarAsync(queryStr, cb) {
+						sa.ajaxNoLoading('/TbBusinessCar/searchByNo', {
+							carNo: queryStr
+						}, function(resp) {
+							cb(resp.data)
+						}.bind(this))
 					},
 					closeFn() {
 						parent.app.f5();
@@ -694,25 +609,68 @@
 					},
 					// 提交数据 
 					ok: function() {
-
-						sa.ajax('/TbBusiness/add', m, function(res) {
+						let goods = this.goods;
+						let m = this.m;
+						if (goods.needDeclare == 1 && !m.declareNo) {
+							sa.error('请选择申报单');
+							return false;
+						}
+						if (goods.needOperateTime == 1 && !m.operateTime) {
+							sa.error('请选择作业时间');
+							return false;
+						}
+						if (this.car.list.length == 0) {
+							sa.error('请录入车辆');
+							return false;
+						}
+						let typeList = this.itemTypeList;
+						let selectList = [];
+						for (let i in typeList) {
+							let type = typeList[i];
+							if (type.need == 1 && !type.itemId) {
+								sa.error(type.name + '必选');
+								return false;
+							}
+							if (type.itemId) {
+								let obj = {
+									typeId: type.id,
+									typeName: type.name,
+									id: type.itemId,
+									num: type.num,
+									price:type.price,
+									remark:type.remark
+								}
+								selectList.push(obj);
+							}
+						}
+						let carList = this.car.list;
+						m.itemJson = JSON.stringify(selectList);
+						m.carJson = JSON.stringify(carList);
+						let chinaCarNo=carList
+						.filter(car=>sa.isCarNo(car.carNo.toUpperCase()))
+						.map(car=>car.carNo.toUpperCase())
+						.join("、");
+						let yueCarNo=carList
+						.filter(car=>!sa.isCarNo(car.carNo.toUpperCase()))
+						.map(car=>car.carNo.toUpperCase())
+						.join("、");
+						m.cardNo=yueCarNo;
+						m.chinaCarNo=chinaCarNo;
+						sa.ajax('/TbBusiness/addOtherBusiness', sa.removeNull(m), function(res) {
 							sa.alert('增加成功', this.clean);
 						}.bind(this));
 					},
 					// 添加/修改 完成后的动作
 					clean: function() {
-						this.modal.list = [];
-						if (this.id == 0) {
-							this.m = this.createModel();
-						} else {
-							parent.app.f5(); // 刷新父页面列表
-							sa.closeCurrIframe(); // 关闭本页 
-						}
+						parent.app.f5(); // 刷新父页面列表
+						sa.closeCurrIframe(); // 关闭本页 
 					},
 					getCurrentCustomer() {
 						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
 							let id = resp.data;
-							if (id == 1) {} else {
+							if (id == 1) {
+								this.getCustomerList();
+							} else {
 								this.m.customerId = id;
 							}
 							this.currentCustomerId = id;
@@ -722,8 +680,7 @@
 				mounted: function() {
 					this.getCurrentCustomer();
 					this.getGoods();
-					this.getUnitList();
-					this.findInAndNoBusinessCar();
+					this.getItemType();
 				}
 			})
 		</script>

+ 571 - 199
sp-admin/sa-view/tb-business/tb-car-disincle-edit.html

@@ -25,105 +25,244 @@
 			}
 
 			.item-num .el-input__inner {
-				width: 100px;
+				width: 130px;
+			}
+
+			.xj {
+				display: inline;
+				color: red;
+				margin-left: 9px;
+				font-weight: bold;
+			}
+
+			.hj {
+				color: red;
+				margin-left: 9px;
+				font-weight: bold;
+
 			}
 		</style>
 	</head>
 	<body>
-		<div class="vue-box" :class="{sbot: id}" style="display: none;" :style="'display: block;'">
+		<div class="vue-box sbot" style="display: none;" :style="'display: block;'">
 			<!-- ------- 内容部分 ------- -->
 			<div class="s-body">
 				<div class="c-panel">
-					<div class="c-title" v-if="id == 0">数据添加</div>
-					<div class="c-title" v-else>数据修改</div>
+					<div class="c-title">数据添加</div>
 					<el-form v-if="m" label-position="left">
-						<el-card class="box-card">
-							<div slot="header" class="clearfix">
-								<span>基本资料</span>
-							</div>
-							<el-row>
-								<el-col :span='12'>
-									<div class="c-item" v-if="currentCustomerId=='1'">
-										<label class="c-label"><span style="color: red;">*</span>客户:</label>
-										<el-select v-model="m.customerId" placeholder="请选择">
-											<el-option v-for="item in customerList" :key="item.id" :label="item.name"
-												:value="item.id">
-											</el-option>
-										</el-select>
-									</div>
-									<div class="c-item">
-										<label class="c-label"><span style="color: red;">*</span>车牌号:</label>
-										<el-autocomplete v-model="m.carNo" placeholder="请输入车牌号"
-											@select="handleSelectCar" value-key='carNo'
-											:fetch-suggestions="queryCarAsync">
-										</el-autocomplete>
-									</div>
-									<sa-item type="num" name="车辆规格(米)" placeholder="请输入车辆规格" v-model="m.carSize" br>
-									</sa-item>
-									<sa-item name="作业人员" placeholder="请输入作业人员" v-model="m.operator" br>
-									</sa-item>
-								</el-col>
-								<el-col :span='12'>
-									<div class="c-item">
-										<label class="c-label">车辆类型:</label>
-										<el-select v-model="m.carType" placeholder="请选择" @change="carTypeChange">
-											<el-option :label="item.name" :value="item.name"
-												v-for="(item,index) in carTypeList">
-											</el-option>
-										</el-select>
-									</div>
-									<sa-item v-if="m.carType.indexOf('重')!==-1" type="num" name="载重(kg)"
-										placeholder="请输入车辆载重" v-model="m.carWeight" br>
-									</sa-item>
-									<div class="c-item">
-										<label class="c-label"><span style="color: red;">*</span>作业时间:</label>
-										<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
-											v-model="m.operateTime"></el-date-picker>
-									</div>
-								</el-col>
-							</el-row>
+						<el-row>
+							<el-card class="box-card">
+								<div slot="header" class="clearfix">
+									<span>基本资料</span>
+								</div>
+								<div>
+									<el-row>
+										<el-col span=8>
+											<div class="c-item">
+												<label class="c-label"><span style="color: red;">*</span>业务项目:</label>
+												<el-select v-model="m.goodsId" placeholder="请选择" @change="goodsChange">
+													<el-option v-for="item in goodsList" :key="item.id"
+														:label="item.name" :value="item.id">
+													</el-option>
+												</el-select>
+											</div>
+											<sa-item name="作业人员" placeholder="请输入作业人员" v-model="m.operator" br>
+											</sa-item>
+										</el-col>
+										<el-col span=8>
+											<div class="c-item">
+												<label class="c-label">
+													<span style="color: red;" v-if="goods.needDeclare==1">*</span>
+													申报单号:</label>
+												<el-input v-model="m.declareNo" placeholder="选择申报单"
+													:readonly="goods.needDeclare==1" clearable>
+												</el-input>
+												<div style="cursor: pointer;color: blue;display: inline;"
+													@click="handlerDeclare">
+													<i class="el-icon-folder-add"></i>
+												</div>
+
+											</div>
+											<div class="c-item">
+												<label class="c-label"><span style="color: red;"
+														v-if="goods.needOperateTime==1">*</span>作业时间:</label>
+												<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
+													v-model="m.operateTime"></el-date-picker>
+											</div>
+										</el-col>
+										<el-col span=8>
+											<div class="c-item" v-if="currentCustomerId=='1'">
+												<label class="c-label"><span style="color: red;">*</span>客户:</label>
+												<el-select :disabled="goods.needDeclare||m.declareNo"
+													v-model="m.customerId" placeholder="请选择">
+													<el-option v-for="item in customerList" :key="item.id"
+														:label="item.name" :value="item.id">
+													</el-option>
+												</el-select>
+											</div>
+										</el-col>
+									</el-row>
+								</div>
+							</el-card>
+						</el-row>
+						<el-row>
+							<el-card class="box-card">
+								<div slot="header" class="clearfix">
+									<span>车辆</span>
+									<el-button style="float: right;" icon="el-icon-plus" type="primary"
+										@click="showAddModal">添加
+									</el-button>
+								</div>
+								<el-table :data="car.list">
+									<el-table-column type="index" width="50" label="序号">
+									</el-table-column>
+									<el-table-column prop="carNo" label="车牌号">
+									</el-table-column>
+									<el-table-column prop="carSize" label="规格(米)">
+									</el-table-column>
+									<el-table-column prop="carType" label="类型">
+									</el-table-column>
+									<el-table-column prop="netWeight" label="载重(kg)">
+									</el-table-column>
+									<el-table-column label="操作">
+										<template slot-scope="s">
+											<el-button class="c-btn" type="info" @click="editFn(s.row)">修改</el-button>
+											<el-button class="c-btn" type="danger" @click="deleteFn(s.row)">删除
+											</el-button>
+										</template>
+									</el-table-column>
+								</el-table>
+							</el-card>
+						</el-row>
+						<el-row>
 							<el-card class="box-card">
 								<div slot="header" class="clearfix">
-									<span>收费明细<label style="color: red;">(总共{{totalPrice}}元)</label></span>
-									<el-select v-model="m.itemTypeId" placeholder="请选择" @change="itemChange"
-										style="float: right; padding: 3px 0">
-										<el-option v-for="(item,index) in itemTypeList" :label="item.name"
-											:value="item.id">
-										</el-option>
-									</el-select>
+									<span>业务项</span>
 								</div>
 								<div>
-									<el-checkbox-group v-model="checkList">
-										<el-row v-for="(item,index) in items"
-											style="border-bottom: 1px solid #E4E4E4;line-height: 90px;">
-											<el-col :span="11">
-												<el-checkbox :disabled="item.need==1" :label="item.id">
-													<div>{{item.itemName}}(<label
-															style="color: red;">{{item.price}}{{item.unit}}</label>)
-													</div>
-												</el-checkbox>
+									<el-form-item v-for="(type,index) in itemTypeList">
+										<el-row>
+											<el-col span="9">
+												<label style="color: red;"
+													v-if="type.need==1">*</label>{{type.name}}</label>
+												<el-select v-model="type.itemId" style="width: 120px;"
+													@change="itemChange(type)" placeholder="请选择">
+													<el-option v-for="item in type.items" :key="item.id"
+														:label="item.itemName" :value="item.id">
+													</el-option>
+												</el-select>
 											</el-col>
-											<el-col :span="6">
-												<el-input-number :disabled="item.inc==0" class="item-num"
-													v-model="item.num" :min="1" :max="10"></el-input-number>
+											<el-col span="7">
+												<el-input-number style="margin-left: 60px;" class="item-num"
+													v-model="type.num" :min="1" :max="10" size="mini"
+													:disabled="type.inc==0"></el-input-number>
+												<div class="xj" v-if="type.itemId">
+													{{type.price*type.num}}元
+													<label @click="cleanItem(type)"
+														style="margin-left: 5px;cursor: pointer">(<i
+															class="el-icon-delete"></i>)</label>
+												</div>
 											</el-col>
-											<el-col :span="7">
+											<el-col span="8">
 												<sa-item type="textarea" name="备注" placeholder="请输入备注"
-													v-model="item.remark" br>
-												</sa-item>
+													v-model="type.remark"></sa-item>
 											</el-col>
 										</el-row>
-									</el-checkbox-group>
+										<el-divider></el-divider>
+									</el-form-item>
+									<div class="hj" v-if="totalPrice>0">
+										合计费用:{{totalPrice}}<label>元</label>
+									</div>
 								</div>
 							</el-card>
+						</el-row>
 					</el-form>
 				</div>
 			</div>
 			<!-- ------- 底部按钮 ------- -->
 			<div class="s-foot">
 				<el-button type="primary" @click="ok()">确定</el-button>
-				<el-button @click="sa.closeCurrIframe()">取消</el-button>
+				<el-button @click="closeFn()">取消</el-button>
 			</div>
+			<el-dialog title="车辆录入" :visible.sync="car.visible" width="400">
+				<span>
+					<el-form label-position="left">
+						<div class="c-item">
+							<label class="c-label"><span style="color: red;">*</span>车牌号:</label>
+							<el-autocomplete v-model="car.form.carNo" placeholder="请输入车牌号" value-key='carNo'
+								:fetch-suggestions="queryCarAsync">
+							</el-autocomplete>
+						</div>
+						<div class="c-item">
+							<label class="c-label">车辆类型:</label>
+							<el-select v-model="car.form.carType" placeholder="请选择" @change="carTypeChange">
+								<el-option :label="item.name" :value="item.name" v-for="(item,index) in carTypeList">
+								</el-option>
+							</el-select>
+						</div>
+						<div class="c-item">
+							<label class="c-label">
+								<span style="color: red;" v-if="goods.needCarSize==1">*</span>
+								规格(米):</label>
+							<el-input-number class="item-num" v-model="car.form.carSize" :min="1" :max="50">
+							</el-input-number>
+						</div>
+						<div class="c-item" v-if="car.form.carType.indexOf('空')==-1">
+							<label class="c-label">
+								<span style="color: red;" v-if="goods.needCarSize==1">*</span>
+								载重(kg):</label>
+							<el-input-number class="item-num" v-model="car.form.netWeight" :min="1" :max="999999">
+							</el-input-number>
+						</div>
+					</el-form>
+				</span>
+				<span slot="footer" class="dialog-footer">
+					<el-button @click="car.visible = false">取 消</el-button>
+					<el-button type="primary" @click="confirmAdd">确 定</el-button>
+				</span>
+			</el-dialog>
+			<el-dialog title="申报单" :visible.sync="declare.visible" width="90%">
+				<div class="delect-search">
+					申报人:
+					<el-input style="width: 140px;" v-model="declare.p.declarePeople" placeholder="申报人">
+					</el-input>
+					<el-button type="primary" @click="getDeclareList">搜索</el-button>
+					<el-button type="info" @click="resetDclare">重置</el-button>
+				</div>
+				<el-card class="box-card" style="margin-top: 20px;">
+					<div slot="header">
+						<span>列表</span>
+					</div>
+					<el-table :data="declare.list" ref="declareTable">
+						<el-table-column type="selection">
+						</el-table-column>
+						<el-table-column prop="declarePeople" label="申报人">
+						</el-table-column>
+						<el-table-column prop="customerName" label="申报公司" width=200>
+						</el-table-column>
+						<el-table-column prop="createTime" width="140" label="申报时间">
+						</el-table-column>
+						<el-table-column prop="declareNo" width="180" label="申报单号">
+						</el-table-column>
+						<el-table-column prop="goodsName" label="产品学名">
+						</el-table-column>
+						<el-table-column prop="carNo" label="越南车牌">
+						</el-table-column>
+						<el-table-column prop="grossWeight" label="毛重(kg)">
+						</el-table-column>
+					</el-table>
+					<div class="block">
+						<el-pagination layout="prev, pager, next" @current-change="getDeclareList"
+							:page-size="declare.p.pageSize" :total="declare.p.dataCount"
+							:current-page="declare.p.pageNo">
+						</el-pagination>
+					</div>
+				</el-card>
+				<span slot="footer" class="dialog-footer">
+					<el-button @click="declare.visible = false">取 消</el-button>
+					<el-button type="primary" @click="confirmSelectDeclare">确 定</el-button>
+				</span>
+			</el-dialog>
 		</div>
 		<script>
 			var app = new Vue({
@@ -133,105 +272,313 @@
 				},
 				el: '.vue-box',
 				data: {
-					id: sa.p('id', ''),
-					p: { // 查询参数
-						business: 0,
-						pageNo: 1, // 当前页 
-						pageSize: 50, // 页大小 
-						sortType: 0 // 排序方式 
-					},
-					id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改) 
 					m: {
-						id: '', // 主键 
-						carNo: '',
-						carSize: '',
-						carType: '载重',
-						carWeight: '',
-						itemTypeId: ''
+						id: sa.p('id', ''), // 主键 
+						customerId: '', // 客户id 
+						customerName: '', // 客户名称 
+						operateTime: '',
+						no: '', // 编号
+						goodsId: '',
+						goodsName: '', // 商品 
 					}, // 实体对象 
-					itemTypeList: [],
-					items: [],
-					businessItems: [],
-					checkList: [],
 					customerList: [],
+					carList: [],
+					currentCustomerId: 1,
+					itemTypeList: [],
+					filterTypeList: [],
+					goodsList: [],
+					tableData: [],
+					car: {
+						visible: false,
+						list: [],
+						form: {
+							carNo: '',
+							carType: '',
+							netWeight: '',
+							carSize: ''
+						}
+					},
+					declare: {
+						visible: false,
+						list: [],
+						p: {
+							pageNo: 1,
+							pageSize: 8,
+							dataCount: 0,
+							declarePeople: '',
+							production: '',
+							businessId: ''
+						}
+					},
+					goods: {
+						id: '',
+						name: '',
+						needWeight: 1,
+						needCarSize: 1,
+						needDeclare: 1,
+						needOperateTime: 1,
+					},
 					carTypeList: [],
-					currentCustomerId: ''
+					intiItems: []
 				},
 				computed: {
-
-
 					totalPrice() {
-						let checkList = this.checkList;
-						let items = this.items
-							.filter(obj => checkList.indexOf(obj.id) !== -1);
+						let itemList = this.itemTypeList.filter(obj => obj.itemId);
 						let price = 0;
-						for (let i in items) {
-							let item = items[i];
-							price = price + item.price * item.num;
+						for (let i in itemList) {
+							let type = itemList[i];
+							let num = type.num;
+							let items = type.items;
+							for (let j in items) {
+								let item = items[j];
+								if (item.id == type.itemId) {
+									price += num * item.price;
+									break;
+								}
+							}
 						}
 						return price;
 					}
 				},
 				methods: {
-					queryCarAsync(queryStr, cb) {
-						if(!queryStr){
-							cb([]);
-							return;
+					resetDclare() {
+						this.declare.p.pageNo = 1;
+						this.declare.p.pageSize = 8;
+						this.declare.p.production = '';
+						this.declare.p.declarePeople = '';
+						this.getDeclareList();
+					},
+					handlerDeclare() {
+						this.declare.visible = true;
+						this.getDeclareList();
+					},
+					getDeclareList() {
+						let currentCustomerId = this.currentCustomerId;
+						if (currentCustomerId != '1') {
+							this.declare.p.customerId = this.currentCustomerId;
 						}
-						sa.ajaxNoLoading('/TbBusinessCar/searchInNotOutCar',{carNo:queryStr},function(resp){
-							cb(resp.data)
+						this.declare.p.declareNo = this.m.declareNo;
+						sa.ajax('/TbDeclare/getNotBindList', sa.removeNull(this.declare.p), function(resp) {
+							let list = resp.data;
+							this.declare.list = list;
+							this.declare.p.pageNo = resp.pageNo;
+							this.declare.p.dataCount = resp.dataCount;
+							list.forEach(row => {
+								if (row.declareNo == this.m.declareNo) {
+									this.$nextTick(() => {
+										this.$refs['declareTable'].toggleRowSelection(row, true)
+									})
+								}
+							})
 						}.bind(this))
 					},
-					handleSelectCar(data) {
-						this.m.carNo = data.carNo;
-						if(!this.m.carSize){
-							this.m.carSize=data.carSize;
+					confirmSelectDeclare() {
+						// 获取选中元素的id列表
+						let selection = this.$refs['declareTable'].selection;
+						let declareNo = sa.getArrayField(selection, 'declareNo');
+						if (selection.length == 0) {
+							return sa.msg('请至少选择一条数据')
+						}
+						if (selection.length > 1) {
+							return sa.msg('只能选择一条数据')
+						}
+						let declare = selection[0];
+						let oldNo = this.m.declareNo;
+						if (oldNo && oldNo !== declare.declareNo) {
+							this.car.list = [];
+						}
+						if (oldNo !== declare.declareNo) {
+							this.m.declareNo = declare.declareNo;
+							this.m.customerId = declare.customerId;
+							this.m.customerName = declare.customerName;
+							let carNo = declare.carNo;
+							let grossWeight = declare.grossWeight;
+							let carList = this.car.list;
+							let exit = carList.filter(obj => obj.carNo == carNo).pop();
+							if (!exit) {
+								let car = {
+									carNo: carNo,
+									netWeight: grossWeight,
+									carType: '载重'
+								}
+								this.car.list.push(car)
+							}
+							this.m.cardNo = declare.carNo;
+							this.m.chinaCarNo = declare.chinaCarNo;
+							this.m.netWeight = declare.grossWeight;
+							let chinaCarNo = declare.chinaCarNo;
+							if (chinaCarNo) {
+								let list = [];
+								chinaCarNo.replace(",", ",").split(",").forEach(carNo => {
+									let exit = carList.filter(obj => obj.carNo == carNo).pop();
+									if (!exit) {
+										let car = {
+											carNo: carNo,
+											carType: '空车'
+										}
+										this.car.list.push(car)
+									}
+								})
+							}
+							this.filterItems();
+						}
+						this.declare.visible = false;
+					},
+					cleanItem(type) {
+						type.itemId = '';
+						type.itemName = '';
+						type.price = '';
+					},
+					itemChange(type) {
+						let itemId = type.itemId;
+						let item = type.items.filter(obj => obj.id == itemId).pop();
+						if (item) {
+							type.inc = item.inc;
+							type.price = item.price;
+						}
+					},
+					confirmAdd() {
+						let carNo = this.car.form.carNo;
+						let netWeight = this.car.form.netWeight;
+						let goods = this.goods;
+						let form = this.car.form;
+						let carType = form.carType;
+						if (!carNo) {
+							sa.error('请录入车牌号')
+							return false;
+						}
+						if (!form.carSize && goods.needCarSize == 1) {
+							sa.error('请填入车辆规格')
+							return false;
+						}
+						if (carType.indexOf('空') !== -1) {
+							netWeight = 0;
+						}
+						let list = this.car.list;
+						let index = list.map(obj => obj.carNo).indexOf(carNo);
+						if (index > -1) {
+							list.splice(index, 1);
+						}
+						let carSize = form.carSize;
+						let car = {
+							id: form.id,
+							carNo: form.carNo.toUpperCase(),
+							carType: carType,
+							carSize: carSize,
+							netWeight: netWeight
+						}
+						this.car.list.push(car);
+						this.car.visible = false;
+						this.filterItems();
+					},
+					filterItems() {
+						let carList = this.car.list;
+						let filterTypeList = JSON.parse(JSON.stringify(this.filterTypeList));
+						if (carList.length == 0) {
+							this.itemTypeList = filterTypeList;
+							return;
+						}
+						let car = carList[0];
+						let checkCarList = carList.filter(car => car.carType.indexOf('空') == -1);
+						if(checkCarList.length>0){
+							car=checkCarList[0];
+						}
+						let carSize = car.carSize;
+						let carType = car.carType;
+						let netWeight = car.netWeight;
+						let tempList = [];
+						for (let i in filterTypeList) {
+							let type = filterTypeList[i];
+							let items = type.items;
+							if (carType) {
+								items = items.filter(item => item.itemType && item.itemType.indexOf(carType) !== -1);
+							}
+							if (carSize && carSize > 1) {
+								items = items.filter(item => item.minLength <= carSize && item.carLength >= carSize);
+							}
+							if (netWeight && netWeight > 1 && carType.indexOf('空') == -1) {
+								items = items.filter(item => item.minWeight <= netWeight && item.maxWeight >= netWeight);
+							}
+							let itemIds = items.map(item => item.id);
+							if (itemIds.indexOf(type.itemId) == -1) {
+								this.cleanItem(type);
+							}
+							type.items = items;
+							tempList.push(type);
 						}
+						this.itemTypeList = tempList;
+					},
+					showAddModal() {
+						this.car.visible = true;
+						this.car.form.carNo = '';
+						this.car.form.carSize = '';
+						this.car.form.netWeight = '';
+					},
+					editFn(data) {
+						Object.assign(this.car, {
+							visible: true,
+							form: data
+						})
+					},
+					deleteFn(data) {
+						this.car.list.splice(this.car.list.indexOf(data), 1);
+						this.filterItems();
 					},
-					itemChange() {
-						sa.ajax('/TbItem/getTypeItemList', {
+					getGoods() {
+						sa.ajaxNoLoading('/TbGoods/getList', {
 							pageNo: 1,
-							pageSize: 30,
-							typeId: this.m.itemTypeId
+							pageSize: 10,
+							businessType: 1
 						}, function(resp) {
 							let list = resp.data;
-							if (this.m.carType) {
-								list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
-									.carType) !== -1);
-							}
-							this.items = list;
-							this.checkList = list.filter(obj => obj.need == 1 || obj.itemType.indexOf(this.m
-								.carType) !== -1).map(obj => obj.id);
-							let businessItems = this.businessItems;
-							list.forEach(obj => {
-								businessItems.forEach(item => {
-									if (obj.id == item.itemId) {
-										obj.remark = item.remark;
-										obj.num = item.num;
-									}
-								})
-							})
+							this.goods = list.filter(goods => goods.id == this.m.goodsId).pop();
+							this.goodsList = list;
+							this.getTypeByGoodsId();
 						}.bind(this))
 					},
-					getCustomer() {
-						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
-							let id = resp.data;
-							if (id == '1') {
-								this.getCustomerList();
-							} else {
-								this.m.customerId = id;
-							}
-							this.currentCustomerId = id;
-						}.bind(this));
+					goodsChange(v) {
+						let goodsList = this.goodsList;
+						let goods = goodsList.filter(goods => goods.id == v).pop();
+						this.goods = goods;
+						this.m.goodsName = goods.name;
+						this.getTypeByGoodsId();
 					},
-					carTypeChange(v) {
-						this.getItems();
+					getTypeByGoodsId() {
+						sa.ajaxNoLoading('/TbItemType/getTypeByGoodsId', {
+							goodsId: this.m.goodsId
+						}, function(resp) {
+							let list = resp.data;
+							let initItems = this.intiItems;
+							for (let i in initItems) {
+								let initItem = initItems[i];
+								for (let j in list) {
+									let type = list[j];
+									if (type.id == initItem.itemTypeId) {
+										type.num = initItem.num;
+										type.price = initItem.itemPrice;
+										type.itemId = initItem.itemId;
+										type.remark = initItem.remark;
+									}
+								}
+							}
+
+							this.itemTypeList = list;
+							this.filterTypeList = JSON.parse(JSON.stringify(this.itemTypeList));
+							this.filterItems();
+						}.bind(this))
 					},
 					getItemType() {
 						sa.ajax('/TbItem/getItemType', function(resp) {
-							this.carTypeList = resp.data;
+							let list = resp.data;
+							if (list.length > 0) {
+								this.car.form.carType = list[0].name;
+							}
+							this.carTypeList = list;
 						}.bind(this))
 					},
+					carTypeChange(v) {
+
+					},
 					getCustomerList() {
 						sa.ajax('/TbCostomer/getList', {
 							pageNo: 1,
@@ -239,81 +586,106 @@
 							sortType: 20,
 							judgeStatus: 2
 						}, function(res) {
-							this.customerList = res.data; // 数据
-						}.bind(this));
-					},
-					getItemTypeList() {
-						sa.ajax('/TbItemType/getList', sa.removeNull(this.p), function(res) {
 							let list = res.data;
-							this.itemTypeList = list;
-
-							this.getItems();
+							this.customerList = list;
 						}.bind(this));
 					},
-					getItems() {
-						sa.ajax('/TbItem/getTypeItemList', {
-							pageNo: 1,
-							pageSize: 30,
-							typeId: this.m.itemTypeId
+					queryCarAsync(queryStr, cb) {
+						sa.ajaxNoLoading('/TbBusinessCar/searchByNo', {
+							carNo: queryStr
 						}, function(resp) {
-							let list = resp.data;
-							if (this.m.carType) {
-								list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
-									.carType) !== -1);
-							}
-							this.items = list;
-							this.checkList = list.filter(obj => obj.need == 1 || obj.itemType.indexOf(this.m
-								.carType) !== -1).map(obj => obj.id);
-							let businessItems = this.businessItems;
-							list.forEach(obj => {
-								businessItems.forEach(item => {
-									if (obj.id == item.itemId) {
-										obj.remark = item.remark;
-										obj.num = item.num;
-									}
-								})
-							})
+							cb(resp.data)
 						}.bind(this))
 					},
-					ok() {
+					closeFn() {
+						parent.app.f5();
+						sa.closeCurrIframe();
+					},
+					// 提交数据 
+					ok: function() {
+						let goods = this.goods;
 						let m = this.m;
-						if (!m.carNo) {
-							sa.error('请输入车牌号')
+						if (goods.needDeclare == 1 && !m.declareNo) {
+							sa.error('请选择申报单');
+							return false;
+						}
+						if (goods.needOperateTime == 1 && !m.operateTime) {
+							sa.error('请选择作业时间');
 							return false;
 						}
-						if (!m.operateTime) {
-							sa.error('请选择作业时间')
+						if (this.car.list.length == 0) {
+							sa.error('请录入车辆');
 							return false;
 						}
-						let checkList = this.checkList;
-						let itemList = this.items;
-						let list = itemList.filter(obj => checkList.indexOf(obj.id) !== -1);
-						m.itemJson = JSON.stringify(list);
+						let typeList = this.itemTypeList;
+						let selectList = [];
+						for (let i in typeList) {
+							let type = typeList[i];
+							if (type.need == 1 && !type.itemId) {
+								sa.error(type.name + '必选');
+								return false;
+							}
+							if (type.itemId) {
+								let obj = {
+									typeId: type.id,
+									typeName: type.name,
+									id: type.itemId,
+									num: type.num,
+									price: type.price,
+									remark: type.remark
+								}
+								selectList.push(obj);
+							}
+						}
+						let carList = this.car.list;
+						m.itemJson = JSON.stringify(selectList);
+						m.carJson = JSON.stringify(carList);
+						let chinaCarNo = carList
+							.filter(car => sa.isCarNo(car.carNo.toUpperCase()))
+							.map(car => car.carNo.toUpperCase())
+							.join("、");
+						let yueCarNo = carList
+							.filter(car => !sa.isCarNo(car.carNo.toUpperCase()))
+							.map(car => car.carNo.toUpperCase())
+							.join("、");
+						m.cardNo = yueCarNo;
+						m.chinaCarNo = chinaCarNo;
+						m.cars = null;
 						m.items = null;
-						sa.ajax('/api/editOtherBusiness', sa.removeNull(m), function(resp) {
-							parent.app.f5(); // 刷新父页面列表
-							sa.closeCurrIframe(); // 关闭本页 
-						}.bind(this))
+						sa.ajax('/TbBusiness/editOtherBusiness', sa.removeNull(m), function(res) {
+							sa.alert('修改成功', this.clean);
+						}.bind(this));
+					},
+					// 添加/修改 完成后的动作
+					clean: function() {
+						parent.app.f5(); // 刷新父页面列表
+						sa.closeCurrIframe(); // 关闭本页 
+					},
+					getCurrentCustomer() {
+						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
+							let id = resp.data;
+							if (id == 1) {
+								this.getCustomerList();
+							} else {
+								this.m.customerId = id;
+							}
+							this.currentCustomerId = id;
+						}.bind(this));
 					},
 					getOtherBusinessById() {
-						sa.ajax('/TbBusiness/getOtherBusinessById', {
-							id: this.id
-						}, function(resp) {
+						sa.ajax('/TbBusiness/getOtherBusinessById?id=' + this.m.id, function(resp) {
 							let data = resp.data;
-							this.m = data
-							this.businessItems = data.items;
-							this.checkList = data.items.map(obj => obj.itemId);
-							console.log(this.checkList);
-							this.getItemTypeList();
-							this.getItemType();
+							this.car.list = data.cars;
+							this.intiItems = data.items;
+							this.m = resp.data;
+							this.getGoods();
 						}.bind(this))
-					}
+					},
 				},
 				mounted: function() {
+					this.getCurrentCustomer();
 					this.getOtherBusinessById();
-					this.getCustomer();
-
-
+					this.getItemType();
 				}
 			})
 		</script>

+ 12 - 24
sp-admin/sa-view/tb-business/tb-car-disincle-info.html

@@ -37,21 +37,17 @@
 									<div>
 										<el-row>
 											<el-col span="12">
-												<sa-info name="客户名称" br v-if="m.customerName">{{m.customerName}}</sa-info>
-												<sa-info name="车规格" br>{{m.cardSize}}(米)</sa-info>
-												<sa-info name="业务类型" br>{{m.goodsName}}</sa-info>
-												<sa-info name="载重" br v-if="m.goodsName!=='空车'">{{m.netWeight}}(kg)</sa-info>
-												<sa-info type="enum" name="支付状态" :value="m.payStatus"
-													:jv="{1: '未支付', 2: '已支付未确认', 3: '已支付已确认'}" br></sa-info>
+												<sa-info name="客户名称" br v-if="m.customerName">{{m.customerName}}
+												</sa-info>
+												<sa-info name="业务项目" br>{{m.goodsName}}</sa-info>
+												<sa-info name="作业时间" br>{{m.operateTime}}</sa-info>
+												<sa-info name="业务费用" br>{{m.itemPrice}}(元)</sa-info>
 											</el-col>
 											<el-col span="12">
 												<sa-info name="业务编号" br>{{m.no}}</sa-info>
 												<sa-info name="录入时间" br>{{m.createTime}}</sa-info>
-												<sa-info name="车牌" br>
-													<label v-if="m.chinaCarNo">{{m.chinaCarNo}}</label>
-													<label v-else>{{m.cardNo}}</label>
-												</sa-info>
-												<sa-info name="业务费用" br>{{m.itemPrice}}(元)</sa-info>
+												<sa-info type="enum" name="支付状态" :value="m.payStatus"
+													:jv="{1: '未支付', 2: '已支付未确认', 3: '已支付已确认'}" br></sa-info>
 												<sa-info name="支付时间" br>{{m.payTime}}</sa-info>
 											</el-col>
 										</el-row>
@@ -75,15 +71,13 @@
 										<sa-td width="120" name="车辆状态" prop="isLock" type="enum"
 											:jv="{1: '锁定[#ff0000]', 0: '正常[#005500]'}">
 										</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="driverName"></sa-td>
-										<sa-td name="联系号码" prop="driverPhone"></sa-td>
 										<sa-td name="入场时间" prop="realInTime" width=180></sa-td>
 										<sa-td name="离场时间" prop="realOutTime" width=180></sa-td>
 									</el-table>
@@ -99,9 +93,9 @@
 											style="color: red; font-weight: bold;margin-left: 20px;">合计:({{m.itemPrice}}元)</label>
 									</div>
 									<el-table :data="tableData" style="width: 100%">
-										<el-table-column prop="itemTypeName" label="业务分类" width="180">
+										<el-table-column prop="itemTypeName" label="收费项" width="180">
 										</el-table-column>
-										<el-table-column prop="itemName" label="具体项目" width="180">
+										<el-table-column prop="itemName" label="收费明细" width="180">
 										</el-table-column>
 										<el-table-column prop="itemPrice" label="单价">
 										</el-table-column>
@@ -180,16 +174,10 @@
 						})
 					},
 					ok() {
-						if (!this.upload.form.ticket) {
-							sa.error('请上传凭据');
-							return;
-						}
-						sa.ajax('/TbBusinessItem/update', this.upload.form, function(resp) {
-							this.upload.visible = false;
-						}.bind(this))
+
 					},
 					getInfo() {
-						sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
+						sa.ajax('/TbBusiness/getOtherBusinessById?id=' + this.id, function(res) {
 							this.m = res.data;
 							this.tableData = res.data.items;
 						}.bind(this))

+ 44 - 31
sp-admin/sa-view/tb-business/tb-car-disincle-list.html

@@ -39,7 +39,8 @@
 						</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.carNo = '';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 />
@@ -48,35 +49,38 @@
 				<el-table class="data-table" ref="data-table" :data="dataList">
 					<el-table-column type="index" width="50"></el-table-column>
 					<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>
-					<sa-td name="车牌号" prop="carNo"></sa-td>
+					<sa-td name="客户名称" prop="customerName" width="190"></sa-td>
+					<sa-td name="业务项" prop="goodsName" width="160"></sa-td>
+					<el-table-column label="车牌号" width="160">
+						<template slot-scope="s">
+							<label v-if="s.row.cardNo&&!s.row.chinaCarNo">{{s.row.cardNo}}</label>
+							<label v-if="s.row.cardNo&&s.row.chinaCarNo">{{s.row.cardNo}}、{{s.row.chinaCarNo}}</label>
+							<label v-if="!s.row.cardNo&&s.row.chinaCarNo">{{s.row.chinaCarNo}}</label>
+						</template>
+					</el-table-column>
 					<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="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>
 					</sa-td>
 					<el-table-column label="操作" width="360px" fixed="right">
 						<template slot-scope="s">
 							<el-button class="c-btn" type="primary" v-if="sa.isAuth('tb-flex-business-confirm')
 								&&currentCustomerId=='1'&&s.row.adminConfirmInput==0" @click="confirmFn(s.row)">账单确认</el-button>
-								<el-button class="c-btn" type="primary" v-if="sa.isAuth('tb-business-confirm')
+							<el-button class="c-btn" type="primary" v-if="sa.isAuth('tb-business-confirm')
 									&&currentCustomerId=='1'&&s.row.adminConfirmInput==1" @click="checkConfirmFn(s.row)">查看账单</el-button>
 							<el-button class="c-btn" type="success" @click="get(s.row)">查看</el-button>
-							<el-button class="c-btn" type="primary" v-if="currentCustomerId=='1'||(s.row.adminConfirmInput==0&&sa.isAuth('tb-flex-business-edit'))"
+							<el-button class="c-btn" type="primary"
+								v-if="currentCustomerId=='1'||(s.row.adminConfirmInput==0&&sa.isAuth('tb-flex-business-edit'))"
 								@click="update(s.row)">
 								修改</el-button>
-								<el-button class="c-btn" type="primary" 
-								v-if="(currentCustomerId=='1'||(sa.isAuth('tb-flex-business-pay')))
-								&&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="primary" v-if="(currentCustomerId=='1'||(sa.isAuth('tb-flex-business-pay')))
+								&&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)">删除
@@ -123,7 +127,7 @@
 					currentCustomerId: '1',
 					confirm: {
 						visible: false,
-						title:'',
+						title: '',
 						form: {
 							ids: ''
 						}
@@ -131,7 +135,6 @@
 					p: { // 查询参数  
 						id: '', // 主键 
 						no: '', // 编号 
-						isCar: 1,
 						adminConfirmInput: -1,
 						carNo: '', // 车牌号 
 						outDayTime: '', // 离境时间 
@@ -149,11 +152,19 @@
 					}
 				},
 				methods: {
-					businessFn(data){
-						sa.showIframe('绑定车辆', '../tb-business-car/tb-business-car-business.html?id=' + data.id+'&businessCarId='+data.businessCarId+'&carNo='+data.carNo, '90%',"90%");
+					businessFn(data) {
+						sa.ajaxNoLoading('/TbBusinessCar/getOtherBusinessCarByBusinessId', {
+							businessId: data.id
+						}, function(resp) {
+							let list = resp.data;
+							let str = list.map(car => car.carNo).join('、');
+							let businessCarIds=list.map(car => car.id).join(',');
+							sa.showIframe('绑定车辆', 'tb-business-car-business.html?id=' + data.id +
+								'&businessCarId=' + data.businessCarId + '&carNo=' + str+'&businessCarIds='+businessCarIds, '90%', "90%");
+						}.bind(this))
 					},
-					handlerPay(data){
-						sa.showIframe('人工收费', 'tb-car-disincle-pay.html?id=' + data.id, '1050px', '90%');
+					handlerPay(data) {
+						sa.showIframe('线下收费', 'tb-car-disincle-pay.html?id=' + data.id, '1050px', '95%');
 					},
 					getCurrendCustomer() {
 						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
@@ -182,20 +193,20 @@
 							data.items = resp.data;
 							Object.assign(this.confirm, {
 								visible: true,
-								title:'账单确认',
+								title: '账单确认',
 								form: data,
 							})
 							this.confirm.form.ids = data.id;
 						}.bind(this));
 					},
-					checkConfirmFn(data){
+					checkConfirmFn(data) {
 						sa.ajax('/TbBusinessItem/getList', {
 							businessId: data.id
 						}, function(resp) {
 							data.items = resp.data;
 							Object.assign(this.confirm, {
 								visible: true,
-								title:'查看账单',
+								title: '查看账单',
 								form: data,
 							})
 						}.bind(this));
@@ -203,11 +214,13 @@
 					// 删除
 					del: function(data) {
 						sa.confirm('是否删除,此操作不可撤销', function() {
-							sa.ajax('/TbBusiness/deleteOtherBusiness?id=' + data.id+'&businessCarId='+data.businessCarId, function(res) {
-								sa.arrayDelete(this.dataList, data);
-								sa.ok('删除成功');
-								sa.f5TableHeight(); // 刷新表格高度 
-							}.bind(this))
+							sa.ajax('/TbBusiness/deleteOtherBusiness?id=' + data.id + '&businessCarId=' +
+								data.businessCarId,
+								function(res) {
+									sa.arrayDelete(this.dataList, data);
+									sa.ok('删除成功');
+									sa.f5TableHeight(); // 刷新表格高度 
+								}.bind(this))
 						}.bind(this));
 					},
 					sureConfirmFn() {
@@ -220,7 +233,7 @@
 					},
 					// 刷新
 					f5: function() {
-						sa.ajaxNoLoading('/TbBusiness/getCarDisincleList', sa.removeNull(this.p), function(res) {
+						sa.ajaxNoLoading('/TbBusiness/getOtherBusiness', sa.removeNull(this.p), function(res) {
 							this.dataList = res.data; // 数据
 							this.dataCount = res.dataCount; // 数据总数 
 							sa.f5TableHeight(); // 刷新表格高度 

+ 18 - 20
sp-admin/sa-view/tb-business/tb-car-disincle-pay.html

@@ -35,27 +35,29 @@
 										<sa-info name="客户名称" br v-if="m.customerName">{{m.customerName}}
 										</sa-info>
 										<sa-info name="业务编号" br>{{m.no}}</sa-info>
+										<sa-info name="业务项" br>{{m.goodsName}}</sa-info>
 										<sa-info name="作业时间" br>{{m.operateTime}}</sa-info>
 									</el-col>
 									<el-col span="12">
 										<sa-info type="enum" name="支付状态" :value="m.payStatus"
 											:jv="{1: '未支付', 2: '已支付未确认', 3: '已支付已确认'}" br></sa-info>
+										<sa-info name="支付时间" br>{{m.payTime}}</sa-info>
 										<sa-info name="录入时间" br>{{m.createTime}}</sa-info>
-
 										<sa-info name="业务费用" br>{{m.itemPrice}}(元)</sa-info>
 									</el-col>
 								</el-row>
 								<el-row v-for="(item,index) in tableData">
+									<el-divider content-position="left"><label style="font-weight: bold;">收费项:{{item.itemTypeName}}</label></el-divider>
 									<el-col span="12">
-										<sa-info name="业务分类" br>{{item.itemTypeName}}</sa-info>
+										<sa-info name="收费明细" br>{{item.itemName}}</sa-info>
 									</el-col>
 									<el-col span="12">
-										<sa-info name="业务明细" br>{{item.itemName}}</sa-info>
+										<sa-info name="计价" br>{{item.itemPrice}}/{{item.unit}}</sa-info>
 									</el-col>
 								</el-row>
 								<el-row v-for="(item,index) in m.cars">
+									<el-divider content-position="left" ><label style="font-weight: bold;">车牌号:{{item.carNo}}</label></el-divider>
 									<el-col span="12">
-										<sa-info name="车牌号" br>{{item.carNo}}</sa-info>
 										<div class="c-item">
 											<label class="c-label">入场时间:</label>
 											<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
@@ -68,7 +70,6 @@
 										</div>
 									</el-col>
 									<el-col span="12">
-										<sa-info name="车牌颜色" br>{{item.color}}</sa-info>
 										<sa-item name="入场通道" placeholder="请输入入场通道" v-model="item.inChannel" br>
 										</sa-item>
 										<sa-item name="离场通道" placeholder="请输入离场通道" v-model="item.outChannel" br>
@@ -117,28 +118,25 @@
 				},
 				methods: {
 					confirmFn() {
-						let m=this.m;
-						let car=m.cars[0];
-						let obj={
-							id:m.id,
-							inChannel:car.inChannel,
-							outChannel:car.outChannel,
-							realInTime:car.realInTime,
-							realOutTime:car.realOutTime,
-							remark:m.remark
+						let m = this.m;
+						let cars = m.cars;
+						let obj = {
+							id: m.id,
+							cars:JSON.stringify(cars),
+							remark: m.remark
 						}
 						sa.confirm('是否确认该业务已线下收费?', function() {
-							sa.ajax('/TbBusiness/manualConfirm',obj, function(res) {
+							sa.ajax('/TbBusiness/manualConfirm', obj, function(res) {
 								parent.app.f5(); // 刷新父页面列表
 								sa.closeCurrIframe(); // 关闭本页 
-								}.bind(this))
+							}.bind(this))
 						}.bind(this));
 					},
 					getInfo() {
-						sa.ajax('/TbBusiness/getById?id=' + this.id, function(res) {
-							let data=res.data;
-							data.remark='线下收费'
-							this.m=data;
+						sa.ajax('/TbBusiness/getOtherBusinessById?id=' + this.id, function(res) {
+							let data = res.data;
+							data.remark = '线下收费'
+							this.m = data;
 							this.tableData = res.data.items;
 						}.bind(this))
 					}

+ 48 - 28
sp-admin/sa-view/tb-goods/tb-goods-add.html

@@ -3,7 +3,8 @@
 	<head>
 		<title>商品管理-添加/修改</title>
 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+		<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">
@@ -14,8 +15,14 @@
 		<script src="../../static/kj/layer/layer.js"></script>
 		<script src="../../static/sa.js"></script>
 		<style type="text/css">
-			.c-panel .el-form .c-label{width: 7em !important;}
-			.c-panel .el-form .el-input, .c-panel .el-form .el-textarea__inner{width: 250px;}
+			.c-panel .el-form .c-label {
+				width: 7em !important;
+			}
+
+			.c-panel .el-form .el-input,
+			.c-panel .el-form .el-textarea__inner {
+				width: 250px;
+			}
 		</style>
 	</head>
 	<body>
@@ -23,10 +30,17 @@
 			<!-- ------- 内容部分 ------- -->
 			<div class="s-body">
 				<div class="c-panel">
-                    <div class="c-title" v-if="id == 0">数据添加</div>
+					<div class="c-title" v-if="id == 0">数据添加</div>
 					<div class="c-title" v-else>数据修改</div>
 					<el-form v-if="m">
 						<sa-item type="text" name="业务名称" v-model="m.name" br></sa-item>
+						<div class="c-item">
+							<label class="c-label">付款步骤:</label>
+							<el-select v-model="m.payStep" placeholder="请选择">
+								<el-option :label="item.name" :value="item.id" v-for="(item,index) in stepList">
+								</el-option>
+							</el-select>
+						</div>
 						<!-- <sa-item type="enum" name="状态" v-model="m.status" :jv="{1: '禁用', 2: '启用'}" jtype="3" br></sa-item> -->
 						<sa-item name="" class="s-ok" br>
 							<el-button type="primary" icon="el-icon-plus" @click="ok()">保存</el-button>
@@ -40,69 +54,75 @@
 				<el-button @click="sa.closeCurrIframe()">取消</el-button>
 			</div>
 		</div>
-        <script>
-			
+		<script>
 			var app = new Vue({
 				components: {
 					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue')
 				},
 				el: '.vue-box',
 				data: {
-					id: sa.p('id', 0),		// 获取超链接中的id参数(0=添加,非0=修改) 
-					m: null,		// 实体对象 
+					id: sa.p('id', 0), // 获取超链接中的id参数(0=添加,非0=修改) 
+					m: null, // 实体对象 
+					stepList:[]
 				},
 				methods: {
+					getPayStep(){
+						sa.ajaxNoLoading('/TbGoods/getPayStep',function(resp){
+							this.stepList=resp.data;
+						}.bind(this))
+					},
 					// 创建一个 默认Model 
 					createModel: function() {
 						return {
-							id: '',		// 主键 
-							code: '',		// 编号 
-							name: '',		// 名称 
-							status: '2',		// 状态(1=禁用,2=启用) 
-							businessType: 1,		// 创建时间 
+							id: '', // 主键 
+							code: '', // 编号 
+							name: '', // 名称 
+							status: '2', // 状态(1=禁用,2=启用) 
+							businessType: 1, // 创建时间 
 						}
 					},
 					// 提交数据 
-					ok: function(){
+					ok: function() {
 						// 表单校验 
 						let m = this.m;
+						m.businessType=1;
 						sa.checkNull(m.name, '请输入 [名称]');
 						// 开始增加或修改
-						if(this.id <= 0) {	// 添加
-							sa.ajax('/TbGoods/add', m, function(res){
-								sa.alert('增加成功', this.clean); 
+						if (this.id <= 0) { // 添加
+							sa.ajax('/TbGoods/add', m, function(res) {
+								sa.alert('增加成功', this.clean);
 							}.bind(this));
-						} else {	// 修改
-							sa.ajax('/TbGoods/update', m, function(res){
+						} else { // 修改
+							sa.ajax('/TbGoods/update', m, function(res) {
 								sa.alert('修改成功', this.clean);
 							}.bind(this));
 						}
 					},
 					// 添加/修改 完成后的动作
 					clean: function() {
-						if(this.id == 0) {
+						if (this.id == 0) {
 							this.m = this.createModel();
 						} else {
-							parent.app.f5();		// 刷新父页面列表
-							sa.closeCurrIframe();	// 关闭本页 
+							parent.app.f5(); // 刷新父页面列表
+							sa.closeCurrIframe(); // 关闭本页 
 						}
 					}
 				},
-				mounted: function(){
+				mounted: function() {
+					this.getPayStep();
 					// 初始化数据 
-					if(this.id <= 0) {	
+					if (this.id <= 0) {
 						this.m = this.createModel();
-					} else {	
+					} else {
 						sa.ajax('/TbGoods/getById?id=' + this.id, function(res) {
 							this.m = res.data;
-							if(res.data == null) {
+							if (res.data == null) {
 								sa.alert('未能查找到 id=' + this.id + " 详细数据");
 							}
 						}.bind(this))
 					}
 				}
 			})
-			
 		</script>
 	</body>
-</html>
+</html>

+ 47 - 15
sp-admin/sa-view/tb-goods/tb-goods-list.html

@@ -33,18 +33,37 @@
 					<el-table-column type="index" width="50">
 					</el-table-column>
 					<sa-td name="业务名称" prop="name"></sa-td>
-					<sa-td name="载重" prop="needWeight" type="switch" :jv="{0: '非必填[#005500]', 1: '必填[#ff0000]'}"
-						@change="s => updateNeedWeight(s.row)"></sa-td>
-					<sa-td name="规格" prop="needCarSize" type="switch" :jv="{0: '非必填[#005500]', 1: '必填[#ff0000]'}"
-						@change="s => updateNeedCarSize(s.row)"></sa-td>
-					<sa-td name="申报单" prop="needDeclare" type="switch" :jv="{0: '非必填[#005500]', 1: '必填[#ff0000]'}"
-						@change="s => updateNeedDeclare(s.row)"></sa-td>
-					<sa-td name="作业时间" prop="needOperateTime" type="switch" :jv="{0: '非必填[#005500]', 1: '必填[#ff0000]'}"
-						@change="s => updateNeedOperateTime(s.row)"></sa-td>
-					<sa-td name="中国车" prop="chinaCarPay" type="switch" :jv="{0: '免费[#005500]', 1: '收费[#ff0000]'}"
-						@change="s => updateChinaCarPay(s.row)"></sa-td>
-					<sa-td name="越南车" prop="vietnamCarPay" type="switch" :jv="{0: '免费[#005500]', 1: '收费[#ff0000]'}"
-						@change="s => updateVietnamCarPay(s.row)"></sa-td>
+					<sa-td name="付款步骤" prop="payStep" type="enum" :jv="{1: '下单后', 2: '确认后'}" width="80"></sa-td>
+					<sa-td name="载重" prop="needWeight" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
+						@change="s => updateNeedWeight(s.row)" width="90"></sa-td>
+					<sa-td name="规格" prop="needCarSize" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
+						@change="s => updateNeedCarSize(s.row)" width="90"></sa-td>
+					<sa-td name="申报单" prop="needDeclare" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
+						@change="s => updateNeedDeclare(s.row)" width="90"></sa-td>
+					<sa-td name="作业时间" prop="needOperateTime" type="switch" :jv="{0: '选填[#005500]', 1: '必填[#ff0000]'}"
+						@change="s => updateNeedOperateTime(s.row)" width="90"></sa-td>
+					<sa-td name="中国车" prop="chinaCarPay" type="switch" :jv="{0: '免停车费[#005500]', 1: '收停车费[#ff0000]'}"
+						@change="s => updateChinaCarPay(s.row)" width="120"></sa-td>
+					<sa-td name="越南车" prop="vietnamCarPay" type="switch" :jv="{0: '免停车费[#005500]', 1: '收停车费[#ff0000]'}"
+						@change="s => updateVietnamCarPay(s.row)" width="120"></sa-td>
+					<el-table-column label="中国车离场限制" width="140">
+						<template slot-scope="s">
+							<el-select v-model="s.row.chinaCarLeave" @change="chinaLeaveChange(s.row)">
+								<el-option v-for="item in leaveSetting" :key="item.id" :value="item.id"
+									:label="item.name">
+								</el-option>
+							</el-select>
+						</template>
+					</el-table-column>
+					<el-table-column label="越南车离场限制" width="140">
+						<template slot-scope="s">
+							<el-select v-model="s.row.vietnamCarLeave" @change="vietnamLeaveChange(s.row)">
+								<el-option v-for="item in leaveSetting" :key="item.id" :value="item.id"
+									:label="item.name">
+								</el-option>
+							</el-select>
+						</template>
+					</el-table-column>
 					<sa-td name="创建时间" prop="createTime" width="160"></sa-td>
 					<el-table-column label="操作" fixed="right" width="230">
 						<template slot-scope="s">
@@ -74,7 +93,6 @@
 				el: '.vue-box',
 				data: {
 					p: { // 查询参数  
-						businessType: 1, // 编号 
 						name: '', // 名称 
 						pageNo: 1, // 当前页 
 						pageSize: 10, // 页大小 
@@ -82,6 +100,7 @@
 					},
 					dataCount: 0,
 					dataList: [], // 数据集合 
+					leaveSetting: []
 				},
 				methods: {
 					businessFn(data) {
@@ -96,6 +115,17 @@
 							sa.f5TableHeight(); // 刷新表格高度 
 						}.bind(this));
 					},
+					getLeaveSetting: function() {
+						sa.ajax('/TbGoods/getLeaveSetting', function(res) {
+							this.leaveSetting = res.data; // 数据
+						}.bind(this));
+					},
+					chinaLeaveChange(v) {
+						console.log(v)
+					},
+					vietnamLeaveChange(v) {
+						console.log(v)
+					},
 					// 查看
 					get: function(data) {
 						sa.showIframe('数据详情', 'tb-goods-info.html?id=' + data.id, '1050px', '90%');
@@ -108,13 +138,14 @@
 						}
 						this.get(selection[0]);
 					},
+
 					// 修改
 					update: function(data) {
-						sa.showIframe('修改数据', 'tb-goods-add.html?id=' + data.id, '450px', '30%');
+						sa.showIframe('修改数据', 'tb-goods-add.html?id=' + data.id, '450px', '50%');
 					},
 					// 新增
 					add: function(data) {
-						sa.showIframe('新增数据', 'tb-goods-add.html?id=-1', '450px', '30%');
+						sa.showIframe('新增数据', 'tb-goods-add.html?id=-1', '450px', '50%');
 					},
 					// 删除
 					del: function(data) {
@@ -281,6 +312,7 @@
 				},
 				created: function() {
 					this.f5();
+					this.getLeaveSetting();
 					sa.onInputEnter();
 				}
 			})

+ 2 - 16
sp-admin/sa-view/tb-item-type/tb-item-type-add.html

@@ -40,13 +40,6 @@
 						<sa-item type="text" name="项目名称" v-model="m.name" placeholder="请输入项目名称" br>
 						</sa-item>
 						<div class="c-item">
-							<label class="c-label">付款步骤:</label>
-							<el-select  v-model="m.payStep" placeholder="请选择">
-								<el-option :label="item.name" :value="item.id" v-for="(item,index) in stepList">
-								</el-option>
-							</el-select>
-						</div>
-						<div class="c-item">
 							<label class="c-label">排序:</label>
 							<el-input-number class="item-num" v-model="m.sort" :step="1" :min="1" step-strictly>
 							</el-input-number>
@@ -84,19 +77,12 @@
 					stepList:[]
 				},
 				methods: {
-					getPayStep(){
-						sa.ajax('/TbItemType/getPayStep',function(resp){
-							this.stepList=resp.data;
-						}.bind(this))
-					},
+				
 					// 提交数据 
 					ok: function() {
 						// 表单校验 
 						let m = this.m;
 						sa.checkNull(m.name, '请输入 [项目名称]');
-						// sa.checkNull(m.code, '请输入 [项目编号]');
-						sa.checkNull(this.businessType, '请选择 [项目分类]');
-						m.businessType=this.businessType.join(',');
 						// 开始增加或修改
 						if (this.id <= 0) { // 添加
 							sa.ajax('/TbItemType/add', m, function(res) {
@@ -117,7 +103,7 @@
 					},
 				},
 				mounted: function() {
-					this.getPayStep();
+				
 					// 初始化数据 
 					if (this.id <= 0) {} else {
 						sa.ajax('/TbItemType/getById?id=' + this.id, function(res) {

+ 0 - 1
sp-admin/sa-view/tb-item-type/tb-item-type-list.html

@@ -32,7 +32,6 @@
 				<el-table class="data-table" ref="data-table" :data="dataList">
 					<el-table-column type="index" width="50"></el-table-column>
 					<sa-td name="项目名称" prop="name" ></sa-td>
-					<sa-td name="付款步骤" prop="payStep" type="enum" :jv="{1: '下单后', 2: '确认后'}"></sa-td>
 					<sa-td name="排序" prop="sort"></sa-td>
 					<el-table-column label="操作" fixed="right" width="260px">
 						<template slot-scope="s">

+ 0 - 23
sp-server/src/main/java/com/pj/api/h5/ApiController.java

@@ -206,31 +206,8 @@ public class ApiController {
         return AjaxJson.getSuccessData(type);
     }
 
-    @RequestMapping(value = "addCarDisinfect")
-    public AjaxJson addCarDisinfect(@RequestBody OtherBusinessBO otherBusinessBO) {
-        apiService.addCarDisinfect(otherBusinessBO);
-        return AjaxJson.getSuccess();
-    }
 
-    @RequestMapping(value = "editCarDisinfect")
-    public AjaxJson editCarDisinfect(@RequestBody OtherBusinessBO otherBusinessBO) {
-        apiService.editOtherBusiness(otherBusinessBO);
-        return AjaxJson.getSuccess();
-    }
 
-    @RequestMapping("addOtherBusiness")
-    public AjaxJson addOtherBusiness(OtherBusinessBO otherBusinessBO) {
-        otherBusinessBO.setItems(JSONUtil.toList(otherBusinessBO.getItemJson(), TbItem.class));
-        apiService.addCarDisinfect(otherBusinessBO);
-        return AjaxJson.getSuccess();
-    }
-
-    @RequestMapping("editOtherBusiness")
-    public AjaxJson editOtherBusiness(OtherBusinessBO otherBusinessBO) {
-        otherBusinessBO.setItems(JSONUtil.toList(otherBusinessBO.getItemJson(), TbItem.class));
-        apiService.editOtherBusiness(otherBusinessBO);
-        return AjaxJson.getSuccess();
-    }
 
 
 }

+ 16 - 7
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -34,6 +34,7 @@ import com.pj.utils.cache.RedisUtil;
 import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import sun.misc.BASE64Decoder;
@@ -73,8 +74,7 @@ public class OpenService {
     TaskService taskService;
     @Resource
     TbCarNoColorService tbCarNoColorService;
-    @Resource
-    private TbBusinessPeopleService tbBusinessPeopleService;
+
 
     private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
 
@@ -102,7 +102,7 @@ public class OpenService {
         TbCar tbCar = tbCarService.findByCardNo(carNo);
         if (tbBusinessCar == null
                 || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() != null)
-                || tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() == null
+                || (tbBusinessCar.getRealInTime() != null && tbBusinessCar.getRealOutTime() == null)
                 || tbBusinessCar.getPay() == 1) {
             tbBusinessCar = new TbBusinessCar();
             tbBusinessCar.setCarNo(carNo).setPay(0).setCarSize(0D).setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时")
@@ -244,17 +244,26 @@ public class OpenService {
     }
 
 
+    @Async
     public void handlerInRecord(InRecordBO inRecordBO) {
+        List<TbCarNoColor> carNoColorList = tbCarNoColorService.getFreeColor();
+        String freeColors = carNoColorList.stream().map(TbCarNoColor::getCarNoColor).collect(Collectors.joining(","));
         String carNo = inRecordBO.getCarNumber().trim().toUpperCase();
         // 入场==>取车牌颜色
         List<TbBusinessCar> cars = tbBusinessCarService.findByCarNo(carNo);
         cars.stream().filter(obj -> StrUtil.isEmpty(obj.getColor()))
                 .forEach(tbBusinessCar -> {
-                    tbBusinessCar.setColor(inRecordBO.getCarColor());
+                    String color = inRecordBO.getCarColor();
+                    String prefixColor = StrUtil.sub(color, 0, 1);
+                    if (StrUtil.contains(freeColors, prefixColor)) {
+                        tbBusinessCar.setPayType(TbBusinessCar.PayTypeEnum.FEE_TYPE.getType());
+                    }
+                    TbCar tbCar = tbCarService.findByCardNo(tbBusinessCar.getCarNo());
+                    if (tbCar != null && !TbCar.CarTypeEnum.BUSINESS_CAR.getType().equals(tbCar.getCarType())) {
+                        tbBusinessCar.setPayType(TbBusinessCar.PayTypeEnum.FEE_TYPE.getType());
+                    }
+                    tbBusinessCar.setColor(color);
                     tbBusinessCarService.updateById(tbBusinessCar);
                 });
-        if (cars.isEmpty()) {
-            //handlerIn(carNo, inRecordBO.getChannelName(), null);
-        }
     }
 }

+ 29 - 162
sp-server/src/main/java/com/pj/api/service/ApiService.java

@@ -41,6 +41,8 @@ import com.pj.project.tb_disinfect.TbDisinfect;
 import com.pj.project.tb_disinfect.TbDisinfectService;
 import com.pj.project.tb_district.TbDistrict;
 import com.pj.project.tb_district.TbDistrictService;
+import com.pj.project.tb_goods.TbGoods;
+import com.pj.project.tb_goods.TbGoodsService;
 import com.pj.project.tb_item.TbItem;
 import com.pj.project.tb_item_type.TbItemType;
 import com.pj.project.tb_item_type.TbItemTypeService;
@@ -113,6 +115,9 @@ public class ApiService {
     private TbItemTypeService tbItemTypeService;
 
     @Resource
+    private TbGoodsService tbGoodsService;
+
+    @Resource
     private TbBusinessSortService tbBusinessSortService;
 
     private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
@@ -147,7 +152,25 @@ public class ApiService {
         if (StrUtil.isEmpty(carNo) || StrUtil.length(carNo) < 3) {
             return new HashSet<>();
         }
-        List<TbBusinessCar> list = tbBusinessCarService.searchPartCar(carNo);
+        Set<TbBusinessCar> set = new HashSet<>();
+        //查询出未缴费的车辆
+        List<TbBusinessCar> list = tbBusinessCarService.searchNoPayCar(carNo);
+        for (TbBusinessCar businessCar : list) {
+            String businessCarId = businessCar.getId();
+            List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(businessCarId);
+            for (TbBusiness tbBusiness : businessList) {
+                Integer payStep = tbBusiness.getPayStep();
+                //确认之后才可以缴费
+                if (TbGoods.PayStep.AFTER_CONFIRM.getCode().equals(payStep)&&tbBusiness.getAdminConfirmInput()==1){
+                    set.add(businessCar);
+                    break;
+                }
+            }
+            set.add(businessCar);
+
+        }
+
+
         list = list.stream().filter(tbBusinessCar -> {
             String businessId = tbBusinessCar.getBusinessId();
             if (StrUtil.isEmpty(businessId)) {
@@ -162,8 +185,8 @@ public class ApiService {
             String businessCarId = tbBusinessCar.getId();
             List<TbBusiness> businesses = tbBusinessService.findOtherBusinessByCarId(businessCarId);
             return businesses.stream().anyMatch(tbBusiness -> tbBusiness.getPayMoney().doubleValue() < tbBusiness.getTotalMoney().doubleValue()
-                    && (((TbItemType.PayStep.BEFORE_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() >= 0)
-                    || (TbItemType.PayStep.AFTER_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() == 1))
+                    && (((TbGoods.PayStep.BEFORE_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() >= 0)
+                    || (TbGoods.PayStep.AFTER_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() == 1))
             ));
         }).collect(Collectors.toList());
 
@@ -298,169 +321,12 @@ public class ApiService {
         List<TbBusinessItem> list = tbBusinessItemService.getList(startPage);
         list.parallelStream().forEach(tbBusinessItem -> {
             TbBusiness tbBusiness = tbBusinessService.getById(tbBusinessItem.getBusinessId());
-            if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(tbBusiness.getBusinessType())) {
-                TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(tbBusiness.getBusinessCarId());
-                tbBusinessItem.setCardNo(tbBusinessCar.getCarNo());
-            } else {
-                List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(tbBusiness.getId());
-                String carStr = cars.stream().map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
-                tbBusinessItem.setCardNo(carStr);
-            }
+            List<TbBusinessCar> businessCars = tbBusinessCarService.findOtherBusinessCar(tbBusiness.getId());
+            tbBusinessItem.setCardNo(businessCars.stream().map(TbBusinessCar::getCarNo).collect(Collectors.joining("、")));
         });
         return list;
     }
 
-    public void addCarDisinfect(OtherBusinessBO otherBusinessBO) {
-        List<TbItem> tbItems = otherBusinessBO.getItems();
-        if (tbItems.isEmpty()) {
-            throw new BusinessException("请选择明细");
-        }
-        String carNo = otherBusinessBO.getCarNo().trim().toUpperCase();
-        checkOtherBusiness(otherBusinessBO, tbItems, carNo);
-        TbBusinessCar db = tbBusinessCarService.findNotOutCar(carNo);
-        String customerId = otherBusinessBO.getCustomerId();
-        TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
-        TbCar tbCar = tbCarService.findByCardNo(carNo);
-        if (db == null) {
-            db = tbBusinessCarService.findNotInCar(carNo);
-            if (db == null) {
-                db = new TbBusinessCar();
-            }
-        } else {
-            db.setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode());
-            tbBusinessCarService.updateById(db);
-        }
-        db.setPay(0).setCarNo(carNo).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
-                .setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
-                .setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
-        db.setCarSize(otherBusinessBO.getCarSize()).setTimeUpdate(new Date()).setCustomerId(customerId)
-                .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
-        tbBusinessCarService.saveOrUpdate(db);
-        TbBusiness tbBusiness = new TbBusiness();
-        tbBusiness.setCreateBy(StpUserUtil.getAdmin().getName());
-        tbBusiness.setBusinessCarId(db.getId()).setPayStep(tbItemType.getPayStep());
-        TbCostomer tbCostomer = tbCostomerService.getById(customerId);
-        if (tbCostomer != null) {
-            tbBusiness.setCustomerId(customerId).setCustomerName(tbCostomer.getName());
-        }
-        BigDecimal price = new BigDecimal("0");
-        List<TbBusinessItem> itemList = new ArrayList<>();
-        String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
-        int index = 1;
-        for (TbItem tbItem : tbItems) {
-            TbBusinessItem item = new TbBusinessItem();
-            int num = tbItem.getNum();
-            RelationTypeItem relationTypeItem = relationTypeItemService.findByTypeIdAndItemId(otherBusinessBO.getItemTypeId(), tbItem.getId());
-            BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
-            item.setNo(no + "0" + index).setPayTypeName(tbItem.getPayTypeName()).setPayType(tbItem.getPayType())
-                    .setBusinessType(tbItem.getBusinessType()).setTaxRate(NumberUtil.div(tbItem.getTaxRate().doubleValue(), 100D, 2));
-            item.setItemCode(tbItem.getItemCode()).setNum(num + "").setItemId(tbItem.getId()).setItemCode(tbItem.getItemCode())
-                    .setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice()).setRemark(tbItem.getRemark())
-                    .setItemTypeId(otherBusinessBO.getItemTypeId()).setItemTypeName(relationTypeItem.getTypeName())
-                    .setUnit(tbItem.getUnit()).setTotal(itemTotalPrice).setCreateTime(new Date());
-            price = price.add(itemTotalPrice);
-            itemList.add(item);
-            index++;
-        }
-        tbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getCarWeight())
-                .setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
-                .setNo(no).setGoodsName(otherBusinessBO.getCarType()).setItemTypeId(otherBusinessBO.getItemTypeId())
-                .setCreateTime(new Date()).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
-                .setItemTypeName(tbItemType.getName())
-                .setItemPrice(price).setTotalMoney(price);
-        String prefix = carNo.substring(0, 1);
-        if (CAR_LIST.contains(prefix)) {
-            tbBusiness.setChinaCarNo(carNo);
-        } else {
-            tbBusiness.setCardNo(carNo);
-        }
-        tbBusinessService.save(tbBusiness);
-        itemList.forEach(tbBusinessItem -> tbBusinessItem.setBusinessId(tbBusiness.getId()));
-        tbBusinessItemService.saveBatch(itemList);
-    }
-
-    @Deprecated
-    public void editCarDisinfect(CarDisincle carDisincle, String itemJson, String type) {
-        String carId = carDisincle.getBusinessCarId();
-        TbBusinessCar businessCar = tbBusinessCarService.getById(carId);
-        if (businessCar == null) {
-            throw new BusinessException("数据不存在");
-        }
-        List<TbItem> tbItems = JSONUtil.toList(itemJson, TbItem.class);
-
-    }
-
-    public void editOtherBusiness(OtherBusinessBO otherBusinessBO) {
-        List<TbItem> tbItems = otherBusinessBO.getItems();
-        if (tbItems.isEmpty()) {
-            throw new BusinessException("请选择明细");
-        }
-        TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
-        String businessId = otherBusinessBO.getId();
-        tbBusinessItemService.removeByBusinessId(businessId);
-        String carNo = otherBusinessBO.getCarNo();
-        String customerId = otherBusinessBO.getCustomerId();
-        TbCostomer tbCostomer = tbCostomerService.getById(customerId);
-        TbBusiness tbBusiness = tbBusinessService.getById(businessId);
-        checkOtherBusiness(otherBusinessBO, tbItems, carNo);
-        tbBusiness.setOperateTime(otherBusinessBO.getOperateTime())
-                .setOperator(otherBusinessBO.getOperator())
-                .setPayStep(tbItemType.getPayStep()).setItemTypeName(tbItemType.getName())
-                .setCardSize(otherBusinessBO.getCarSize()).setItemTypeId(tbItemType.getId())
-                .setCustomerId(customerId).setNetWeight(otherBusinessBO.getCarWeight())
-                .setGoodsName(otherBusinessBO.getCarType())
-                .setCustomerName(tbCostomer.getName());
-        String prefix = carNo.substring(0, 1);
-        if (CAR_LIST.contains(prefix)) {
-            tbBusiness.setChinaCarNo(carNo);
-        } else {
-            tbBusiness.setCardNo(carNo);
-        }
-        String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
-        TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(tbBusiness.getBusinessCarId());
-        TbBusinessCar otherCar = tbBusinessCarService.searchOtherBusinessCarNotOut(carNo);
-        if (otherCar != null) {
-            List<TbBusiness> checkList = tbBusinessService.findOtherBusinessByCarId(tbBusiness.getBusinessCarId());
-            if (checkList.size() == 1) {
-                tbBusinessCarService.removeById(tbBusiness.getBusinessCarId());
-            }
-            tbBusiness.setBusinessCarId(otherCar.getId());
-        } else {
-            tbBusinessCar.setCarSize(otherBusinessBO.getCarSize()).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
-                    .setCustomerId(otherBusinessBO.getCustomerId()).setCarNo(carNo)
-                    .setTimeUpdate(new Date());
-            tbBusinessCarService.updateById(tbBusinessCar);
-        }
-
-        int index = 1;
-        BigDecimal price = new BigDecimal("0");
-        List<TbBusinessItem> itemList = new ArrayList<>();
-        for (TbItem tbItem : tbItems) {
-            TbBusinessItem item = new TbBusinessItem();
-            int num = tbItem.getNum();
-            RelationTypeItem relationTypeItem = relationTypeItemService.findByTypeIdAndItemId(otherBusinessBO.getItemTypeId(), tbItem.getId());
-            BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
-            item.setNo(no + "0" + index).setPayTypeName(tbItem.getPayTypeName())
-                    .setPayType(tbItem.getPayType())
-                    .setBusinessType(tbItem.getBusinessType())
-                    .setTaxRate(NumberUtil.div(tbItem.getTaxRate().doubleValue(), 100D, 2))
-                    .setItemCode(tbItem.getItemCode()).setNum(num + "")
-                    .setItemId(tbItem.getId()).setItemCode(tbItem.getItemCode())
-                    .setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice())
-                    .setRemark(tbItem.getRemark())
-                    .setItemTypeId(otherBusinessBO.getItemTypeId())
-                    .setItemTypeName(relationTypeItem.getTypeName()).setBusinessId(otherBusinessBO.getId())
-                    .setUnit(tbItem.getUnit()).setTotal(itemTotalPrice).setCreateTime(new Date());
-            price = price.add(itemTotalPrice);
-            itemList.add(item);
-            index++;
-        }
-        tbBusiness.setItemPrice(price);
-        tbBusinessItemService.saveBatch(itemList);
-        tbBusinessService.updateById(tbBusiness);
-
-
-    }
 
     private void checkOtherBusiness(OtherBusinessBO otherBusinessBO, List<TbItem> tbItems, String carNo) {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -507,4 +373,5 @@ public class ApiService {
         }
     }
 
+
 }

+ 21 - 24
sp-server/src/main/java/com/pj/api/wx/service/WxService.java

@@ -31,6 +31,8 @@ import com.pj.project.tb_costomer.TbCostomer;
 import com.pj.project.tb_costomer.TbCostomerService;
 import com.pj.project.tb_fee_details.TbFeeDetailsService;
 import com.pj.project.tb_fee_statistics.TbFeeStatisticsService;
+import com.pj.project.tb_goods.TbGoods;
+import com.pj.project.tb_goods.TbGoodsService;
 import com.pj.project.tb_order.TbOrder;
 import com.pj.project.tb_order.TbOrderService;
 import com.pj.project.tb_pay_record.TbPayRecord;
@@ -79,6 +81,8 @@ public class WxService {
     TbFeeDetailsService tbFeeDetailsService;
     @Resource
     private TbOrderService tbOrderService;
+    @Resource
+    private TbGoodsService tbGoodsService;
 
     private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
 
@@ -221,7 +225,7 @@ public class WxService {
         if (StrUtil.isNotEmpty(attachStr)) {
             Attach attach = JSONUtil.toBean(attachStr, Attach.class);
             List<PriceBO> cars = JSONUtil.toList(attach.getC(), PriceBO.class);
-            tbFeeStatisticsService.countParkFee(cars);//停车费统计
+            tbFeeStatisticsService.countParkFee(cars);//停车费统计
             for (PriceBO bo1 : cars) {
                 TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
                 BigDecimal price = bo1.getP();
@@ -241,40 +245,33 @@ public class WxService {
             tbFeeDetailsService.chargeParkFee(cars, transactionId, outTradeNo);//添加cars的收费明细
             String businessId = attach.getB();
             if (StrUtil.isNotEmpty(businessId)) {
-                List<TbBusinessItem> items;
-                List<TbBusiness> businessList = new ArrayList<>();
-                if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(tbOrder.getBusinessType())) {
-                    List<String> businessIds = StrUtil.splitTrim(businessId, ",");
-                    items = tbBusinessItemService.findByBusinessIdList(businessIds);
-                    businessList = tbBusinessService.listByIds(businessIds);
-                } else {
-                    items = tbBusinessItemService.findByBusinessId(businessId);
-                    TbBusiness tbBusiness = tbBusinessService.getById(businessId);
-                    businessList.add(tbBusiness);
-                    //整车越南车变成已支付=免费
-                    List<TbBusinessCar> carList = tbBusinessCarService.findByBusinessId(businessId);
+                List<String> businessIds = StrUtil.splitTrim(businessId, ",");
+                List<TbBusinessItem> items = tbBusinessItemService.findByBusinessIdList(businessIds);
+                List<TbBusiness> businessList = tbBusinessService.listByIds(businessIds);
+                for (TbBusiness tbBusiness : businessList) {
+                    tbBusiness.setPayTime(now).setPayType(3).setConfirmInput(1).setConfirmInputTime(now)
+                            .setPayMoney(tbBusiness.getPayMoney().add(tbBusiness.getItemPrice()))
+                            .setPayNo(transactionId);
+                    tbBusiness.setPayStatus(tbBusiness.getPayMoney().equals(tbBusiness.getTotalMoney()) ? 3 : 4);
+                    tbBusinessService.updateById(tbBusiness);
+                    TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
+                    List<TbBusinessCar> carList = tbBusinessCarService.findOtherBusinessCar(businessId);
                     carList.forEach(tbBusinessCar -> {
                         String carNo = tbBusinessCar.getCarNo();
                         String carNoStr = StrUtil.sub(carNo, 0, 1);
-                        if (!CAR_LIST.contains(carNoStr)) {
-                            tbBusinessCar.setPay(1).setPayTime(new Date());
+                        if (CAR_LIST.contains(carNoStr)&&tbGoods.getChinaCarPay()==1
+                                ||!CAR_LIST.contains(carNoStr)&&tbGoods.getVietnamCarPay()==1){
+                            tbBusinessCar.setPay(1).setPayTime(now);
                             tbBusinessCarService.updateById(tbBusinessCar);
                         }
                     });
                 }
-                tbFeeStatisticsService.countBusinessFee(items, transactionId, outTradeNo);//业务费统计
+                tbFeeStatisticsService.countBusinessFee(items, transactionId, outTradeNo);//业务费统计
                 items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setPayTime(now));
                 tbBusinessItemService.updateBatchById(items);
-                businessList.forEach(tbBusiness -> {
-                    tbBusiness.setPayTime(now).setPayType(3).setConfirmInput(1).setConfirmInputTime(now)
-                            .setPayMoney(tbBusiness.getPayMoney().add(tbBusiness.getItemPrice()))
-                            .setPayNo(transactionId);
-                    tbBusiness.setPayStatus(tbBusiness.getPayMoney().equals(tbBusiness.getTotalMoney()) ? 3 : 4);
-                    tbBusinessService.updateById(tbBusiness);
-                });
             }
             String a = attach.getA();
-            if (StrUtil.isNotEmpty(a)) {
+            if (StrUtil.isNotEmpty(a)) {//充值的======>
                 AccountChargeBO chargeBO = JSONUtil.toBean(a, AccountChargeBO.class);
                 tbAccountService.recharge(chargeBO.getId(), chargeBO.getC(), TbChargeRecord.Ch.WECHAT.getType(), money);
             }

+ 1 - 2
sp-server/src/main/java/com/pj/project/relation_business_car/RelationBusinessCar.java

@@ -37,8 +37,7 @@ public class RelationBusinessCar extends Model<RelationBusinessCar> implements S
 	/**
 	 *  
 	 */
-	@TableId(type = IdType.AUTO)
-	private Long id;	
+	private String id;
 
 	/**
 	 *  

+ 19 - 1
sp-server/src/main/java/com/pj/project/relation_business_car/RelationBusinessCarService.java

@@ -2,6 +2,7 @@ package com.pj.project.relation_business_car;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.project.tb_business.TbBusiness;
@@ -47,6 +48,23 @@ public class RelationBusinessCarService extends ServiceImpl<RelationBusinessCarM
 	List<RelationBusinessCar> getList(SoMap so) {
 		return relationBusinessCarMapper.getList(so);	
 	}
-	
 
+
+	public List<RelationBusinessCar> findByBusinessId(String businessId) {
+		QueryWrapper<RelationBusinessCar>ew=new QueryWrapper<>();
+		ew.eq("business_id",businessId);
+		return list(ew);
+	}
+
+    public void removeByBusinessId(String businessId) {
+        QueryWrapper<RelationBusinessCar>ew=new QueryWrapper<>();
+        ew.eq("business_id",businessId);
+        this.remove(ew);
+    }
+
+    public List<RelationBusinessCar> findByBusinessCarId(String businessCarId) {
+        QueryWrapper<RelationBusinessCar>ew=new QueryWrapper<>();
+        ew.eq("business_car_id",businessCarId);
+        return list(ew);
+    }
 }

+ 0 - 49
sp-server/src/main/java/com/pj/project/relation_business_car/RelationBusinessCarUtil.java

@@ -1,49 +0,0 @@
-package com.pj.project.relation_business_car;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.pj.utils.sg.*;
-
-/**
- * 工具类:relation_business_car -- 
- * @author qzy 
- *
- */
-@Component
-public class RelationBusinessCarUtil {
-
-	
-	/** 底层 Mapper 对象 */
-	public static RelationBusinessCarMapper relationBusinessCarMapper;
-	@Autowired
-	private void setRelationBusinessCarMapper(RelationBusinessCarMapper relationBusinessCarMapper) {
-		RelationBusinessCarUtil.relationBusinessCarMapper = relationBusinessCarMapper;
-	}
-	
-	
-	/** 
-	 * 将一个 RelationBusinessCar 对象进行进行数据完整性校验 (方便add/update等接口数据校验) [G] 
-	 */
-	static void check(RelationBusinessCar r) {
-		AjaxError.throwByIsNull(r.getId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(r.getBusinessId(), "[] 不能为空");		// 验证:  
-		AjaxError.throwByIsNull(r.getBusinessCarId(), "[] 不能为空");		// 验证:  
-	}
-
-	/** 
-	 * 获取一个RelationBusinessCar (方便复制代码用) [G] 
-	 */ 
-	static RelationBusinessCar getRelationBusinessCar() {
-		RelationBusinessCar r = new RelationBusinessCar();	// 声明对象 
-		r.setId(0L);		//  
-		r.setBusinessId("");		//  
-		r.setBusinessCarId("");		//  
-		return r;
-	}
-	
-	
-	
-	
-	
-}

+ 1 - 1
sp-server/src/main/java/com/pj/project/relation_goods_type/RelationGoodsType.java

@@ -43,7 +43,7 @@ public class RelationGoodsType extends Model<RelationGoodsType> implements Seria
 	/**
 	 *  
 	 */
-	private Long goodsId;	
+	private String goodsId;
 
 	/**
 	 * 作业类型 

+ 1 - 1
sp-server/src/main/java/com/pj/project/relation_goods_type/RelationGoodsTypeController.java

@@ -30,7 +30,7 @@ public class RelationGoodsTypeController {
 	@RequestMapping("saveBatch")
 	public AjaxJson saveBatch(){
 		SoMap so = SoMap.getRequestSoMap();
-		Long goodsId=so.getLong("goodsId");
+		String goodsId=so.getString("goodsId");
 		String typeIds=so.getString("typeIds");
 		relationGoodsTypeService.saveBatch(goodsId,typeIds);
 		return AjaxJson.getSuccess();

+ 2 - 2
sp-server/src/main/java/com/pj/project/relation_goods_type/RelationGoodsTypeService.java

@@ -53,13 +53,13 @@ public class RelationGoodsTypeService extends ServiceImpl<RelationGoodsTypeMappe
     }
 
 
-    public List<RelationGoodsType> findByGoodsId(Long goodsId) {
+    public List<RelationGoodsType> findByGoodsId(String goodsId) {
         QueryWrapper<RelationGoodsType> ew = new QueryWrapper<>();
         ew.eq("goods_id", goodsId);
         return list(ew);
     }
 
-    public void saveBatch(Long goodsId, String typeIds) {
+    public void saveBatch(String goodsId, String typeIds) {
         if (StrUtil.isEmpty(typeIds)) {
             throw new BusinessException("请选择业务类型");
         }

+ 32 - 0
sp-server/src/main/java/com/pj/project/tb_business/OtherBusinessBO.java

@@ -0,0 +1,32 @@
+package com.pj.project.tb_business;
+
+import com.pj.project.tb_business_car.TbBusinessCar;
+import com.pj.project.tb_item.TbItem;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+public class OtherBusinessBO implements Serializable {
+    private String id;
+    private String customerId;
+    private String customerName;
+    private String declareNo;
+    private String operator;
+    private String chinaCarNo;
+    private String cardNo;
+    private Double carSize;
+    private String operateTime;
+    private String goodsId;
+    private String carJson;
+    private String itemJson;
+    private Double netWeight;
+    private List<TbItem> items=new ArrayList<>();
+    private List<TbBusinessCar> cars=new ArrayList<>();
+
+}

+ 5 - 1
sp-server/src/main/java/com/pj/project/tb_business/TbBusiness.java

@@ -47,6 +47,9 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
     public static final String PERMISSION_PAY = "tb-business-pay";
     public static final String PERMISSION_INPUT = "tb-business-add";
     public static final String PERMISSION_MANUAL_PAY = "tb-flex-business-pay";
+    //其他业务
+    public static final String PERMISSION_FLAX_BUSINESS_ADD = "tb-flex-business-add";
+    public static final String PERMISSION_FLAX_BUSINESS_EDIT = "tb-flex-business-edit";
 
 
 
@@ -95,6 +98,7 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
      * 商品
      */
     private String goodsName;
+    private String goodsId;
 
     /**
      * 商品编号
@@ -228,7 +232,7 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
     private String operator;
     private String operateTime;
 
-    private String businessCarId;
+
 
     private String itemTypeName;
 

+ 52 - 21
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java

@@ -8,26 +8,20 @@ import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
-import com.pj.api.bo.OtherBusinessBO;
 import com.pj.constants.UserTypeEnum;
 import com.pj.project.tb_business_car.TbBusinessCar;
 import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_business_item.TbBusinessItem;
 import com.pj.project.tb_business_item.TbBusinessItemService;
-import com.pj.project.tb_declare.TbDeclare;
 import com.pj.project.tb_declare.TbDeclareService;
 import com.pj.project.tb_item.TbItem;
 import com.pj.project.tb_notices.TbNoticesService;
-import com.pj.project.tb_pass_record.TbPassRecord;
-import com.pj.project.tb_pass_record.TbPassRecordService;
 import com.pj.utils.so.SoMap;
-import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import com.pj.utils.sg.*;
-import com.pj.project4sp.SP;
 
 import com.pj.current.satoken.StpUserUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
@@ -163,12 +157,8 @@ 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 {
-            List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(id);
-            t.setCars(cars);
-        }
+        List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(id);
+        t.setCars(cars);
         return AjaxJson.getSuccessData(t);
     }
 
@@ -202,6 +192,21 @@ public class TbBusinessController {
     }
 
     /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getOtherBusiness")
+    public AjaxJson getOtherBusiness() {
+        SoMap so = SoMap.getRequestSoMap();
+        String currentCustomerId = StpUserUtil.getCustomerId();
+        if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
+            so.put("customerId", currentCustomerId);
+        }
+        so.put("businessType", TbBusiness.BusinessType.CAR_DISINCLE.getCode());
+        List<TbBusiness> list = tbBusinessService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
+
+    /**
      * 改
      */
     @RequestMapping("pay")
@@ -330,23 +335,49 @@ public class TbBusinessController {
         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 cars = so.getString("cars");
+        List<TbBusinessCar> carList = JSONUtil.toList(cars, TbBusinessCar.class);
+        tbBusinessService.manualConfirmPay(id, carList, remark);
         return AjaxJson.getSuccess();
     }
 
 
     @RequestMapping(value = "unBindCar")
     public AjaxJson unBindCar(String id, String businessCarId) {
-        tbBusinessService.unBindCar(id,businessCarId);
+        tbBusinessService.unBindCar(id, businessCarId);
+        return AjaxJson.getSuccess();
+    }
+
+
+
+
+    @RequestMapping(value = "addOtherBusiness")
+    @SaCheckPermission(value = TbBusiness.PERMISSION_FLAX_BUSINESS_ADD)
+    public AjaxJson addOtherBusiness(OtherBusinessBO otherBusinessBO) {
+        List<TbItem> items = JSONUtil.toList(otherBusinessBO.getItemJson(), TbItem.class);
+        List<TbBusinessCar> cars = JSONUtil.toList(otherBusinessBO.getCarJson(), TbBusinessCar.class);
+        otherBusinessBO.setItems(items).setCars(cars);
+        tbBusinessService.addOtherBusiness(otherBusinessBO);
+        return AjaxJson.getSuccess();
+    }
+
+    @RequestMapping(value = "editOtherBusiness")
+    @SaCheckPermission(value = TbBusiness.PERMISSION_FLAX_BUSINESS_EDIT)
+    public AjaxJson editOtherBusiness(OtherBusinessBO otherBusinessBO) {
+        List<TbItem> items = JSONUtil.toList(otherBusinessBO.getItemJson(), TbItem.class);
+        List<TbBusinessCar> cars = JSONUtil.toList(otherBusinessBO.getCarJson(), TbBusinessCar.class);
+        otherBusinessBO.setItems(items).setCars(cars);
+        tbBusinessService.editOtherBusiness(otherBusinessBO);
         return AjaxJson.getSuccess();
     }
-    @RequestMapping(value = "bindCar")
-    public AjaxJson bindCar(String id, String businessCarId) {
-        tbBusinessService.bindCar(id,businessCarId);
+
+    @RequestMapping(value = "bindOtherBusinessCar")
+    @SaCheckPermission(value = TbBusiness.PERMISSION_FLAX_BUSINESS_EDIT)
+    public AjaxJson bindOtherBusinessCar(OtherBusinessBO otherBusinessBO) {
+        SoMap soMap = SoMap.getRequestSoMap();
+        String businessId = soMap.getString("businessId");
+        String businessCarIds = soMap.getString("businessCarIds");
+        tbBusinessService.bindOtherBusinessCar(businessId, StrUtil.splitTrim(businessCarIds, ","));
         return AjaxJson.getSuccess();
     }
 

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

@@ -36,4 +36,8 @@ public interface TbBusinessMapper extends BaseMapper<TbBusiness> {
                                           @Param("timeEnd") String timeEnd,  @Param("businessId")String businessId);
 
     void unBindCar(String id);
+
+    List<TbBusiness> getOtherBusiness(SoMap soMap);
+
+    List<TbBusiness> findOtherBusinessByCarId(@Param("businessCarId")String businessCarId);
 }

+ 67 - 32
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessMapper.xml

@@ -34,6 +34,8 @@
             <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=' this.has("carNo") '>and (card_no like concat('%', #{carNo},'%') or china_car_no like concat('%', #{carNo},'%'))</if>
+            <if test='adminConfirmInput !=null and adminConfirmInput>-1'>and admin_confirm_input = #{adminConfirmInput}</if>
             <if test='isCar==0'>
                 and declare_no is not null
             </if>
@@ -74,18 +76,18 @@
         </choose>
     </select>
     <select id="getCarDisincleList" resultType="com.pj.project.tb_business.CarDisincle">
-		SELECT
-            a.id,
-            b.id as businessCarId,
-            a.`no`,a.operate_time,
-            a.item_price,a.goods_name,a.admin_confirm_input,b.car_no,
-            b.base_part_money,a.total_money,a.pay_money,a.create_time,
-            b.real_in_time,b.real_out_time,b.car_no ,a.net_weight,a.card_size,a.pay_status,a.item_type_name
+        SELECT
+        a.id,
+        b.id as businessCarId,
+        a.`no`,a.operate_time,
+        a.item_price,a.goods_name,a.admin_confirm_input,b.car_no,
+        b.base_part_money,a.total_money,a.pay_money,a.create_time,
+        b.real_in_time,b.real_out_time,b.car_no ,a.net_weight,a.card_size,a.pay_status,a.item_type_name
         from tb_business a,tb_business_car b
         WHERE a.business_car_id=b.id and (a.declare_no='' or a.declare_no is null)
-            <if test="cardNo !='' and cardNo !=null">
-                and b.car_no like concat('%',#{cardNo},'%')
-            </if>
+        <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>
@@ -102,40 +104,73 @@
             and b.car_no like concat ('%',#{carNo},'%')
         </if>
         ORDER BY a.create_time desc
-	</select>
+    </select>
     <select id="checkCarBusinessType" resultType="java.lang.Integer">
         SELECT
-	        count(a.id)
+        count(a.id)
         FROM
-            tb_business_car a,
-            tb_business b
+        tb_business_car a,
+        tb_business b
         WHERE
-            a.id = b.business_car_id
-            AND a.car_no =#{carNo}
-            and b.item_type_id=#{typeId}
-            <if test="before==1">
-                AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{operateTime}
-            </if>
+        a.id = b.business_car_id
+        AND a.car_no =#{carNo}
+        and b.item_type_id=#{typeId}
+        <if test="before==1">
+            AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{operateTime}
+        </if>
         <if test="before==0">
             AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{operateTime}
         </if>
     </select>
     <select id="checkCarBusinessTypeByTime" resultType="java.lang.Integer">
-          SELECT
-	        count(b.id)
+        SELECT
+        count(b.id)
         FROM
-            tb_business_car a,
-            tb_business b
+        tb_business_car a,
+        tb_business b
         WHERE
-            a.id = b.business_car_id
-            AND a.car_no =#{carNo}
-            and b.item_type_id=#{typeId}
-            AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{timeStart}
-            and DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{timeEnd}
-            <if test="businessId!=null and businessId !=''">
-                and b.id !=#{businessId}
-            </if>
+        a.id = b.business_car_id
+        AND a.car_no =#{carNo}
+        and b.item_type_id=#{typeId}
+        AND DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &gt; #{timeStart}
+        and DATE_FORMAT( b.operate_time, '%Y-%m-%d %H:%i:%s' ) &lt; #{timeEnd}
+        <if test="businessId!=null and businessId !=''">
+            and b.id !=#{businessId}
+        </if>
     </select>
 
 
+    <resultMap id="otherBusinessMap" type="com.pj.project.tb_business.TbBusiness">
+        <result property="id" column="id"/>
+        <result property="cardNo" column="card_no"/>
+        <result property="chinaCarNo" column="china_car_no"/>
+        <result property="no" column="no"/>
+        <result property="createTime" column="create_time"/>
+        <result property="customerName" column="customer_name"/>
+        <result property="goodsName" column="goods_name"/>
+        <result property="adminConfirmInput" column="admin_confirm_input"/>
+        <result property="itemPrice" column="item_price"/>
+        <result property="payMoney" column="pay_money"/>
+        <result property="operateTime" column="operate_time"/>
+        <collection property="items" ofType="com.pj.project.tb_item.TbItem" select="getItems" column="id"/>
+    </resultMap>
+    <select id="getOtherBusiness" resultType="com.pj.project.tb_business.TbBusiness">
+        select * from tb_business
+        <trim prefix="where" prefixOverrides="and||or">
+            <if test="customerId !=null and customerId !=''">
+                and customer_id=#{customerId}
+            </if>
+            <if test="carNo !=null and carNo !=''">
+                and (card_no like concat('%',#{carNo},'%') or china_car_no like concat('%',#{carNo},'%'))
+            </if>
+        </trim>
+        order by create_time desc
+    </select>
+    <select id="getItems" resultType="com.pj.project.tb_item.TbItem">
+        select * from tb_item where business_id=#{id}
+    </select>
+    <select id="findOtherBusinessByCarId" resultType="com.pj.project.tb_business.TbBusiness">
+        select a.* from tb_business a,relation_business_car b where  a.id=b.business_id and b.business_car_id=#{businessCarId}
+    </select>
+
 </mapper>

+ 366 - 124
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -1,16 +1,13 @@
 package com.pj.project.tb_business;
 
 import java.math.BigDecimal;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.LocalTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
@@ -19,9 +16,7 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.pj.api.bo.OtherBusinessBO;
 import com.pj.api.bo.OtherBusinessEditBO;
-import com.pj.api.open.ResultJson;
 import com.pj.api.wx.bo.MsgDataBO;
 import com.pj.api.wx.service.WxService;
 import com.pj.constants.UserTypeEnum;
@@ -30,6 +25,11 @@ import com.pj.current.config.MyConfig;
 import com.pj.current.config.PartConfig;
 import com.pj.current.config.WxConfig;
 import com.pj.current.satoken.StpUserUtil;
+import com.pj.project.relation_business_car.RelationBusinessCar;
+import com.pj.project.relation_business_car.RelationBusinessCarService;
+import com.pj.project.relation_goods_type.RelationGoodsTypeService;
+import com.pj.project.relation_type_item.RelationTypeItem;
+import com.pj.project.relation_type_item.RelationTypeItemService;
 import com.pj.project.tb_business_car.TbBusinessCar;
 import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_business_item.TbBusinessItem;
@@ -54,10 +54,7 @@ import com.pj.project.tb_item.TbItem;
 import com.pj.project.tb_item.TbItemService;
 import com.pj.project.tb_item_type.TbItemType;
 import com.pj.project.tb_item_type.TbItemTypeService;
-import com.pj.project.tb_notices.TbNoticesMapper;
 import com.pj.project.tb_notices.TbNoticesService;
-import com.pj.project.tb_pass_record.TbPassRecord;
-import com.pj.project.tb_pass_record.TbPassRecordService;
 import com.pj.project.tb_sort_group.TbSortGroup;
 import com.pj.project.tb_sort_group.TbSortGroupService;
 import com.pj.project.tb_unit.TbUnit;
@@ -65,13 +62,8 @@ import com.pj.project.tb_unit.TbUnitService;
 import com.pj.project4sp.admin.SpAdmin;
 import com.pj.project4sp.admin.SpAdminService;
 import com.pj.project4sp.global.BusinessException;
-import com.pj.project4sp.role.SpRoleUtil;
-import com.pj.project4sp.role4permission.SpRolePermissionService;
 import com.pj.utils.so.SoMap;
-import org.aspectj.weaver.loadtime.Aj;
-import org.omg.CORBA.OBJ_ADAPTER;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -87,7 +79,7 @@ import javax.annotation.Resource;
  * @author qzy
  */
 @Service
-@Transactional
+@Transactional(rollbackFor = Exception.class)
 public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness> implements IService<TbBusiness> {
 
     /**
@@ -144,6 +136,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     private TbBusinessSortService tbBusinessSortService;
     @Resource
     private TbSortGroupService tbSortGroupService;
+    @Resource
+    private TbGoodsService tbGoodsService;
+    @Resource
+    private RelationTypeItemService relationTypeItemService;
+    @Resource
+    private RelationBusinessCarService relationBusinessCarService;
 
 
     private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
@@ -326,7 +324,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
     public List<TbBusiness> getList(SoMap so) {
-
         return tbBusinessMapper.getList(so);
     }
 
@@ -356,10 +353,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     .setConfirmInputTime(new Date())
                     .setConfirmInputBy(StpUserUtil.getAdmin().getName());
             this.updateById(business);
-            List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(business.getId());
-            if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType())) {
-                cars = Collections.singletonList(tbBusinessCarService.getById(business.getBusinessCarId()));
-            }
+            List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(business.getId());
             String carNoStr = cars.stream().map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
             storeMsg(business.getCustomerId(), "业务订单【" + business.getNo() + "】已确认" + DateUtil.now() + "。");
             List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
@@ -497,41 +491,37 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     }
 
 
-    public Map<String, Object> getBusinessMoney(String carId, String state) {
+    public Map<String, Object> getBusinessMoney(String businessCarId, String state) {
         Map<String, Object> result = new HashMap<>();
-        TbBusinessCar car = tbBusinessCarService.getById(carId);
-        String businessId = car.getBusinessId();
-        Integer businessType = car.getBusinessType();
-        result.put("type", businessType);
-        result.put("showPay", true);
+        List<TbBusiness> businessList = this.findOtherBusinessByCarId(businessCarId);
         List<TbBusinessCar> cars = new ArrayList<>();
-        List<TbBusinessItem> items = new ArrayList<>();
-        cars.add(car);
-        //其他业务
-        String itemTypeId = "";
-        if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(businessType)) {
-            List<TbBusiness> businesses = this.findOtherBusinessByCarId(carId);
-            businesses = businesses.stream()
-                    .filter(tbBusiness -> tbBusiness.getPayMoney().doubleValue() < tbBusiness.getTotalMoney().doubleValue()
-                                    && ((TbItemType.PayStep.BEFORE_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() >= 0)
-                                    || (TbItemType.PayStep.AFTER_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() == 1)
-                            )
-                    )
-                    .collect(Collectors.toList());
-            List<String> businessIdList = businesses.stream().map(TbBusiness::getId).collect(Collectors.toList());
-            if (!businessIdList.isEmpty()) {
-                itemTypeId = businesses.get(0).getItemTypeId();
-                items = tbBusinessItemService.findByBusinessIdList(businessIdList);
-                businessId = String.join(",", businessIdList);
-            }
-        } else if (TbBusiness.BusinessType.HOLD_CAR.getCode().equals(businessType)) {
-            cars = tbBusinessCarService.findByBusinessId(businessId);
-            TbBusiness tbBusiness = this.getById(businessId);
-            if (tbBusiness.getPayStatus() != TbBusiness.PayStatus.HAS_PAY_CONFIRM.getCode()) {
-                items = tbBusinessItemService.findByBusinessId(businessId);
-            }
-        }
-        result.put("businessId", businessId);
+
+        //中国车是否需要支付
+        int vietnamCarPay = businessList.stream().anyMatch(tbBusiness -> {
+            TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
+            return tbGoods.getVietnamCarPay() == 1;
+        }) ? 1 : 0;
+        //越南车是否需要支付
+        int chinaCarPay = businessList.stream().anyMatch(tbBusiness -> {
+            TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
+            return tbGoods.getChinaCarPay() == 1;
+        }) ? 1 : 0;
+        //无业务的车辆
+        if (businessList.isEmpty()) {
+            vietnamCarPay = 1;
+            chinaCarPay = 1;
+            cars.add(tbBusinessCarService.getById(businessCarId));
+        }
+        businessList.forEach(tbBusiness -> {
+            List<TbBusinessCar> businessCars = tbBusinessCarService.findOtherBusinessCar(tbBusiness.getId());
+            cars.addAll(businessCars);
+        });
+        List<String> businessIdList = businessList.stream().map(TbBusiness::getId).collect(Collectors.toList());
+        String businessIds = StrUtil.join(",", businessIdList);
+//        result.put("type", businessType);
+        result.put("showPay", true);
+        result.put("businessId", businessIds);
+        List<TbBusinessItem> items = tbBusinessItemService.findByBusinessIdList(businessIdList);
         Date now = new Date();
         List<Map<String, Object>> carsList = new ArrayList<>();
         for (TbBusinessCar tbBusinessCar : cars) {
@@ -544,7 +534,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 }
                 partMoney = this.calculationPartMoney(inTime, now);
             }
-            if (StrUtil.isNotEmpty(tbBusinessCar.getColor())) {
+            if (StrUtil.isNotEmpty(tbBusinessCar.getColor())) {//蓝色车辆免费
                 List<TbCarNoColor> freeList = tbCarNoColorService.getFreeColor();
                 List<String> colorList = freeList.stream().map(f -> f.getCarNoColor().substring(0, 1)).collect(Collectors.toList());
                 String color = tbBusinessCar.getColor().substring(0, 1);
@@ -552,8 +542,13 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     partMoney = new BigDecimal("0");
                 }
             }
-            //越南车牌,整车业务免停车费
-            if (!CAR_LIST.contains(carNo) && TbBusiness.BusinessType.HOLD_CAR.getCode().equals(businessType)) {
+
+            //越南车牌,是否免费
+            if (!CAR_LIST.contains(carNo) && vietnamCarPay == 0) {
+                partMoney = new BigDecimal("0");
+            }
+            //中国车,是否免费
+            if (CAR_LIST.contains(carNo) && chinaCarPay == 0) {
                 partMoney = new BigDecimal("0");
             }
             Map<String, Object> carMap = new HashMap<>();
@@ -561,8 +556,7 @@ 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())) {
+            if (TbBusinessCar.PayTypeEnum.FEE_TYPE.getType().equals(tbBusinessCar.getPayType())) {
                 carMap.put("price", 0);
             }
             carsList.add(carMap);
@@ -579,32 +573,29 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             itemMap.put("price", itemPrice);
             itemMap.put("pay", item.getPayStatus());
             itemList.add(itemMap);
-        }
-        result.put("itemsPrice", itemsPrice);
-        result.put("itemList", itemList);
-        if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(businessType) && StrUtil.isNotEmpty(itemTypeId)) {
-            TbBusinessSort tbBusinessSort = tbBusinessSortService.findByItemTypeId(itemTypeId);
-            TbSortGroup sortGroup = tbSortGroupService.getById(tbBusinessSort.getGroupId());
-            if (sortGroup.getCompletePay().equals(1) && sortGroup.getStatus().equals(1)) {
-                List<TbBusinessSort> sorts = tbBusinessSortService.findByGroupId(sortGroup.getId());
-                if (sorts.size() > items.size()) {
-                    result.put("showPay", false);
+            TbBusinessSort tbBusinessSort = tbBusinessSortService.findByItemTypeId(item.getItemTypeId());
+            if (tbBusinessSort != null) {
+                TbSortGroup sortGroup = tbSortGroupService.getById(tbBusinessSort.getGroupId());
+                if (sortGroup.getCompletePay().equals(1) && sortGroup.getStatus().equals(1)) {
+                    List<TbBusinessSort> sorts = tbBusinessSortService.findByGroupId(sortGroup.getId());
+                    if (sorts.size() > items.size()) {
+                        result.put("showPay", false);
+                    }
                 }
             }
         }
-
+        result.put("itemsPrice", itemsPrice);
+        result.put("itemList", itemList);
         return result;
     }
 
     public List<TbBusiness> findOtherBusinessByCarId(String businessCarId) {
-        QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
-        ew.eq("business_car_id", businessCarId);
-        return list(ew);
+        return tbBusinessMapper.findOtherBusinessByCarId(businessCarId);
     }
 
     public void uploadReport(TbBusiness tbBusiness) {
         this.updateById(tbBusiness);
-        List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(tbBusiness.getId());
+        List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(tbBusiness.getId());
         tbBusinessCarService.updateBatchById(cars);
     }
 
@@ -613,31 +604,38 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         return tbBusinessMapper.getCarDisincleList(soMap);
     }
 
-    public OtherBusinessEditBO getOtherBusinessById(String id) {
+    public TbBusiness getOtherBusinessById(String id) {
         TbBusiness tbBusiness = this.getById(id);
         List<TbBusinessItem> tbBusinessItems = tbBusinessItemService.findByBusinessId(id);
-        TbBusinessCar car = tbBusinessCarService.getById(tbBusiness.getBusinessCarId());
-        OtherBusinessEditBO otherBusinessBO = new OtherBusinessEditBO();
-        otherBusinessBO.setId(tbBusiness.getId()).setOperator(tbBusiness.getOperator()).setOperateTime(tbBusiness.getOperateTime());
-        otherBusinessBO.setCustomerId(tbBusiness.getCustomerId());
-        otherBusinessBO.setCarNo(car.getCarNo()).setCarWeight(tbBusiness.getNetWeight())
-                .setCarSize(tbBusiness.getCardSize()).setCarType(tbBusiness.getGoodsName())
-                .setItemTypeId(tbBusiness.getItemTypeId());
-        otherBusinessBO.setItems(tbBusinessItems);
-        return otherBusinessBO;
+        tbBusiness.setItems(tbBusinessItems);
+        List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(id);
+        tbBusiness.setCars(cars);
+        return tbBusiness;
     }
 
     public void deleteOtherBusiness(String id) {
         TbBusiness db = super.getById(id);
-        TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(db.getBusinessCarId());
-        if (tbBusinessCar == null || tbBusinessCar.getRealInTime() == null) {
-            List<TbBusiness> businesses = this.findOtherBusinessByCarId(db.getBusinessCarId());
-            if (businesses.size() == 1) {
-                tbBusinessCarService.removeById(db.getBusinessCarId());
-            }
+        String declareNo = db.getDeclareNo();
+        if (StrUtil.isNotEmpty(declareNo)) {
+            tbDeclareService.rebackDeclareNo(declareNo);
         }
         this.removeById(id);
+        //删除响应业务项
         tbBusinessItemService.removeByBusinessId(id);
+        //检查是否删除车辆
+        List<TbBusinessCar> tbBusinessCarList = tbBusinessCarService.findOtherBusinessCar(id);
+        tbBusinessCarList.forEach(tbBusinessCar -> {
+            //未入场
+            if (tbBusinessCar.getRealInTime() == null) {
+                List<RelationBusinessCar> relationBusinessCars = relationBusinessCarService.findByBusinessCarId(tbBusinessCar.getId());
+                //无关联业务==>删除
+                if (relationBusinessCars.size() == 1) {
+                    tbBusinessCarService.removeById(tbBusinessCar.getId());
+                }
+            }
+        });
+        //删除关系
+        relationBusinessCarService.removeByBusinessId(id);
     }
 
     public int checkCarBusinessType(String typeId, String carNo, String operateTime, int before) {
@@ -648,25 +646,29 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         return tbBusinessMapper.checkCarBusinessTypeByTime(typeId, carNo, timeStart, timeEnd, businessId);
     }
 
-    public void manualConfirmPay(String id, String inChannel, Date realInTime, String outChannel, Date realOutTime, String remark) {
+    public void manualConfirmPay(String id, List<TbBusinessCar> cars, String remark) {
         TbBusiness db = this.getById(id);
         if (db == null) {
             throw new BusinessException("业务不存在");
         }
-        db.setPayStatus(3).setPayMoney(db.getItemPrice());
+        Date now = new Date();
+        db.setPayStatus(3).setPayMoney(db.getItemPrice()).setPayTime(now);
         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.setInChannel(inChannel)
-                .setOutChannel(outChannel)
-                .setRealOutTime(realOutTime)
-                .setRealInTime(realInTime);
-        tbBusinessCarService.updateById(tbBusinessCar);
+        cars.forEach(tbBusinessCar -> {
+            Date realInTime = tbBusinessCar.getRealInTime();
+            Date realOutTime = tbBusinessCar.getRealOutTime();
+            if (realInTime != null && realOutTime != null) {
+                BigDecimal price = calculationPartMoney(realInTime, realOutTime);
+                tbBusinessCar.setMoney(price);
+            }
+            tbBusinessCar.setPay(1);
+            tbBusinessCarService.updateById(tbBusinessCar);
+        });
         List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
-        items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setRemark(StrUtil.isEmpty(remark) ? "手动确认" : remark));
+        items.forEach(tbBusinessItem -> tbBusinessItem
+                .setPayStatus(1).setPayTime(now)
+                .setRemark(StrUtil.isEmpty(remark) ? "手动确认" : remark)
+        );
         tbBusinessItemService.updateBatchById(items);
     }
 
@@ -680,29 +682,269 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         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);
+
+    public void addOtherBusiness(OtherBusinessBO otherBusinessBO) {
+        List<TbItem> tbItems = otherBusinessBO.getItems();
+        if (tbItems.isEmpty()) {
+            throw new BusinessException("请选择明细");
         }
-        db.setBusinessCarId(businessCarId);
-        this.updateById(db);
+        List<TbBusinessCar> cars = otherBusinessBO.getCars();
+        if (cars.isEmpty()) {
+            throw new BusinessException("作业车辆不能为空");
+        }
+        Date now = new Date();
+        TbGoods tbGoods = tbGoodsService.getById(otherBusinessBO.getGoodsId());
+        TbBusiness tbBusiness = new TbBusiness();
+        String customerId = otherBusinessBO.getCustomerId();
+        tbBusiness.setCreateBy(StpUserUtil.getAdmin().getName());
+        tbBusiness.setPayStep(tbGoods.getPayStep());
+        TbCostomer tbCostomer = tbCostomerService.getById(customerId);
+        if (tbCostomer != null) {
+            tbBusiness.setCustomerId(customerId).setCustomerName(tbCostomer.getName());
+        }
+        BigDecimal price = new BigDecimal("0");
+        List<TbBusinessItem> itemList = new ArrayList<>();
+        String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
+        int index = 1;
+        for (TbItem tbItem : tbItems) {
+            TbItem db = tbItemService.getById(tbItem.getId());
+            TbBusinessItem item = new TbBusinessItem();
+            int num = tbItem.getNum();
+            String typeId = tbItem.getTypeId();
+            TbItemType tbItemType = tbItemTypeService.getById(typeId);
+            BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
+            item.setNo(no + "0" + index).setPayTypeName(db.getPayTypeName()).setPayType(db.getPayType())
+                    .setBusinessType(db.getBusinessType()).setTaxRate(NumberUtil.div(db.getTaxRate().doubleValue(), 100D, 2));
+            item.setItemCode(db.getItemCode()).setNum(num + "").setItemId(db.getId())
+                    .setItemName(db.getItemName()).setItemPrice(db.getPrice()).setRemark(tbItem.getRemark())
+                    .setItemTypeId(typeId).setItemTypeName(tbItemType.getName())
+                    .setUnit(db.getUnit()).setTotal(itemTotalPrice).setCreateTime(now);
+            price = price.add(itemTotalPrice);
+            itemList.add(item);
+            index++;
+        }
+        String declareNo = otherBusinessBO.getDeclareNo();
+        tbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getNetWeight())
+                .setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
+                .setNo(no).setGoodsName(tbGoods.getName()).setGoodsId(otherBusinessBO.getGoodsId())
+                .setPayStep(tbGoods.getPayStep()).setDeclareNo(declareNo).setCardNo(otherBusinessBO.getCardNo());
+        tbBusiness.setCreateTime(now).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
+                .setItemPrice(price).setTotalMoney(price);
+        tbBusiness.setChinaCarNo(otherBusinessBO.getChinaCarNo());
+        this.save(tbBusiness);
+        Integer chinaCarPay = tbGoods.getChinaCarPay();
+        Integer vietnamCarPay = tbGoods.getVietnamCarPay();
+        String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
+        for (TbBusinessCar car : cars) {
+            String carNo = car.getCarNo().trim().toUpperCase();
+            String carPrefix = StrUtil.sub(carNo, 0, 1);
+            //最新一条记录
+            TbBusinessCar db = tbBusinessCarService.findTheLastRecord(carNo);
+            //不存在,或者已离场记录--->新建记录;
+            if (db == null || db.getRealInTime() != null && db.getRealOutTime() != null) {
+                db = new TbBusinessCar();
+                db.setCreateTime(now).setPay(0).setNo(carBuseinssNo + RandomUtil.randomNumbers(4));
+            }
+            for (TbBusinessItem item : itemList) {
+                checkOtherBusiness(item.getItemTypeId(), otherBusinessBO.getOperateTime(), tbBusiness.getId(), carNo);
+            }
+            if ((CAR_LIST.contains(carPrefix) && chinaCarPay == 1) || (!CAR_LIST.contains(carPrefix) && vietnamCarPay == 1)) {
+                db.setPayType(TbBusinessCar.PayTypeEnum.FEE_TYPE.getType());
+            }
+            db.setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode());
+            TbCar tbCar = tbCarService.findByCardNo(carNo);
+            db.setCarNo(carNo).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
+                    .setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
+            db.setCarSize(car.getCarSize())
+                    .setTimeUpdate(now).setCarType(car.getCarType())
+                    .setNetWeight(car.getNetWeight())
+                    .setCustomerId(customerId)
+                    .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
+            tbBusinessCarService.saveOrUpdate(db);
+            RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
+            relationBusinessCar.setBusinessId(tbBusiness.getId()).setBusinessCarId(db.getId());
+            relationBusinessCarService.save(relationBusinessCar);
+        }
+        if (StrUtil.isNotEmpty(declareNo)) {
+            TbDeclare declare = tbDeclareService.findByDeclareNo(declareNo);
+            declare.setBusinessId(tbBusiness.getId());
+        }
+        itemList.forEach(tbBusinessItem -> tbBusinessItem.setBusinessId(tbBusiness.getId()));
+        tbBusinessItemService.saveBatch(itemList);
+
     }
+
+
+    public List<TbBusiness> getOtherBusiness(SoMap startPage) {
+        return tbBusinessMapper.getOtherBusiness(startPage);
+    }
+
+    public void editOtherBusiness(OtherBusinessBO otherBusinessBO) {
+        String id = otherBusinessBO.getId();
+        TbBusiness dbBusiness = this.getById(id);
+        if (dbBusiness == null) {
+            throw new BusinessException("记录不存在");
+        }
+        List<TbItem> tbItems = otherBusinessBO.getItems();
+        if (tbItems.isEmpty()) {
+            throw new BusinessException("请选择明细");
+        }
+        List<TbBusinessCar> cars = otherBusinessBO.getCars();
+        if (cars.isEmpty()) {
+            throw new BusinessException("作业车辆不能为空");
+        }
+        tbBusinessItemService.removeByBusinessId(id);
+        Date now = new Date();
+        List<RelationBusinessCar> relationBusinessCars = relationBusinessCarService.findByBusinessId(id);
+        List<String> businessCarIds = cars.stream().filter(tbBusinessCar -> StrUtil.isNotEmpty(tbBusinessCar.getId()))
+                .map(TbBusinessCar::getId).collect(Collectors.toList());
+        List<String> removeIds = relationBusinessCars.stream()
+                .filter(relationBusinessCar -> !businessCarIds.contains(relationBusinessCar.getBusinessCarId()))
+                .map(RelationBusinessCar::getId)
+                .collect(Collectors.toList());
+        if (!removeIds.isEmpty()) {
+            relationBusinessCarService.removeByIds(removeIds);
+        }
+        TbGoods tbGoods = tbGoodsService.getById(otherBusinessBO.getGoodsId());
+        Integer chinaCarPay = tbGoods.getChinaCarPay();
+        Integer vietnamCarPay = tbGoods.getVietnamCarPay();
+        String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
+        BigDecimal price = new BigDecimal("0");
+        List<TbBusinessItem> itemList = new ArrayList<>();
+        String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
+        int index = 1;
+        for (TbItem tbItem : tbItems) {
+            TbItem db = tbItemService.getById(tbItem.getId());
+            TbBusinessItem item = new TbBusinessItem();
+            int num = tbItem.getNum();
+            TbItemType tbItemType = tbItemTypeService.getById(tbItem.getTypeId());
+            BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
+            item.setNo(no + "0" + index).setPayTypeName(db.getPayTypeName()).setPayType(db.getPayType())
+                    .setBusinessType(db.getBusinessType()).setTaxRate(NumberUtil.div(db.getTaxRate().doubleValue(), 100D, 2));
+            item.setItemCode(db.getItemCode()).setNum(num + "").setItemId(db.getId()).setBusinessId(dbBusiness.getId())
+                    .setItemName(db.getItemName()).setItemPrice(db.getPrice()).setRemark(tbItem.getRemark())
+                    .setItemTypeId(tbItem.getTypeId()).setItemTypeName(tbItemType.getName())
+                    .setUnit(db.getUnit()).setTotal(itemTotalPrice).setCreateTime(now);
+            price = price.add(itemTotalPrice);
+            itemList.add(item);
+            index++;
+        }
+        dbBusiness.setItemPrice(price).setTotalMoney(price);
+        tbBusinessItemService.saveBatch(itemList);
+        for (TbBusinessCar tbBusinessCar : cars) {
+            String businessCarId = tbBusinessCar.getId();
+            String carNo = tbBusinessCar.getCarNo();
+            for (TbBusinessItem item : itemList) {
+                checkOtherBusiness(item.getItemTypeId(), otherBusinessBO.getOperateTime(), dbBusiness.getId(), carNo);
+            }
+            String carPrefix = StrUtil.sub(carNo, 0, 1);
+            if (StrUtil.isNotEmpty(businessCarId)) {
+                TbBusinessCar dbBusinessCar = tbBusinessCarService.getById(businessCarId);
+                dbBusinessCar.setNetWeight(tbBusinessCar.getNetWeight()).setCarType(tbBusinessCar.getCarType())
+                        .setCarSize(tbBusinessCar.getCarSize()).setCarNo(carNo);
+                tbBusinessCarService.updateById(dbBusinessCar);
+            } else {
+                TbBusinessCar checkCar = tbBusinessCarService.findTheLastRecord(carNo);
+                if (checkCar == null ||
+                        (checkCar.getRealInTime() != null && checkCar.getRealOutTime() != null)) {
+                    checkCar = new TbBusinessCar();
+                    checkCar.setCreateTime(now).setPay(0).setNo(carBuseinssNo + RandomUtil.randomNumbers(4));
+                }
+                checkCar.setCarNo(carNo).setCarType(tbBusinessCar.getCarType()).setCarSize(tbBusinessCar.getCarSize())
+                        .setNetWeight(tbBusinessCar.getNetWeight()).setCustomerId(dbBusiness.getCustomerId())
+                        .setTimeUpdate(now).setIsLock(0);
+                if ((CAR_LIST.contains(carPrefix) && chinaCarPay == 1) || (!CAR_LIST.contains(carPrefix) && vietnamCarPay == 1)) {
+                    checkCar.setPayType(TbBusinessCar.PayTypeEnum.FEE_TYPE.getType());
+                }
+                tbBusinessCarService.saveOrUpdate(checkCar);
+                RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
+                relationBusinessCar.setBusinessId(dbBusiness.getId()).setBusinessCarId(checkCar.getId());
+                relationBusinessCarService.save(relationBusinessCar);
+            }
+        }
+        if (!StrUtil.equals(dbBusiness.getGoodsId(), otherBusinessBO.getGoodsId())) {
+            dbBusiness.setGoodsId(otherBusinessBO.getGoodsId())
+                    .setGoodsName(tbGoods.getName()).setPayStep(tbGoods.getPayStep());
+        }
+        String declareNo = otherBusinessBO.getDeclareNo();
+        if (!StrUtil.equals(declareNo, dbBusiness.getDeclareNo())) {
+            tbDeclareService.rebackDeclareNo(dbBusiness.getDeclareNo());
+        }
+        dbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getNetWeight())
+                .setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
+                .setNo(no).setGoodsId(otherBusinessBO.getGoodsId())
+                .setDeclareNo(declareNo).setCardNo(otherBusinessBO.getCardNo());
+        dbBusiness.setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
+                .setItemPrice(price).setTotalMoney(price);
+        dbBusiness.setChinaCarNo(otherBusinessBO.getChinaCarNo());
+        this.updateById(dbBusiness);
+    }
+
+    public void bindOtherBusinessCar(String businessId, List<String> businessCarIdList) {
+        TbBusiness tbBusiness = this.getById(businessId);
+        relationBusinessCarService.removeByBusinessId(businessId);
+        List<TbBusinessCar> carList = tbBusinessCarService.listByIds(businessCarIdList);
+        String chinaCarNo = carList.stream().filter(tbBusinessCar -> {
+            String carNo = tbBusinessCar.getCarNo();
+            String carStr = StrUtil.sub(carNo, 0, 1);
+            return CAR_LIST.contains(carStr);
+        }).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
+        String yueCarNo = carList.stream().filter(tbBusinessCar -> {
+            String carNo = tbBusinessCar.getCarNo();
+            String carStr = StrUtil.sub(carNo, 0, 1);
+            return !CAR_LIST.contains(carStr);
+        }).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
+        tbBusiness.setChinaCarNo(chinaCarNo);
+        tbBusiness.setCardNo(yueCarNo);
+        this.updateById(tbBusiness);
+        businessCarIdList.forEach(businessCarId -> {
+            RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
+            relationBusinessCar.setBusinessCarId(businessCarId).setBusinessId(businessId);
+            relationBusinessCarService.save(relationBusinessCar);
+        });
+    }
+
+    private void checkOtherBusiness(String itemTypeId, String operateTimeStr, String businessId, String carNo) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        TbBusinessSort sort = tbBusinessSortService.findByItemTypeId(itemTypeId);
+        List<TbBusinessSort> sorts = tbBusinessSortService.findByGroupId(sort.getGroupId());
+        LocalDateTime operateTime = LocalDateTime.parse(operateTimeStr, formatter);
+        int i = 0;
+        for (TbBusinessSort tbBusinessSort : sorts) {
+            if (i == 0 && StrUtil.equals(tbBusinessSort.getTypeId(), itemTypeId) && sorts.size() > 1) {
+                TbBusinessSort afterItem = sorts.get(i + 1);
+                String typeId = afterItem.getTypeId();
+                Integer interval = afterItem.getIntervalTime();
+                LocalDateTime endTime = operateTime.plusMinutes(interval);
+                if (afterItem.getIntervalTime() > 0) {
+                    int count = this.checkCarBusinessType(typeId, carNo, endTime.format(formatter), 1);
+                    if (count > 0) {
+                        throw new BusinessException("车辆:[" + carNo + "]" + tbBusinessSort.getTypeName() + "后" + afterItem.getIntervalTime() + "分钟才可以执行" + afterItem.getTypeName());
+                    }
+                }
+            }
+            if (i > 0 && StrUtil.equals(tbBusinessSort.getTypeId(), itemTypeId)) {
+                TbBusinessSort beforeItem = sorts.get(i - 1);
+                String typeId = beforeItem.getTypeId();
+                Integer interval = tbBusinessSort.getIntervalTime();
+                LocalDateTime endTime = operateTime.minusMinutes(interval);
+                if (tbBusinessSort.getIntervalTime() > 0) {
+                    int count = this.checkCarBusinessType(typeId, carNo, endTime.format(formatter), 0);
+                    if (count > 0) {
+                        throw new BusinessException("车辆:[" + carNo + "]" + beforeItem.getTypeName() + "后" + tbBusinessSort.getIntervalTime() + "分钟才可以执行" + tbBusinessSort.getTypeName());
+                    }
+                }
+            }
+            Integer singleIntervalTime = tbBusinessSort.getSingleIntervalTime();
+            String timeStart = operateTime.minusHours(singleIntervalTime).format(formatter);
+            String timeEnd = operateTime.plusHours(singleIntervalTime).format(formatter);
+            int count = this.checkCarBusinessType(itemTypeId, carNo, timeStart, timeEnd, businessId);
+            if (count > 0) {
+                throw new BusinessException("车辆:[" + carNo + "]" + singleIntervalTime + "小时内已有相同作业");
+            }
+            i++;
+        }
+    }
+
+
 }

+ 14 - 1
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCar.java

@@ -13,9 +13,11 @@ import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.pj.current.config.PartConfig;
+import lombok.AllArgsConstructor;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
+import lombok.Getter;
 import lombok.experimental.Accessors;
 import org.springframework.data.annotation.Id;
 
@@ -123,14 +125,25 @@ public class TbBusinessCar extends Model<TbBusinessCar> implements Serializable
     private Date timeUpdate;
 
     private Integer businessType=0;
+    private String carType;
+    private String netWeight;
+    private Date createTime;
 
 
 
 
-    @TableField(exist = false)
     private String payType;
 
 
+    @Getter
+    @AllArgsConstructor
+    public static enum PayTypeEnum{
+        FEE_TYPE("免费"),
+        HAS_PAY_TYPE("已支付"),
+        NO_PAY_TYPE("未支付");
+        private String type;
+    }
+
 
 
 }

+ 17 - 9
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarController.java

@@ -9,6 +9,7 @@ import com.pj.constants.UserTypeEnum;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_costomer.TbCostomer;
 import com.pj.utils.so.SoMap;
+import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -69,15 +70,7 @@ public class TbBusinessCarController {
         return AjaxJson.getSuccessData(list);
     }
 
-    /**
-     * 查 - 根据id
-     */
-    @RequestMapping("update")
-    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
-    public AjaxJson update(TbBusinessCar t) {
-        tbBusinessCarService.updateCar(t);
-        return AjaxJson.getSuccess();
-    }
+
 
     /**
      * 查 - 根据id
@@ -120,10 +113,25 @@ public class TbBusinessCarController {
             so.put("startDay",startDayStr);
             so.put("endDay",endDayStr);
         }
+        String carNo=so.getString("carNo");
+        if (StrUtil.isNotEmpty(carNo)){
+            so.put("carNoList",carNo.split("、"));
+        }
         List<TbBusinessCar> list = tbBusinessCarService.getList(so.startPage());
         return AjaxJson.getPageData(so.getDataCount(), list);
     }
 
+    @RequestMapping("searchByNo")
+    public AjaxJson searchByNo(String carNo){
+        List<TbBusinessCar> list= tbBusinessCarService.searchByNo(carNo);
+        return AjaxJson.getSuccessData(list);
+    }
+    @RequestMapping("getOtherBusinessCarByBusinessId")
+    public AjaxJson getOtherBusinessCarByBusinessId(String businessId){
+        List<TbBusinessCar> list= tbBusinessCarService.findOtherBusinessCar(businessId);
+        return AjaxJson.getSuccessData(list);
+    }
+
     /**
      * 手动添加放行记录
      */

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

@@ -40,4 +40,6 @@ public interface TbBusinessCarMapper extends BaseMapper<TbBusinessCar> {
     int checkCarBusinessType(@Param("typeId")String typeId, @Param("carNo")String carNo,@Param("timeEnd") String timeEnd);
 
     void removeBusinessId(String id);
+
+    List<TbBusinessCar> findOtherBusinessCar(String businessId);
 }

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

@@ -33,7 +33,15 @@
             <if test=' this.has("id") '>and id = #{id}</if>
             <if test=' this.has("businessId") '>and business_id = #{businessId}</if>
             <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
-            <if test=' this.has("carNo") '>and car_no like concat('%',#{carNo},'%')</if>
+            <if test=' this.has("carNo") and carNo.indexOf("、")==-1'>
+                and car_no like concat('%',#{carNo},'%')
+            </if>
+            <if test=' this.has("carNoList") and carNoList.length>0'>
+                and car_no in
+                <foreach collection="carNoList" open="(" close=")" item="carNo" separator=",">
+                    #{carNo}
+                </foreach>
+            </if>
             <if test=' this.has("preInTime") '>and pre_in_time = #{preInTime}</if>
             <if test=' this.has("preOutTime") '>and pre_out_time = #{preOutTime}</if>
             <if test=' this.has("realInTime") '>and real_in_time = #{realInTime}</if>
@@ -141,6 +149,9 @@
         and c.business_type=#{typeId}
         and DATE_FORMAT(b.operate_time,'%Y-%m-%d %H:%i:%s') &gt;#{timeEnd}
     </select>
+    <select id="findOtherBusinessCar" resultType="com.pj.project.tb_business_car.TbBusinessCar">
+        select a.* from  tb_business_car a,relation_business_car b where  a.id=b.business_car_id and b.business_id=#{businessId}
+    </select>
 
 
 </mapper>

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

@@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.current.config.PartConfig;
 import com.pj.current.config.SystemObject;
+import com.pj.project.relation_business_car.RelationBusinessCar;
+import com.pj.project.relation_business_car.RelationBusinessCarService;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_business.TbBusinessService;
 import com.pj.project.tb_business_item.TbBusinessItem;
@@ -74,6 +76,9 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
 
     @Resource
     private TbCarNoColorService tbCarNoColorService;
+    @Resource
+    @Lazy
+    private RelationBusinessCarService relationBusinessCarService;
 
 
     /**
@@ -150,12 +155,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         });
     }
 
-    public List<TbBusinessCar> findByBusinessId(String businessId) {
-        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
-        ew.eq("business_id", businessId);
-        return list(ew);
-    }
-
 
     public List<TbBusinessCar> searchPartCar(String carNo) {
         return tbBusinessCarMapper.searchPartCar(carNo.toUpperCase());
@@ -210,33 +209,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         this.save(t);
     }
 
-    public void updateCar(TbBusinessCar t) {
-        this.updateById(t);
-        TbBusiness tbBusiness = tbBusinessService.getById(t.getBusinessId());
-        String carNo = t.getCarNo();
-        if (!CAR_LIST.contains(carNo.substring(0, 1))) {
-            tbBusiness.setCardNo(carNo);
-        } else {
-            List<TbBusinessCar> cars = this.findByBusinessId(t.getBusinessId());
-            String chiaCarNo = cars.stream().filter(obj -> CAR_LIST.contains(obj.getCarNo().substring(0, 1))).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
-            tbBusiness.setChinaCarNo(chiaCarNo);
-        }
-        tbBusinessService.updateById(tbBusiness);
-    }
-
-    public void adminIn(String businessId, String carNo, Date realInTime) {
-        TbBusinessCar car = this.findByBusinessIdAndCarNo(businessId, carNo);
-        car.setRealInTime(realInTime);
-        this.updateById(car);
-    }
-
-    public void adminOut(String businessId, String carNo, Date realOutTime) {
-        TbBusinessCar car = this.findByBusinessIdAndCarNo(businessId, carNo);
-        car.setRealOutTime(realOutTime);
-        this.updateById(car);
-    }
-
-
     public AjaxJson deleteCar(String id) {
         TbBusinessCar db = this.getById(id);
         String checkStr = db.getCarNo().substring(0, 1);
@@ -269,49 +241,51 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
 
     public void updateCarRecord(TbBusinessCar t) throws Exception {
         TbBusinessCar db = this.getById(t.getId());
-        if (StrUtil.equals(db.getCarNo().toUpperCase().trim(), t.getCarNo().toUpperCase().trim())) {
-            db.setRealInTime(t.getRealInTime()).setColor(t.getColor())
-                    .setRealOutTime(t.getRealOutTime()).setInImage(t.getInImage())
-                    .setOutImage(t.getOutImage())
-                    .setCarSize(t.getCarSize())
-                    .setDriverName(t.getDriverName())
-                    .setDriverPhone(t.getDriverPhone()).setTimeUpdate(new Date());
+        String oldCarNo = db.getCarNo();
+        String newCarNo = t.getCarNo();
+        db.setRealInTime(t.getRealInTime()).setColor(t.getColor())
+                .setRealOutTime(t.getRealOutTime()).setInImage(t.getInImage())
+                .setOutImage(t.getOutImage())
+                .setCarSize(t.getCarSize())
+                .setDriverName(t.getDriverName())
+                .setDriverPhone(t.getDriverPhone()).setTimeUpdate(new Date());
+        //车牌没改
+        if (StrUtil.equals(oldCarNo, newCarNo)) {
             this.updateById(db);
             return;
         }
-        String carNo = t.getCarNo().toUpperCase();
-        TbBusinessCar old = this.getById(t.getId());
-        String oldCarNo = old.getCarNo();
-        TbBusinessCar notOutCar = findNotOutCar(carNo);
-        if (notOutCar != null && !notOutCar.getId().equals(t.getId())) {
-            throw new Exception("该车" + carNo + "已进场但未出场");
+        //改了车牌,看下新车牌是否被占用
+        TbBusinessCar lastRecord = this.findTheLastRecord(newCarNo);
+        //未离场,不能改
+        if (lastRecord != null && lastRecord.getRealInTime() != null && lastRecord.getRealOutTime() == null) {
+            throw new Exception("该车" + newCarNo + "已入场但未离场");
         }
-        String businessId = t.getBusinessId();
-        TbBusinessCar businessCar = this.findByBusinessIdAndCarNo(businessId, carNo);
-        if (businessCar != null && !StrUtil.equals(t.getId(), businessCar.getId())) {
+        if (lastRecord != null && lastRecord.getRealInTime() == null) {
             throw new Exception("车辆已存在");
         }
-        t.setCarNo(carNo);
+        db.setCarNo(newCarNo);
         this.updateById(t);
-        TbBusiness tbBusiness = tbBusinessService.getById(t.getBusinessId());
-        if (tbBusiness != null) {
-            if (!CAR_LIST.contains(carNo.substring(0, 1))) {
-                tbBusiness.setCardNo(carNo);
+        List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(t.getId());
+        String carStr = StrUtil.sub(newCarNo, 0, 1);
+        for (TbBusiness tbBusiness : businessList) {
+            if (!CAR_LIST.contains(carStr)) {
+                tbBusiness.setCardNo(newCarNo);
             } else {
-                List<TbBusinessCar> cars = this.findByBusinessId(t.getBusinessId());
-                String chiaCarNo = cars.stream().filter(obj -> CAR_LIST.contains(obj.getCarNo().substring(0, 1))).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
-                tbBusiness.setChinaCarNo(chiaCarNo);
+                List<TbBusinessCar> cars = this.findOtherBusinessCar(t.getBusinessId());
+                String chinaCarNo = cars.stream().filter(obj -> CAR_LIST.contains(obj.getCarNo().substring(0, 1))).map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
+                tbBusiness.setChinaCarNo(chinaCarNo);
             }
             tbBusinessService.updateById(tbBusiness);
 
-            List<TbFeeDetails> feeDetailsLIst = tbFeeDetailsService.getByBusinessIdAndCarNo(businessId, oldCarNo);
-            feeDetailsLIst.forEach(fee -> fee.setCarNo(carNo));
+            List<TbFeeDetails> feeDetailsLIst = tbFeeDetailsService.getByBusinessIdAndCarNo(tbBusiness.getId(), oldCarNo);
+            feeDetailsLIst.forEach(fee -> fee.setCarNo(newCarNo));
             tbFeeDetailsService.updateBatchById(feeDetailsLIst);
-        } else {
+        }
+        if (businessList.isEmpty()) {
             List<TbFeeDetails> feeDetailsList = tbFeeDetailsService.getByBusinessCarIdAndCarNoAndFeeType(t.getId(), oldCarNo, TbFeeDetails.fee.PARK_FEE.getCode());
             for (TbFeeDetails feeDetail : feeDetailsList) {
                 if (feeDetail != null) {
-                    feeDetail.setCarNo(carNo);
+                    feeDetail.setCarNo(newCarNo);
                     tbFeeDetailsService.updateById(feeDetail);
                 }
             }
@@ -361,17 +335,10 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         if (!tbFeeDetails.isEmpty()) {
             return AjaxJson.getError("该车有付款记录,不能删除");
         }
-        List<TbBusiness> businesses = tbBusinessService.findOtherBusinessByCarId(id);
-        if (!businesses.isEmpty()) {
+        List<RelationBusinessCar> relationBusinessCars = relationBusinessCarService.findByBusinessCarId(id);
+        if (!relationBusinessCars.isEmpty()) {
             return AjaxJson.getError("该车有业务,不能删除");
         }
-        TbBusinessCar db = this.getById(id);
-        if (StrUtil.isNotEmpty(db.getBusinessId())) {
-            TbBusiness tbBusiness = tbBusinessService.getById(db.getBusinessId());
-            if (tbBusiness != null) {
-                return AjaxJson.getError("该车有业务,不能删除");
-            }
-        }
         this.removeById(id);
         return AjaxJson.getSuccess();
     }
@@ -428,4 +395,28 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         List<TbBusinessCar> list = list(ew);
         return list.isEmpty() ? null : list.get(0);
     }
+
+    public List<TbBusinessCar> searchByNo(String carNo) {
+        if (StrUtil.length(carNo) < 3) {
+            return Collections.emptyList();
+        }
+        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
+        ew.select("car_no");
+        ew.like("car_no", carNo);
+        List<TbBusinessCar> list = list(ew);
+        return list.stream().distinct().collect(Collectors.toList());
+    }
+
+    public List<TbBusinessCar> findOtherBusinessCar(String businessId) {
+
+        return tbBusinessCarMapper.findOtherBusinessCar(businessId);
+    }
+
+    public List<TbBusinessCar> searchNoPayCar(String carNo) {
+        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
+        ew.like("car_no", carNo)
+                .eq("pay", 0)
+                .isNull("pay_time");
+        return list(ew);
+    }
 }

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_business_item/PayTask.java

@@ -67,7 +67,7 @@ public class PayTask extends Task {
             }
 
             TbBusinessCarService tbBusinessCarService = SpringUtil.getBean(TbBusinessCarService.class);
-            List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(businessId);
+            List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
             cars = cars.stream().filter(tbBusinessCar -> tbBusinessCar.getPay() == 0).collect(Collectors.toList());
             for (TbBusinessCar tbBusinessCar : cars) {
                 shouldPay = shouldPay.add(tbBusinessCar.getBasePartMoney());

+ 4 - 0
sp-server/src/main/java/com/pj/project/tb_business_item/TbBusinessItemService.java

@@ -2,6 +2,7 @@ package com.pj.project.tb_business_item;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -165,6 +166,9 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
     }
 
     public List<TbBusinessItem> findByBusinessIdList(List<String> businessIdList) {
+        if (businessIdList.isEmpty()){
+            return Collections.emptyList();
+        }
         QueryWrapper<TbBusinessItem> ew = new QueryWrapper<>();
         ew.in("business_id", businessIdList);
         return list(ew);

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareController.java

@@ -84,7 +84,7 @@ public class TbDeclareController {
 	@RequestMapping("getNotBindList")
 	public AjaxJson getNotBindList() {
 		SoMap so = SoMap.getRequestSoMap();
-		so.put("bind",1);
+		//so.put("bind",1);
 		List<TbDeclare> list = tbDeclareService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}

+ 2 - 0
sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareMapper.java

@@ -55,4 +55,6 @@ public interface TbDeclareMapper extends BaseMapper<TbDeclare> {
 
 
     void removeBusinessId(@Param("businessId") String businessId);
+
+	void rebackDeclareNo(@Param("declareNo")String declareNo);
 }

+ 3 - 0
sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareMapper.xml

@@ -49,6 +49,9 @@
     <update id="removeBusinessId">
         update tb_declare set business_id=null  where business_id=#{businessId}
     </update>
+    <update id="rebackDeclareNo">
+        update  tb_declare set declare_no=null  where  declare_no=#{declareNo}
+    </update>
 
 
     <!-- ================================== 查询相关 ================================== -->

+ 4 - 0
sp-server/src/main/java/com/pj/project/tb_declare/TbDeclareService.java

@@ -67,4 +67,8 @@ public class TbDeclareService extends ServiceImpl<TbDeclareMapper, TbDeclare> im
 	public void removeBusinessId(String businessId) {
 		tbDeclareMapper.removeBusinessId(businessId);
 	}
+
+	public void rebackDeclareNo(String declareNo) {
+		tbDeclareMapper.rebackDeclareNo(declareNo);
+	}
 }

+ 1 - 6
sp-server/src/main/java/com/pj/project/tb_fee_statistics/TbFeeStatisticsService.java

@@ -248,12 +248,7 @@ public class TbFeeStatisticsService extends ServiceImpl<TbFeeStatisticsMapper, T
             if (StrUtil.isEmpty(business.getCardNo())) {
                 carNo = business.getChinaCarNo();
             }
-            TbBusinessCar businessCar;
-            if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType())) {
-                businessCar = tbBusinessCarService.getById(business.getBusinessCarId());
-            } else {
-                businessCar = tbBusinessCarService.findByBusinessIdAndCarNo(item.getBusinessId(), carNo);
-            }
+            TbBusinessCar businessCar = tbBusinessCarService.findByBusinessIdAndCarNo(item.getBusinessId(), carNo);
             businessFeeDetail.setBusinessId(item.getBusinessId()).setBusinessNo(business.getNo())
                     .setBusinessItemNo(item.getNo()).setBusinessCarId(businessCar.getId()).setBusinessCarNo(businessCar.getNo())
                     .setCarNo(carNo)

+ 50 - 9
sp-server/src/main/java/com/pj/project/tb_goods/TbGoods.java

@@ -1,13 +1,15 @@
 package com.pj.project.tb_goods;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.util.*;
 
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.AllArgsConstructor;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
+import lombok.Getter;
 import lombok.experimental.Accessors;
 
 /**
@@ -42,8 +44,7 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	/**
 	 * 主键 
 	 */
-	@TableId(type = IdType.AUTO)
-	private Long id;	
+	private String id;
 
 	/**
 	 * 编号 
@@ -86,14 +87,54 @@ public class TbGoods extends Model<TbGoods> implements Serializable {
 	/**
 	 * 申报时间是否必填(1=是,0=否)
 	 */
-	private Integer needOperateTime;
-
-
+	private Integer needOperateTime=1;
+	private Integer payStep=2;
 	private Integer chinaCarPay=1;
 	private Integer vietnamCarPay=1;
-
-
-
+	private Integer chinaCarLeave=1;
+	private Integer vietnamCarLeave=1;
+
+
+
+
+
+	@Getter
+	@AllArgsConstructor
+	public static enum PayStep {
+		BEFORE_CONFIRM(1,"下单后"),
+		AFTER_CONFIRM(2,"确认订单后");
+		private Integer code;
+		private String desc;
+		public static List<Map<String, Object>> getList() {
+			List<Map<String, Object>> list = new ArrayList<>();
+			for (PayStep tbItem : PayStep.values()) {
+				Map<String, Object> map = new HashMap<>();
+				map.put("id", tbItem.getCode());
+				map.put("name", tbItem.getDesc());
+				list.add(map);
+			}
+			return list;
+		}
+	}
+	@Getter
+	@AllArgsConstructor
+	public static enum LeaveEnum {
+		PART_MONEY(1,"只交停车费"),
+		BUSINESS_MONEY(2,"只交业务费"),
+		APART_BUSINESS(3,"停车费+业务费");
+		private Integer code;
+		private String desc;
+		public static List<Map<String, Object>> getList() {
+			List<Map<String, Object>> list = new ArrayList<>();
+			for (LeaveEnum tbItem : LeaveEnum.values()) {
+				Map<String, Object> map = new HashMap<>();
+				map.put("id", tbItem.getCode());
+				map.put("name", tbItem.getDesc());
+				list.add(map);
+			}
+			return list;
+		}
+	}
 
 
 

+ 142 - 111
sp-server/src/main/java/com/pj/project/tb_goods/TbGoodsController.java

@@ -19,121 +19,152 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 
 /**
  * Controller: tb_goods -- 商品管理
- * @author qzy 
+ *
+ * @author qzy
  */
 @RestController
 @RequestMapping("/TbGoods/")
 public class TbGoodsController {
 
-	/** 底层 Service 对象 */
-	@Autowired
-	TbGoodsService tbGoodsService;
-
-	/** 增 */  
-	@RequestMapping("add")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_ADD)
-	public AjaxJson add(TbGoods t){
-		t.setCreateTime(new Date());
-		tbGoodsService.save(t);
-		return AjaxJson.getSuccessData(t);
-	}
-
-	/** 删 */  
-	@RequestMapping("delete")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		tbGoodsService.removeById(id);
-		return AjaxJson.getSuccess();
-	}
-	
-
-	
-	/** 改 */  
-	@RequestMapping("update")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson update(TbGoods t){
-		tbGoodsService.update(t);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 查 - 根据id */  
-	@RequestMapping("getById")
-	public AjaxJson getById(Long id){
-		TbGoods t = tbGoodsService.getById(id);
-		return AjaxJson.getSuccessData(t);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	@RequestMapping("getList")
-	public AjaxJson getList() { 
-		SoMap so = SoMap.getRequestSoMap();
-		List<TbGoods> list = tbGoodsService.getList(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
-	
-	
-	
-	/** 改 - 状态(1=禁用,2=启用) */  
-	@RequestMapping("updateStatus")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE)
-	public AjaxJson updateStatus(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "status", value, id);
-		return AjaxJson.getByLine(line);
-	}
-
-
-
-
-	/** 改 - 载重是否必填(1=是,0=否) */
-	@RequestMapping("updateNeedWeight")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson updateNeedWeight(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_weight", value, id);
-		return AjaxJson.getByLine(line);
-	}
-
-	/** 改 - 规格是否必填(1=是,0=否) */
-	@RequestMapping("updateNeedCarSize")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson updateNeedCarSize(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_car_size", value, id);
-		return AjaxJson.getByLine(line);
-	}
-
-	/** 改 - 申报单是否必填(1=是,0=否) */
-	@RequestMapping("updateNeedDeclare")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson updateNeedDeclare(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_declare", value, id);
-		return AjaxJson.getByLine(line);
-	}
-
-	/** 改 - 申报时间是否必填(1=是,0=否) */
-	@RequestMapping("updateNeedOperateTime")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson updateNeedOperateTime(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_operate_time", value, id);
-		return AjaxJson.getByLine(line);
-	}
-	/** 改 - 申报时间是否必填(1=是,0=否) */
-	@RequestMapping("updateVietnamCarPay")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson updateVietnamCarPay(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "vietnam_car_pay", value, id);
-		return AjaxJson.getByLine(line);
-	}
-
-	/** 改 - 申报时间是否必填(1=是,0=否) */
-	@RequestMapping("updateChinaCarPay")
-	@SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
-	public AjaxJson updateChinaCarPay(Long id, String value){
-		int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "china_car_pay", value, id);
-		return AjaxJson.getByLine(line);
-	}
-	
-	
-	
-	
-	
+    /**
+     * 底层 Service 对象
+     */
+    @Autowired
+    TbGoodsService tbGoodsService;
+
+    /**
+     * 增
+     */
+    @RequestMapping("add")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_ADD)
+    public AjaxJson add(TbGoods t) {
+        t.setCreateTime(new Date());
+        tbGoodsService.save(t);
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 删
+     */
+    @RequestMapping("delete")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_DEL)
+    public AjaxJson delete(Long id) {
+        tbGoodsService.removeById(id);
+        return AjaxJson.getSuccess();
+    }
+
+
+    /**
+     * 改
+     */
+    @RequestMapping("update")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson update(TbGoods t) {
+        tbGoodsService.update(t);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("getById")
+    public AjaxJson getById(Long id) {
+        TbGoods t = tbGoodsService.getById(id);
+        return AjaxJson.getSuccessData(t);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getList")
+    public AjaxJson getList() {
+        SoMap so = SoMap.getRequestSoMap();
+        List<TbGoods> list = tbGoodsService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
+
+
+    /**
+     * 改 - 状态(1=禁用,2=启用)
+     */
+    @RequestMapping("updateStatus")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE)
+    public AjaxJson updateStatus(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "status", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+
+    /**
+     * 改 - 载重是否必填(1=是,0=否)
+     */
+    @RequestMapping("updateNeedWeight")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson updateNeedWeight(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_weight", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改 - 规格是否必填(1=是,0=否)
+     */
+    @RequestMapping("updateNeedCarSize")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson updateNeedCarSize(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_car_size", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改 - 申报单是否必填(1=是,0=否)
+     */
+    @RequestMapping("updateNeedDeclare")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson updateNeedDeclare(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_declare", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改 - 申报时间是否必填(1=是,0=否)
+     */
+    @RequestMapping("updateNeedOperateTime")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson updateNeedOperateTime(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "need_operate_time", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改 - 申报时间是否必填(1=是,0=否)
+     */
+    @RequestMapping("updateVietnamCarPay")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson updateVietnamCarPay(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "vietnam_car_pay", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改 - 申报时间是否必填(1=是,0=否)
+     */
+    @RequestMapping("updateChinaCarPay")
+    @SaCheckPermission(TbGoods.PERMISSION_CODE_EDIT)
+    public AjaxJson updateChinaCarPay(Long id, String value) {
+        int line = SP.publicMapper.updateColumnById(TbGoods.TABLE_NAME, "china_car_pay", value, id);
+        return AjaxJson.getByLine(line);
+    }
+
+
+    @RequestMapping("getPayStep")
+    public AjaxJson getPayStep() {
+        return AjaxJson.getSuccessData(TbGoods.PayStep.getList());
+    }
+
+    @RequestMapping("getLeaveSetting")
+    public AjaxJson getLeaveSetting() {
+        return AjaxJson.getSuccessData(TbGoods.LeaveEnum.getList());
+    }
+
 
 }

+ 3 - 18
sp-server/src/main/java/com/pj/project/tb_item_type/TbItemType.java

@@ -80,28 +80,13 @@ public class TbItemType extends Model<TbItemType> implements Serializable {
     @TableField(exist = false)
     private String itemId;
     @TableField(exist = false)
+    private BigDecimal price;
+    @TableField(exist = false)
     private Integer num = 1;
     @TableField(exist = false)
     private String itemName;
 
-    @Getter
-    @AllArgsConstructor
-    public static enum PayStep {
-        BEFORE_CONFIRM(1,"下单后"),
-        AFTER_CONFIRM(2,"确认订单后");
-        private Integer code;
-        private String desc;
-        public static List<Map<String, Object>> getList() {
-            List<Map<String, Object>> list = new ArrayList<>();
-            for (PayStep tbItem : PayStep.values()) {
-                Map<String, Object> map = new HashMap<>();
-                map.put("id", tbItem.getCode());
-                map.put("name", tbItem.getDesc());
-                list.add(map);
-            }
-            return list;
-        }
-    }
+
 
 
 

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

@@ -106,10 +106,7 @@ public class TbItemTypeController {
         return AjaxJson.getPageData(so.getDataCount(), list);
     }
 
-    @RequestMapping("getPayStep")
-    public AjaxJson getPayStep() {
-        return AjaxJson.getSuccessData(TbItemType.PayStep.getList());
-    }
+
 
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
@@ -123,7 +120,7 @@ public class TbItemTypeController {
 
 
     @RequestMapping("getTypeByGoodsId")
-    public AjaxJson getTypeByGoodsId(Long goodsId) {
+    public AjaxJson getTypeByGoodsId(String goodsId) {
         return AjaxJson.getSuccessData(tbItemTypeService.getTypeByGoodsId(goodsId));
     }
 

+ 18 - 24
sp-server/src/main/java/com/pj/project/tb_item_type/TbItemTypeService.java

@@ -106,35 +106,29 @@ public class TbItemTypeService extends ServiceImpl<TbItemTypeMapper, TbItemType>
         super.updateById(t);
     }
 
-    public List<TbItemType> getTypeByGoodsId(Long goodsId) {
+    public List<TbItemType> getTypeByGoodsId(String goodsId) {
         List<RelationGoodsType> relationGoodsTypes = relationGoodsTypeService.findByGoodsId(goodsId);
         if (relationGoodsTypes.isEmpty()) {
             return Collections.emptyList();
         }
-        List<String> typeIds = relationGoodsTypes.stream().map(RelationGoodsType::getTypeId).collect(Collectors.toList());
-        List<RelationTypeItem> relationTypeItems = relationTypeItemService.findByTypeIds(typeIds);
-        List<TbItemType>itemTypeList=new ArrayList<>();
-        relationTypeItems.stream().collect(Collectors.groupingBy(RelationTypeItem::getTypeId))
-                .forEach((typeId, list) -> {
-                    TbItemType tbItemType = this.getById(typeId);
-                    List<String> itemIds = list.stream().map(RelationTypeItem::getItemId).collect(Collectors.toList());
-                    List<TbItem> items = tbItemService.listByIds(itemIds);
-                    for (TbItem item:items){
-                        relationTypeItems.stream()
-                                .filter(relationTypeItem -> relationTypeItem.getItemId().equals(item.getId())&&relationTypeItem.getTypeId().equals(typeId))
-                                .findFirst().ifPresent(relationTypeItem -> {
-                            System.out.println(1111);
-                            item.setInc(relationTypeItem.getInc());
-                        });
-                    }
-                    if (items.size()==1){
-                        TbItem tbItem=items.get(0);
-                        tbItemType.setItemId(tbItem.getId()).setItemName(tbItem.getItemName());
-                    }
-                    tbItemType.setItems(items);
-                    itemTypeList.add(tbItemType);
+        List<TbItemType> itemTypeList = new ArrayList<>();
+        for (RelationGoodsType relationGoodsType : relationGoodsTypes) {
+            String typeId = relationGoodsType.getTypeId();
+            List<RelationTypeItem> list = relationTypeItemService.findByTypeId(typeId);
+            TbItemType tbItemType = this.getById(typeId);
+            tbItemType.setNeed(relationGoodsType.getNeedSelect());
+            List<String> itemIds = list.stream().map(RelationTypeItem::getItemId).collect(Collectors.toList());
+            List<TbItem> items = tbItemService.listByIds(itemIds);
+            for (TbItem item : items) {
+                list.stream()
+                        .filter(relationTypeItem -> relationTypeItem.getItemId().equals(item.getId()) && relationTypeItem.getTypeId().equals(typeId))
+                        .findFirst().ifPresent(relationTypeItem -> {
+                    item.setInc(relationTypeItem.getInc());
                 });
-
+            }
+            tbItemType.setItems(items);
+            itemTypeList.add(tbItemType);
+        }
         return itemTypeList;
     }
 }