| | |
| | | package com.aps.job.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.core.utils.StringUtils; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.job.mapper.ApsWorkOrderJobMapper; |
| | | import com.aps.job.domain.ApsWorkOrderJob; |
| | | import com.aps.job.service.IApsWorkOrderJobService; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | /** |
| | | * 工单同步Service业务层处理 |
| | |
| | | { |
| | | @Autowired |
| | | private ApsWorkOrderJobMapper apsWorkOrderJobMapper; |
| | | |
| | | /** |
| | | * 获取订单接口 |
| | | * */ |
| | | @Value("${u9.workOrderJobUrl}") |
| | | private String getWorkOrderUrl; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | |
| | | /** |
| | | * 查询工单同步 |
| | |
| | | { |
| | | return apsWorkOrderJobMapper.deleteApsWorkOrderJobById(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void batchInsertApsWorkOrderJob() { |
| | | |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | Integer PageIndex=1; |
| | | Integer PageSize=10; |
| | | Boolean continueFlag=true; |
| | | /* while (continueFlag){*/ |
| | | JSONObject requestBody = new JSONObject(); |
| | | requestBody.put("PageIndex", PageIndex); |
| | | requestBody.put("PageSize", PageSize); |
| | | HttpEntity<String> request = new HttpEntity<>(requestBody.toJSONString(), headers); |
| | | ResponseEntity<String> response = restTemplate.postForEntity(getWorkOrderUrl, request, String.class); |
| | | if (response.getStatusCode().is2xxSuccessful()) { |
| | | String responseBody = response.getBody(); |
| | | if(StringUtils.isNotEmpty(responseBody)){ |
| | | JSONObject responseBodyJson = JSONObject.parseObject(responseBody); |
| | | if("200".equals(responseBodyJson.getString("status"))){ |
| | | JSONArray result = responseBodyJson.getJSONArray("data"); |
| | | List<ApsWorkOrderJob> jobs = new ArrayList<>(); |
| | | if (result!=null){ |
| | | for (int i = 0; i < result.size(); i++) { |
| | | ApsWorkOrderJob order = result.getObject(i, ApsWorkOrderJob.class); |
| | | jobs.add(order); |
| | | } |
| | | } |
| | | apsWorkOrderJobMapper.batchInsertApsWorkOrderJob(jobs); |
| | | } |
| | | } |
| | | } |
| | | /* }*/ |
| | | } |
| | | } |