|  |  |  | 
|---|
|  |  |  | import com.bstek.dorado.annotation.DataResolver; | 
|---|
|  |  |  | import com.bstek.dorado.annotation.Expose; | 
|---|
|  |  |  | import com.fzzy.api.data.ApiParam; | 
|---|
|  |  |  | 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 he | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class Api1113PR { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Api1113Rep api1113Rep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Api1113Rep api1113Rep; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiCommonService apiCommonService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiCommonService apiCommonService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiPushManager apiPushManager; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiPushManager apiPushManager; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#listAll | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<Api1113> listAll() { | 
|---|
|  |  |  | return api1113Rep.findAll(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#listAll | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataProvider | 
|---|
|  |  |  | public List<Api1113> listAll() { | 
|---|
|  |  |  | return api1113Rep.findAll(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#updateSave | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param entity | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataResolver | 
|---|
|  |  |  | public void updateSave(Api1113 entity) { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#updateSave | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param entity | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @DataResolver | 
|---|
|  |  |  | public void updateSave(Api1113 entity) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 手动将doradoEntity对象转换为标准Bean对象 | 
|---|
|  |  |  | Api1113 data = new Api1113(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  | // 手动将doradoEntity对象转换为标准Bean对象 | 
|---|
|  |  |  | Api1113 data = new Api1113(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1113Rep.save(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | api1113Rep.save(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#delData | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delData(Api1113 data) { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#delData | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delData(Api1113 data) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1113Rep.deleteById(data.getDwdm()); | 
|---|
|  |  |  | api1113Rep.deleteById(data.getDwdm()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * 更新删除标记 api1113PR#delUpdate | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param entity | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delUpdate(Api1113 entity) { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新删除标记 api1113PR#delUpdate | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param entity | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String delUpdate(Api1113 entity) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | entity.setCzbz(Constant.CZBZ_D); | 
|---|
|  |  |  | entity.setCzbz(Constant.CZBZ_D); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Api1113 data = new Api1113(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  | Api1113 data = new Api1113(); | 
|---|
|  |  |  | BeanUtils.copyProperties(entity, data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1113Rep.save(data); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | api1113Rep.save(data); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#pushData | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param items | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String pushData(List<Api1113> items) { | 
|---|
|  |  |  | ResponseDto responseDto; | 
|---|
|  |  |  | String result = ""; | 
|---|
|  |  |  | Api1113 d; | 
|---|
|  |  |  | //获取配置 | 
|---|
|  |  |  | String kqdm = items.get(0).getKqdm(); | 
|---|
|  |  |  | ApiConfs apiConf = apiCommonService.getConf(kqdm); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * api1113PR#pushData | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param items | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Expose | 
|---|
|  |  |  | public String pushData(List<Api1113> items) { | 
|---|
|  |  |  | //获取配置 | 
|---|
|  |  |  | String kqdm = items.get(0).getKqdm(); | 
|---|
|  |  |  | ApiConfs apiConf = apiCommonService.getConf(kqdm); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == apiConf) return "系统没有获取到当前库区配置信息,执行失败"; | 
|---|
|  |  |  | if (null == apiConf) return "系统没有获取到当前库区配置信息,执行失败"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //封装参数 | 
|---|
|  |  |  | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_11, Constant.API_CODE_1113); | 
|---|
|  |  |  | //获取实现接口 | 
|---|
|  |  |  | ApiRemoteService apiRemoteService = apiPushManager.getApiRemoteService(apiConf.getPushProtocol()); | 
|---|
|  |  |  | if (null == apiRemoteService) return "系统没有当前推送协议配置,执行失败"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取实现接口 | 
|---|
|  |  |  | ApiRemoteService apiRemoteService = apiPushManager.getApiRemoteService(param.getPushProtocol()); | 
|---|
|  |  |  | if (null == apiRemoteService) return "系统没有当前推送协议配置,执行失败"; | 
|---|
|  |  |  | return pushDataSingle(items, apiRemoteService, apiConf); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Api1113 data : items) { | 
|---|
|  |  |  | d = new Api1113(); | 
|---|
|  |  |  | BeanUtils.copyProperties(data, d); | 
|---|
|  |  |  | param.setBizId(data.getBizId()); | 
|---|
|  |  |  | responseDto = apiRemoteService.pushData(param, apiConf, d); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 单条数据json推送 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param items | 
|---|
|  |  |  | * @param apiRemoteService | 
|---|
|  |  |  | * @param apiConf | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String pushDataSingle(List<Api1113> items, ApiRemoteService apiRemoteService, ApiConfs apiConf) { | 
|---|
|  |  |  | ResponseDto responseDto; | 
|---|
|  |  |  | String result = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | result += responseDto.toString(); | 
|---|
|  |  |  | if (responseDto.getSuccess() == 0) { | 
|---|
|  |  |  | if (Constant.CZBZ_I.equals(d.getCzbz())) { | 
|---|
|  |  |  | api1113Rep.updateStatus(data.getKqdm(), Constant.CZBZ_U); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //封装参数 | 
|---|
|  |  |  | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_11, Constant.API_CODE_1113); | 
|---|
|  |  |  | Api1113 d; | 
|---|
|  |  |  | for (Api1113 data : items) { | 
|---|
|  |  |  | d = new Api1113(); | 
|---|
|  |  |  | BeanUtils.copyProperties(data, d); | 
|---|
|  |  |  | param.setBizId(data.getBizId()); | 
|---|
|  |  |  | responseDto = apiRemoteService.pushData(param, apiConf, d); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | result += responseDto.toString(); | 
|---|
|  |  |  | if (responseDto.getSuccess() == 0) { | 
|---|
|  |  |  | if (Constant.CZBZ_I.equals(d.getCzbz())) { | 
|---|
|  |  |  | api1113Rep.updateStatus(data.getKqdm(), Constant.CZBZ_U); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 多条数据json推送 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param items | 
|---|
|  |  |  | * @param apiRemoteService | 
|---|
|  |  |  | * @param apiConf | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String pushDataList(List<Api1113> items, ApiRemoteService apiRemoteService, ApiConfs apiConf) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //封装参数 | 
|---|
|  |  |  | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_11, Constant.API_CODE_1113); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //推送,数据为集合形式 | 
|---|
|  |  |  | ResponseDto responseDto = apiRemoteService.pushData(param, apiConf, items); | 
|---|
|  |  |  | if (responseDto.getSuccess() == 0) { | 
|---|
|  |  |  | //推送成功,更新数据上传状态 | 
|---|
|  |  |  | for (Api1113 data : items) { | 
|---|
|  |  |  | if (Constant.CZBZ_I.equals(data.getCzbz())) { | 
|---|
|  |  |  | //更新状态 | 
|---|
|  |  |  | api1113Rep.updateStatus(data.getKqdm(), Constant.CZBZ_U); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return responseDto.toString(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|