Ver código fonte

优化,定时删除操作日志

qzyReal 3 anos atrás
pai
commit
7d6b475d71

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

@@ -108,7 +108,7 @@
 						channel: this.state
 					}).then(resp => {
 						let data = resp.data;
-						if (data.cars.length > 0) {
+						if (data.cars&&data.cars.length > 0) {
 							this.total = data.total;
 							this.cars = data.cars;
 						}

+ 0 - 1
sp-admin/sa-frame/index/index.js

@@ -467,7 +467,6 @@ var sa_admin = new Vue({
 			// console.log('%c%s', 'color: green; font-size: 12px; font-weight: 400; margin-top: 4px; margin-bottom: 4px;', str);
 			var str2 = ('如在使用中发现任何bug或者疑问,请加入QQ群交流:782974737,点击加入:' + 'https://jq.qq.com/?_wv=1027&k=5DHN5Ib');
 			var s = str;// + ' \n' + str2;
-			console.log('%c%s', 'color: green; font-size: 12px; margin-top: 2px; margin-bottom: 2px;', s);
 		},
 		
 	},

+ 123 - 22
sp-admin/sa-view/tb-business/tb-business-add.html

@@ -71,6 +71,15 @@
 											</el-select>
 										</div>
 										<div class="c-item">
+											<label class="c-label">申报单:</label>
+											<el-input v-model="m.declareNo" placeholder="选择申报单">
+												<div slot="suffix" style="cursor: pointer;color: blue;"
+													@click="handlerDeclare">
+													<i class="el-icon-folder-add"></i>
+												</div>
+											</el-input>
+										</div>
+										<div class="c-item">
 											<label class="c-label"><span style="color: red;">*</span>运输货品:</label>
 											<el-select v-model="m.goodsName" placeholder="请选择" @change="goodsChange">
 												<el-option v-for="item in goodsList" :key="item.id" :label="item.name"
@@ -80,7 +89,7 @@
 										</div>
 										<sa-item type="num" name="载重(吨)" placeholder="请输入车辆载重" v-model="m.netWeight" br>
 										</sa-item>
-									<!-- 	<sa-item type="text" name="境外车牌号" placeholder="请输入境外车牌号" v-model="m.cardNo" br>
+										<!-- 	<sa-item type="text" name="境外车牌号" placeholder="请输入境外车牌号" v-model="m.cardNo" br>
 										</sa-item> -->
 										<div class="c-item">
 											<label class="c-label"><span style="color: red;">*</span>境外车牌号:</label>
@@ -258,6 +267,47 @@
 					<el-button type="primary" @click="confirmAddCar">确 定</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="car.form.driverPhone" placeholder="产品">
+					</el-input>
+					批号:
+					<el-input style="width: 140px;" v-model="car.form.driverPhone" 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="goodsName" label="产品学名">
+						</el-table-column>
+						<el-table-column prop="productionNo" label="生产批号">
+						</el-table-column>
+						<el-table-column prop="grossWeight" label="毛重">
+						</el-table-column>
+						<el-table-column prop="num" label="件数">
+						</el-table-column>
+						<el-table-column prop="carSize" label="货主单位">
+						</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({
@@ -285,7 +335,7 @@
 						driverIdCard: '', // 司机身份证 
 						payTicket: '', // 支付凭证 
 					}, // 实体对象 
-					checkItem:'',
+					checkItem: '',
 					customerList: [],
 					carList: [],
 					driverList: [],
@@ -328,6 +378,17 @@
 							driverPhone: '',
 							carSize: ''
 						}
+					},
+					declare: {
+						visible: false,
+						list: [],
+						p: {
+							pageNo: 1,
+							pageSize: 8,
+							dataCount: 0,
+							declareNo: '',
+							production: ''
+						}
 					}
 				},
 				computed: {
@@ -350,32 +411,72 @@
 					}
 				},
 				methods: {
-					findInAndNoBusinessCar(){
-						sa.ajax('/TbBusinessCar/findInAndNoBusinessCar',function(resp){
-							this.carList=resp.data;
+					resetDclare() {
+						this.declare.p = {
+							pageNo: 1,
+							pageSize: 8,
+							declareNo: '',
+							production: ''
+						}
+						this.getDeclareList();
+					},
+					handlerDeclare() {
+						this.declare.visible = true;
+						this.getDeclareList();
+					},
+					getDeclareList() {
+						sa.ajax('/tbDeClare/getList', sa.removeNull(this.declare.p), function(resp) {
+							let list = resp.data;
+							list.forEach(row => {
+								if (row.productionNo == this.m.declareNo) {
+									this.$refs.declareTable.toggleRowSelection(row, true)
+								}
+							})
+							this.declare.list = list;
+							this.declare.p.pageNo = resp.pageNo;
+							this.declare.p.dataCount = resp.dataCount;
+						}.bind(this))
+					},
+					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('只能选择一条数据')
+						}
+						this.m.declareNo = declareNo;
+						this.declare.visible = false;
+					},
+					findInAndNoBusinessCar() {
+						sa.ajax('/TbBusinessCar/findInAndNoBusinessCar', function(resp) {
+							this.carList = resp.data;
 						}.bind(this))
 					},
-					handleSelectCar(data){
-						this.m.cardNo=data.carNo;
+					handleSelectCar(data) {
+						this.m.cardNo = data.carNo;
 					},
-					queryCarAsync(queryStr,cb){
+					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;
+					handleSelectChinaCar(data) {
+						this.car.form.carNo = data.carNo;
 					},
-					queryChinaCarAsync(queryStr,cb){
+					queryChinaCarAsync(queryStr, cb) {
 						let list = this.carList;
-						let filterList = list.filter(obj => obj.carNo.indexOf(queryStr) !== -1&&obj.carNo!==this.m.cardNo);
+						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='';
+						let typeName = type.name;
+						if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
+							this.checkItem = '';
 						}
 					},
 					itemChange(itemId) {
@@ -383,14 +484,14 @@
 						let item = items.filter(obj => obj.id == itemId)[0];
 						let typeName = item.typeName;
 						let checkItem = this.checkItem;
-						if ((typeName == '干杂货人工装卸' && checkItem=='特殊车辆') ||
-							(typeName == '特殊车辆' && checkItem=='干杂货人工装卸')) {
+						if ((typeName == '干杂货人工装卸' && checkItem == '特殊车辆') ||
+							(typeName == '特殊车辆' && checkItem == '干杂货人工装卸')) {
 							this.itemTypeList.filter(obj => obj.id == item.typeId)[0].itemId = ''
 							sa.error('不能同时选择干杂货人工装卸和特殊车辆')
 							return false;
 						}
-						if (typeName == '干杂货人工装卸' ||typeName == '特殊车辆') {
-							this.checkItem=typeName;
+						if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
+							this.checkItem = typeName;
 						}
 					},
 					addCar() {
@@ -599,17 +700,17 @@
 							return;
 						}
 						let checkList = this.itemTypeList;
-						let chechItem=this.checkItem;
+						let chechItem = this.checkItem;
 						for (let j in this.needTypeId) {
 							let id = this.needTypeId[j];
 							for (let i in checkList) {
 								let type = checkList[i];
 								let typeName = type.name;
-								if (id == type.id && !type.itemId&&typeName!=='特殊车辆'&&typeName!=='干杂货人工装卸') {
+								if (id == type.id && !type.itemId && typeName !== '特殊车辆' && typeName !== '干杂货人工装卸') {
 									sa.error('选择[' + this.m.goodsName + ']时,[' + typeName + ']必选')
 									return;
 								}
-								if(!chechItem&&this.m.goodsName=='干杂货'){
+								if (!chechItem && this.m.goodsName == '干杂货') {
 									sa.error('请选择特殊车辆或干杂货人工装卸之一')
 									return;
 								}

+ 101 - 0
sp-admin/sa-view/tb-business/tb-business-edit.html

@@ -67,6 +67,15 @@
 											</el-select>
 										</div>
 										<div class="c-item">
+											<label class="c-label">申报单:</label>
+											<el-input v-model="m.declareNo" placeholder="选择申报单">
+												<div slot="suffix" style="cursor: pointer;color: blue;"
+													@click="handlerDeclare">
+													<i class="el-icon-folder-add"></i>
+												</div>
+											</el-input>
+										</div>
+										<div class="c-item">
 											<label class="c-label"><span style="color: red;">*</span>运输货品:</label>
 											<el-select v-model="m.goodsName" placeholder="请选择" @change="goodsChange">
 												<el-option v-for="item in goodsList" :key="item.id" :label="item.name"
@@ -261,6 +270,47 @@
 					<el-button type="primary" @click="confirmAddCar">确 定</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="car.form.driverPhone" placeholder="产品">
+					</el-input>
+					批号:
+					<el-input style="width: 140px;" v-model="car.form.driverPhone" 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="goodsName" label="产品学名">
+						</el-table-column>
+						<el-table-column prop="productionNo" label="生产批号">
+						</el-table-column>
+						<el-table-column prop="grossWeight" label="毛重">
+						</el-table-column>
+						<el-table-column prop="num" label="件数">
+						</el-table-column>
+						<el-table-column prop="carSize" label="货主单位">
+						</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({
@@ -331,6 +381,18 @@
 							driverPhone: '',
 							carSize: ''
 						}
+					},
+					declare: {
+						visible: false,
+						list: [],
+						declareNo: '',
+						p: {
+							pageNo: 1,
+							pageSize: 8,
+							dataCount: 0,
+							declareNo: '',
+							production: ''
+						}
 					}
 				},
 				computed: {
@@ -353,6 +415,45 @@
 					}
 				},
 				methods: {
+					resetDclare() {
+						this.declare.p = {
+							pageNo: 1,
+							pageSize: 8,
+							declareNo: '',
+							production: ''
+						}
+						this.getDeclareList();
+					},
+					handlerDeclare() {
+						this.declare.visible = true;
+						this.getDeclareList();
+					},
+					getDeclareList() {
+						sa.ajax('/tbDeClare/getList', sa.removeNull(this.declare.p), function(resp) {
+							let list = resp.data;
+							list.forEach(row => {
+								if (row.productionNo == this.m.declareNo) {
+									this.$refs.declareTable.toggleRowSelection(row, true)
+								}
+							})
+							this.declare.list = list;
+							this.declare.p.pageNo = resp.pageNo;
+							this.declare.p.dataCount = resp.dataCount;
+						}.bind(this))
+					},
+					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('只能选择一条数据')
+						}
+						this.m.declareNo = declareNo;
+						this.declare.visible = false;
+					},
 					findInAndNoBusinessCar(){
 						sa.ajax('/TbBusinessCar/findInAndNoBusinessCar',function(resp){
 							this.carList=resp.data;

+ 1 - 1
sp-server/app.pid

@@ -1 +1 @@
-8184
+19168

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

@@ -83,10 +83,10 @@ public class ApiService {
     public Map<String, Object> getPartCarByChannel(String channel) {
         Map<String, Object> result = new HashMap<>();
         String carNo = RedisUtil.get(channel);
-        if (StrUtil.isEmpty(carNo)) {
+        TbBusinessCar tbBusinessCar = tbBusinessCarService.findInBuNoOutAndNotPay(carNo);
+        if (tbBusinessCar==null) {
             return result;
         }
-        TbBusinessCar tbBusinessCar = tbBusinessCarService.findInBuNoOutAndNotPay(carNo);
         Date now=new Date();
         BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now, tbBusinessCar.getCarSize());
         BigDecimal dif = price.subtract(tbBusinessCar.getMoney());

+ 1 - 1
sp-server/src/main/java/com/pj/api/wx/WxService.java

@@ -154,7 +154,7 @@ public class WxService {
         BigDecimal money = new BigDecimal(total_fee).divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP);
         log.info("wx pay notify;{}", JSONUtil.toJsonStr(result));
         String tradeNo = result.get("out_trade_no").toString();
-        tradeNo=StrUtil.subBefore(tradeNo,"_",false);
+        tradeNo=StrUtil.subBefore(tradeNo,"_",true);
         String attachStr = result.get("attach") == null ? "" : result.get("attach").toString();
         String transactionId = result.get("transaction_id").toString();
         Date now = new Date();

+ 2 - 0
sp-server/src/main/java/com/pj/project/tb_account/TbAccount.java

@@ -79,4 +79,6 @@ public class TbAccount extends Model<TbAccount> implements Serializable {
      */
     private Date createTime;
 
+    private String payPassword;
+    private String payPasswordSalt;
 }

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

@@ -57,6 +57,10 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
      * 客户id
      */
     private String customerId;
+    /**
+     * 申报单号
+     */
+    private String declareNo;
 
     /**
      * 客户名称

+ 1 - 0
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessController.java

@@ -162,6 +162,7 @@ public class TbBusinessController {
      */
     @RequestMapping("getList")
     public AjaxJson getList() {
+        System.out.println(StrUtil.subBefore("c_2222_fhjk","_",true));
         SoMap so = SoMap.getRequestSoMap();
         String currentCustomerId = StpUserUtil.getCustomerId();
         if (!currentCustomerId.equals(UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {

+ 1 - 0
sp-server/src/main/java/com/pj/project4sp/apilog/SpApilogMapper.java

@@ -66,4 +66,5 @@ public interface SpApilogMapper {
 	SoMap staBy(SoMap so);
 
 
+    void cleanHistoryLog(@Param("cleanDayBefore") String cleanDayBefore);
 }

+ 79 - 77
sp-server/src/main/java/com/pj/project4sp/apilog/SpApilogMapper.xml

@@ -2,9 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.pj.project4sp.apilog.SpApilogMapper">
 
-	
-	<!-- 保存入库 -->
-	<insert id="saveObj">
+
+    <!-- 保存入库 -->
+    <insert id="saveObj">
 		insert into 
 		sp_apilog (
 			id, req_ip, req_api, req_parame, req_type, req_token, req_header, user_id, admin_id, start_time,
@@ -13,29 +13,32 @@
 			#{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqType}, #{reqToken}, #{reqHeader}, #{userId}, #{adminId}, #{startTime},
 			#{resCode}, #{resMsg}, #{resString}, #{endTime}, #{costTime}) 
 	</insert>
-	
-	
-	<!-- 增 -->
-	<insert id="add">
+
+
+    <!-- 增 -->
+    <insert id="add">
 		insert into 
 		sp_apilog (id, req_ip, req_api, req_parame, req_token, user_id, admin_id, start_time) 
 		values (#{id}, #{reqIp}, #{reqApi}, #{reqParame}, #{reqToken}, #{userId}, #{adminId}, now(3)) 
 	</insert>
 
-	<!-- 删 -->
-	<delete id="delete">
+    <!-- 删 -->
+    <delete id="delete">
 		delete from sp_apilog 
 		where id = #{id}
 	</delete>
 
-	<!-- 删 -->
-	<delete id="deleteByStartEnd">
+    <!-- 删 -->
+    <delete id="deleteByStartEnd">
 		delete from sp_apilog 
 		where start_time BETWEEN #{startTime} AND #{endTime} 
 	</delete>
-	
-	<!-- 改 -->
-	<update id="update">
+    <delete id="cleanHistoryLog">
+		delete  from sp_apilog where date_format(end_time,'%Y-%m-%d') &lt;=#{cleanDayBefore}
+	</delete>
+
+    <!-- 改 -->
+    <update id="update">
 		update sp_apilog set
 		res_code = #{resCode}, 
 		res_msg = #{resMsg}, 
@@ -44,71 +47,70 @@
 		cost_time = #{costTime} 
 		where id = #{id}
 	</update>
-	
-	<!-- ================================== 查询相关 ================================== -->
-	
-	<!-- 通用映射 -->
-	<resultMap id="model" type="com.pj.project4sp.apilog.SpApilog">
-		<result property="id" column="id" />
-		<result property="reqIp" column="req_ip" />
-		<result property="reqApi" column="req_api" />
-		<result property="reqParame" column="req_parame" />
-		<result property="reqType" column="req_type" />
-		<result property="reqToken" column="req_token" />
-		<result property="reqHeader" column="req_header" />
-		<result property="resCode" column="res_code" />
-		<result property="resMsg" column="res_msg" />
-		<result property="resString" column="res_string" />
-		<result property="userId" column="user_id" />
-		<result property="adminId" column="admin_id" />
-		<result property="startTime" column="start_time" />
-		<result property="endTime" column="end_time" />
-		<result property="costTime" column="cost_time" />
-	</resultMap>
-	
-	<!-- 公共查询sql片段 -->
-	<sql id="select_sql">
+
+    <!-- ================================== 查询相关 ================================== -->
+
+    <!-- 通用映射 -->
+    <resultMap id="model" type="com.pj.project4sp.apilog.SpApilog">
+        <result property="id" column="id"/>
+        <result property="reqIp" column="req_ip"/>
+        <result property="reqApi" column="req_api"/>
+        <result property="reqParame" column="req_parame"/>
+        <result property="reqType" column="req_type"/>
+        <result property="reqToken" column="req_token"/>
+        <result property="reqHeader" column="req_header"/>
+        <result property="resCode" column="res_code"/>
+        <result property="resMsg" column="res_msg"/>
+        <result property="resString" column="res_string"/>
+        <result property="userId" column="user_id"/>
+        <result property="adminId" column="admin_id"/>
+        <result property="startTime" column="start_time"/>
+        <result property="endTime" column="end_time"/>
+        <result property="costTime" column="cost_time"/>
+    </resultMap>
+
+    <!-- 公共查询sql片段 -->
+    <sql id="select_sql">
 		select * from sp_apilog 
 	</sql>
-	
-	<!-- 查询,根据条件(参数为null或0时默认忽略此条件) -->
-	<select id="getList" resultMap="model" >
-		<include refid="select_sql"></include>
-		where 1 = 1 
-		<if test=' this.has("id")  '>and id = #{id} </if>
-		<if test=' this.has("reqToken") '>and req_token = #{reqToken} </if>
-		<if test=' this.has("reqIp") '> and req_ip = #{reqIp} </if>
-		<if test=' this.has("reqApi") '>and req_api = #{reqApi} </if>
-		<if test=' this.has("resCode") '>and res_code = #{resCode} </if>
-		<if test=' this.has("userId") '>and user_id = #{userId} </if>
-		<if test=' this.has("adminId") '>and admin_id = #{adminId} </if>
-		<if test=' this.has("sTime") '>and start_time &gt;= #{sTime} </if>
-		<if test=' this.has("eTime") '>and start_time &lt;= #{eTime} </if>
-		order by 
-		<choose>
-			<when test='sortType == 0'>id desc</when> 
-			<when test='sortType == 1'>start_time desc, id desc</when> 
-			<when test='sortType == 2'>cost_time desc, id desc</when> 
-		 	<otherwise>id desc</otherwise>
-		 </choose>
-	</select>
-	
-	
-	
-	<!-- 统计 -->
-	<select id="staBy" resultType="somap">
-		select sum(cost_time) as cost_time_count from sp_apilog 
-		where 1 = 1 
-		<if test=' this.has("id")  '>and id = #{id} </if>
-		<if test=' this.has("reqToken") '>and req_token = #{reqToken} </if>
-		<if test=' this.has("reqIp") '> and req_ip = #{reqIp} </if>
-		<if test=' this.has("reqApi") '>and req_api = #{reqApi} </if>
-		<if test=' this.has("resCode") '>and res_code = #{resCode} </if>
-		<if test=' this.has("userId") '>and user_id = #{userId} </if>
-		<if test=' this.has("adminId") '>and admin_id = #{adminId} </if>
-		<if test=' this.has("sTime") '>and start_time &gt;= #{sTime} </if>
-		<if test=' this.has("eTime") '>and start_time &lt;= #{eTime} </if>
-	</select>
+
+    <!-- 查询,根据条件(参数为null或0时默认忽略此条件) -->
+    <select id="getList" resultMap="model">
+        <include refid="select_sql"></include>
+        where 1 = 1
+        <if test=' this.has("id")  '>and id = #{id}</if>
+        <if test=' this.has("reqToken") '>and req_token = #{reqToken}</if>
+        <if test=' this.has("reqIp") '>and req_ip = #{reqIp}</if>
+        <if test=' this.has("reqApi") '>and req_api = #{reqApi}</if>
+        <if test=' this.has("resCode") '>and res_code = #{resCode}</if>
+        <if test=' this.has("userId") '>and user_id = #{userId}</if>
+        <if test=' this.has("adminId") '>and admin_id = #{adminId}</if>
+        <if test=' this.has("sTime") '>and start_time &gt;= #{sTime}</if>
+        <if test=' this.has("eTime") '>and start_time &lt;= #{eTime}</if>
+        order by
+        <choose>
+            <when test='sortType == 0'>id desc</when>
+            <when test='sortType == 1'>start_time desc, id desc</when>
+            <when test='sortType == 2'>cost_time desc, id desc</when>
+            <otherwise>id desc</otherwise>
+        </choose>
+    </select>
+
+
+    <!-- 统计 -->
+    <select id="staBy" resultType="somap">
+        select sum(cost_time) as cost_time_count from sp_apilog
+        where 1 = 1
+        <if test=' this.has("id")  '>and id = #{id}</if>
+        <if test=' this.has("reqToken") '>and req_token = #{reqToken}</if>
+        <if test=' this.has("reqIp") '>and req_ip = #{reqIp}</if>
+        <if test=' this.has("reqApi") '>and req_api = #{reqApi}</if>
+        <if test=' this.has("resCode") '>and res_code = #{resCode}</if>
+        <if test=' this.has("userId") '>and user_id = #{userId}</if>
+        <if test=' this.has("adminId") '>and admin_id = #{adminId}</if>
+        <if test=' this.has("sTime") '>and start_time &gt;= #{sTime}</if>
+        <if test=' this.has("eTime") '>and start_time &lt;= #{eTime}</if>
+    </select>
 
 
 </mapper>

+ 4 - 4
sp-server/src/main/java/com/pj/project4sp/apilog/SpApilogUtil.java

@@ -62,8 +62,8 @@ public class SpApilogUtil {
     	request.setAttribute(APILOG_OBJ_SAVE_KEY, a);
     	
     	// 控制台日志 
-    	LogUtil.info("----------------------------------------------------------------");
-		LogUtil.info("IP: " + a.getReqIp() + "\tr-> " + a.getReqApi()+ "\tp-> " + a.getReqParame());
+    	//LogUtil.info("----------------------------------------------------------------");
+		//LogUtil.info("IP: " + a.getReqIp() + "\tr-> " + a.getReqApi()+ "\tp-> " + a.getReqParame());
 	}
 	
 
@@ -72,7 +72,7 @@ public class SpApilogUtil {
 	 * @param aj
 	 */
 	public static void endRequest(AjaxJson aj) {
-		if(isWeb() == false)  {
+		if(!isWeb())  {
 			return;
 		}
 		
@@ -99,7 +99,7 @@ public class SpApilogUtil {
 				a.setResString("{\"msg\": \"数据过长,无法写入 (length=" + a.getResString().length() + ")\"}");		
 			}
 		
-        	LogUtil.info("本次请求耗时:" + ((a.getCostTime() + 0.0) / 1000) + "s, 返回:" + a.getResString());
+        	//LogUtil.info("本次请求耗时:" + ((a.getCostTime() + 0.0) / 1000) + "s, 返回:" + a.getResString());
         	spApilogMapper.saveObj(a);
 		} catch (Exception e) {
 			e.printStackTrace();

+ 21 - 0
sp-server/src/main/java/com/pj/project4sp/apilog/Task.java

@@ -0,0 +1,21 @@
+package com.pj.project4sp.apilog;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+
+@Component
+@Slf4j
+public class Task {
+    @Resource
+    SpApilogMapper spApilogMapper;
+    @Scheduled(cron = "0 0 4 * * ?")
+    public void cleanLog(){
+        log.info("start clean api log");
+        LocalDate today=LocalDate.now();
+        spApilogMapper.cleanHistoryLog(today.minusDays(-2).toString());
+    }
+}

+ 1 - 3
sp-server/src/main/resources/logback.xml

@@ -103,9 +103,7 @@
 			<onMismatch>DENY</onMismatch>
 		</filter>
 	</appender>
-	<logger name="com.cryann.hsms.driver.config.log" additivity="false">
-		<appender-ref ref="SXFX_info_LOG"/>
-	</logger>
+
 
 	<logger name="org.springframework" level="WARN"/>
 	<logger name="org.hibernate" level="WARN"/>