1.车辆进出记录表增加,第三方停车场id,通道id,通道code
2.优化第三方接口
This commit is contained in:
gaoben 2021-05-11 17:01:41 +08:00
parent 2090cffd3c
commit 96fd9ff546
9 changed files with 676 additions and 306 deletions

View File

@ -68,6 +68,9 @@ public class CarOpenApi {
@Autowired @Autowired
private TenPackService tenPackService; private TenPackService tenPackService;
@Autowired
private TenPackChannalService tenPackChannalService;
@PostMapping({"/getMsg/{cellId}"}) @PostMapping({"/getMsg/{cellId}"})
@ApiOperation("获取MSG") @ApiOperation("获取MSG")
@ApiImplicitParams({@ApiImplicitParam(name = "sn", value = "设备sn", paramType = "query", dataType = "String", required = true)}) @ApiImplicitParams({@ApiImplicitParam(name = "sn", value = "设备sn", paramType = "query", dataType = "String", required = true)})
@ -122,68 +125,135 @@ public class CarOpenApi {
return R.ok(); return R.ok();
} }
@PostMapping({"/pushEnterRecord"}) // @PostMapping({"/pushEnterRecord"})
@ApiOperation("第三方推送入场记录") // @ApiOperation("第三方推送入场记录")
public Map pushEnterRecord(@RequestBody Object object) { // public Map pushEnterRecord(@RequestBody Object object) {
Map<String, String> res = new HashMap<>(); // Map<String, String> res = new HashMap<>();
res.put("code", "401"); // res.put("code", "401");
res.put("msg", "签名结果不一致"); // res.put("msg", "签名结果不一致");
JSONObject msgJson = (JSONObject) JSONObject.toJSON(object); // JSONObject msgJson = (JSONObject) JSONObject.toJSON(object);
String sign = msgJson.getString("sign"); // String sign = msgJson.getString("sign");
String appKey = msgJson.getString("appKey"); // String appKey = msgJson.getString("appKey");
Long timestamp = msgJson.getLong("timestamp"); // Long timestamp = msgJson.getLong("timestamp");
JSONObject bizContent = msgJson.getJSONObject("bizContent"); // JSONObject bizContent = msgJson.getJSONObject("bizContent");
String parkCode = bizContent.getString("parkCode"); // String parkCode = bizContent.getString("parkCode");
String parkName = bizContent.getString("parkName"); // String parkName = bizContent.getString("parkName");
String orderNum = bizContent.getString("orderNum"); // String orderNum = bizContent.getString("orderNum");
String plateNum = bizContent.getString("plateNum"); // String plateNum = bizContent.getString("plateNum");
String channelName = bizContent.getString("channelName"); // String channelName = bizContent.getString("channelName");
long enterTimeLong = bizContent.getLongValue("enterTime"); // long enterTimeLong = bizContent.getLongValue("enterTime");
Date enterTime = new Date(enterTimeLong * 1000L); // Date enterTime = new Date(enterTimeLong * 1000L);
int type = bizContent.getIntValue("type"); // int type = bizContent.getIntValue("type");
int carType = bizContent.getIntValue("carType"); // int carType = bizContent.getIntValue("carType");
String imgUrl = bizContent.getString("imgUrl"); // String imgUrl = bizContent.getString("imgUrl");
//
//去掉 amp; // //去掉 amp;
imgUrl = imgUrl.replace("amp;", ""); // imgUrl = imgUrl.replace("amp;", "");
//
TenPackRecordEnterEntity enter = new TenPackRecordEnterEntity(); // TenPackRecordEnterEntity enter = new TenPackRecordEnterEntity();
enter.setParkCode(parkCode); // enter.setParkCode(parkCode);
enter.setParkName(parkName); // enter.setParkName(parkName);
enter.setOrderNumber(orderNum); // enter.setOrderNumber(orderNum);
enter.setPlateNumber(plateNum); // enter.setPlateNumber(plateNum);
enter.setChannelName(channelName); // enter.setChannelName(channelName);
enter.setType(Integer.valueOf(type)); // enter.setType(Integer.valueOf(type));
enter.setCarType(Integer.valueOf(carType)); // enter.setCarType(Integer.valueOf(carType));
enter.setEnterTime(enterTime); // enter.setEnterTime(enterTime);
if (!StringUtils.isEmpty(imgUrl)) { // if (!StringUtils.isEmpty(imgUrl)) {
URL url = null; // URL url = null;
InputStream is = null; // InputStream is = null;
HttpURLConnection httpUrl = null; // HttpURLConnection httpUrl = null;
try { // try {
url = new URL(imgUrl); // url = new URL(imgUrl);
//
BufferedImage image = ImageIO.read(url); // BufferedImage image = ImageIO.read(url);
//获取图片的宽 // //获取图片的宽
System.out.println("Width: " + image.getWidth()); // System.out.println("Width: " + image.getWidth());
System.out.println("Height: " + image.getHeight()); // System.out.println("Height: " + image.getHeight());
int w = image.getWidth(); // int w = image.getWidth();
int h = image.getHeight(); // int h = image.getHeight();
//调整尺寸不能大于1024 // //调整尺寸不能大于1024
if(w>1024 || h>1024){ // if(w>1024 || h>1024){
image = ThumbnailsUtils.resizeImageOne(image,1024,1024); // image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
} // }
//
String fileName = "car/" + enter.getParkCode() + "/" + UUIDUtil.uuid() + ".jpg"; // String fileName = "car/" + enter.getParkCode() + "/" + UUIDUtil.uuid() + ".jpg";
//
byte[] data = ImageUtils.imageToBytes(image); // byte[] data = ImageUtils.imageToBytes(image);
is = new ByteArrayInputStream(data); // is = new ByteArrayInputStream(data);
int rl = is.available(); // int rl = is.available();
PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L); // PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
putObjectOptions.setContentType("image/jpeg"); // putObjectOptions.setContentType("image/jpeg");
this.minioClient.putObject(this.minioConfig // this.minioClient.putObject(this.minioConfig
.getBucketName(), fileName, is, putObjectOptions); // .getBucketName(), fileName, is, putObjectOptions);
//
//// httpUrl = (HttpURLConnection) url.openConnection();
//// httpUrl.connect();
//// httpUrl.getInputStream();
//// is = httpUrl.getInputStream();
//// String fileName = "car/" + enter.getParkCode() + "/" + UUIDUtil.uuid() + ".jpg";
//// PutObjectOptions putObjectOptions = new PutObjectOptions(is.available(), -1L);
//// putObjectOptions.setContentType("image/jpeg");
//// this.minioClient.putObject(this.minioConfig
//// .getBucketName(), fileName, is, putObjectOptions);
// enter.setImage(fileName);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (is != null)
// try {
// is.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// if (httpUrl != null)
// httpUrl.disconnect();
// }
// }
// this.tenPackRecordEnterService.save(enter);
// res.put("code", "200");
// res.put("msg", "成功");
// return res;
// }
//
// @PostMapping({"/pushExitRecord"})
// @ApiOperation("第三方推送出场记录")
// public Map pushExitRecord(@RequestBody Object object) {
// Map<String, String> res = new HashMap<>();
// res.put("code", "401");
// res.put("msg", "签名结果不一致");
// JSONObject msgJson = (JSONObject) JSONObject.toJSON(object);
// String sign = msgJson.getString("sign");
// String appKey = msgJson.getString("appKey");
// Long timestamp = msgJson.getLong("timestamp");
// JSONObject bizContent = msgJson.getJSONObject("bizContent");
// String parkCode = bizContent.getString("parkCode");
// String parkName = bizContent.getString("parkName");
// String orderNum = bizContent.getString("orderNum");
// String plateNum = bizContent.getString("plateNum");
// String channelName = bizContent.getString("channelName");
// long exitTimeLong = bizContent.getLongValue("exitTime");
// Date exitTime = new Date(exitTimeLong * 1000L);
// int type = bizContent.getIntValue("type");
// int carType = bizContent.getIntValue("carType");
// long parkTime = bizContent.getLongValue("parkTime");
// String imgUrl = bizContent.getString("imgUrl");
// TenPackRecordExitEntity enter = new TenPackRecordExitEntity();
// enter.setParkCode(parkCode);
// enter.setParkName(parkName);
// enter.setOrderNumber(orderNum);
// enter.setPlateNumber(plateNum);
// enter.setChannelName(channelName);
// enter.setType(Integer.valueOf(type));
// enter.setCarType(Integer.valueOf(carType));
// enter.setExitTime(exitTime);
// enter.setPackTime(Long.valueOf(parkTime));
// if (!StringUtils.isEmpty(imgUrl)) {
// URL url = null;
// InputStream is = null;
// HttpURLConnection httpUrl = null;
// try {
// url = new URL(imgUrl);
// httpUrl = (HttpURLConnection) url.openConnection(); // httpUrl = (HttpURLConnection) url.openConnection();
// httpUrl.connect(); // httpUrl.connect();
// httpUrl.getInputStream(); // httpUrl.getInputStream();
@ -193,92 +263,25 @@ public class CarOpenApi {
// putObjectOptions.setContentType("image/jpeg"); // putObjectOptions.setContentType("image/jpeg");
// this.minioClient.putObject(this.minioConfig // this.minioClient.putObject(this.minioConfig
// .getBucketName(), fileName, is, putObjectOptions); // .getBucketName(), fileName, is, putObjectOptions);
enter.setImage(fileName); // enter.setImage(fileName);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} finally { // } finally {
if (is != null) // if (is != null)
try { // try {
is.close(); // is.close();
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
if (httpUrl != null) // if (httpUrl != null)
httpUrl.disconnect(); // httpUrl.disconnect();
} // }
} // }
this.tenPackRecordEnterService.save(enter); // this.tenPackRecordExitService.save(enter);
res.put("code", "200"); // res.put("code", "200");
res.put("msg", "成功"); // res.put("msg", "成功");
return res; // return res;
} // }
@PostMapping({"/pushExitRecord"})
@ApiOperation("第三方推送出场记录")
public Map pushExitRecord(@RequestBody Object object) {
Map<String, String> res = new HashMap<>();
res.put("code", "401");
res.put("msg", "签名结果不一致");
JSONObject msgJson = (JSONObject) JSONObject.toJSON(object);
String sign = msgJson.getString("sign");
String appKey = msgJson.getString("appKey");
Long timestamp = msgJson.getLong("timestamp");
JSONObject bizContent = msgJson.getJSONObject("bizContent");
String parkCode = bizContent.getString("parkCode");
String parkName = bizContent.getString("parkName");
String orderNum = bizContent.getString("orderNum");
String plateNum = bizContent.getString("plateNum");
String channelName = bizContent.getString("channelName");
long exitTimeLong = bizContent.getLongValue("exitTime");
Date exitTime = new Date(exitTimeLong * 1000L);
int type = bizContent.getIntValue("type");
int carType = bizContent.getIntValue("carType");
long parkTime = bizContent.getLongValue("parkTime");
String imgUrl = bizContent.getString("imgUrl");
TenPackRecordExitEntity enter = new TenPackRecordExitEntity();
enter.setParkCode(parkCode);
enter.setParkName(parkName);
enter.setOrderNumber(orderNum);
enter.setPlateNumber(plateNum);
enter.setChannelName(channelName);
enter.setType(Integer.valueOf(type));
enter.setCarType(Integer.valueOf(carType));
enter.setExitTime(exitTime);
enter.setPackTime(Long.valueOf(parkTime));
if (!StringUtils.isEmpty(imgUrl)) {
URL url = null;
InputStream is = null;
HttpURLConnection httpUrl = null;
try {
url = new URL(imgUrl);
httpUrl = (HttpURLConnection) url.openConnection();
httpUrl.connect();
httpUrl.getInputStream();
is = httpUrl.getInputStream();
String fileName = "car/" + enter.getParkCode() + "/" + UUIDUtil.uuid() + ".jpg";
PutObjectOptions putObjectOptions = new PutObjectOptions(is.available(), -1L);
putObjectOptions.setContentType("image/jpeg");
this.minioClient.putObject(this.minioConfig
.getBucketName(), fileName, is, putObjectOptions);
enter.setImage(fileName);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
if (httpUrl != null)
httpUrl.disconnect();
}
}
this.tenPackRecordExitService.save(enter);
res.put("code", "200");
res.put("msg", "成功");
return res;
}
/* /*
@ -383,11 +386,22 @@ public class CarOpenApi {
// //
Long cellId = null; Long cellId = null;
Long tenantId = null; Long tenantId = null;
String parkCodeXa = null;
String channalCodeXa = null;
TenPackEntity packEntity = tenPackService.getOne(new QueryWrapper<TenPackEntity>() TenPackEntity packEntity = tenPackService.getOne(new QueryWrapper<TenPackEntity>()
.eq("park_code",parkCode)); .eq("park_code",parkCode));
if(packEntity!=null){ if(packEntity!=null){
cellId = packEntity.getCellId(); cellId = packEntity.getCellId();
tenantId = packEntity.getTenantId(); tenantId = packEntity.getTenantId();
parkCodeXa = packEntity.getParkCodeXa();
TenPackChannalEntity channalEntity = tenPackChannalService.getOne(
new QueryWrapper<TenPackChannalEntity>()
.eq("channal_name",channelName)
.eq("pack_id",packEntity.getParkId())
);
if(channalEntity!=null){
channalCodeXa = channalEntity.getChannalCodeXa();
}
} }
if (serviceName.equals("enter")) { if (serviceName.equals("enter")) {
long enterTimeLong = bizContent.getLongValue("enterTime"); long enterTimeLong = bizContent.getLongValue("enterTime");
@ -403,6 +417,8 @@ public class CarOpenApi {
enter.setEnterTime(enterTime); enter.setEnterTime(enterTime);
enter.setCellId(cellId); enter.setCellId(cellId);
enter.setTenantId(tenantId); enter.setTenantId(tenantId);
enter.setParkCodeXa(parkCodeXa);
enter.setChannalCodeXa(channalCodeXa);
if (fileName.length() > 0) if (fileName.length() > 0)
enter.setImage(fileName); enter.setImage(fileName);
this.tenPackRecordEnterService.save(enter); this.tenPackRecordEnterService.save(enter);

View File

@ -8,10 +8,7 @@ import io.minio.MinioClient;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.*;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.config.MinioConfig; import net.shapelight.common.config.MinioConfig;
@ -164,7 +161,7 @@ public class XaImageTask implements ITask {
syncRecords.add(syncRecord); syncRecords.add(syncRecord);
updateRecords.add(record); updateRecords.add(record);
count++; count++;
if (count >= 30) if (count >= 10)
break; break;
} }
} }
@ -185,71 +182,133 @@ public class XaImageTask implements ITask {
String enJson = XaUtils.encryptStr(json.trim(), appSecret); String enJson = XaUtils.encryptStr(json.trim(), appSecret);
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,"","RYJCZPXX", "RYJCZPXX", appId, appSecret); List<XaRYJCZPXX> syncRecordsUpdates = jsonData.getDatas();
for(XaRYJCZPXX xx: syncRecordsUpdates){
xx.setLV_ZPZP("");
}
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,jsonData,"RYJCZPXX", "RYJCZPXX", appId, appSecret);
String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId()); String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId());
String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "RYJCZPXX", "RYJCZPXX", appId, appSecret,tranId); String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "RYJCZPXX", "RYJCZPXX", appId, appSecret,tranId);
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传人员识别记录返回数据:" + resJson); log.debug("上传人员识别记录图片返回数据:" + resJson);
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenRecordEntity recordEntity : updateRecords) { // for (TenRecordEntity recordEntity : updateRecords) {
recordEntity.setXaSyncImage(1); // recordEntity.setXaSyncImage(1);
tenRecordService.updateById(recordEntity); // tenRecordService.updateById(recordEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenRecordEntity recordEntity : updateRecords) {
recordEntity.setXaSyncImage(1);
tenRecordService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRecords.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenRecordEntity recordEntity = updateRecords.get(i);
recordEntity.setXaSyncImage(1);
tenRecordService.updateById(recordEntity);
}
}
} }
} }
} }
private void processRecordCarEnterImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { private void processRecordCarEnterImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) {
List<TenPackRecordEnterEntity> records = this.tenPackRecordEnterService.getNotSync(cellId); List<TenPackRecordEnterEntity> records = this.tenPackRecordEnterService.getNotSyncImage(cellId);
List<XaTCCTCSBXX> syncRecords = new ArrayList(); List<XaTCCTCSBZPXX> syncRecords = new ArrayList();
List<TenPackRecordEnterEntity> updateRecords = new ArrayList<>(); List<TenPackRecordEnterEntity> updateRecords = new ArrayList<>();
int count = 0; int count = 0;
for (TenPackRecordEnterEntity record : records) { for (TenPackRecordEnterEntity record : records) {
XaTCCTCSBXX syncRecord = new XaTCCTCSBXX(); XaTCCTCSBZPXX syncRecord = new XaTCCTCSBZPXX();
TenPackEntity packEntity = tenPackService.getOne(new QueryWrapper<TenPackEntity>() // TenPackEntity packEntity = tenPackService.getOne(new QueryWrapper<TenPackEntity>()
.eq("park_code",record.getParkCode())); // .eq("park_code",record.getParkCode()));
//
// if(packEntity==null){
// continue;
// }
// String packCodeXa = packEntity.getParkCodeXa();
// if(packCodeXa==null || packCodeXa.length()==0){
// continue;
// }
//
// TenPackChannalEntity channalEntity = tenPackChannalService.getOne(new QueryWrapper<TenPackChannalEntity>()
// .eq("channal_name",record.getChannelName()));
// if(channalEntity==null){
// continue;
// }
// String channalCodeXa = channalEntity.getChannalCodeXa();
// if(channalCodeXa==null || channalCodeXa.length()==0){
// continue;
// }
if(packEntity==null){
syncRecord.setLV_TCCBH(record.getParkCodeXa());
syncRecord.setLV_ZPSJ(DateUtils.format(record.getEnterTime(), "yyyyMMddHHmmss"));
String base64Image = "";
InputStream inStream = null;
ByteArrayOutputStream outStream = null;
try {
minioClient.statObject(minioConfig.getBucketName(), record.getImage());
inStream = minioClient.getObject(minioConfig.getBucketName(), record.getImage());
outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, length);
}
base64Image = Base64.getEncoder().encodeToString(outStream.toByteArray());
} catch (Exception e) {
log.error("照片不存在:" + record.getImage());
e.printStackTrace();
} finally {
if (inStream != null) {
try {
inStream.close();
} catch (IOException e) {
log.error("inputStream close IOException:" + e.getMessage());
}
}
if (outStream != null) {
try {
outStream.close();
} catch (IOException e) {
log.error("outStream close IOException:" + e.getMessage());
}
}
}
if (base64Image.length() == 0) {
continue; continue;
} }
String packCodeXa = packEntity.getParkCodeXa(); syncRecord.setLV_ZPZP(base64Image);//base64图片
if(packCodeXa==null || packCodeXa.length()==0){
continue;
}
TenPackChannalEntity channalEntity = tenPackChannalService.getOne(new QueryWrapper<TenPackChannalEntity>()
.eq("channal_name",record.getChannelName()));
if(channalEntity==null){
continue;
}
String channalCodeXa = channalEntity.getChannalCodeXa();
if(channalCodeXa==null || channalCodeXa.length()==0){
continue;
}
syncRecord.setLV_TCCBH(packCodeXa);
syncRecord.setLV_CPHM(record.getPlateNumber());
syncRecord.setLV_CPLX("03");//01 大型汽车号牌 2 小型汽车号牌 03 使馆汽车号牌 04 领馆汽车号牌
syncRecord.setLV_GCSJ(DateUtils.format(record.getEnterTime(), "yyyyMMddHHmmss"));
syncRecord.setLV_GCLX("1");//1进场2出场
syncRecord.setLV_JKBM(record.getRecordEnterId()+"");
syncRecord.setLV_SBXT("10");//申报系统,默认10
syncRecord.setLV_KKSBBH(channalCodeXa);
syncRecord.setLV_PROCMODE("PMINSERT");
syncRecords.add(syncRecord); syncRecords.add(syncRecord);
updateRecords.add(record); updateRecords.add(record);
count++; count++;
if (count >= 30) if (count >= 10)
break; break;
} }
if(count == 0){
return;
}
XaData jsonData = new XaData(); XaData jsonData = new XaData();
jsonData.setDatas(syncRecords); jsonData.setDatas(syncRecords);
@ -264,19 +323,43 @@ public class XaImageTask implements ITask {
String enJson = XaUtils.encryptStr(json.trim(), appSecret); String enJson = XaUtils.encryptStr(json.trim(), appSecret);
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,"","TCCTCSBXX", "TCCTCSBXX", appId, appSecret); List<XaTCCTCSBZPXX> syncRecordsUpdates = jsonData.getDatas();
for(XaTCCTCSBZPXX xx: syncRecordsUpdates){
xx.setLV_ZPZP("");
}
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,jsonData,"TCCTCSBZPXX", "TCCTCSBZPXX", appId, appSecret);
String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId()); String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId());
String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "TCCTCSBXX", "TCCTCSBXX", appId, appSecret,tranId); String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "TCCTCSBZPXX", "TCCTCSBZPXX", appId, appSecret,tranId);
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传车辆进场记录返回数据:" + resJson); log.debug("上传车辆进场图片返回数据:" + resJson);
tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { if(resJson.contains("ErrorLineParameter")){
for (TenPackRecordEnterEntity recordEntity : updateRecords) { JSONObject resJsonObject = JSONObject.parseObject(resJson);
recordEntity.setXaSync(1); String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
tenPackRecordEnterService.updateById(recordEntity); if(errLine.equals("empty")){
for (TenPackRecordEnterEntity recordEntity : updateRecords) {
recordEntity.setXaSyncImage(1);
tenPackRecordEnterService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRecords.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenPackRecordEnterEntity recordEntity = updateRecords.get(i);
recordEntity.setXaSyncImage(1);
tenPackRecordEnterService.updateById(recordEntity);
}
}
} }
} }
} }
@ -285,51 +368,86 @@ public class XaImageTask implements ITask {
private void processRecordCarExitImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) { private void processRecordCarExitImage(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) {
List<TenPackRecordExitEntity> records = this.tenPackRecordExitService.getNotSync(cellId); List<TenPackRecordExitEntity> records = this.tenPackRecordExitService.getNotSyncImage(cellId);
List<XaTCCTCSBXXEXIT> syncRecords = new ArrayList(); List<XaTCCTCSBZPXX> syncRecords = new ArrayList();
List<TenPackRecordExitEntity> updateRecords = new ArrayList<>(); List<TenPackRecordExitEntity> updateRecords = new ArrayList<>();
int count = 0; int count = 0;
for (TenPackRecordExitEntity record : records) { for (TenPackRecordExitEntity record : records) {
XaTCCTCSBXXEXIT syncRecord = new XaTCCTCSBXXEXIT(); XaTCCTCSBZPXX syncRecord = new XaTCCTCSBZPXX();
TenPackEntity packEntity = tenPackService.getOne(new QueryWrapper<TenPackEntity>() // TenPackEntity packEntity = tenPackService.getOne(new QueryWrapper<TenPackEntity>()
.eq("park_code",record.getParkCode())); // .eq("park_code",record.getParkCode()));
//
// if(packEntity==null){
// continue;
// }
// String packCodeXa = packEntity.getParkCodeXa();
// if(packCodeXa==null || packCodeXa.length()==0){
// continue;
// }
//
// TenPackChannalEntity channalEntity = tenPackChannalService.getOne(new QueryWrapper<TenPackChannalEntity>()
// .eq("channal_name",record.getChannelName()));
// if(channalEntity==null){
// continue;
// }
// String channalCodeXa = channalEntity.getChannalCodeXa();
// if(channalCodeXa==null || channalCodeXa.length()==0){
// continue;
// }
if(packEntity==null){
syncRecord.setLV_TCCBH(record.getParkCodeXa());
syncRecord.setLV_ZPSJ(DateUtils.format(record.getExitTime(), "yyyyMMddHHmmss"));
String base64Image = "";
InputStream inStream = null;
ByteArrayOutputStream outStream = null;
try {
minioClient.statObject(minioConfig.getBucketName(), record.getImage());
inStream = minioClient.getObject(minioConfig.getBucketName(), record.getImage());
outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, length);
}
base64Image = Base64.getEncoder().encodeToString(outStream.toByteArray());
} catch (Exception e) {
log.error("照片不存在:" + record.getImage());
e.printStackTrace();
} finally {
if (inStream != null) {
try {
inStream.close();
} catch (IOException e) {
log.error("inputStream close IOException:" + e.getMessage());
}
}
if (outStream != null) {
try {
outStream.close();
} catch (IOException e) {
log.error("outStream close IOException:" + e.getMessage());
}
}
}
if (base64Image.length() == 0) {
continue; continue;
} }
String packCodeXa = packEntity.getParkCodeXa(); syncRecord.setLV_ZPZP(base64Image);//base64图片
if(packCodeXa==null || packCodeXa.length()==0){
continue;
}
TenPackChannalEntity channalEntity = tenPackChannalService.getOne(new QueryWrapper<TenPackChannalEntity>()
.eq("channal_name",record.getChannelName()));
if(channalEntity==null){
continue;
}
String channalCodeXa = channalEntity.getChannalCodeXa();
if(channalCodeXa==null || channalCodeXa.length()==0){
continue;
}
syncRecord.setLV_TCCBH(packCodeXa);
syncRecord.setLV_CPHM(record.getPlateNumber());
syncRecord.setLV_CPLX("03");//01 大型汽车号牌 2 小型汽车号牌 03 使馆汽车号牌 04 领馆汽车号牌
syncRecord.setLV_GCSJ(DateUtils.format(record.getExitTime(), "yyyyMMddHHmmss"));
syncRecord.setLV_GCLX("1");//1进场2出场
syncRecord.setLV_CKBM(record.getRecordExitId()+"");
syncRecord.setLV_SBXT("10");//申报系统,默认10
syncRecord.setLV_KKSBBH(channalCodeXa);
syncRecord.setLV_PROCMODE("PMINSERT");
syncRecords.add(syncRecord); syncRecords.add(syncRecord);
updateRecords.add(record); updateRecords.add(record);
count++; count++;
if (count >= 30) if (count >= 10)
break; break;
} }
if(count == 0){
return;
}
XaData jsonData = new XaData(); XaData jsonData = new XaData();
jsonData.setDatas(syncRecords); jsonData.setDatas(syncRecords);
@ -344,7 +462,12 @@ public class XaImageTask implements ITask {
String enJson = XaUtils.encryptStr(json.trim(), appSecret); String enJson = XaUtils.encryptStr(json.trim(), appSecret);
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,"","TCCTCSBXX", "TCCTCSBXX", appId, appSecret); List<XaTCCTCSBZPXX> syncRecordsUpdates = jsonData.getDatas();
for(XaTCCTCSBZPXX xx: syncRecordsUpdates){
xx.setLV_ZPZP("");
}
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,jsonData,"TCCTCSBXX", "TCCTCSBXX", appId, appSecret);
String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId()); String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId());
@ -352,12 +475,36 @@ public class XaImageTask implements ITask {
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传车辆进场记录返回数据:" + resJson); log.debug("上传车辆出场记录返回数据:" + resJson);
tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenPackRecordExitEntity recordEntity : updateRecords) { // for (TenPackRecordExitEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1); // recordEntity.setXaSync(1);
tenPackRecordExitService.updateById(recordEntity); // tenPackRecordExitService.updateById(recordEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenPackRecordExitEntity recordEntity : updateRecords) {
recordEntity.setXaSyncImage(1);
tenPackRecordExitService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRecords.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenPackRecordExitEntity recordEntity = updateRecords.get(i);
recordEntity.setXaSyncImage(1);
tenPackRecordExitService.updateById(recordEntity);
}
}
} }
} }
} }
@ -384,9 +531,9 @@ public class XaImageTask implements ITask {
ByteArrayOutputStream outStream = null; ByteArrayOutputStream outStream = null;
try { try {
minioClient.statObject(minioConfig.getBucketName(), person.getOrgImage()); minioClient.statObject(minioConfig.getBucketName(), person.getFaceImage());
inStream = minioClient.getObject(minioConfig.getBucketName(), person.getOrgImage()); inStream = minioClient.getObject(minioConfig.getBucketName(), person.getFaceImage());
outStream = new ByteArrayOutputStream(); outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int length; int length;
@ -425,7 +572,7 @@ public class XaImageTask implements ITask {
count++; count++;
if (count >= 50) if (count >= 10)
break; break;
} }
} }
@ -446,21 +593,49 @@ public class XaImageTask implements ITask {
String enJson = XaUtils.encryptStr(json.trim(), appSecret); String enJson = XaUtils.encryptStr(json.trim(), appSecret);
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,"","SYRK", "SYRK", appId, appSecret); List<XaTCCTCSBZPXX> syncRecordsUpdates = jsonData.getDatas();
for(XaTCCTCSBZPXX xx: syncRecordsUpdates){
xx.setLV_ZPZP("");
}
TenTranEntity tranEntity = tenTranService.saveApi(fwikUrl,jsonData,"RYRKPHOTO", "RYRKPHOTO", appId, appSecret);
String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId()); String tranId = String.format("%s%016d",DateUtils.format(tranEntity.getTranDate(),"yyyyMMddHHmmss"),tranEntity.getTranId());
String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "SYRK", "SYRK", appId, appSecret,tranId); String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "RYRKPHOTO", "RYRKPHOTO", appId, appSecret,tranId);
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("processRealPersonImage" + resJson); log.debug("上传实有人口返回数据" + resJson);
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenPersonEntity personEntity : updatePersons) { // for (TenPersonEntity personEntity : updatePersons) {
personEntity.setXaSyncImage(1); // personEntity.setXaSyncImage(1);
tenPersonService.updateNonal(personEntity); // tenPersonService.updateNonal(personEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenPersonEntity recordEntity : updatePersons) {
recordEntity.setXaSyncImage(1);
tenPersonService.updateById(recordEntity);
}
}else{
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.setXaSyncImage(1);
tenPersonService.updateById(recordEntity);
}
}
} }
} }
} }

View File

@ -5,11 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.utils.DateUtils; import net.shapelight.common.utils.DateUtils;
@ -168,10 +164,32 @@ public class XaRealDataTask implements ITask {
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenRoomEntity room : updateRooms) { // for (TenRoomEntity room : updateRooms) {
room.setXaSync(1); // room.setXaSync(1);
tenRoomService.updateById(room); // tenRoomService.updateById(room);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenRoomEntity recordEntity : updateRooms) {
recordEntity.setXaSync(1);
tenRoomService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRooms.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenRoomEntity recordEntity = updateRooms.get(i);
recordEntity.setXaSync(1);
tenRoomService.updateById(recordEntity);
}
}
} }
} }
} }
@ -249,14 +267,36 @@ public class XaRealDataTask implements ITask {
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJson); log.debug("上传实有人口返回数据:" + resJson);
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenPersonEntity personEntity : updatePersons) { // for (TenPersonEntity personEntity : updatePersons) {
personEntity.setXaSync(1); // personEntity.setXaSync(1);
tenPersonService.updateNonal(personEntity); // tenPersonService.updateNonal(personEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenPersonEntity recordEntity : updatePersons) {
recordEntity.setXaSync(1);
tenPersonService.updateById(recordEntity);
}
}else{
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);
}
}
} }
} }
} }
@ -312,14 +352,36 @@ public class XaRealDataTask implements ITask {
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJson); log.debug("上传门禁返回数据:" + resJson);
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenPersonEntity personEntity : updatePersons) { // for (TenPersonEntity personEntity : updatePersons) {
personEntity.setXaSyncCard(1); // personEntity.setXaSyncCard(1);
tenPersonService.updateNonal(personEntity); // tenPersonService.updateNonal(personEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenPersonEntity recordEntity : updatePersons) {
recordEntity.setXaSyncCard(1);
tenPersonService.updateById(recordEntity);
}
}else{
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.setXaSyncCard(1);
tenPersonService.updateById(recordEntity);
}
}
} }
} }
} }
@ -376,14 +438,36 @@ public class XaRealDataTask implements ITask {
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJson); log.debug("上传设备信息返回数据:" + resJson);
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenDeviceEntity deviceEntity : updateDevices) { // for (TenDeviceEntity deviceEntity : updateDevices) {
deviceEntity.setXaSync(1); // deviceEntity.setXaSync(1);
tenDeviceService.evictupdateById(deviceEntity); // tenDeviceService.evictupdateById(deviceEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenDeviceEntity recordEntity : updateDevices) {
recordEntity.setXaSync(1);
tenDeviceService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateDevices.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenDeviceEntity recordEntity = updateDevices.get(i);
recordEntity.setXaSync(1);
tenDeviceService.updateById(recordEntity);
}
}
} }
} }
} }

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -52,8 +53,8 @@ public class XaRecordTask implements ITask {
if (type.intValue() == 1) { if (type.intValue() == 1) {
String appId = object.getString("appId"); String appId = object.getString("appId");
String appSecret = object.getString("appSecret"); String appSecret = object.getString("appSecret");
// String fwikUrl = XaApi.getFwikUrl(appId, appSecret); String fwikUrl = XaApi.getFwikUrl(appId, appSecret);
String fwikUrl = "http://"; // String fwikUrl = "http://";
if (fwikUrl != null) { if (fwikUrl != null) {
List<TenCellEntity> allCells = this.tenCellService.list((Wrapper)(new QueryWrapper()) List<TenCellEntity> allCells = this.tenCellService.list((Wrapper)(new QueryWrapper())
.eq("tenant_id", sysTenUser.getTenantId())); .eq("tenant_id", sysTenUser.getTenantId()));
@ -138,10 +139,32 @@ public class XaRecordTask implements ITask {
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenRecordEntity recordEntity : updateRecords) { // for (TenRecordEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1); // recordEntity.setXaSync(1);
tenRecordService.updateById(recordEntity); // tenRecordService.updateById(recordEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenRecordEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1);
tenRecordService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRecords.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenRecordEntity recordEntity = updateRecords.get(i);
recordEntity.setXaSync(1);
tenRecordService.updateById(recordEntity);
}
}
} }
} }
} }
@ -220,10 +243,32 @@ public class XaRecordTask implements ITask {
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenPackRecordEnterEntity recordEntity : updateRecords) { // for (TenPackRecordEnterEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1); // recordEntity.setXaSync(1);
tenPackRecordEnterService.updateById(recordEntity); // tenPackRecordEnterService.updateById(recordEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenPackRecordEnterEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1);
tenPackRecordEnterService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRecords.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenPackRecordEnterEntity recordEntity = updateRecords.get(i);
recordEntity.setXaSync(1);
tenPackRecordEnterService.updateById(recordEntity);
}
}
} }
} }
} }
@ -301,17 +346,37 @@ public class XaRecordTask implements ITask {
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}"; // String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
// String resJson = "23232"; // String resJson = "23232";
// System.out.println(s); // System.out.println(s);
log.debug("上传车辆场记录返回数据:" + resJson); log.debug("上传车辆场记录返回数据:" + resJson);
tranEntity.setTranResult(resJson); tranEntity.setTranResult(resJson);
tenTranService.updateById(tranEntity); tenTranService.updateById(tranEntity);
//上传成功修改sync状态 //上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) { // if (resJson.contains("\"code\":\"0000\"")) {
for (TenPackRecordExitEntity recordEntity : updateRecords) { // for (TenPackRecordExitEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1); // recordEntity.setXaSync(1);
tenPackRecordExitService.updateById(recordEntity); // tenPackRecordExitService.updateById(recordEntity);
// }
// }
if(resJson.contains("ErrorLineParameter")){
JSONObject resJsonObject = JSONObject.parseObject(resJson);
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
if(errLine.equals("empty")){
for (TenPackRecordExitEntity recordEntity : updateRecords) {
recordEntity.setXaSync(1);
tenPackRecordExitService.updateById(recordEntity);
}
}else{
String[] lines = errLine.split(",");
List<String> lineList = Arrays.asList(lines);
for (int i = 0;i<updateRecords.size();i++) {
if(lineList.contains(i+1+"")){
continue;
}else {
TenPackRecordExitEntity recordEntity = updateRecords.get(i);
recordEntity.setXaSync(1);
tenPackRecordExitService.updateById(recordEntity);
}
}
} }
} }
} }
} }

View File

@ -59,6 +59,15 @@ public class TenPackRecordEnterEntity implements Serializable {
private Integer xaSyncImage; private Integer xaSyncImage;
@ApiModelProperty("停车场西安对接变价")
private String parkCodeXa;
@ApiModelProperty("通道西安编码")
private String channalCodeXa;
@ApiModelProperty("通道编码")
private String channalCode;
@ApiModelProperty("小区名称") @ApiModelProperty("小区名称")
@TableField(exist=false) @TableField(exist=false)
private String cellName; private String cellName;

View File

@ -76,6 +76,15 @@ public class TenPackRecordExitEntity implements Serializable {
private Integer xaSyncImage; private Integer xaSyncImage;
@ApiModelProperty("停车场西安对接变价")
private String parkCodeXa;
@ApiModelProperty("通道西安编码")
private String channalCodeXa;
@ApiModelProperty("通道编码")
private String channalCode;
@ApiModelProperty("小区名称") @ApiModelProperty("小区名称")
@TableField(exist=false) @TableField(exist=false)
private String cellName; private String cellName;

View File

@ -32,53 +32,59 @@ public class TenPackRecordEnterServiceImpl extends ServiceImpl<TenPackRecordEnte
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
List<Long> cellIds = new ArrayList<>(); List<Long> cellIds = new ArrayList<>();
// cellIds.add(709832651506188289L); // cellIds.add(709832651506188289L);
String cellId = (String)params.get("cellId"); String cellId = (String) params.get("cellId");
if (cellId!=null && !cellId.isEmpty()){ if (cellId != null && !cellId.isEmpty()) {
Long cellLong = Long.parseLong(cellId); Long cellLong = Long.parseLong(cellId);
cellIds.add(cellLong); cellIds.add(cellLong);
}else { } else {
List<TenCellEntity> cells = tenCellService.queryAll(params); List<TenCellEntity> cells = tenCellService.queryAll(params);
for (TenCellEntity cell : cells) { for (TenCellEntity cell : cells) {
cellIds.add(cell.getCellId()); cellIds.add(cell.getCellId());
} }
} }
if (cellIds.size() == 0) { if (cellIds.size() == 0) {
return new PageUtils(new ArrayList<>(),0,0,0); return new PageUtils(new ArrayList<>(), 0, 0, 0);
} }
IPage<TenPackRecordEnterEntity> page = this.page( IPage<TenPackRecordEnterEntity> page = this.page(
new Query<TenPackRecordEnterEntity>().getPage(params), new Query<TenPackRecordEnterEntity>().getPage(params),
new QueryWrapper<TenPackRecordEnterEntity>() new QueryWrapper<TenPackRecordEnterEntity>()
.eq("tenant_id",params.get("tenantId")) .eq("tenant_id", params.get("tenantId"))
.in("cell_id",cellIds) .in("cell_id", cellIds)
.orderByDesc("enter_time") .orderByDesc("enter_time")
); );
for(TenPackRecordEnterEntity entity: page.getRecords()){ for (TenPackRecordEnterEntity entity : page.getRecords()) {
TenCellEntity cell = tenCellService.getById(entity.getCellId()); TenCellEntity cell = tenCellService.getById(entity.getCellId());
entity.setCellName(cell.getName()); entity.setCellName(cell.getName());
} }
return new PageUtils(page); return new PageUtils(page);
} }
@Override @Override
public List<TenPackRecordEnterEntity> getNotSync(Long cellId) { public List<TenPackRecordEnterEntity> getNotSync(Long cellId) {
// String todayString = DateUtils.format(new Date(),DateUtils.DATE_PATTERN); // String todayString = DateUtils.format(new Date(),DateUtils.DATE_PATTERN);
// String todayStart = todayString+" 00:00:00"; // String todayStart = todayString+" 00:00:00";
// String todayEnd = todayString+" 23:59:59"; // String todayEnd = todayString+" 23:59:59";
return this.list(new QueryWrapper<TenPackRecordEnterEntity>() return this.list(new QueryWrapper<TenPackRecordEnterEntity>()
.eq("cell_id",cellId) .eq("cell_id", cellId)
.eq("xa_sync",0) .eq("xa_sync", 0)
.isNotNull("image") .isNotNull("image")
.last(" and TO_DAYS(enter_time) = TO_DAYS(NOW())")); .isNotNull("park_code_xa")
.isNotNull("channal_code_xa")
.last(" and TO_DAYS(enter_time) = TO_DAYS(NOW())"));
} }
@Override @Override
public List<TenPackRecordEnterEntity> getNotSyncImage(Long cellId) { public List<TenPackRecordEnterEntity> getNotSyncImage(Long cellId) {
return this.list(new QueryWrapper<TenPackRecordEnterEntity>() return this.list(new QueryWrapper<TenPackRecordEnterEntity>()
.eq("cell_id",cellId) .eq("cell_id", cellId)
.eq("xa_sync_image",0) .eq("xa_sync_image", 0)
.isNotNull("image") .isNotNull("image")
.eq("xa_sync",1) .isNotNull("park_code_xa")
.isNotNull("channal_code_xa")
.eq("xa_sync", 1)
.last(" and TO_DAYS(enter_time) = TO_DAYS(NOW())")); .last(" and TO_DAYS(enter_time) = TO_DAYS(NOW())"));
} }
} }

View File

@ -63,6 +63,9 @@ public class TenPackRecordExitServiceImpl extends ServiceImpl<TenPackRecordExitD
return this.list(new QueryWrapper<TenPackRecordExitEntity>() return this.list(new QueryWrapper<TenPackRecordExitEntity>()
.eq("cell_id",cellId) .eq("cell_id",cellId)
.eq("xa_sync",0) .eq("xa_sync",0)
.isNotNull("image")
.isNotNull("park_code_xa")
.isNotNull("channal_code_xa")
.last(" and TO_DAYS(exit_time) = TO_DAYS(NOW())")); .last(" and TO_DAYS(exit_time) = TO_DAYS(NOW())"));
} }
@Override @Override
@ -71,6 +74,9 @@ public class TenPackRecordExitServiceImpl extends ServiceImpl<TenPackRecordExitD
.eq("cell_id",cellId) .eq("cell_id",cellId)
.eq("xa_sync_image",0) .eq("xa_sync_image",0)
.eq("xa_sync",1) .eq("xa_sync",1)
.isNotNull("image")
.isNotNull("park_code_xa")
.isNotNull("channal_code_xa")
.last(" and TO_DAYS(exit_time) = TO_DAYS(NOW())")); .last(" and TO_DAYS(exit_time) = TO_DAYS(NOW())"));
} }
} }

View File

@ -109,11 +109,11 @@ public class XaApi {
conn.setRequestMethod("POST"); conn.setRequestMethod("POST");
String currdate = new SimpleDateFormat("yyyyMMdd").format(new Date()); String currdate = new SimpleDateFormat("yyyyMMdd").format(new Date());
String token = XaUtils.md5(appid + secre + currdate + json.replaceAll("\r\n", "")); String token = XaUtils.md5(appid + secre + currdate + json.replaceAll("\r\n", ""));
System.out.println("json****" + json); // System.out.println("json****" + json);
System.out.println("333appid***" + appid); // System.out.println("333appid***" + appid);
System.out.println("333token***" + token); // System.out.println("333token***" + token);
System.out.println("333serviceId***" + serviceId); // System.out.println("333serviceId***" + serviceId);
System.out.println("333serviceValue***" + serviceValue); // System.out.println("333serviceValue***" + serviceValue);
conn.setRequestProperty("appid", appid); conn.setRequestProperty("appid", appid);
conn.setRequestProperty("token", token); conn.setRequestProperty("token", token);