|
@@ -1,35 +1,78 @@
|
|
package com.steerinfo.dil.service.impl;
|
|
package com.steerinfo.dil.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.ctrip.framework.apollo.util.http.HttpUtil;
|
|
|
|
+import com.steerinfo.dil.feign.JoinFeign;
|
|
import com.steerinfo.dil.mapper.OmstrainOrderMapper;
|
|
import com.steerinfo.dil.mapper.OmstrainOrderMapper;
|
|
import com.steerinfo.dil.mapper.TmsttOrderMapper;
|
|
import com.steerinfo.dil.mapper.TmsttOrderMapper;
|
|
import com.steerinfo.dil.model.OmstrainOrder;
|
|
import com.steerinfo.dil.model.OmstrainOrder;
|
|
import com.steerinfo.dil.model.TmsttOrder;
|
|
import com.steerinfo.dil.model.TmsttOrder;
|
|
import com.steerinfo.dil.service.IOmstrainOrderService;
|
|
import com.steerinfo.dil.service.IOmstrainOrderService;
|
|
import com.steerinfo.dil.util.DataChange;
|
|
import com.steerinfo.dil.util.DataChange;
|
|
|
|
+import com.steerinfo.dil.util.HTTPRequestUtils;
|
|
|
|
+import com.steerinfo.dil.util.getRequestUtils;
|
|
|
|
+import org.apache.commons.lang3.AnnotationUtils;
|
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
|
+import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
|
|
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
+import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.tools.ant.taskdefs.Get;
|
|
import org.apache.tools.ant.taskdefs.Get;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
|
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.client.RestClientException;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import java.io.IOException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.sql.Wrapper;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class OmstrainOrderServiceImpl implements IOmstrainOrderService {
|
|
public class OmstrainOrderServiceImpl implements IOmstrainOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RestTemplate restTemplate;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
OmstrainOrderMapper omstrainOrderMapper;
|
|
OmstrainOrderMapper omstrainOrderMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
TmsttOrderMapper tmsttOrderMapper;
|
|
TmsttOrderMapper tmsttOrderMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ JoinFeign joinFeign;
|
|
|
|
+
|
|
|
|
+ private String guoYuanUrl="http://113.204.217.110:9810/dagang/receiving";
|
|
|
|
+ //城嘉库登录访问接口
|
|
|
|
+ private String chengJiaLoginUrl="http://122.112.226.137:8083/dagon/login";
|
|
|
|
+ //城嘉库推送数据接口
|
|
|
|
+ private String chengJiaSendUrl="http://122.112.226.137:8083/dagon/selectSaleSteelOrder";
|
|
|
|
+
|
|
|
|
+ @Bean
|
|
|
|
+ @LoadBalanced
|
|
|
|
+ private RestTemplate getRestTemplate() {
|
|
|
|
+ return new RestTemplate();
|
|
|
|
+ }
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public int generateOmstrain(Map<String, Object> map) {
|
|
|
|
|
|
+ public int generateOmstrain(Map<String, Object> map) throws IOException {
|
|
//需要做的事,
|
|
//需要做的事,
|
|
int i;
|
|
int i;
|
|
//1.生成火运订单,
|
|
//1.生成火运订单,
|
|
@@ -92,9 +135,157 @@ public class OmstrainOrderServiceImpl implements IOmstrainOrderService {
|
|
}else{
|
|
}else{
|
|
i =+ omstrainOrderMapper.insertSelective(omstrainOrder);
|
|
i =+ omstrainOrderMapper.insertSelective(omstrainOrder);
|
|
}
|
|
}
|
|
|
|
+ //调用join接口推送数据(面向异地库)
|
|
|
|
+ Map<String, Object> RemoteMap = joinFeign.selectSaleSteelOrder(map);
|
|
|
|
+ List<Map<String,Object>> data =(List<Map<String, Object>>) RemoteMap.get("data");
|
|
|
|
+ //根据汽运订单查找分属于哪个异地库。
|
|
|
|
+ String inwardWarehouse = omstrainOrderMapper.getInwardWarehouse(orderId);
|
|
|
|
+ if (inwardWarehouse!=null) {
|
|
|
|
+ if (inwardWarehouse.equals("重庆金田库")) {
|
|
|
|
+ for (Map<String,Object> jitianMap:data) {
|
|
|
|
+ Map<String, Object> orchardStorehouse = new HashMap<>();
|
|
|
|
+ List<Map<String, Object>> orchardStorehouseList = new ArrayList<>();
|
|
|
|
+ Object sendTime = jitianMap.get("sendTime");
|
|
|
|
+ String transportType = (String) jitianMap.get("transportType");
|
|
|
|
+ //发送时间
|
|
|
|
+ orchardStorehouse.put("sendTime", sendTime);
|
|
|
|
+ //系统代码
|
|
|
|
+ orchardStorehouse.put("sysCode", "DGXT");
|
|
|
|
+ //仓库代码
|
|
|
|
+ orchardStorehouse.put("warehouseCode", "LJJT");
|
|
|
|
+ //运输方式
|
|
|
|
+ orchardStorehouse.put("transportType", transportType);
|
|
|
|
+ //去掉sendTime
|
|
|
|
+ jitianMap.remove("sendTime");
|
|
|
|
+ jitianMap.remove("transportType");
|
|
|
|
+
|
|
|
|
+ orchardStorehouseList.add(jitianMap);
|
|
|
|
+ orchardStorehouse.put("details", orchardStorehouseList);
|
|
|
|
+ //调用果园库接口
|
|
|
|
+ sendMesToGuoyuan(orchardStorehouse);
|
|
|
|
+ }
|
|
|
|
+ } else if (inwardWarehouse.equals("成都城嘉库")) {
|
|
|
|
+ //调用城嘉库登录接口获取token
|
|
|
|
+ //调用城嘉库推送接口
|
|
|
|
+ String token = DagonloginChenJiaku();
|
|
|
|
+ if (token != null) {
|
|
|
|
+ for (Map<String,Object> map1:data) {
|
|
|
|
+ map1.put("token", token);
|
|
|
|
+ sendMesToChengJia(map1);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ System.out.println("登录城嘉库失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return i;
|
|
return i;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 访问城嘉库接口方法
|
|
|
|
+ * @param
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String DagonloginChenJiaku() throws IOException {
|
|
|
|
+ Map<String, String> reqMap = new HashMap<>();
|
|
|
|
+ reqMap.put("username","dagon");
|
|
|
|
+ reqMap.put("password","147258");
|
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
|
+// jsonObject.putAll(reqMap);
|
|
|
|
+// Map<String,Object> map=new HashMap<>();
|
|
|
|
+// map.put("username","dagon");
|
|
|
|
+// map.put("password","147258");
|
|
|
|
+// jsonObject.putAll(map);
|
|
|
|
+// jsonObject.put("username","dagon");
|
|
|
|
+// jsonObject.put("password","147258");
|
|
|
|
+ String jsonData = null;
|
|
|
|
+ jsonData = getRequestUtils.doPost(chengJiaLoginUrl,reqMap);
|
|
|
|
+ if(!"null".equals(jsonData)){
|
|
|
|
+ System.out.println(jsonData);
|
|
|
|
+ HashMap hashMap = JSON.parseObject(jsonData, HashMap.class);
|
|
|
|
+ BigDecimal code = DataChange.dataToBigDecimal( hashMap.get("code"));
|
|
|
|
+ System.out.println(hashMap.get("message"));
|
|
|
|
+ if(200==code.intValue()){
|
|
|
|
+ Map<String,Object> result =(Map<String,Object>) hashMap.get("result");
|
|
|
|
+ String token =(String) result.get("token");
|
|
|
|
+ return token;
|
|
|
|
+ }else {
|
|
|
|
+ System.out.println("推送数据失败"+hashMap.get("message"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// String body = restTemplate.postForEntity(chengJiaLoginUrl, reqMap, String.class).getBody();
|
|
|
|
+// System.out.println(body);
|
|
|
|
+// return body;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 推送数据给城嘉库
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 访问重庆果园库接口方法
|
|
|
|
+ * @param map
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public int sendMesToChengJia(Map<String, Object> map){
|
|
|
|
+ String token =(String) map.get("token");
|
|
|
|
+ Map<String,Object> jsonObject = new HashMap<>();
|
|
|
|
+ jsonObject.remove(token);
|
|
|
|
+ jsonObject.putAll(map);
|
|
|
|
+ String jsonData = null;
|
|
|
|
+ jsonData = getRequestUtils.doPostAddHeader(chengJiaSendUrl, jsonObject,token);
|
|
|
|
+ if(!"null".equals(jsonData)){
|
|
|
|
+ System.out.println(jsonData);
|
|
|
|
+ HashMap hashMap = JSON.parseObject(jsonData, HashMap.class);
|
|
|
|
+ BigDecimal code = DataChange.dataToBigDecimal(hashMap.get("code"));
|
|
|
|
+ System.out.println(hashMap.get("message"));
|
|
|
|
+ if(code.intValue()==200){
|
|
|
|
+ return 1;
|
|
|
|
+ }else {
|
|
|
|
+ System.out.println("推送数据失败"+hashMap.get("message"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 访问重庆果园库接口方法
|
|
|
|
+ * @param map
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public int sendMesToGuoyuan(Map<String, Object> map){
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.putAll(map);
|
|
|
|
+ String jsonData = null;
|
|
|
|
+ try {
|
|
|
|
+ jsonData = HTTPRequestUtils.send(guoYuanUrl, jsonObject, "utf-8");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ if(!"null".equals(jsonData)){
|
|
|
|
+ System.out.println(jsonData);
|
|
|
|
+ HashMap hashMap = JSON.parseObject(jsonData, HashMap.class);
|
|
|
|
+ BigDecimal code =DataChange.dataToBigDecimal(hashMap.get("code"));
|
|
|
|
+ System.out.println(hashMap.get("message"));
|
|
|
|
+ if(code.intValue()==200){
|
|
|
|
+ return 1;
|
|
|
|
+ }else {
|
|
|
|
+ System.out.println("推送数据失败"+hashMap.get("message"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<Map<String, Object>> getOrderTrainMes(Integer orderId) {
|
|
public List<Map<String, Object>> getOrderTrainMes(Integer orderId) {
|
|
List<Map<String,Object>>mapList = omstrainOrderMapper.getOrderTrainMes(orderId);
|
|
List<Map<String,Object>>mapList = omstrainOrderMapper.getOrderTrainMes(orderId);
|