|
@@ -18,6 +18,7 @@ import org.jeecg.modules.openApi.entity.DxpDataPlan;
|
|
|
import org.jeecg.modules.openApi.service.IDxpDataPlanService;
|
|
|
import org.jeecg.modules.system.util.HttpHelper;
|
|
|
import org.jeecg.modules.system.util.InterfaceConnUtils;
|
|
|
+import org.jeecg.modules.system.util.oConvertUtils;
|
|
|
import org.quartz.Job;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.quartz.JobExecutionException;
|
|
@@ -26,7 +27,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
|
@Slf4j
|
|
@@ -43,17 +46,68 @@ public class PushShippingDetailsJob implements Job {
|
|
|
private String srmAccessToken;
|
|
|
|
|
|
|
|
|
+ boolean isRunning = false;
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
|
|
+ if (isRunning){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ isRunning = true;
|
|
|
+ try {
|
|
|
+ //查询IP及账套信息、时间戳
|
|
|
+ QueryWrapper<DxpDataPlan> dxpDataPlanQueryWrapper = new QueryWrapper<>();
|
|
|
+ dxpDataPlanQueryWrapper.eq("code", "senYu_Srm_Yfh");
|
|
|
+ List<DxpDataPlan> dxpDataPlans = iDxpDataPlanService.list(dxpDataPlanQueryWrapper);
|
|
|
+
|
|
|
+ List<String> shippingDetailIdList = syShippingDetailsService.getPushSrmIds();
|
|
|
+ shippingDetailIdList = shippingDetailIdList.stream().distinct().collect(Collectors.toList());
|
|
|
+ for (String id : shippingDetailIdList){
|
|
|
+ List<PurchasePreDeliverVo> purchasePreDeliverVoList=syShippingDetailsService.getPurchasePreDeliverVoList(id);
|
|
|
+ if (purchasePreDeliverVoList.size()>0){
|
|
|
+ ReqPurchasePreDeliverVo reqPurchasePreDeliverVo = new ReqPurchasePreDeliverVo();
|
|
|
+ reqPurchasePreDeliverVo.setVerifyToken(srmAccessToken);
|
|
|
+ reqPurchasePreDeliverVo.setBillList(purchasePreDeliverVoList);
|
|
|
+ String reqString = JSONObject.toJSONString(reqPurchasePreDeliverVo);
|
|
|
+ log.info("查看请求信息\t"+reqString);
|
|
|
+ //获取url
|
|
|
+ String url = dxpDataPlans.get(0).getItemIp();
|
|
|
+ //处理返回信息
|
|
|
+ String respStr = HttpHelper.httpJsonPost(url, reqString, null);
|
|
|
+ log.info("查看返回信息\t"+respStr);
|
|
|
+ JSONObject informationJson = JSONObject.parseObject(respStr);
|
|
|
+ JSONArray jsonArray=informationJson.getJSONArray("result");
|
|
|
+ log.info("jsonArray\t"+jsonArray);
|
|
|
+ for (int i=0;i<jsonArray.size();i++){
|
|
|
+ JSONObject jsonObject=jsonArray.getJSONObject(i);
|
|
|
+ String syShippingId=jsonObject.getString("syShippingId");
|
|
|
+ boolean success=jsonObject.getBoolean("success");
|
|
|
+ String message= oConvertUtils.getString(jsonObject.getString("message"));
|
|
|
+ String status = success?"1":"2";
|
|
|
+ syShippingDetailsService.setPurshInfo(
|
|
|
+ Arrays.asList(syShippingId.split(",")),
|
|
|
+ status, message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (Exception ex){
|
|
|
+ log.error("推送失败:{}", ex);
|
|
|
+ }finally {
|
|
|
+ isRunning = false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
//查询IP及账套信息、时间戳
|
|
|
- QueryWrapper<DxpDataPlan> dxpDataPlanQueryWrapper = new QueryWrapper<>();
|
|
|
- dxpDataPlanQueryWrapper.eq("code", "senYu_Srm_Yfh");
|
|
|
- List<DxpDataPlan> dxpDataPlans = iDxpDataPlanService.list(dxpDataPlanQueryWrapper);
|
|
|
+ QueryWrapper<DxpDataPlan> dxpDataPlanQueryWrapper = new QueryWrapper<>();
|
|
|
+ dxpDataPlanQueryWrapper.eq("code", "senYu_Srm_Yfh");
|
|
|
+ List<DxpDataPlan> dxpDataPlans = iDxpDataPlanService.list(dxpDataPlanQueryWrapper);
|
|
|
|
|
|
//获取10条符合条件的数据
|
|
|
LambdaQueryWrapper<SyShippingDetails> detailsLambdaQueryWrapper=new LambdaQueryWrapper();
|
|
|
- detailsLambdaQueryWrapper.eq(SyShippingDetails::getState, "1");//提交状态=1
|
|
|
- detailsLambdaQueryWrapper.eq(SyShippingDetails::getPushState, "0");//推送srm状态=0
|
|
|
+ //detailsLambdaQueryWrapper.eq(SyShippingDetails::getState, "1");//提交状态=1
|
|
|
+ // 提交状态在子表
|
|
|
+ detailsLambdaQueryWrapper.eq(SyShippingDetails::getPushSrmState, "0");//推送srm状态=0
|
|
|
detailsLambdaQueryWrapper.eq(SyShippingDetails::getDelFlag, "0");//删除状态=0
|
|
|
detailsLambdaQueryWrapper.last("limit 10");//一次最多同步10条数据
|
|
|
List<SyShippingDetails> list=syShippingDetailsService.list(detailsLambdaQueryWrapper);
|
|
@@ -95,39 +149,6 @@ public class PushShippingDetailsJob implements Job {
|
|
|
syShippingDetailsService.updateBatchById(list1);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
- }
|
|
|
- //转JSON
|
|
|
-// Gson userGson = new GsonBuilder().create();
|
|
|
-// result.put("payload", userGson.toJson(JSONObject.toJSON(purchasePreDeliverVos)));
|
|
|
-// System.out.println("查看推送信息\t"+result);
|
|
|
-// //获取url
|
|
|
-// String url = dxpDataPlans.get(0).getItemIp();
|
|
|
-// //调用doPost
|
|
|
-// InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
|
|
|
-// List<SyShippingDetails> list1=new ArrayList<>();
|
|
|
-// try {
|
|
|
-// //处理返回信息
|
|
|
-// JSONObject informationJson = interfaceConnUtils.doPostToBasicAuth(result, url);
|
|
|
-// System.out.println("查看返回信息\t"+informationJson);
|
|
|
-// JSONArray jsonArray=informationJson.getJSONArray("result");
|
|
|
-// System.out.println("jsonArray\t"+jsonArray);
|
|
|
-// for (int i=0;i<jsonArray.size();i++){
|
|
|
-// JSONObject jsonObject=jsonArray.getJSONObject(i);
|
|
|
-// SyShippingDetails syShippingDetails=new SyShippingDetails();
|
|
|
-// String syShippingId=jsonObject.getString("syShippingId");
|
|
|
-// boolean success=jsonObject.getBoolean("success");
|
|
|
-// String message=jsonObject.getString("message");
|
|
|
-// syShippingDetails.setPushSrmState("2");
|
|
|
-// if (success){
|
|
|
-// syShippingDetails.setPushSrmState("1");
|
|
|
-// }
|
|
|
-// syShippingDetails.setPushSrmMessage(message);
|
|
|
-// syShippingDetails.setId(syShippingId);
|
|
|
-// list1.add(syShippingDetails);
|
|
|
-// }
|
|
|
-// syShippingDetailsService.updateBatchById(list1);
|
|
|
-// }catch (Exception e){
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|