Commit 3d28332a by xiaoyj

设备验证入库接口修改

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@21859 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 8192b4da
......@@ -64,7 +64,7 @@ public enum ResultCodeEnum {
INDENT_RECEIVE_ADDRESSID_NOT_EXIST(5100, "该收货地址不存在"),
DEVICE_MOUNT_ERROR(5101,"设备数量超出订货单数量"),
DEVICE_EXIST(5102,"数据库设备已存在"),
DEVICE_MWECHANT_NOT_EXIST(5103,"该设备不属于你的服务商库存"),
DEVICE_MWECHANT_NOT_EXIST(5103,"设备不属于你的服务商库存"),
INDENT_COMPLETE_CANNOT_CANCEL(5104, "该订货单已经完成,不允许取消"),
INDENT_NOT_EXIST(5105,"订货单不存在")
;
......
package com.glsx.ordercenter.dto;
public class ErrorDevice {
private String deviceNo;
private String error;
public String getDeviceNo() {
return deviceNo;
}
public void setDeviceNo(String deviceNo) {
this.deviceNo = deviceNo;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
......@@ -4,9 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.Page;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.ErrorDevice;
import com.glsx.ordercenter.mapper.SysDeviceMapper;
import com.glsx.ordercenter.pojo.SysDevice;
import com.glsx.ordercenter.pojo.SysDeviceExample;
import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -69,6 +69,7 @@ public class DeviceServiceImpl implements DeviceService{
@Transactional
public ResultObject checkAndInserts(List<String> deviceNos, SysIndent sysIndent, int userId) {
List<SysDevice> list = new ArrayList<>();
List<ErrorDevice> errorDevices=new ArrayList<>();
if (sysIndent.getSendType() == 2) {
//运营发货
//1.清除用户的订货单设备
......@@ -82,7 +83,10 @@ public class DeviceServiceImpl implements DeviceService{
//设备重复校验
SysDevice sysDevice = deviceRepeat(deviceNo, userId);
if (sysDevice != null) {
return new ResultObject(ResultCodeEnum.DEVICE_EXIST.getCode(), "你的库存中存在设备" + deviceNo);
ErrorDevice errorDevice=new ErrorDevice();
errorDevice.setDeviceNo(deviceNo);
errorDevice.setError("你的库存存在设备号");
errorDevices.add(errorDevice);
}
SysDevice sysDevice1 = new SysDevice();
sysDevice1.setUserId(userId);
......@@ -94,6 +98,9 @@ public class DeviceServiceImpl implements DeviceService{
sysDevice1.setUpdateBy(userId);
list.add(sysDevice1);
}
if(errorDevices.size()>0){
return new ResultObject(ResultCodeEnum.DEVICE_EXIST.getCode(),ResultCodeEnum.DEVICE_EXIST.getMsg(),errorDevices);
}
inserts(list);
}
if(sysIndent.getSendType()==1){
......@@ -103,14 +110,20 @@ public class DeviceServiceImpl implements DeviceService{
//判断设备是否已经属于该技工
SysDevice sysDevice1 = deviceRepeat(deviceNo, userId);
if(sysDevice1!=null && !sysIndent.getIndentNo().equals(sysDevice1.getIndentNo())){
return new ResultObject(ResultCodeEnum.DEVICE_EXIST.getCode(), "你的库存中存在设备" + deviceNo);
ErrorDevice errorDevice=new ErrorDevice();
errorDevice.setDeviceNo(deviceNo);
errorDevice.setError("你的库存存在设备号");
errorDevices.add(errorDevice);
}
if(sysDevice1==null){
//查询该设备是否在技工的服务商列表中
SysDevice sysDevice = new SysDevice();
sysDevice = getByDeviceNoAndUserId(deviceNo, userId);
if (sysDevice == null) {
return new ResultObject(ResultCodeEnum.DEVICE_MWECHANT_NOT_EXIST.getCode(), ResultCodeEnum.DEVICE_MWECHANT_NOT_EXIST.getMsg());
ErrorDevice errorDevice=new ErrorDevice();
errorDevice.setDeviceNo(deviceNo);
errorDevice.setError("设备不属于你的服务商库存");
errorDevices.add(errorDevice);
}
Date date = new Date();
sysDevice.setUpdateTime(date);
......@@ -120,6 +133,9 @@ public class DeviceServiceImpl implements DeviceService{
list.add(sysDevice);
}
}
if(errorDevices.size()>0){
return new ResultObject(ResultCodeEnum.DEVICE_MWECHANT_NOT_EXIST.getCode(),ResultCodeEnum.DEVICE_MWECHANT_NOT_EXIST.getMsg(),errorDevices);
}
updates(list);
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
......
......@@ -322,13 +322,14 @@
</update>
<select id="catIndentDevices" resultType="com.glsx.ordercenter.pojo.SysDevice">
SELECT
sd.device_no AS deviceNO,
sd.device_no AS deviceNo,
sda.data_value AS deviceName
FROM
sys_device sd
INNER JOIN sys_dict_data sda ON sd.device_type = sda.data_key
WHERE
sd.indent_no = #{indentNo}
ORDER BY sd.id DESC
</select>
<select id="getByDeviceNoAndUserId" parameterType="com.glsx.ordercenter.pojo.SysDevice" resultMap="BaseResultMap">
SELECT
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!