Commit 7b6411f1 by zhanghj

V1.2.0--提交PC端订货单列表接口功能代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@21743 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 4db8cf5c
package com.glsx.ordercenter.controller;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.feign.client.UserClient;
import com.glsx.ordercenter.pojo.*;
import com.glsx.ordercenter.service.ReceiveAddressService;
import com.glsx.ordercenter.utils.KdApiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -20,13 +15,22 @@ import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
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.fastjson.JSONObject;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.Page;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.pojo.GroupA;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.service.IndentService;
import com.glsx.ordercenter.service.ReceiveAddressService;
/**
*
......@@ -54,6 +58,45 @@ public class IndentController extends BaseController{
@Autowired
private UserClient userClient;
/**
*
* @author zhanghj
* @Title: getIndentListByPage
* @Description: TODO PC端分页获取订货单列表
* @param pageIndex
* @param pageSize
* @param indent
* @return
* ResultObject
*
*/
@AuthCheck
@RequestMapping(value="/getIndentListByPage", method=RequestMethod.GET)
public ResultObject getIndentListByPage(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, SysIndent indent) {
Map<String, Object> result = new HashMap<String, Object>();
if(indent!=null){
logger.info("订货单列表搜索传递的参数:"+JSONObject.toJSONString(indent));
}
Integer indentStatus = indent.getIndentStatus();
/**
* 50定义为取消
*/
if (indentStatus != null && 50 == indentStatus) {
indent.setIsCanceled((byte) 1);
indent.setIndentStatus(null);
}
Page page = new Page(pageIndex, pageSize);
List<SysIndent> list = indentService.getIndentListByPage(page, indent);
com.github.pagehelper.Page<SysIndent> pages = (com.github.pagehelper.Page<SysIndent>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
@AuthCheck
@RequestMapping(value="/add", method=RequestMethod.POST)
public ResultObject add(HttpServletRequest request, @Validated(value = {Default.class}) SysIndent indent, BindingResult bindingResult) {
......
package com.glsx.ordercenter.mapper;
import java.util.List;
import com.glsx.ordercenter.pojo.SysIndent;
import org.apache.ibatis.annotations.Param;
public interface SysIndentMapper {
......@@ -20,4 +23,16 @@ public interface SysIndentMapper {
int getIndentCount(SysIndent indent);
Integer getSendDeviceNum(@Param("userId") Integer userId, @Param("deviceType")String deviceType);
/**
*
* @author zhanghj
* @Title: getIndentListByPage
* @Description: TODO 分页获取订货单列表
* @param indent
* @return
* List<SysIndent>
*
*/
List<SysIndent> getIndentListByPage(SysIndent indent);
}
\ No newline at end of file
......@@ -21,8 +21,12 @@ public class SysIndent extends BaseModel{
*/
private Integer userId;
private String username;
@NotBlank(message="{param.not.null}", groups={Default.class, GroupA.class})
private String deviceType;
private String deviceName;
/**
* 订货数量
......@@ -180,17 +184,33 @@ public class SysIndent extends BaseModel{
this.receiveAddressId = receiveAddressId;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Override
public String toString() {
return "SysIndent [id=" + id + ", indentNo=" + indentNo + ", sendType="
+ sendType + ", userId=" + userId + ", deviceType="
+ deviceType + ", deviceAmount=" + deviceAmount
+ ", indentStatus=" + indentStatus + ", isCanceled="
+ isCanceled + ", districtCode=" + districtCode + ", address="
+ address + ", receiveAddressId=" + receiveAddressId
+ ", phone=" + phone + ", receiverName=" + receiverName
+ ", beginDate=" + beginDate + ", endDate=" + endDate + "]";
+ sendType + ", userId=" + userId + ", username=" + username
+ ", deviceType=" + deviceType + ", deviceName=" + deviceName
+ ", deviceAmount=" + deviceAmount + ", indentStatus="
+ indentStatus + ", isCanceled=" + isCanceled
+ ", districtCode=" + districtCode + ", address=" + address
+ ", receiveAddressId=" + receiveAddressId + ", phone=" + phone
+ ", receiverName=" + receiverName + ", beginDate=" + beginDate
+ ", endDate=" + endDate + "]";
}
}
\ No newline at end of file
package com.glsx.ordercenter.service;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.pojo.SysIndentLog;
import com.glsx.ordercenter.pojo.SysIndentLogModel;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.pojo.SysOrder;
import java.util.List;
/**
*
* @Title IndentService.java
......@@ -73,5 +78,18 @@ public interface IndentService {
*/
SysIndent selectByPrimaryKey(Integer id);
/**
*
* @author zhanghj
* @Title: getIndentListByPage
* @Description: TODO 分页获取库存列表
* @param page
* @param indent
* @return
* List<SysOrder>
*
*/
List<SysIndent> getIndentListByPage(Page page, SysIndent indent);
List<SysIndentLogModel> listIndentLog(String indentId);
}
......@@ -3,20 +3,25 @@ package com.glsx.ordercenter.service.impl;
import java.util.Date;
import java.util.List;
import com.glsx.ordercenter.constants.IndentStatusEnum;
import com.glsx.ordercenter.mapper.SysIndentLogisticsMapper;
import com.glsx.ordercenter.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.DateUtil;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.IndentStatusEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysIndentLogMapper;
import com.glsx.ordercenter.mapper.SysIndentLogisticsMapper;
import com.glsx.ordercenter.mapper.SysIndentMapper;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.pojo.SysIndentLog;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.pojo.SysReceiveAddress;
import com.glsx.ordercenter.service.DeviceRepertoryService;
import com.glsx.ordercenter.service.IndentService;
import com.glsx.ordercenter.service.ReceiveAddressService;
......@@ -205,6 +210,16 @@ public class IndentServiceImpl implements IndentService {
return num;
}
@Override
public List<SysIndent> getIndentListByPage(Page page, SysIndent indent) {
// TODO Auto-generated method stub
int pageIndex = page.getPageIndex();
int pageSize = page.getPageSize();
PageHelper.startPage(pageIndex, pageSize, true);
List<SysIndent> list = indentDao.getIndentListByPage(indent);
return list;
}
/**
* 订货单操作日志
* @param indentId
......
......@@ -4,11 +4,14 @@
<resultMap id="BaseResultMap" type="com.glsx.ordercenter.pojo.SysIndent">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="indent_no" jdbcType="VARCHAR" property="indentNo" />
<result column="send_type" jdbcType="INTEGER" property="sendType" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="device_type" jdbcType="VARCHAR" property="deviceType" />
<result column="device_amount" jdbcType="INTEGER" property="deviceAmount" />
<result column="indent_status" jdbcType="INTEGER" property="indentStatus" />
<result column="is_canceled" jdbcType="TINYINT" property="isCanceled" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="receiver_name" jdbcType="VARCHAR" property="receiverName" />
<result column="district_code" jdbcType="INTEGER" property="districtCode" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
......@@ -16,6 +19,8 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="INTEGER" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="deviceName" jdbcType="VARCHAR" property="deviceName" />
</resultMap>
<sql id="Base_Column_List">
id, indent_no, user_id, device_type, device_amount, indent_status, is_canceled, district_code,
......@@ -253,4 +258,45 @@
where ssm.service_id = #{userId}
);
</select>
<select id="getIndentListByPage" parameterType="com.glsx.ordercenter.pojo.SysIndent" resultMap="BaseResultMap">
<if test="username != null and username != ''">
<bind name="username" value="'%' + username + '%'"/>
</if>
<if test="beginDate != null and beginDate != ''">
<bind name="beginDate" value=" beginDate + ' 00:00'"/>
</if>
<if test="endDate != null and endDate != ''">
<bind name="endDate" value="endDate + ' 23:59'"/>
</if>
select
si.id, si.indent_no, si.send_type, si.user_id, si.device_type,
si.device_amount, si.indent_status, si.is_canceled, si.phone,
si.receiver_name, si.district_code, si.address, si.remark,
si.create_by, si.create_time, si.update_by, si.update_time,
su.username,
sdd.data_value as deviceName
FROM
sys_indent si
LEFT JOIN sys_user su ON si.user_id = su.id
LEFT JOIN sys_dict_data sdd ON si.device_type = sdd.data_key
<where>
si.send_type = 2
<if test="indentStatus != null">
and si.indent_status = #{indentStatus}
</if>
<if test="isCanceled != null">
and si.is_canceled = #{isCanceled}
</if>
<if test="beginDate != null and beginDate != ''">
and si.create_time &gt;= #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and si.create_time &lt;= #{endDate}
</if>
<if test="username != null">
and su.username like #{username}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!