| | |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiPushManager; |
| | | import com.fzzy.api.service.ApiRemoteService; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.view.repository.ApiInfoDataRep; |
| | | import com.fzzy.otherview.whhpjl.WhjlConstant; |
| | | import com.fzzy.otherview.whhpjl.dto.WhjlApi1111; |
| | | import com.fzzy.push.gd2022.ApiCodeConstant; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | | import javax.persistence.criteria.CriteriaQuery; |
| | | import javax.persistence.criteria.Predicate; |
| | | import javax.persistence.criteria.Root; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 仓储设备信息 |
| | | * |
| | | * @Author:YAN |
| | | */ |
| | | * @Author: YYC |
| | | * @Description:仓储设备报废记录 |
| | | * @DateTime: 2023-10-25 14:13 |
| | | **/ |
| | | @Component |
| | | public class WhjlApi1111PR { |
| | | |
| | | |
| | | @Autowired |
| | | private ApiCommonService apiCommonService; |
| | |
| | | |
| | | /** |
| | | * 获取列表信息 |
| | | * whjlApi1111PR#listData |
| | | * WhjlApi1111PR#listData |
| | | * |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<WhjlApi1111> listData() { |
| | | List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_1111); |
| | | if (null == result || result.isEmpty()) { |
| | | return null; |
| | | } |
| | | public void listData(Page<WhjlApi1111> page, ApiParam param) { |
| | | |
| | | Pageable pageable = PageRequest.of(page.getPageNo() - 1, page.getPageSize(), Sort.Direction.DESC, "updateTime"); |
| | | |
| | | Specification specification = new Specification<ApiInfoData>() { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Override |
| | | public Predicate toPredicate(Root<ApiInfoData> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { |
| | | List<Predicate> predicates = new ArrayList<>(); //所有的断言 |
| | | Predicate predicate = criteriaBuilder.equal(root.get("inteId"), WhjlConstant.API_CODE_1111); |
| | | predicates.add(predicate); |
| | | if (null != param) { |
| | | if (StringUtils.isNotBlank(param.getKqdm())) { |
| | | Predicate predicate1 = criteriaBuilder.equal(root.get("kqdm"), param.getKqdm()); |
| | | predicates.add(predicate1); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(param.getCzbz())) { |
| | | Predicate predicate2 = criteriaBuilder.equal(root.get("czbz"), param.getCzbz()); |
| | | predicates.add(predicate2); |
| | | } |
| | | if (null != param.getStart()) { |
| | | Predicate predicate3 = criteriaBuilder.greaterThan(root.get("updateTime"), ContextUtil.getCurZero(param.getStart())); |
| | | predicates.add(predicate3); |
| | | } |
| | | |
| | | if (null != param.getEnd()) { |
| | | Predicate predicate4 = criteriaBuilder.lessThan(root.get("updateTime"), ContextUtil.getNextZero(param.getEnd())); |
| | | predicates.add(predicate4); |
| | | } |
| | | } |
| | | return criteriaBuilder.and(predicates.toArray(new Predicate[0])); |
| | | } |
| | | }; |
| | | org.springframework.data.domain.Page<ApiInfoData> japPage = apiInfoDataRep.findAll(specification, pageable); |
| | | page.setEntityCount((int) japPage.getTotalElements()); |
| | | List<WhjlApi1111> list = new ArrayList<>(); |
| | | WhjlApi1111 whjlApi1111; |
| | | for (ApiInfoData infoData : result) { |
| | | for (ApiInfoData infoData : japPage.getContent()) { |
| | | whjlApi1111 = JSONObject.parseObject(infoData.getData(), WhjlApi1111.class); |
| | | whjlApi1111.setKqdm(infoData.getKqdm()); |
| | | whjlApi1111.setCzbz(infoData.getCzbz()); |
| | |
| | | whjlApi1111.setBizId(infoData.getDataId()); |
| | | list.add(whjlApi1111); |
| | | } |
| | | return list; |
| | | page.setEntities(list); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 更新或修改 |
| | | * whjlApi1111PR#saveData |
| | | * WhjlApi1111PR#saveData |
| | | * |
| | | * @param data |
| | | * @return |
| | |
| | | ApiInfoData infoData = new ApiInfoData(); |
| | | infoData.setId(data.getBizId()); |
| | | infoData.setKqdm(data.getKqdm()); |
| | | infoData.setInteType(WhjlConstant.API_CATEGORY_11); |
| | | infoData.setInteType(WhjlConstant.API_CATEGORY_12); |
| | | infoData.setInteId(WhjlConstant.API_CODE_1111); |
| | | infoData.setUpdateTime(new Date()); |
| | | infoData.setDataId(data.getBizId()); |
| | |
| | | |
| | | /** |
| | | * 删除 |
| | | * whjlApi1111PR#delData |
| | | * WhjlApi1111PR#delData |
| | | * |
| | | * @param data |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 上传 |
| | | * whjlApi1111PR#pushData |
| | | * WhjlApi1111PR#pushData |
| | | * |
| | | * @param items |
| | | * @return |
| | |
| | | } |
| | | |
| | | //封装参数 |
| | | ApiParam param = new ApiParam(apiConf, WhjlConstant.API_CATEGORY_11, WhjlConstant.API_CODE_1111); |
| | | ApiParam param = new ApiParam(apiConf, WhjlConstant.API_CATEGORY_12, WhjlConstant.API_CODE_1111); |
| | | |
| | | //获取实现接口 |
| | | ApiRemoteService apiService = apiPushManager.getApiRemoteService(param.getPushProtocol()); |
| | |
| | | return "系统没有当前推送协议配置,执行失败"; |
| | | } |
| | | |
| | | ApiInfoData infoData; |
| | | ResponseDto responseDto; |
| | | ApiInfoData infoData; |
| | | for (WhjlApi1111 data : items) { |
| | | responseDto = apiService.pushData(param, apiConf, data); |
| | | if (responseDto.getSuccess() == 0) { |
| | | 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.setInteType(WhjlConstant.API_CATEGORY_12); |
| | | 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); |
| | | } |
| | | } |