| | |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.data.PushProtocol; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | | import com.fzzy.api.entity.Api1101; |
| | | import com.fzzy.api.entity.ApiConfs; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 单位信息 |
| | | * |
| | | * @author he |
| | | * @author czt |
| | | */ |
| | | @Component |
| | | public class Api1101PR { |
| | |
| | | */ |
| | | @Expose |
| | | public String pushData(List<Api1101> items) { |
| | | ResponseDto responseDto; |
| | | String result = ""; |
| | | |
| | | //获取配置 |
| | | String kqdm = items.get(0).getKqdm(); |
| | | ApiConfs apiConf = apiCommonService.getConf(kqdm); |
| | | |
| | | if (null == apiConf) return "系统没有获取到当前库区配置信息,执行失败"; |
| | | if (null == apiConf) { |
| | | return "系统没有获取到当前库区配置信息,执行失败"; |
| | | } |
| | | |
| | | //获取实现接口 |
| | | ApiRemoteService apiRemoteService = apiPushManager.getApiRemoteService(apiConf.getPushProtocol()); |
| | | if (null == apiRemoteService) { |
| | | return "系统没有当前推送协议配置,执行失败"; |
| | | } |
| | | |
| | | //根据省份协议,判断是集合形式上报还是单条json上报 |
| | | if(PushProtocol.SB_SH_2023.getCode().equals(apiConf.getPushProtocol())){ |
| | | return pushDataList(items, apiRemoteService, apiConf); |
| | | } |
| | | |
| | | return pushDataSingle(items, apiRemoteService, apiConf); |
| | | } |
| | | |
| | | /** |
| | | * 单条数据json推送 |
| | | * @param items |
| | | * @param apiRemoteService |
| | | * @param apiConf |
| | | * @return |
| | | */ |
| | | private String pushDataSingle(List<Api1101> items, ApiRemoteService apiRemoteService, ApiConfs apiConf) { |
| | | ResponseDto responseDto; |
| | | String result = ""; |
| | | |
| | | //封装参数 |
| | | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_11, Constant.API_CODE_1101); |
| | | |
| | | //获取实现接口 |
| | | ApiRemoteService apiRemoteService = apiPushManager.getApiRemoteService(param.getPushProtocol()); |
| | | if (null == apiRemoteService) return "系统没有当前推送协议配置,执行失败"; |
| | | |
| | | Api1101 d; |
| | | for (ApiParent data : items) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 集合形式推送 |
| | | * @param items |
| | | * @param apiRemoteService |
| | | * @param apiConf |
| | | * @return |
| | | */ |
| | | private String pushDataList(List<Api1101> items, ApiRemoteService apiRemoteService, ApiConfs apiConf) { |
| | | |
| | | //封装参数 |
| | | ApiParam param = new ApiParam(apiConf, Constant.API_CATEGORY_11, Constant.API_CODE_1101); |
| | | |
| | | |
| | | //推送,数据为集合形式 |
| | | ResponseDto responseDto = apiRemoteService.pushData(param, apiConf, items); |
| | | if (responseDto.getSuccess() == 0) { |
| | | //推送成功,更新数据上传状态 |
| | | for (Api1101 data : items) { |
| | | if (Constant.CZBZ_I.equals(data.getCzbz())) { |
| | | //更新状态 |
| | | api1101Rep.updateStatus(data.getKqdm(), Constant.CZBZ_U); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return responseDto.toString(); |
| | | } |
| | | |
| | | } |