1.修改市接口地址为网址
2.修改实有人口上传主键冲突的处理
This commit is contained in:
gaoben 2021-11-01 17:04:58 +08:00
parent 1c6fb64a91
commit ec5b95dde1
5 changed files with 79 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.*; import java.util.*;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.utils.Constant; import net.shapelight.common.utils.Constant;
import net.shapelight.common.utils.DateUtils; import net.shapelight.common.utils.DateUtils;
@ -298,23 +299,47 @@ public class XaRealDataTask implements ITask {
if(resJson.contains("ErrorLineParameter")){ if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson); JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim(); String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
JSONArray datas = resJsonObject.getJSONArray("datas");
if(errLine.equals("empty")){ if(errLine.equals("empty")){
for (TenPersonEntity recordEntity : updatePersons) { for (TenPersonEntity recordEntity : updatePersons) {
recordEntity.setXaSync(1); recordEntity.setXaSync(1);
tenPersonService.updateById(recordEntity); tenPersonService.updateById(recordEntity);
} }
}else{ }else{
String[] lines = errLine.split(","); // List<XaSYRK> syncPersonsDelete = new ArrayList();
List<String> lineList = Arrays.asList(lines); //一条一条判断
for (int i = 0;i<updatePersons.size();i++) { for(int i = 0;i<datas.size();i++){
if(lineList.contains(i+1+"")){ JSONObject dataResult = datas.getJSONObject(i);
continue; String res = dataResult.getString("Result");
}else { if(res.equals("接收成功")){
TenPersonEntity recordEntity = updatePersons.get(i); TenPersonEntity recordEntity = updatePersons.get(i);
recordEntity.setXaSync(1); recordEntity.setXaSync(1);
tenPersonService.updateById(recordEntity); tenPersonService.updateById(recordEntity);
}else if(res.indexOf("违反唯一约束条件")>0){
TenPersonEntity recordEntity = updatePersons.get(i);
recordEntity.setXaSync(1);
tenPersonService.updateById(recordEntity);
//页面删除过但是没有上报这次上报
// XaSYRK realPerson = syncPersons.get(i);
// realPerson.setLV_ZXSJ(DateUtils.format(new Date(),DateUtils.DATE_YEAR_MONTH));
// syncPersonsDelete.add(realPerson);
} }
} }
// if(syncPersonsDelete.size()>0){
// processRealPersonDelete(appId, appSecret, xqid, fwikUrl, cellId,syncPersonsDelete);
// }
// String[] lines = errLine.split(",");
// List<String> lineList = Arrays.asList(lines);
// for (int i = 0;i<updatePersons.size();i++) {
// if(lineList.contains(i+1+"")){
// //判断错误信息
// continue;
// }else {
// TenPersonEntity recordEntity = updatePersons.get(i);
// recordEntity.setXaSync(1);
// tenPersonService.updateById(recordEntity);
// }
// }
} }
} }
} }
@ -500,4 +525,40 @@ public class XaRealDataTask implements ITask {
} }
} }
} }
private void processRealPersonDelete(String appId, String appSecret, String xqid, String fwikUrl, Long cellId,List<XaSYRK> syncPersons) {
XaData jsonData = new XaData();
jsonData.setDatas(syncPersons);
List<XaPages> listPages = new ArrayList<>();
XaPages pages = new XaPages();
pages.setPno("1");
pages.setPsize(syncPersons.size()+"");
listPages.add(pages);
jsonData.setPages(listPages);
String json = JSONObject.toJSONString(jsonData);
String enJson = XaUtils.encryptStr(json.trim(), appSecret);
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,jsonData,"SYRK", "SYRK", appId, appSecret);
String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId());
String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "SYRK", "SYRK", appId, appSecret,tranId);
log.debug("上传删除实有人口返回数据:" + resJson);
tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity);
// if(resJson.contains("ErrorLineParameter")){
// JSONObject resJsonObject = JSONObject.parseObject(resJson);
// String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
// JSONArray datas = resJsonObject.getJSONArray("datas");
// if(errLine.equals("empty")){
//
// }else{
// //一条一条判断
// }
// }
}
} }

View File

@ -26,9 +26,9 @@ public class XaApi {
private static final Logger log = LoggerFactory.getLogger(net.shapelight.modules.xian.service.XaApi.class); private static final Logger log = LoggerFactory.getLogger(net.shapelight.modules.xian.service.XaApi.class);
private static final String XqAddrUrl = "http://117.34.12.66:10011/zhxqgl/interface/get_xq_addr.jsp"; private static final String XqAddrUrl = "http://police.xa.gov.cn/ZHXQ/zhxqgl/interface/get_xq_addr.jsp";
private static final String FwikUrl = "http://117.34.12.66:10011/ywxzservice/get_fwjk_url.jsp"; private static final String FwikUrl = "http://police.xa.gov.cn/ZHXQ/ywxzservice/get_fwjk_url.jsp";
/** /**
* appid: 1297164778041095 * appid: 1297164778041095
@ -125,6 +125,8 @@ public class XaApi {
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
conn.setRequestProperty("User-Agent","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30");
//连接建立超时时间还有读取数据超时时间 //连接建立超时时间还有读取数据超时时间
conn.setConnectTimeout(60000); conn.setConnectTimeout(60000);
conn.setReadTimeout(60000); conn.setReadTimeout(60000);

View File

@ -261,6 +261,7 @@ public class XaUtils {
conn.setRequestMethod("POST"); conn.setRequestMethod("POST");
conn.setDoOutput(true); conn.setDoOutput(true);
conn.setDoInput(true); conn.setDoInput(true);
conn.setRequestProperty("User-Agent","Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36 Edg/95.0.1020.30");
StringBuffer paramsBuffer = new StringBuffer(); StringBuffer paramsBuffer = new StringBuffer();
mapParams.forEach((key,value)->{ mapParams.forEach((key,value)->{
paramsBuffer.append("&"+key+"="); paramsBuffer.append("&"+key+"=");
@ -426,7 +427,7 @@ public class XaUtils {
Map<String,String> paramMap = new HashMap<>(); Map<String,String> paramMap = new HashMap<>();
paramMap.put("appid",appid); paramMap.put("appid",appid);
paramMap.put("appsecret",md5(secre)); paramMap.put("appsecret",md5(secre));
String FwjkUrl = httpPOSTParam("http://117.34.12.66:10011/ywxzservice/get_fwjk_url.jsp", String FwjkUrl = httpPOSTParam("http://police.xa.gov.cn/ZHXQ/ywxzservice/get_fwjk_url.jsp",
appid,secre,paramMap); appid,secre,paramMap);
System.out.println("FwjkUrl:"+FwjkUrl); System.out.println("FwjkUrl:"+FwjkUrl);

View File

@ -61,5 +61,8 @@ public class XaSYFW {
@JSONField(name="LV_PROCMODE") @JSONField(name="LV_PROCMODE")
private String LV_PROCMODE = "PMINSERT"; private String LV_PROCMODE = "PMINSERT";
@JSONField(name="LV_ZXSJ")
private String LV_ZXSJ = "11111111";
} }

View File

@ -131,5 +131,8 @@ public class XaSYRK {
@JSONField(name="LV_ZJZL") @JSONField(name="LV_ZJZL")
private String LV_ZJZL = "10"; private String LV_ZJZL = "10";
@JSONField(name="LV_ZXSJ")
private String LV_ZXSJ = "11111111";
} }