|  |  |  | 
|---|
|  |  |  | import com.bstek.dorado.annotation.DataResolver; | 
|---|
|  |  |  | import com.bstek.dorado.annotation.Expose; | 
|---|
|  |  |  | import com.bstek.dorado.data.provider.Page; | 
|---|
|  |  |  | import com.fzzy.api.entity.Api1301; | 
|---|
|  |  |  | import com.fzzy.api.data.PushProtocol; | 
|---|
|  |  |  | import com.fzzy.api.entity.ApiConfs; | 
|---|
|  |  |  | import com.fzzy.api.service.ApiCommonService; | 
|---|
|  |  |  | import com.fzzy.api.service.ApiPushManager; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 安全管理数据 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author chen | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isNotBlank(param.getCzbz())) { | 
|---|
|  |  |  | Predicate predicate2 = cb.equal(root.get("czbz"),param.getCzbz()); | 
|---|
|  |  |  | Predicate predicate2 = cb.equal(root.get("czbz"), param.getCzbz()); | 
|---|
|  |  |  | predicates.add(predicate2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null != param.getStart()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | Api1301 data = new Api1301(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(StringUtils.isEmpty(data.getId())){ | 
|---|
|  |  |  | data.setId(ContextUtil.getUUID()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | api1301Rep.save(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1301PR#delData | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delData(Api1301 data) { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1301PR#delData | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delData(Api1301 data) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1301Rep.deleteById(data.getId()); | 
|---|
|  |  |  | api1301Rep.deleteById(data.getFxdbm()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * 更新删除标记 api1301PR#delUpdate | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param entity | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delUpdate(Api1301 entity) { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新删除标记 api1301PR#delUpdate | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param entity | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delUpdate(Api1301 entity) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | entity.setCzbz(Constant.CZBZ_D); | 
|---|
|  |  |  | entity.setCzbz(Constant.CZBZ_D); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Api1301 data = new Api1301(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  | Api1301 data = new Api1301(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1301Rep.save(data); | 
|---|
|  |  |  | api1301Rep.save(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1301PR#pushData | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String pushData(List<Api1301> items) { | 
|---|
|  |  |  | ResponseDto responseDto; | 
|---|
|  |  |  | String result = ""; | 
|---|
|  |  |  | Api1301 d; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String kqdm = items.get(0).getKqdm(); | 
|---|
|  |  |  | ApiConfs apiConf = apiCommonService.getConf(kqdm); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == apiConf) return "系统没有获取到当前库区配置信息,执行失败"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //封装参数 | 
|---|
|  |  |  | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_11, Constant.API_CODE_1301); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取实现接口 | 
|---|
|  |  |  | ApiRemoteService apiService = apiPushManager.getApiRemoteService(param.getPushProtocol()); | 
|---|
|  |  |  | ApiRemoteService apiService = apiPushManager.getApiRemoteService(apiConf.getPushProtocol()); | 
|---|
|  |  |  | if (null == apiService) return "系统没有当前推送协议配置,执行失败"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return pushDataSingle(items, apiService, apiConf); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 单条数据json推送 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param items | 
|---|
|  |  |  | * @param apiService | 
|---|
|  |  |  | * @param apiConf | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String pushDataSingle(List<Api1301> items, ApiRemoteService apiService, ApiConfs apiConf) { | 
|---|
|  |  |  | ResponseDto responseDto; | 
|---|
|  |  |  | String result = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //封装参数 | 
|---|
|  |  |  | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_13, Constant.API_CODE_1301); | 
|---|
|  |  |  | Api1301 d; | 
|---|
|  |  |  | for (Api1301 data : items) { | 
|---|
|  |  |  | d = new Api1301(); | 
|---|
|  |  |  | BeanUtils.copyProperties(data, d); | 
|---|
|  |  |  | responseDto = apiService.pushData(param, apiConf, d); | 
|---|
|  |  |  | result += responseDto.toString(); | 
|---|
|  |  |  | if (responseDto.getSuccess() == 0) { | 
|---|
|  |  |  | //todo 代表上传成功 ,后期需要保存日志 | 
|---|
|  |  |  | if("i".equals(d.getCzbz())){ | 
|---|
|  |  |  | d.setCzbz("u"); | 
|---|
|  |  |  | if (Constant.CZBZ_I.equals(d.getCzbz())) { | 
|---|
|  |  |  | d.setCzbz(Constant.CZBZ_U); | 
|---|
|  |  |  | api1301Rep.save(d); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 多条数据json推送 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param items | 
|---|
|  |  |  | * @param apiRemoteService | 
|---|
|  |  |  | * @param apiConf | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String pushDataList(List<Api1301> items, ApiRemoteService apiRemoteService, ApiConfs apiConf) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //封装参数 | 
|---|
|  |  |  | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_13, Constant.API_CODE_1301); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //推送,数据为集合形式 | 
|---|
|  |  |  | ResponseDto responseDto = apiRemoteService.pushData(param, apiConf, items); | 
|---|
|  |  |  | if (responseDto.getSuccess() == 0) { | 
|---|
|  |  |  | //推送成功,更新数据上传状态 | 
|---|
|  |  |  | for (Api1301 data : items) { | 
|---|
|  |  |  | if (Constant.CZBZ_I.equals(data.getCzbz())) { | 
|---|
|  |  |  | //更新状态 | 
|---|
|  |  |  | data.setCzbz(Constant.CZBZ_U); | 
|---|
|  |  |  | api1301Rep.save(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return responseDto.toString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|