Commit a5a95436 by zhanghj

V1.2.0--提交订货单相关代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@21600 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 0d80823d
......@@ -72,5 +72,10 @@ public interface BizConstants {
*/
public static final int SYSMERCHANT_WOKE_STATUS = 1;
public static final int SYSMERCHANT_UNWOKE_STATUS = 2;
/**
* 订货单编码前缀
*/
public static final String INDENT_NO_PREFIX = "8000";
}
package com.glsx.ordercenter.constants;
/**
*
* @Title IndentStatusEnum.java
* @Package com.glsx.ordercenter.constants
* @Description TODO 订货单状态enum
* @author zhanghj
* @date 2019年6月3日 下午5:43:40
* @version 1.0.0
*/
public enum IndentStatusEnum {
INDENT_UNCHECKED(10, "待审核"),
INDENT_WAITDELIVER(20, "待发货"),
INDENT_DELIVERED(30, "待收货"),
INDENT_COMPLETE(40, "已完成");
/**
* 订货单状态
*/
private int indentStatus;
/**
* 状态对应的信息
*/
private String msg;
private IndentStatusEnum(int indentStatus, String msg) {
this.indentStatus = indentStatus;
this.msg = msg;
}
public int getIndentStatus() {
return indentStatus;
}
public void setIndentStatus(int indentStatus) {
this.indentStatus = indentStatus;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.glsx.ordercenter.controller;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import com.glsx.common.annotation.AuthCheck;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.service.IndentService;
/**
*
* @Title IndentController.java
* @Package com.glsx.ordercenter.controller
* @Description TODO 订货单controller
* @author zhanghj
* @date 2019年6月3日 下午4:29:20
* @version 1.0.0
*/
@RestController
@RequestMapping(value="/indent")
public class IndentController extends BaseController{
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private IndentService indentService;
@AuthCheck
@RequestMapping(value="/add", method=RequestMethod.POST)
public ResultObject add(HttpServletRequest request, @Validated(value = {Default.class}) SysIndent indent, BindingResult bindingResult) {
logger.info("添加订货单参数:" + indent.toString());
if (bindingResult.hasErrors()) {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
Integer userId = UserUtils.getUserId(request);
indent.setCreateBy(userId);
indent.setCreateTime(new Date());
indentService.add(indent);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
}
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.pojo.SysIndent;
public interface SysIndentMapper {
int deleteByPrimaryKey(Integer id);
int insert(SysIndent record);
int insertSelective(SysIndent record);
SysIndent selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(SysIndent record);
int updateByPrimaryKey(SysIndent record);
int getIndentCount(SysIndent indent);
}
\ No newline at end of file
......@@ -12,7 +12,7 @@ public class BaseModel {
/**
* 创建人
*/
private String createBy;
private Integer createBy;
/**
* 创建时间
*/
......@@ -20,7 +20,7 @@ public class BaseModel {
/**
* 更新人
*/
private String updateBy;
private Integer updateBy;
/**
* 更新时间
*/
......@@ -29,44 +29,35 @@ public class BaseModel {
* 备注
*/
private String remark;
public String getCreateBy() {
public Integer getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
public void setCreateBy(Integer createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
public Integer getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
public void setUpdateBy(Integer updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
package com.glsx.ordercenter.pojo;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
public class SysIndent extends BaseModel{
private Integer id;
private String indentNo;
/**
* 发货方式(1:服务商发货;2:广联发货)
*/
private Integer sendType;
/**
* 接收人用户id
*/
@NotNull(message="{param.not.null}", groups={Default.class})
private Integer userId;
@NotBlank(message="{param.not.null}", groups={Default.class})
private String deviceType;
/**
* 订货数量
*/
@NotNull(message="{param.not.null}", groups={Default.class})
private Integer deviceAmount;
private Integer indentStatus;
private Byte isCanceled;
@NotNull(message="{param.not.null}", groups={Default.class})
private Integer districtCode;
private String address;
/**
* 收货地址的电话
*/
private String phone;
/**
* 收货地址的姓名
*/
private String receiverName;
/**
* 查询:开始时间
*/
private String beginDate;
/**
* 查询:结束时间
*/
private String endDate;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getIndentNo() {
return indentNo;
}
public void setIndentNo(String indentNo) {
this.indentNo = indentNo == null ? null : indentNo.trim();
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType == null ? null : deviceType.trim();
}
public Integer getDeviceAmount() {
return deviceAmount;
}
public void setDeviceAmount(Integer deviceAmount) {
this.deviceAmount = deviceAmount;
}
public Integer getIndentStatus() {
return indentStatus;
}
public void setIndentStatus(Integer indentStatus) {
this.indentStatus = indentStatus;
}
public Byte getIsCanceled() {
return isCanceled;
}
public void setIsCanceled(Byte isCanceled) {
this.isCanceled = isCanceled;
}
public Integer getDistrictCode() {
return districtCode;
}
public void setDistrictCode(Integer districtCode) {
this.districtCode = districtCode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public String getBeginDate() {
return beginDate;
}
public void setBeginDate(String beginDate) {
this.beginDate = beginDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getReceiverName() {
return receiverName;
}
public void setReceiverName(String receiverName) {
this.receiverName = receiverName;
}
public Integer getSendType() {
return sendType;
}
public void setSendType(Integer sendType) {
this.sendType = sendType;
}
}
\ No newline at end of file
package com.glsx.ordercenter.service;
import javax.servlet.http.HttpServletRequest;
import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.pojo.SysIndent;
/**
*
* @Title IndentService.java
* @Package com.glsx.ordercenter.service
* @Description TODO 订货单service
* @author zhanghj
* @date 2019年6月3日 下午5:37:00
* @version 1.0.0
*/
public interface IndentService {
/**
*
* @author zhanghj
* @Title: add
* @Description: TODO 增加订货单
* @param indent
* @return
* ResultObject
*
*/
int add(SysIndent indent);
}
package com.glsx.ordercenter.service.impl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.glsx.common.utils.DateUtil;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.mapper.SysIndentMapper;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.service.IndentService;
@Service
public class IndentServiceImpl implements IndentService {
@Autowired
private SysIndentMapper indentDao;
@Override
@Transactional
public int add(SysIndent indent) {
// TODO Auto-generated method stub
String indentNo = getIndentNo();
indent.setIndentNo(indentNo);
int num = indentDao.insertSelective(indent);
if (num >0) {
}
return num;
}
/**
*
* @author zhanghj
* @Title: getIndentNo
* @Description: TODO 获取订货单号
* @return
* String
*
*/
private synchronized String getIndentNo() {
String orderNoPrefix = BizConstants.INDENT_NO_PREFIX;
String currentDateStr = DateUtil.formatDateYmd(new Date());
String currentDateStr2 = DateUtil.formatDateYmd(new Date());
SysIndent indent = new SysIndent();
String beginDate = currentDateStr2 + " 00:00:00";
String endDate = currentDateStr2 + " 23:59:59";
indent.setBeginDate(beginDate);
indent.setEndDate(endDate);
int todayOrderCounts = getIndentCount(indent);
int countNum = todayOrderCounts + 1;
/*
* 订单类型编号+年+月+日+当日订单数
*/
String orderSn = orderNoPrefix + currentDateStr + countNum;
return orderSn;
}
public int getIndentCount(SysIndent indent) {
// TODO Auto-generated method stub
return indentDao.getIndentCount(indent);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.ordercenter.mapper.SysIndentMapper">
<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="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="district" jdbcType="INTEGER" property="district" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_by" jdbcType="INTEGER" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="INTEGER" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
id, indent_no, user_id, device_type, device_amount, indent_status, is_canceled, district,
address, remark, create_by, create_time, update_by, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_indent
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from sys_indent
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.glsx.ordercenter.pojo.SysIndent">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_indent (indent_no, send_type, user_id,
device_type, device_amount, indent_status,
is_canceled, phone, receiver_name,
district_code, address, remark,
create_by, create_time, update_by,
update_time)
values (#{indentNo,jdbcType=VARCHAR}, #{sendType,jdbcType=TINYINT}, #{userId,jdbcType=INTEGER},
#{deviceType,jdbcType=VARCHAR}, #{deviceAmount,jdbcType=INTEGER}, #{indentStatus,jdbcType=INTEGER},
#{isCanceled,jdbcType=TINYINT}, #{phone,jdbcType=VARCHAR}, #{receiverName,jdbcType=VARCHAR},
#{districtCode,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createBy,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=INTEGER},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.glsx.ordercenter.pojo.SysIndent">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into sys_indent
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="indentNo != null">
indent_no,
</if>
<if test="sendType != null">
send_type,
</if>
<if test="userId != null">
user_id,
</if>
<if test="deviceType != null">
device_type,
</if>
<if test="deviceAmount != null">
device_amount,
</if>
<if test="indentStatus != null">
indent_status,
</if>
<if test="isCanceled != null">
is_canceled,
</if>
<if test="phone != null">
phone,
</if>
<if test="receiverName != null">
receiver_name,
</if>
<if test="districtCode != null">
district_code,
</if>
<if test="address != null">
address,
</if>
<if test="remark != null">
remark,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="indentNo != null">
#{indentNo,jdbcType=VARCHAR},
</if>
<if test="sendType != null">
#{sendType,jdbcType=TINYINT},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="deviceType != null">
#{deviceType,jdbcType=VARCHAR},
</if>
<if test="deviceAmount != null">
#{deviceAmount,jdbcType=INTEGER},
</if>
<if test="indentStatus != null">
#{indentStatus,jdbcType=INTEGER},
</if>
<if test="isCanceled != null">
#{isCanceled,jdbcType=TINYINT},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="receiverName != null">
#{receiverName,jdbcType=VARCHAR},
</if>
<if test="districtCode != null">
#{districtCode,jdbcType=INTEGER},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="getIndentCount" parameterType="com.glsx.ordercenter.pojo.SysIndent" resultType="java.lang.Integer">
select count(*) from sys_indent
<where>
<if test="beginDate != null and beginDate != ''">
and create_time &gt; #{beginDate}
</if>
<if test="endDate != null and endDate != ''">
and create_time &lt; #{endDate}
</if>
</where>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.ordercenter.pojo.SysIndent">
update sys_indent
<set>
<if test="indentNo != null">
indent_no = #{indentNo,jdbcType=VARCHAR},
</if>
<if test="sendType != null">
send_type = #{sendType,jdbcType=TINYINT},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
<if test="deviceAmount != null">
device_amount = #{deviceAmount,jdbcType=INTEGER},
</if>
<if test="indentStatus != null">
indent_status = #{indentStatus,jdbcType=INTEGER},
</if>
<if test="isCanceled != null">
is_canceled = #{isCanceled,jdbcType=TINYINT},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="receiverName != null">
receiver_name = #{receiverName,jdbcType=VARCHAR},
</if>
<if test="districtCode != null">
district_code = #{districtCode,jdbcType=INTEGER},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysIndent">
update sys_indent
set indent_no = #{indentNo,jdbcType=VARCHAR},
send_type = #{sendType,jdbcType=TINYINT},
user_id = #{userId,jdbcType=INTEGER},
device_type = #{deviceType,jdbcType=VARCHAR},
device_amount = #{deviceAmount,jdbcType=INTEGER},
indent_status = #{indentStatus,jdbcType=INTEGER},
is_canceled = #{isCanceled,jdbcType=TINYINT},
phone = #{phone,jdbcType=VARCHAR},
receiver_name = #{receiverName,jdbcType=VARCHAR},
district_code = #{districtCode,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</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!