Commit 4a3a42f6 by zhengxj

finish 修正label为空 on 20190830

by zhengxj 

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@23734 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 48fc1f33
......@@ -5,6 +5,24 @@
*/
package com.glsx.ordercenter.controller;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.annotation.AuthCheck;
......@@ -20,14 +38,7 @@ import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderBiddingRecords;
import com.glsx.ordercenter.service.IOrderBiddingService;
import com.glsx.ordercenter.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import com.glsx.ordercenter.utils.OrderUtil;
/**
* @author Zheng Xiajun
......@@ -43,6 +54,8 @@ public class OrderBiddingController extends BaseController {
private IOrderBiddingService orderBiddingService;
@Autowired
private IOrderService orderService;
@Autowired
private OrderUtil orderUtil;
@SuppressWarnings("resource")
/**
......@@ -147,14 +160,29 @@ public class OrderBiddingController extends BaseController {
public ResultObject getBiddingListByOrderIdAndKeyWord(HttpServletRequest request,
@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize,
@RequestParam(required = true) Integer orderId, String keyWord) {
int isSelectByPhoneNumber = 0;
// 构建关键字搜索条件
if (StringUtils.isEmpty(keyWord)) {
keyWord = null;
}
if (!StringUtils.isEmpty(keyWord)) {
if (keyWord.length() < 2) {
return new ResultObject(ResultCodeEnum.FAIL.getCode(), "输入字符过短,请请输入正确的查询条件");
}
if (keyWord.length() >= 4 && orderUtil.isPureDigital(keyWord)) {
// 按电话号搜索
isSelectByPhoneNumber = 1;
}
}
Map<String, Object> result = new HashMap<>();
if (StringUtils.isEmpty(keyWord)) {
keyWord = null;
}
List<BiddingOrderResp> list = orderBiddingService.selectByOrderIdAndKeyWord(pageIndex, pageSize, orderId,
keyWord);
keyWord,isSelectByPhoneNumber);
Page page = new Page(pageIndex, pageSize);
com.github.pagehelper.Page<BiddingOrderResp> pages = (com.github.pagehelper.Page<BiddingOrderResp>) list;
page.setTotalCount((int) pages.getTotal());
......@@ -216,9 +244,8 @@ public class OrderBiddingController extends BaseController {
public ResultObject orderMarket(HttpServletRequest request, String keyWord,
@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize) {
Map<String, Object> result = new HashMap<String, Object>();
// 获取当前用户信息 根据用户角色筛选订单
// 获取当前用户信息 根据用户角色筛选订单
Integer serviceId = UserUtils.getUserId(request);
Page page = new Page(pageIndex, pageSize);
List<SysOrder> list = orderBiddingService.orderMarket(page, serviceId, keyWord);
......@@ -302,7 +329,7 @@ public class OrderBiddingController extends BaseController {
*
*/
@RequestMapping(value = "/updateBiddingOrderNoBidList", method = {RequestMethod.POST})
public ResultObject updateBiddingOrderNoBidList() {
public ResultObject updateBiddingrderNoBidList() {
orderBiddingService.updateBiddingOrderNoBidList();
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
......
......@@ -28,7 +28,7 @@ public interface SysOrderBiddingRecordsMapper {
int updateByPrimaryKey(SysOrderBiddingRecords record);
List<BiddingOrderResp> selectBiddingList(@Param("orderId") Integer orderId,@Param("keyWord") String keyWord);
List<BiddingOrderResp> selectBiddingList(@Param("orderId") Integer orderId,@Param("keyWord") String keyWord,@Param("isSelectByPhone")int isSelectByPhone);
List<String> selectUserServiceItems(@Param("userId") Integer userId);
......
......@@ -52,7 +52,7 @@ public interface IOrderBiddingService {
ResultObject appointServiceProvider(SysOrderBiddingRecords record);
List<BiddingOrderResp> selectByOrderIdAndKeyWord(int pageIndex, int pageSize, Integer orderId, String keyWord);
List<BiddingOrderResp> selectByOrderIdAndKeyWord(int pageIndex, int pageSize, Integer orderId, String keyWord,int isSelectByPhone);
/**
*
......
......@@ -25,7 +25,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
......@@ -482,9 +481,9 @@ public class OrderBiddingServiceImpl implements IOrderBiddingService {
*/
@Override
public List<BiddingOrderResp> selectByOrderIdAndKeyWord(int pageIndex, int pageSize, Integer orderId,
String keyWord) {
String keyWord,int isSelectByPhone) {
PageHelper.startPage(pageIndex, pageSize);
List<BiddingOrderResp> list = sysOrderBiddingRecordsMapper.selectBiddingList(orderId, keyWord);
List<BiddingOrderResp> list = sysOrderBiddingRecordsMapper.selectBiddingList(orderId, keyWord,isSelectByPhone);
if (!list.isEmpty()) {
for (BiddingOrderResp bor : list) {
bor.setServiceItems(sysOrderBiddingRecordsMapper.selectUserServiceItems(bor.getServiceId()));
......@@ -510,10 +509,7 @@ public class OrderBiddingServiceImpl implements IOrderBiddingService {
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
}
// 构建关键字搜索条件
if (StringUtils.isEmpty(keyWord)) {
keyWord = null;
}
List<SysOrder> orderList = sysOrderBiddingRecordsMapper.selectBiddingOrders(serviceId, keyWord);
// 获取车辆信息
......
......@@ -5,6 +5,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
......@@ -258,4 +259,21 @@ public class OrderUtil {
return carInfo;
}
public boolean isPureDigital(String string) {
if (StringUtil.isEmpty(string))
return false;
String regEx1 = "\\d+";
Pattern p;
Matcher m;
p = Pattern.compile(regEx1);
m = p.matcher(string);
if (m.matches())
return true;
else
return false;
}
}
......@@ -194,22 +194,27 @@
<select id="selectBiddingList" resultMap="ExtBaseResultMap">
SELECT
sobr.*,su.`name`,su.username,su.phone_number from sys_order_bidding_records sobr
LEFT JOIN sys_order so ON sobr.order_id = so.id
LEFT JOIN sys_user su ON sobr.service_id = su.id
LEFT JOIN sys_user_services sus ON su.id = sus.user_id
LEFT JOIN sys_dict_data sdd ON sdd.data_key = sus.service_key
<where>
sobr.price &gt; 0 and sobr.is_bidding &lt;&gt; 0
<if test="orderId != null">
and order_id = #{orderId,jdbcType=INTEGER}
</if>
<if test="keyWord != null">
AND ( su.`name` LIKE CONCAT('%',#{keyWord},'%') OR su.phone_number LIKE CONCAT('%',#{keyWord},'%') OR
sdd.data_value LIKE CONCAT('%',#{keyWord},'%'))
</if>
</where>
SELECT
sobr.*,su.`name`,su.username,su.phone_number from sys_order_bidding_records sobr
LEFT JOIN sys_order so ON sobr.order_id = so.id
LEFT JOIN sys_user su ON sobr.service_id = su.id
LEFT JOIN sys_user_services sus ON su.id = sus.user_id
LEFT JOIN sys_dict_data sdd ON sdd.data_key = sus.service_key
<where>
sobr.price &gt; 0 and sobr.is_bidding &lt;&gt; 0
<if test="orderId != null">
and order_id = #{orderId,jdbcType=INTEGER}
</if>
<if test="isSelectByPhone=1">
AND su.phone_number LIKE CONCAT('%',#{keyWord},'%')
</if>
<if test="isSelectByPhone=0">
<if test="keyWord != null">
AND ( su.`name` LIKE CONCAT('%',#{keyWord},'%') OR
sdd.data_value LIKE CONCAT('%',#{keyWord},'%'))
</if>
</if>
</where>
GROUP BY id
ORDER BY create_time ASC
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!