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{ ...@@ -51,8 +51,8 @@ public class IndentController extends BaseController{
Integer userId = UserUtils.getUserId(request); Integer userId = UserUtils.getUserId(request);
indent.setCreateBy(userId); indent.setCreateBy(userId);
indent.setCreateTime(new Date()); indent.setCreateTime(new Date());
indentService.add(indent); ResultObject result = indentService.add(indent);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); return result;
} }
......
...@@ -36,7 +36,7 @@ public class ReportController extends BaseReportController{ ...@@ -36,7 +36,7 @@ public class ReportController extends BaseReportController{
Integer userId=UserUtils.getUserId(request); Integer userId=UserUtils.getUserId(request);
List<SysOrder> list=unknownOrderService.getUnknowOrderList(null,order, userId); List<SysOrder> list=unknownOrderService.getUnknowOrderList(null,order, userId);
if(list.size()>10000){ 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){ if(list.size()>0){
for(SysOrder sysOrder:list){ for(SysOrder sysOrder:list){
...@@ -63,7 +63,7 @@ public class ReportController extends BaseReportController{ ...@@ -63,7 +63,7 @@ public class ReportController extends BaseReportController{
oueryOrderReq.setUserId( UserUtils.getUserId(request)); oueryOrderReq.setUserId( UserUtils.getUserId(request));
List<SysOrder> list=orderService.getOrderListByExample(null, null, oueryOrderReq); List<SysOrder> list=orderService.getOrderListByExample(null, null, oueryOrderReq);
if(list.size()>10000){ 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){ if(list.size()>0){
for(SysOrder sysOrder:list){ for(SysOrder sysOrder:list){
......
...@@ -15,6 +15,7 @@ public class BusinessException extends RuntimeException { ...@@ -15,6 +15,7 @@ public class BusinessException extends RuntimeException {
protected ResultObject resultEntity; protected ResultObject resultEntity;
protected static final int MIN_AUTO_CODE = 100000; protected static final int MIN_AUTO_CODE = 100000;
protected BusinessException(BusinessException parent) { protected BusinessException(BusinessException parent) {
if(parent != null){ if(parent != null){
this.resultEntity = parent.resultEntity; this.resultEntity = parent.resultEntity;
...@@ -23,10 +24,10 @@ public class BusinessException extends RuntimeException { ...@@ -23,10 +24,10 @@ public class BusinessException extends RuntimeException {
public static BusinessException create(String message) { public static BusinessException create(String message) {
int value= (int) (MIN_AUTO_CODE + Math.round((Integer.MAX_VALUE - MIN_AUTO_CODE) * Math.random())); 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 businessException = new BusinessException(null);
businessException.resultEntity = ResultObject.err(returnCode).message(message); businessException.resultEntity = ResultObject.err(returnCode).message(message);
return businessException; return businessException;
......
...@@ -21,15 +21,15 @@ public interface SysDeviceRepertoryMapper { ...@@ -21,15 +21,15 @@ public interface SysDeviceRepertoryMapper {
List<SysDeviceRepertory> selectByExample(SysDeviceRepertoryExample example); List<SysDeviceRepertory> selectByExample(SysDeviceRepertoryExample example);
SysDeviceRepertory selectByPrimaryKey(Integer id); SysDeviceRepertory get(SysDeviceRepertory record);
int updateByExampleSelective(@Param("record") SysDeviceRepertory record, @Param("example") SysDeviceRepertoryExample example); int updateByExampleSelective(@Param("record") SysDeviceRepertory record, @Param("example") SysDeviceRepertoryExample example);
int updateByExample(@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); int updateByPrimaryKey(SysDeviceRepertory record);
List<DeviceRepertoryReq> getDeviceRepertoryList(Map<String, Object> params); List<DeviceRepertoryReq> getDeviceRepertoryList(Map<String, Object> params);
int updateSelective(SysDeviceRepertory deviceRepertory);
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.ordercenter.pojo; package com.glsx.ordercenter.pojo;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.groups.Default; import javax.validation.groups.Default;
...@@ -25,7 +26,7 @@ public class SysIndent extends BaseModel{ ...@@ -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 deviceAmount;
private Integer indentStatus; private Integer indentStatus;
......
package com.glsx.ordercenter.service; package com.glsx.ordercenter.service;
import com.glsx.ordercenter.dto.DeviceRepertoryReq; import com.glsx.ordercenter.dto.DeviceRepertoryReq;
import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import java.util.List; import java.util.List;
...@@ -29,4 +30,40 @@ public interface DeviceRepertoryService { ...@@ -29,4 +30,40 @@ public interface DeviceRepertoryService {
* @Description: TODO 获取库存列表 * @Description: TODO 获取库存列表
*/ */
List<DeviceRepertoryReq> getServiceRepertoryDetail(String deviceType, String deviceNo); 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 { ...@@ -26,6 +26,6 @@ public interface IndentService {
* ResultObject * ResultObject
* *
*/ */
int add(SysIndent indent); ResultObject add(SysIndent indent);
} }
...@@ -2,7 +2,9 @@ package com.glsx.ordercenter.service.impl; ...@@ -2,7 +2,9 @@ package com.glsx.ordercenter.service.impl;
import com.glsx.ordercenter.dto.DeviceRepertoryReq; import com.glsx.ordercenter.dto.DeviceRepertoryReq;
import com.glsx.ordercenter.mapper.SysDeviceRepertoryMapper; import com.glsx.ordercenter.mapper.SysDeviceRepertoryMapper;
import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import com.glsx.ordercenter.service.DeviceRepertoryService; import com.glsx.ordercenter.service.DeviceRepertoryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -51,4 +53,22 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService { ...@@ -51,4 +53,22 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
return null; 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; ...@@ -6,10 +6,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.DateUtil; import com.glsx.common.utils.DateUtil;
import com.glsx.ordercenter.constants.BizConstants; 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.mapper.SysIndentMapper;
import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import com.glsx.ordercenter.pojo.SysIndent; import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.service.DeviceRepertoryService;
import com.glsx.ordercenter.service.IndentService; import com.glsx.ordercenter.service.IndentService;
@Service @Service
...@@ -18,17 +23,45 @@ public class IndentServiceImpl implements IndentService { ...@@ -18,17 +23,45 @@ public class IndentServiceImpl implements IndentService {
@Autowired @Autowired
private SysIndentMapper indentDao; private SysIndentMapper indentDao;
@Autowired
private DeviceRepertoryService deviceRepertoryService;
@Override @Override
@Transactional @Transactional
public int add(SysIndent indent) { public ResultObject add(SysIndent indent) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
String indentNo = getIndentNo(); String indentNo = getIndentNo();
indent.setIndentNo(indentNo); indent.setIndentNo(indentNo);
int num = indentDao.insertSelective(indent); int num = indentDao.insertSelective(indent);
if (num >0) { 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 { ...@@ -42,7 +75,7 @@ public class IndentServiceImpl implements IndentService {
*/ */
private synchronized String getIndentNo() { private synchronized String getIndentNo() {
String orderNoPrefix = BizConstants.INDENT_NO_PREFIX; String orderNoPrefix = BizConstants.INDENT_NO_PREFIX;
String currentDateStr = DateUtil.formatDateYmd(new Date()); String currentDateStr = DateUtil.formatDateYmd2(new Date());
String currentDateStr2 = DateUtil.formatDateYmd(new Date()); String currentDateStr2 = DateUtil.formatDateYmd(new Date());
SysIndent indent = new SysIndent(); SysIndent indent = new SysIndent();
String beginDate = currentDateStr2 + " 00:00:00"; String beginDate = currentDateStr2 + " 00:00:00";
......
...@@ -4,10 +4,13 @@ import com.glsx.ordercenter.mapper.SysReaceiveAddressMapper; ...@@ -4,10 +4,13 @@ import com.glsx.ordercenter.mapper.SysReaceiveAddressMapper;
import com.glsx.ordercenter.pojo.SysReaceiveAddress; import com.glsx.ordercenter.pojo.SysReaceiveAddress;
import com.glsx.ordercenter.pojo.SysReaceiveAddressExample; import com.glsx.ordercenter.pojo.SysReaceiveAddressExample;
import com.glsx.ordercenter.service.ReaceiveAddressService; import com.glsx.ordercenter.service.ReaceiveAddressService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@Service
public class ReaceiveAddressServiceImpl implements ReaceiveAddressService{ public class ReaceiveAddressServiceImpl implements ReaceiveAddressService{
@Autowired @Autowired
private SysReaceiveAddressMapper mapper; private SysReaceiveAddressMapper mapper;
......
...@@ -89,11 +89,21 @@ ...@@ -89,11 +89,21 @@
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="get" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from sys_device_repertory 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> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
DELETE FROM sys_device_repertory DELETE FROM sys_device_repertory
...@@ -211,7 +221,7 @@ ...@@ -211,7 +221,7 @@
<include refid="Update_By_Example_Where_Clause"/> <include refid="Update_By_Example_Where_Clause"/>
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory"> <update id="updateSelective" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory">
update sys_device_repertory update sys_device_repertory
<set> <set>
<if test="userId != null"> <if test="userId != null">
...@@ -230,10 +240,23 @@ ...@@ -230,10 +240,23 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="version != null"> <if test="version != null">
version = #{version,jdbcType=INTEGER}, version = #{version,jdbcType=INTEGER} + 1,
</if> </if>
</set> </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>
<update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory"> <update id="updateByPrimaryKey" parameterType="com.glsx.ordercenter.pojo.SysDeviceRepertory">
UPDATE sys_device_repertory 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!