Commit 4d6ed358 by zhanghj

V1.2.0--提交增加订货单接口代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@21619 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent a5a95436
......@@ -51,8 +51,8 @@ public class IndentController extends BaseController{
Integer userId = UserUtils.getUserId(request);
indent.setCreateBy(userId);
indent.setCreateTime(new Date());
indentService.add(indent);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
ResultObject result = indentService.add(indent);
return result;
}
......
......@@ -36,7 +36,7 @@ public class ReportController extends BaseReportController{
Integer userId=UserUtils.getUserId(request);
List<SysOrder> list=unknownOrderService.getUnknowOrderList(null,order, userId);
if(list.size()>10000){
throw SysException.create(String.valueOf(ResultCodeEnum.EXPORT_UNKOWN_OEDER_OUTOF_NUMBER.getCode()),ResultCodeEnum.EXPORT_UNKOWN_OEDER_OUTOF_NUMBER.getMsg());
throw SysException.create(ResultCodeEnum.EXPORT_UNKOWN_OEDER_OUTOF_NUMBER.getCode(),ResultCodeEnum.EXPORT_UNKOWN_OEDER_OUTOF_NUMBER.getMsg());
}
if(list.size()>0){
for(SysOrder sysOrder:list){
......@@ -63,7 +63,7 @@ public class ReportController extends BaseReportController{
oueryOrderReq.setUserId( UserUtils.getUserId(request));
List<SysOrder> list=orderService.getOrderListByExample(null, null, oueryOrderReq);
if(list.size()>10000){
throw SysException.create(String.valueOf(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode()),ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
throw SysException.create(ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getCode(),ResultCodeEnum.EXPORT_OEDER_OUTOF_NUMBER.getMsg());
}
if(list.size()>0){
for(SysOrder sysOrder:list){
......
......@@ -15,6 +15,7 @@ public class BusinessException extends RuntimeException {
protected ResultObject resultEntity;
protected static final int MIN_AUTO_CODE = 100000;
protected BusinessException(BusinessException parent) {
if(parent != null){
this.resultEntity = parent.resultEntity;
......@@ -23,10 +24,10 @@ public class BusinessException extends RuntimeException {
public static BusinessException create(String message) {
int value= (int) (MIN_AUTO_CODE + Math.round((Integer.MAX_VALUE - MIN_AUTO_CODE) * Math.random()));
return create(value + "",message);
return create(value ,message);
}
public static BusinessException create(String returnCode,String message){
public static BusinessException create(int returnCode,String message){
BusinessException businessException = new BusinessException(null);
businessException.resultEntity = ResultObject.err(returnCode).message(message);
return businessException;
......
......@@ -21,15 +21,15 @@ public interface SysDeviceRepertoryMapper {
List<SysDeviceRepertory> selectByExample(SysDeviceRepertoryExample example);
SysDeviceRepertory selectByPrimaryKey(Integer id);
SysDeviceRepertory get(SysDeviceRepertory record);
int updateByExampleSelective(@Param("record") SysDeviceRepertory record, @Param("example") SysDeviceRepertoryExample example);
int updateByExample(@Param("record") SysDeviceRepertory record, @Param("example") SysDeviceRepertoryExample example);
int updateByPrimaryKeySelective(SysDeviceRepertory record);
int updateByPrimaryKey(SysDeviceRepertory record);
List<DeviceRepertoryReq> getDeviceRepertoryList(Map<String, Object> params);
int updateSelective(SysDeviceRepertory deviceRepertory);
}
\ No newline at end of file
package com.glsx.ordercenter.pojo;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
......@@ -25,7 +26,7 @@ public class SysIndent extends BaseModel{
/**
* 订货数量
*/
@NotNull(message="{param.not.null}", groups={Default.class})
@Min(value=0, message="{param.not.null}", groups={Default.class})
private Integer deviceAmount;
private Integer indentStatus;
......
package com.glsx.ordercenter.service;
import com.glsx.ordercenter.dto.DeviceRepertoryReq;
import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import java.util.List;
......@@ -29,4 +30,40 @@ public interface DeviceRepertoryService {
* @Description: TODO 获取库存列表
*/
List<DeviceRepertoryReq> getServiceRepertoryDetail(String deviceType, String deviceNo);
/**
*
* @author zhanghj
* @Title: get
* @Description: TODO 获取库存信息
* @param deviceRepertory
* @return
* SysDeviceRepertory
*
*/
SysDeviceRepertory get(SysDeviceRepertory deviceRepertory);
/**
*
* @author zhanghj
* @Title: updateSelective
* @Description: TODO 更新库存
* @param deviceRepertory
* @return
* int
*
*/
int updateSelective(SysDeviceRepertory deviceRepertory);
/**
*
* @author zhanghj
* @Title: insertSelective
* @Description: TODO 插入库存
* @param deviceRepertory
* @return
* int
*
*/
int insertSelective(SysDeviceRepertory deviceRepertory);
}
......@@ -26,6 +26,6 @@ public interface IndentService {
* ResultObject
*
*/
int add(SysIndent indent);
ResultObject add(SysIndent indent);
}
......@@ -2,7 +2,9 @@ package com.glsx.ordercenter.service.impl;
import com.glsx.ordercenter.dto.DeviceRepertoryReq;
import com.glsx.ordercenter.mapper.SysDeviceRepertoryMapper;
import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import com.glsx.ordercenter.service.DeviceRepertoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -51,4 +53,22 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
return null;
}
@Override
public SysDeviceRepertory get(SysDeviceRepertory deviceRepertory) {
// TODO Auto-generated method stub
return sysDeviceRepertoryMapper.get(deviceRepertory);
}
@Override
public int updateSelective(SysDeviceRepertory deviceRepertory) {
// TODO Auto-generated method stub
return sysDeviceRepertoryMapper.updateSelective(deviceRepertory);
}
@Override
public int insertSelective(SysDeviceRepertory deviceRepertory) {
// TODO Auto-generated method stub
return sysDeviceRepertoryMapper.insertSelective(deviceRepertory);
}
}
......@@ -6,10 +6,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.DateUtil;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.exception.BusinessException;
import com.glsx.ordercenter.mapper.SysIndentMapper;
import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.service.DeviceRepertoryService;
import com.glsx.ordercenter.service.IndentService;
@Service
......@@ -18,17 +23,45 @@ public class IndentServiceImpl implements IndentService {
@Autowired
private SysIndentMapper indentDao;
@Autowired
private DeviceRepertoryService deviceRepertoryService;
@Override
@Transactional
public int add(SysIndent indent) {
public ResultObject add(SysIndent indent) {
// TODO Auto-generated method stub
String indentNo = getIndentNo();
indent.setIndentNo(indentNo);
int num = indentDao.insertSelective(indent);
if (num >0) {
SysDeviceRepertory deviceRepertory = new SysDeviceRepertory();
Integer userId = indent.getUserId();
String deviceType = indent.getDeviceType();
deviceRepertory.setUserId(userId);
deviceRepertory.setDeviceType(deviceType);
SysDeviceRepertory repertory = deviceRepertoryService.get(deviceRepertory);
Integer deviceAmount = indent.getDeviceAmount();
if (repertory != null) {
Integer deviceNum = repertory.getDeviceNum();
Integer totalDeviceNum = deviceNum + deviceAmount;
deviceRepertory.setDeviceNum(totalDeviceNum);
deviceRepertory.setUpdateTime(new Date());
Integer version = repertory.getVersion();
deviceRepertory.setVersion(version);
int n = deviceRepertoryService.updateSelective(deviceRepertory);
if (n <= 0) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
} else {
deviceRepertory.setDeviceNum(deviceAmount);
deviceRepertory.setCreateTime(new Date());
int n = deviceRepertoryService.insertSelective(deviceRepertory);
if (n <= 0) {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
}
}
return num;
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
......@@ -42,7 +75,7 @@ public class IndentServiceImpl implements IndentService {
*/
private synchronized String getIndentNo() {
String orderNoPrefix = BizConstants.INDENT_NO_PREFIX;
String currentDateStr = DateUtil.formatDateYmd(new Date());
String currentDateStr = DateUtil.formatDateYmd2(new Date());
String currentDateStr2 = DateUtil.formatDateYmd(new Date());
SysIndent indent = new SysIndent();
String beginDate = currentDateStr2 + " 00:00:00";
......
......@@ -4,10 +4,13 @@ import com.glsx.ordercenter.mapper.SysReaceiveAddressMapper;
import com.glsx.ordercenter.pojo.SysReaceiveAddress;
import com.glsx.ordercenter.pojo.SysReaceiveAddressExample;
import com.glsx.ordercenter.service.ReaceiveAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ReaceiveAddressServiceImpl implements ReaceiveAddressService{
@Autowired
private SysReaceiveAddressMapper mapper;
......
......@@ -89,11 +89,21 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<select id="get" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_device_repertory
where id = #{id,jdbcType=INTEGER}
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="deviceType != null and deviceType != ''">
and device_type = #{deviceType}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
DELETE FROM sys_device_repertory
......@@ -211,7 +221,7 @@
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory">
<update id="updateSelective" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory">
update sys_device_repertory
<set>
<if test="userId != null">
......@@ -230,10 +240,23 @@
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="version != null">
version = #{version,jdbcType=INTEGER},
version = #{version,jdbcType=INTEGER} + 1,
</if>
</set>
where id = #{id,jdbcType=INTEGER}
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="deviceType != null and deviceType != ''">
and device_type = #{deviceType}
</if>
<if test="version != null">
and version = #{version}
</if>
</where>
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory">
UPDATE sys_device_repertory
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!