|
@@ -85,19 +85,13 @@ class PlatformIOTCardViewSet(viewsets.ModelViewSet):
|
|
|
raise ValidationError("不支持该类型设备手动录入物联网卡!")
|
|
raise ValidationError("不支持该类型设备手动录入物联网卡!")
|
|
|
if platform == "四情平台":
|
|
if platform == "四情平台":
|
|
|
platformid = 1
|
|
platformid = 1
|
|
|
- res = requests.post(url="http://www.yfzhwlw.com/equip_simiccid", data={"e_id": device_id, "iccid": simId})
|
|
|
|
|
- if res.text != "0":
|
|
|
|
|
- raise ValidationError("对应平台添加异常!")
|
|
|
|
|
elif platform == "大数据平台":
|
|
elif platform == "大数据平台":
|
|
|
platformid = 2
|
|
platformid = 2
|
|
|
- res = requests.post(url="http://8.136.98.49:8002/api/api_gateway?method=forecast.send_control.device_sim",
|
|
|
|
|
- data={"device_id": device_id, "iccid": simId, "type": "change"})
|
|
|
|
|
- res_json = json.loads(res.text)
|
|
|
|
|
- if res_json["message"] != "":
|
|
|
|
|
- raise ValidationError("对应平台添加异常!")
|
|
|
|
|
else:
|
|
else:
|
|
|
raise ValidationError("平台不存在该设备ID,请核查!")
|
|
raise ValidationError("平台不存在该设备ID,请核查!")
|
|
|
-
|
|
|
|
|
|
|
+ requests.post(url="http://www.yfzhwlw.com/equip_simiccid", data={"e_id": device_id, "iccid": simId},timeout=5)
|
|
|
|
|
+ requests.post(url="http://8.136.98.49:8002/api/api_gateway?method=forecast.send_control.device_sim",
|
|
|
|
|
+ data={"device_id": device_id, "iccid": simId, "type": "change"},timeout=5)
|
|
|
sim_operators, account_status, active_date, data_plan, data_usage, data_balance, expiry_date = Get_SIM_info(
|
|
sim_operators, account_status, active_date, data_plan, data_usage, data_balance, expiry_date = Get_SIM_info(
|
|
|
simId).get_sim_info()
|
|
simId).get_sim_info()
|
|
|
request_data = {
|
|
request_data = {
|
|
@@ -136,26 +130,20 @@ class PlatformIOTCardViewSet(viewsets.ModelViewSet):
|
|
|
"expiry_date" : expiry_date
|
|
"expiry_date" : expiry_date
|
|
|
}
|
|
}
|
|
|
elif req == "change":
|
|
elif req == "change":
|
|
|
|
|
+ deviceId = instance.deviceId
|
|
|
if instance.input_type == 1:
|
|
if instance.input_type == 1:
|
|
|
- raise ValidationError("设备录入物联网卡禁止更改")
|
|
|
|
|
|
|
+ raise ValidationError("设备读取物联网卡禁止更改")
|
|
|
simId = request.POST.get("simId").strip()
|
|
simId = request.POST.get("simId").strip()
|
|
|
if len(simId) > 20 or len(simId) < 19:
|
|
if len(simId) > 20 or len(simId) < 19:
|
|
|
raise ValidationError("物联网卡长度介于19-20位")
|
|
raise ValidationError("物联网卡长度介于19-20位")
|
|
|
if self.get_queryset().filter(simId=simId).exists():
|
|
if self.get_queryset().filter(simId=simId).exists():
|
|
|
- raise ValidationError("预更改卡号已存在")
|
|
|
|
|
-
|
|
|
|
|
- platform = instance.platform
|
|
|
|
|
- device_id = instance.deviceId
|
|
|
|
|
- if platform == 1:
|
|
|
|
|
- res = requests.post(url="http://www.yfzhwlw.com/equip_simiccid",data={"e_id":device_id,"iccid":simId})
|
|
|
|
|
- if res.text != "0":
|
|
|
|
|
- raise ValidationError("对应平台更换异常")
|
|
|
|
|
- else:
|
|
|
|
|
- res = requests.post(url="http://8.136.98.49:8002/api/api_gateway?method=forecast.send_control.device_sim",
|
|
|
|
|
- data={"device_id": device_id,"iccid": simId,"type": "change"})
|
|
|
|
|
- res_json = json.loads(res.text)
|
|
|
|
|
- if res_json["message"] != "":
|
|
|
|
|
- raise ValidationError("对应平台更换异常")
|
|
|
|
|
|
|
+ raise ValidationError("预更改卡号已存在,请核对!")
|
|
|
|
|
+ try:
|
|
|
|
|
+ requests.post(url="http://www.yfzhwlw.com/equip_simiccid",data={"e_id":deviceId,"iccid":simId},timeout=5)
|
|
|
|
|
+ requests.post(url="http://8.136.98.49:8002/api/api_gateway?method=forecast.send_control.device_sim",
|
|
|
|
|
+ data={"device_id": deviceId,"iccid": simId,"type": "change"},timeout=5)
|
|
|
|
|
+ except:
|
|
|
|
|
+ pass
|
|
|
sim_operators,account_status,active_date,data_plan,data_usage,data_balance,expiry_date = Get_SIM_info(simId).get_sim_info()
|
|
sim_operators,account_status,active_date,data_plan,data_usage,data_balance,expiry_date = Get_SIM_info(simId).get_sim_info()
|
|
|
update_data = {
|
|
update_data = {
|
|
|
"simId": simId,
|
|
"simId": simId,
|