| | |
| | | package com.chinaztt.mes.basic.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import com.chinaztt.mes.basic.service.PartService; |
| | | import com.chinaztt.mes.basic.util.DictUtils; |
| | | import com.chinaztt.mes.basic.util.PartUtils; |
| | | import com.chinaztt.mes.basic.util.RedisUtils; |
| | | import com.chinaztt.mes.common.util.JsonUtil; |
| | | import com.chinaztt.ztt.common.core.util.R; |
| | | import com.chinaztt.ztt.common.security.util.SecurityUtils; |
| | | import com.google.gson.Gson; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.entity.ContentType; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private IfsFeignClient ifsFeignClient; |
| | | private DiscoveryClient discoveryClient; |
| | | private Environment environment; |
| | | private RedisTemplate redisTemplate;; |
| | | private RedisTemplate redisTemplate; |
| | | ; |
| | | |
| | | @Override |
| | | public void importPartExcel(List<PartData> list) { |
| | |
| | | if (redisTemplate.hasKey(key)) { |
| | | throw new RuntimeException("有同步任务正在处理"); |
| | | } |
| | | redisTemplate.opsForValue().set(key,1,1000 * 3600); |
| | | redisTemplate.opsForValue().set(key, 1, 1000 * 3600); |
| | | CloseableHttpClient httpClient = HttpClientBuilder.create().build(); |
| | | String syncErpUrl = environment.getProperty("erpPartUrl"); |
| | | HttpPost httpPost = new HttpPost(syncErpUrl); |
| | | httpPost.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 10000); |
| | | httpPost.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,1000 * 3600); |
| | | httpPost.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 1000 * 3600); |
| | | // 将参数转换为JSON字符串 |
| | | Map<String, String> params = new HashMap<>(); |
| | | // params.put("startTime", customOrderSyncDTO.getStartTime()); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void syncNewIfs(Date date) { |
| | | String key = "syncPart_lock" + SecurityUtils.getUser().getId(); |
| | | if (redisTemplate.hasKey(key)) { |
| | | throw new RuntimeException("有同步任务正在处理"); |
| | | } |
| | | redisTemplate.opsForValue().set(key, 1, 1000 * 3600); |
| | | Map<String, Object>map=new HashMap<>(); |
| | | map.put("MODIFY_DATE", DateUtil.format(date,"yyyy-MM-dd")); |
| | | System.out.println(map); |
| | | String url = "http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_PART_INFO_STD&userId=7632&inAttr={'MODIFY_DATE':"+JsonUtil.jsonToString(map)+"}"; |
| | | try { |
| | | String body = HttpRequest.get(url).execute().body(); |
| | | Map<String, Object> mapResult = JsonUtil.jsonToPojo(body, Map.class); |
| | | System.out.println( |
| | | "执行========》"+mapResult); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } finally { |
| | | redisTemplate.delete(key); |
| | | } |
| | | } |
| | | |
| | | } |