Commit f57b7ade by zhanghj

V1.4.0--入库增加设备类型验证功能

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@23650 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 5131c67a
......@@ -119,4 +119,12 @@ public interface BizConstants {
public static final String SEPARATOR = ",";
public static final String SEARCHTYPE_BIDDING = "searchtype_bidding";
/**
* 服务项目
*/
public static final String SYS_ORDER_SERVICE_ITEM_GPS = "sys_order_service_item_gps";
public static final String SYS_ORDER_SERVICE_ITEM_GPS_WIRELESS = "sys_order_service_item_gps_wireless";
public static final String SYS_ORDER_SERVICE_ITEM_GPS_GT700F = "sys_order_service_item_gps_GT700F";
}
......@@ -67,6 +67,8 @@ public enum ResultCodeEnum {
DEVICE_ACTIVE_FAIL(5005,"设备激活失败,请重试"),
DEVICETYPE_DISAFFINITY_ORDERDEVICE(5006,"该设备类型与工单要求安装设备类型不符"),
DEVICE_NOT_RECEIVE(5007,"请先确认收货再激活设备"),
DEVICE_TYPE_NOT_MATCH(5008, "设备类型不符"),
DEVICE_NOT_STOCK_IN_EDUN(5009, "未在虎哥e盾入库"),
/**
* 订货单相关
*/
......
......@@ -33,8 +33,6 @@ import com.glsx.ordercenter.service.IndentService;
public class DeviceCtroller {
@Autowired
private DeviceService deviceService;
@Autowired
private IndentService indentService;
/**
* 订货单的设备清单(技工端/服务商端)
......@@ -59,20 +57,9 @@ public class DeviceCtroller {
if (StringUtils.isEmpty(deviceNos) || StringUtils.isEmpty(indentNo)) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
String[] arr=deviceNos.split(",");
List<String> list= Arrays.asList(arr);
//判断设备数量是否超出订货单数量
SysIndent sysIndent=indentService.getByIndentNo(indentNo);
if(sysIndent==null){
return new ResultObject(ResultCodeEnum.INDENT_NOT_EXIST.getCode(), ResultCodeEnum.INDENT_NOT_EXIST.getMsg());
}
if(list.size()>sysIndent.getDeviceAmount()){
return new ResultObject(ResultCodeEnum.DEVICE_MOUNT_ERROR.getCode(),ResultCodeEnum.DEVICE_MOUNT_ERROR.getMsg());
}
int userId=UserUtils.getUserId(request);
return deviceService.checkAndInserts(list,sysIndent,userId);
return deviceService.checkAndInserts(deviceNos,indentNo,userId);
}
/**
......
......@@ -4,7 +4,6 @@ import java.util.List;
import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.pojo.SysDevice;
import com.glsx.ordercenter.pojo.SysIndent;
public interface DeviceService {
......@@ -24,10 +23,10 @@ public interface DeviceService {
/**
* 验证设备和入库
* @param deviceNos
* @param sysIndent
* @param indentNo
* @param userId
*/
ResultObject checkAndInserts(List<String> deviceNos, SysIndent sysIndent, int userId);
ResultObject checkAndInserts(String deviceNos, String indentNo, int userId);
/**
* 添加或修改设备归属(适用于技工)
......
package com.glsx.ordercenter.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.glsx.common.constants.Constants;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.ErrorDevice;
import com.glsx.ordercenter.mapper.SysDeviceMapper;
......@@ -9,17 +27,15 @@ 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;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.glsx.ordercenter.service.IndentService;
@Service
public class DeviceServiceImpl implements DeviceService{
private Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class);
@Autowired
private SysDeviceMapper sysDeviceMapper;
@Autowired
private IndentService indentService;
@Override
public List<SysDevice> catIndentDevices(String indentNo) {
......@@ -65,10 +81,31 @@ public class DeviceServiceImpl implements DeviceService{
@Override
@Transactional
public ResultObject checkAndInserts(List<String> deviceNos, SysIndent sysIndent, int userId) {
public ResultObject checkAndInserts(String deviceNoList, String indentNo, int userId) {
List<SysDevice> list = new ArrayList<>();
List<ErrorDevice> errorDevices=new ArrayList<>();
String[] arr = deviceNoList.split(",");
List<String> deviceNos= Arrays.asList(arr);
//判断设备数量是否超出订货单数量
SysIndent sysIndent=indentService.getByIndentNo(indentNo);
if(sysIndent==null){
return new ResultObject(ResultCodeEnum.INDENT_NOT_EXIST.getCode(), ResultCodeEnum.INDENT_NOT_EXIST.getMsg());
}
if(list.size()>sysIndent.getDeviceAmount()){
return new ResultObject(ResultCodeEnum.DEVICE_MOUNT_ERROR.getCode(),ResultCodeEnum.DEVICE_MOUNT_ERROR.getMsg());
}
/*
* 去E盾验证设备类型
*/
String deviceType = sysIndent.getDeviceType();
String dType = transToEdunDeviceType(deviceType);
ResultObject obj = checkDeviceFromEdun(dType, deviceNoList);
if (obj != null && obj.getCode() != 0) {
return obj;
}
//1.清除用户的订货单设备
SysDevice device=new SysDevice();
device.setUserId(userId);
......@@ -138,7 +175,60 @@ public class DeviceServiceImpl implements DeviceService{
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
@Override
private ResultObject checkDeviceFromEdun(String dType, String sns) {
ResultObject obj = new ResultObject();
try {
Map<String, String> paramMap = new TreeMap<String, String>();
paramMap.put("deviceType", dType);
paramMap.put("sns", sns);
String url = PropertiesUtil.getProperty("edun.access.platform.url") + "api/workOrder/validateDeviceType";
String result = HttpUtils.get(url, paramMap);
Integer returnCode = (Integer) JSON.parseObject(result).get("error");
JSONArray data = JSON.parseObject(result).getJSONArray("data");
if (returnCode.equals(0)) {
return obj;
} else if (returnCode.equals(1)) {
obj.setCode(ResultCodeEnum.DEVICE_TYPE_NOT_MATCH.getCode());
obj.setMessage(ResultCodeEnum.DEVICE_TYPE_NOT_MATCH.getMsg());
obj.setData(data);
return obj;
} else{
obj.setCode(ResultCodeEnum.DEVICE_NOT_STOCK_IN_EDUN.getCode());
obj.setMessage(ResultCodeEnum.DEVICE_NOT_STOCK_IN_EDUN.getMsg());
obj.setData(data);
return obj;
}
} catch (Exception e) {
obj.setCode(ResultCodeEnum.ERROR.getCode());
obj.setMessage(ResultCodeEnum.ERROR.getMsg());
logger.error(e.getMessage(), e);
}
return obj;
}
/**
*
* @author zhanghj
* @Title: transToEdunDeviceType
* @Description: TODO 包活干设备转化成e盾设备类型 2 先锋设备 1 有线设备 0 无线设备
* @param deviceType
* @return
* String
*
*/
private String transToEdunDeviceType(String deviceType) {
// TODO Auto-generated method stub
if (BizConstants.SYS_ORDER_SERVICE_ITEM_GPS.equals(deviceType)) {
return "1";
} else if (BizConstants.SYS_ORDER_SERVICE_ITEM_GPS_WIRELESS.equals(deviceType)) {
return "2";
} else {
return "0";
}
}
@Override
public void addDevice(int userId, String deviceNo,String installDeviceType,Integer deviceSource) {
SysDeviceExample sysDeviceExample = new SysDeviceExample();
sysDeviceExample.createCriteria().andUserIdEqualTo(userId).andDeviceNoEqualTo(deviceNo);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!