| | |
| | | package com.fzzy.whjl.view.pr; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | | import com.fzzy.api.entity.ApiConfs; |
| | | import com.fzzy.api.entity.ApiInfoData; |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiPushManager; |
| | | import com.fzzy.api.service.ApiRemoteService; |
| | | import com.fzzy.api.view.repository.ApiInfoDataRep; |
| | | import com.fzzy.whjl.WhjlConstant; |
| | | import com.fzzy.whjl.dto.WhjlApi1111; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private ApiCommonService apiCommonService; |
| | | @Autowired |
| | | private ApiPushManager apiPushManager; |
| | | @Autowired |
| | | private ApiInfoDataRep apiInfoDataRep; |
| | | |
| | | /** |
| | | * 获取列表信息 |
| | |
| | | */ |
| | | @DataProvider |
| | | public List<WhjlApi1111> listData() { |
| | | List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_1111); |
| | | if (null == result || result.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<WhjlApi1111> list = new ArrayList<>(); |
| | | WhjlApi1111 whjlApi1111; |
| | | for (ApiInfoData infoData : result) { |
| | | whjlApi1111 = JSONObject.parseObject(infoData.getData(), WhjlApi1111.class); |
| | | whjlApi1111.setKqdm(infoData.getKqdm()); |
| | | whjlApi1111.setCzbz(infoData.getCzbz()); |
| | | whjlApi1111.setUpdateTime(infoData.getUpdateTime()); |
| | | whjlApi1111.setBizId(infoData.getDataId()); |
| | | list.add(whjlApi1111); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @DataResolver |
| | | public String saveData(WhjlApi1111 data) { |
| | | return null; |
| | | public void saveData(WhjlApi1111 data) { |
| | | ApiInfoData infoData = new ApiInfoData(); |
| | | infoData.setId(data.getBizId()); |
| | | infoData.setKqdm(data.getKqdm()); |
| | | infoData.setInteType(WhjlConstant.API_CATEGORY_11); |
| | | infoData.setInteId(WhjlConstant.API_CODE_1111); |
| | | infoData.setUpdateTime(new Date()); |
| | | infoData.setDataId(data.getBizId()); |
| | | infoData.setData(JSON.toJSONString(data)); |
| | | infoData.setCzbz(data.getCzbz()); |
| | | infoData.setRemarks("备注信息"); |
| | | |
| | | apiInfoDataRep.save(infoData); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Expose |
| | | public String delData(WhjlApi1111 data) { |
| | | apiInfoDataRep.deleteById(data.getBizId()); |
| | | return null; |
| | | } |
| | | |
| | |
| | | responseDto = apiService.pushData(param, apiConf, items); |
| | | if (responseDto.getSuccess() == 0) { |
| | | //推送成功,更新数据上传状态 |
| | | WhjlApi1111 d; |
| | | ApiInfoData infoData; |
| | | for (WhjlApi1111 data : items) { |
| | | d = new WhjlApi1111(); |
| | | BeanUtils.copyProperties(data, d); |
| | | if ("i".equals(d.getCzbz())) { |
| | | d.setCzbz("u"); |
| | | //TODO 更新状态,待实现 |
| | | if (Constant.CZBZ_I.equals(data.getCzbz())) { |
| | | |
| | | infoData = new ApiInfoData(); |
| | | infoData.setId(data.getBizId()); |
| | | infoData.setKqdm(data.getKqdm()); |
| | | infoData.setInteType(WhjlConstant.API_CATEGORY_11); |
| | | infoData.setInteId(WhjlConstant.API_CODE_1111); |
| | | infoData.setUpdateTime(new Date()); |
| | | infoData.setDataId(data.getBizId()); |
| | | |
| | | data.setCzbz(Constant.CZBZ_U); |
| | | infoData.setCzbz(Constant.CZBZ_U); |
| | | infoData.setData(JSON.toJSONString(data)); |
| | | |
| | | apiInfoDataRep.save(infoData); |
| | | } |
| | | } |
| | | result += responseDto.toString(); |