|
@@ -1,6 +1,10 @@
|
|
|
package com.bz.smart_city.service.impl.pay;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bz.smart_city.commom.model.AjaxMessage;
|
|
|
+import com.bz.smart_city.commom.util.HttpClientUtils;
|
|
|
import com.bz.smart_city.commom.util.HttpRequest;
|
|
|
import com.bz.smart_city.commom.util.JacksonUtil;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
@@ -121,15 +125,16 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
|
|
|
meterSyncInputDto.setFileNo(fileNos);
|
|
|
|
|
|
//调用接口同步
|
|
|
- String json = JacksonUtil.obj2String(meterSyncInputDto);
|
|
|
+ String json= JSON.toJSON(meterSyncInputDto).toString();
|
|
|
try {
|
|
|
- String result = HttpRequest.doPost(url,json);
|
|
|
- AjaxMessage<List<MeterSyncDto>> ajaxMessage = JacksonUtil.string2Obj(result,AjaxMessage.class);
|
|
|
-
|
|
|
- if(ajaxMessage != null){
|
|
|
+ String result = HttpClientUtils.doPostWithJson(url,json);
|
|
|
+ JSONObject jsonObject= JSON.parseObject(result);
|
|
|
+ Integer status= jsonObject.getInteger("status");
|
|
|
+ if(status.equals(0)){
|
|
|
//更新水表信息
|
|
|
- if(ajaxMessage.getStatus() == 0){
|
|
|
- List<MeterSyncDto> meterSyncDtoList = ajaxMessage.getData();
|
|
|
+ if(1==1){
|
|
|
+ JSONArray datas = jsonObject.getJSONArray("data");
|
|
|
+ List<MeterSyncDto> meterSyncDtoList = datas.toJavaList(MeterSyncDto.class);
|
|
|
if(meterSyncDtoList != null){
|
|
|
for(MeterSyncDto meterSyncDto:meterSyncDtoList){
|
|
|
//水表档案号变更
|
|
@@ -139,7 +144,7 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
|
|
|
try {
|
|
|
meterSyncDto.setMeterCode(meterSyncDto.getFileNo());
|
|
|
//更改营业系统水表档案号
|
|
|
- String updateMeterNoUrl = url + "/api/platform/updateMeterNo";
|
|
|
+ String updateMeterNoUrl = SyncUrl + "/api/platform/updateMeterNo";
|
|
|
String params = String.format("?customerNo=%s&meterNo=%s&meterCode=%s",customerNo,meterSyncDto.getFileNo(),meterSyncDto.getMeterCode());
|
|
|
updateMeterNoUrl += params;
|
|
|
String postResult = HttpRequest.doPost(updateMeterNoUrl ,"");
|
|
@@ -164,29 +169,14 @@ public class DeviceSyncServiceImpl implements DeviceSyncService, InitializingBea
|
|
|
deviceMapper.updateSync(resultMeterSyncDto);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- for(int i=0;i<meterSyncDtoList.size();i++){
|
|
|
-
|
|
|
- //水表档案号变更
|
|
|
- if(!meterSyncDtoList.get(i).getMeterCode().equals(meterSyncDtoList.get(i).getFileNo())){
|
|
|
- //修改计费系统水表档案号
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String strList = JacksonUtil.obj2String(meterSyncDtoList.get(i));
|
|
|
- MeterSyncDto meterSyncDto = JacksonUtil.string2Obj(strList,MeterSyncDto.class);
|
|
|
- meterSyncDto.setCurrStatus(1);
|
|
|
-
|
|
|
- if(StringUtils.isBlank(meterSyncDto.getInitialData()))
|
|
|
- meterSyncDto.setInitialData("0");
|
|
|
- deviceMapper.updateSync(meterSyncDto);
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|