| | |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | |
| | | private FileService fileService; |
| | | |
| | | /** |
| | | * |
| | | * @param req |
| | | * @param gatewaySer |
| | | * @return |
| | | */ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<Object> req, GatewaySer gatewaySer) throws Exception{ |
| | | public ApiV1Resp<Object> analysis(ApiV1Req<Object> req, GatewaySer gatewaySer) throws Exception { |
| | | |
| | | //转化为对象 |
| | | List<Param3030> list = JSONObject.parseArray(req.getData().toString(), Param3030.class); |
| | | Param3030 param = JSONObject.parseObject(JSONObject.toJSONString(req.getData()), Param3030.class); |
| | | |
| | | if(null == list || list.isEmpty()){ |
| | | if (null == param) { |
| | | return ApiV1Resp.error("抓拍信息为空,不解析!", req); |
| | | } |
| | | |
| | | step1(list, gatewaySer); |
| | | step1(param, gatewaySer); |
| | | |
| | | return ApiV1Resp.success(null, req); |
| | | } |
| | | |
| | | /** |
| | | * 异步解析 |
| | | * @param list |
| | | * |
| | | * @param param3030 |
| | | */ |
| | | @Async |
| | | public void step1(List<Param3030> list, GatewaySer gatewaySer) throws Exception { |
| | | public void step1(Param3030 param3030, GatewaySer gatewaySer) throws Exception { |
| | | |
| | | SnapRecord snapRecord; |
| | | for (Param3030 param3030 : list) { |
| | | snapRecord = new SnapRecord(); |
| | | snapRecord.setId(ContextUtil.generateId()); |
| | | snapRecord.setCompanyId(gatewaySer.getCompanyId()); |
| | | snapRecord.setDeptId(gatewaySer.getDeptId()); |
| | | snapRecord.setCameraId(param3030.getCameraId()); |
| | | snapRecord.setResult(param3030.getResult()); |
| | | snapRecord.setTags(param3030.getTags()); |
| | | snapRecord.setSnapTime(DateUtils.parseDate(param3030.getSnapTime(),"yyyy-MM-dd HH:mm:ss")); |
| | | SnapRecord snapRecord = new SnapRecord(); |
| | | snapRecord.setId(ContextUtil.generateId()); |
| | | snapRecord.setCompanyId(gatewaySer.getCompanyId()); |
| | | snapRecord.setDeptId(gatewaySer.getDeptId()); |
| | | snapRecord.setCameraId(param3030.getCameraId()); |
| | | snapRecord.setResult(param3030.getResult()); |
| | | snapRecord.setTags(param3030.getTags()); |
| | | snapRecord.setSnapTime(DateUtils.parseDate(param3030.getSnapTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | //base64转化为图片保存 |
| | | String savePath = fileService.getFileSavePath("SNAP"); |
| | | String fileName = ContextUtil.UUID() + ".jpg"; |
| | | String filePath = savePath+fileName; |
| | | fileService.baseImg2Disk(filePath, param3030.getImgBase64()); |
| | | //base64转化为图片保存 |
| | | String savePath = fileService.getFileSavePath("SNAP"); |
| | | String fileName = ContextUtil.UUID() + ".jpg"; |
| | | String filePath = savePath + fileName; |
| | | fileService.baseImg2Disk(filePath, param3030.getImgBase64()); |
| | | |
| | | //设置保存图片路径 |
| | | snapRecord.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/")); |
| | | //设置保存图片路径 |
| | | snapRecord.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/")); |
| | | |
| | | snapRecordService.addData(snapRecord); |
| | | } |
| | | snapRecordService.addData(snapRecord); |
| | | |
| | | log.info("质押监管接口V1,3030接口解析完成"); |
| | | } |
| | | |