| | |
| | | @Autowired |
| | | private Api1205Rep api1205Rep; |
| | | @Autowired |
| | | private Api1403Rep api1403Rep; |
| | | @Autowired |
| | | private Api1404Rep api1404Rep; |
| | | |
| | | @Override |
| | |
| | | resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode()); |
| | | resd.setMsg(responseDto.getResult()); |
| | | |
| | | return resd; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | return new ResponseDto(99, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ResponseDto pullData(ApiParam param, ApiConfs conf) { |
| | | String inteId = param.getInteId(); |
| | | String kqdm = param.getKqdm(); |
| | | |
| | | try { |
| | | if (null == conf) { |
| | | conf = apiCommonService.getConf(kqdm); |
| | | } |
| | | |
| | | //添加日志 |
| | | ApiLog apiLog = new ApiLog(); |
| | | apiLog.setId(ContextUtil.getUUID()); |
| | | apiLog.setInteId(inteId); |
| | | |
| | | if (StringUtils.isEmpty(inteId)) { |
| | | ResponseDto responseDto = new ResponseDto(99, "没有获取到接口"); |
| | | apiLog.setStatus(99); |
| | | apiLog.setResult("没有获取到接口"); |
| | | apiLogRep.save(apiLog); |
| | | return responseDto; |
| | | } |
| | | |
| | | if (conf == null) { |
| | | ResponseDto responseDto = new ResponseDto(99, "没有获取到上传配置"); |
| | | apiLog.setStatus(99); |
| | | apiLog.setResult("没有获取到上传配置"); |
| | | apiLogRep.save(apiLog); |
| | | return responseDto; |
| | | } |
| | | |
| | | //查询库区信息行政区划码 |
| | | List<Api1102> api1102List = api1102Rep.findPushData(kqdm); |
| | | //封装数据 |
| | | SH2023PullReqDto reqData = new SH2023PullReqDto();; |
| | | |
| | | reqData.setName(conf.getUserName()); |
| | | reqData.setPwd(conf.getAppCode()); |
| | | |
| | | log.info("拉取共享数据请求信息=" + JSON.toJSONString(reqData)); |
| | | |
| | | String url = conf.getApiUrl().replace("UPLOAD", "Shared"); |
| | | SH2023PullRespDto responseDto = SH2023HttpClientUtil.postPullData(url + inteId, JSON.toJSONString(reqData)); |
| | | |
| | | apiLog.setStatus(responseDto.getRetcode() == 200 ? 0 : responseDto.getRetcode()); |
| | | apiLog.setResult(responseDto.getRetMsg()); |
| | | apiLogRep.save(apiLog); |
| | | ResponseDto resd = new ResponseDto(); |
| | | resd.setSuccess(responseDto.getRetcode() == 200 ? 0 : responseDto.getRetcode()); |
| | | resd.setMsg(responseDto.getRetMsg()); |
| | | resd.setData(responseDto.getData()); |
| | | return resd; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | |
| | | api1109.setWjl(JSON.toJSONString(map)); |
| | | //上海市平台文件名称规则:库区编码_业务流水号_分类码_顺序码.jpg,例如:91310114703439394M001_142211080101_GL_00.jpg |
| | | api1109.setWjmc(getWjmc(api1109.getWjlx(), api1109.getWjmc())); |
| | | //业务类型 |
| | | api1109.setYwdh(getYwdh(api1109.getWjlx(), api1109.getWjmc())); |
| | | //设置空属性为默认值 |
| | | changeObject(api1109); |
| | | return api1109; |
| | |
| | | //设置粮食轮换年度 |
| | | List<Api1404> api1404List = api1404Rep.getDataByJhmxdh(apiData.getJhmxh()); |
| | | if (null != api1404List && api1404List.size() > 0) { |
| | | api1202.setLhnd(api1404List.get(0).getShnd()); |
| | | List<Api1403> api1403List = api1403Rep.getDataByLhjhdh(api1404List.get(0).getLhjhdh()); |
| | | if(null != api1403List && api1403List.size() > 0){ |
| | | if(StringUtils.isNotEmpty(api1403List.get(0).getJhnd())){ |
| | | api1202.setLhnd(api1403List.get(0).getJhnd()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //设置批次号 |
| | |
| | | //设置粮食轮换年度 |
| | | List<Api1404> api1404List = api1404Rep.getDataByJhmxdh(apiData.getJhmxh()); |
| | | if (null != api1404List && api1404List.size() > 0) { |
| | | api1205.setLhnd(api1404List.get(0).getShnd()); |
| | | List<Api1403> api1403List = api1403Rep.getDataByLhjhdh(api1404List.get(0).getLhjhdh()); |
| | | if(null != api1403List && api1403List.size() > 0){ |
| | | if(StringUtils.isNotEmpty(api1403List.get(0).getJhnd())){ |
| | | api1205.setLhnd(api1403List.get(0).getJhnd()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //设置批次号 |
| | |
| | | map.put(ceng, new ArrayList<>()); |
| | | } |
| | | map.get(ceng).add(Double.valueOf(grain[0])); |
| | | lwmx += grain[1] + ":" + grain[2] + ":" + grain[3] + "$" + grain[0]; |
| | | lwmx += grain[3] + ":" + grain[2] + ":" + grain[1] + "$" + grain[0]; |
| | | if (Double.valueOf(grain[0]) <= -100) { |
| | | lwmx += "$" + "1" + "#"; |
| | | errorNum++; |
| | |
| | | } |
| | | return wjmc; |
| | | } |
| | | private String getYwdh(String wjlx, String wjmc) { |
| | | String ywdh = ""; |
| | | String[] s = wjmc.split("_"); |
| | | if ("2".equals(wjlx) || "3".equals(wjlx)) { |
| | | ywdh = s[1]; |
| | | } |
| | | return ywdh; |
| | | } |
| | | |
| | | private Object changeObject(Object object) { |
| | | // 使用反射获取属性列表 vo为实体对象名 |
| | |
| | | } |
| | | return object; |
| | | } |
| | | |
| | | } |