|
@@ -9,11 +9,24 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDeposit;
|
|
|
+import org.jeecg.modules.documents.letterDeposit.entity.SyLetterDepositItem;
|
|
|
+import org.jeecg.modules.documents.letterDeposit.entity.VO.ReqLetterDepositItemVO;
|
|
|
+import org.jeecg.modules.documents.letterDeposit.entity.VO.ReqLetterDepositVO;
|
|
|
+import org.jeecg.modules.documents.letterDeposit.service.ISyLetterDepositItemService;
|
|
|
+import org.jeecg.modules.documents.letterDeposit.service.ISyLetterDepositService;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverVo;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.VO.ReqPurchasePreDeliverVo;
|
|
|
+import org.jeecg.modules.documents.shippingDetails.entity.VO.RespUpdateVO;
|
|
|
import org.jeecg.modules.documents.shippingDetails.service.ISyShippingDetailsService;
|
|
|
+import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrder;
|
|
|
+import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrderItem;
|
|
|
+import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqShippingOrderItemVO;
|
|
|
+import org.jeecg.modules.documents.syShippingOrder.entity.VO.ReqShippingOrderVO;
|
|
|
+import org.jeecg.modules.documents.syShippingOrder.service.ISyShippingOrderItemService;
|
|
|
+import org.jeecg.modules.documents.syShippingOrder.service.ISyShippingOrderService;
|
|
|
import org.jeecg.modules.openApi.entity.DxpDataPlan;
|
|
|
import org.jeecg.modules.openApi.service.IDxpDataPlanService;
|
|
|
import org.jeecg.modules.system.util.HttpHelper;
|
|
@@ -31,6 +44,9 @@ import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+/**
|
|
|
+ * 推送SRM出运明细,预托书,托书
|
|
|
+ */
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
public class PushShippingDetailsJob implements Job {
|
|
@@ -41,6 +57,15 @@ public class PushShippingDetailsJob implements Job {
|
|
|
@Autowired
|
|
|
private IDxpDataPlanService iDxpDataPlanService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISyLetterDepositItemService syLetterDepositItemService;
|
|
|
+ @Autowired
|
|
|
+ private ISyLetterDepositService syLetterDepositService;
|
|
|
+ @Autowired
|
|
|
+ private ISyShippingOrderItemService syShippingOrderItemService;
|
|
|
+ @Autowired
|
|
|
+ private ISyShippingOrderService syShippingOrderService;
|
|
|
+
|
|
|
// srm调用校验码
|
|
|
@Value("${srm.access-token}")
|
|
|
private String srmAccessToken;
|
|
@@ -54,38 +79,111 @@ public class PushShippingDetailsJob implements Job {
|
|
|
}
|
|
|
isRunning = true;
|
|
|
try {
|
|
|
- //查询IP及账套信息、时间戳
|
|
|
+ //推送出运明细到srm预发货单
|
|
|
QueryWrapper<DxpDataPlan> dxpDataPlanQueryWrapper = new QueryWrapper<>();
|
|
|
dxpDataPlanQueryWrapper.eq("code", "senYu_Srm_Yfh");
|
|
|
- List<DxpDataPlan> dxpDataPlans = iDxpDataPlanService.list(dxpDataPlanQueryWrapper);
|
|
|
+ DxpDataPlan dxpDataPlan = iDxpDataPlanService.getOne(dxpDataPlanQueryWrapper);
|
|
|
+ if (dxpDataPlan == null){
|
|
|
+ log.warn("推送出运明细到SRM dxp_data_plan未定义" );
|
|
|
+ }else {
|
|
|
+ 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 = dxpDataPlan.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("extraInfo");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- 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("extraInfo");
|
|
|
- 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 推送预托书到srm发货单字段
|
|
|
+ dxpDataPlanQueryWrapper = new QueryWrapper<>();
|
|
|
+ dxpDataPlanQueryWrapper.eq("code", "senYu_Srm_Yts");
|
|
|
+ dxpDataPlan = iDxpDataPlanService.getOne(dxpDataPlanQueryWrapper);
|
|
|
+ if (dxpDataPlan == null){
|
|
|
+ log.warn("推送预托书 dxp_data_plan未定义" );
|
|
|
+ }else {
|
|
|
+ LambdaQueryWrapper<SyLetterDepositItem> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SyLetterDepositItem::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(SyLetterDepositItem::getPushSrmState, "0");
|
|
|
+ List<SyLetterDepositItem> letterDepositItemList = syLetterDepositItemService.list(queryWrapper);
|
|
|
+ if (letterDepositItemList.size()>0){
|
|
|
+ LambdaQueryWrapper<SyLetterDeposit> mQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ mQueryWrapper.in(SyLetterDeposit::getId, letterDepositItemList.stream().map(SyLetterDepositItem::getSyLetterDepositId).distinct().collect(Collectors.toList()));
|
|
|
+ List<SyLetterDeposit> letterDepositList = syLetterDepositService.list(mQueryWrapper);
|
|
|
+ List<ReqLetterDepositItemVO> reqVoList = new ArrayList<>();
|
|
|
+ for (SyLetterDepositItem item : letterDepositItemList){
|
|
|
+ SyLetterDeposit findDetail = letterDepositList.stream().filter(x -> x.getId().equals(item.getSyLetterDepositId())).findFirst().orElse(null);
|
|
|
+ if (findDetail != null){
|
|
|
+ ReqLetterDepositItemVO reqVo = new ReqLetterDepositItemVO();
|
|
|
+ reqVo.fromLetterDeposit(item, findDetail);
|
|
|
+ reqVoList.add(reqVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (reqVoList.size()>0){
|
|
|
+ ReqLetterDepositVO reqVo = new ReqLetterDepositVO();
|
|
|
+ reqVo.setVerifyToken(srmAccessToken);
|
|
|
+ reqVo.setItemList(reqVoList);
|
|
|
+ List<RespUpdateVO> respUpdateVOList = JSONArray.parseArray(HttpHelper.httpJsonPost(dxpDataPlan.getItemIp(), JSONObject.toJSONString(reqVo), null),
|
|
|
+ RespUpdateVO.class);
|
|
|
+ syLetterDepositItemService.updateSrmPushState(respUpdateVOList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 推送托书到srm发货单字段
|
|
|
+ dxpDataPlanQueryWrapper = new QueryWrapper<>();
|
|
|
+ dxpDataPlanQueryWrapper.eq("code", "senYu_Srm_Ts");
|
|
|
+ dxpDataPlan = iDxpDataPlanService.getOne(dxpDataPlanQueryWrapper);
|
|
|
+ if (dxpDataPlan == null){
|
|
|
+ log.warn("推送托书 dxp_data_plan未定义" );
|
|
|
+ }else {
|
|
|
+ LambdaQueryWrapper<SyShippingOrderItem> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SyShippingOrderItem::getDelFlag, "0");
|
|
|
+ queryWrapper.eq(SyShippingOrderItem::getPushSrmState, "0");
|
|
|
+ List<SyShippingOrderItem> itemList = syShippingOrderItemService.list(queryWrapper);
|
|
|
+ if (itemList.size()>0){
|
|
|
+ LambdaQueryWrapper<SyShippingOrder> mQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ mQueryWrapper.in(SyShippingOrder::getId, itemList.stream().map(SyShippingOrderItem::getSyShippingOrderItemId).distinct().collect(Collectors.toList()));
|
|
|
+ List<SyShippingOrder> orderList = syShippingOrderService.list(mQueryWrapper);
|
|
|
+ List<ReqShippingOrderItemVO> reqVoList = new ArrayList<>();
|
|
|
+ for (SyShippingOrderItem item : itemList){
|
|
|
+ SyShippingOrder findOrder = orderList.stream().filter(x -> x.getId().equals(item.getSyShippingOrderItemId())).findFirst().orElse(null);
|
|
|
+ if (findOrder != null){
|
|
|
+ ReqShippingOrderItemVO reqVo = new ReqShippingOrderItemVO();
|
|
|
+ reqVo.fromShippingOrder(item, findOrder);
|
|
|
+ reqVoList.add(reqVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (reqVoList.size()>0){
|
|
|
+ ReqShippingOrderVO reqVo = new ReqShippingOrderVO();
|
|
|
+ reqVo.setVerifyToken(srmAccessToken);
|
|
|
+ reqVo.setItemList(reqVoList);
|
|
|
+ List<RespUpdateVO> respUpdateVOList = JSONArray.parseArray(HttpHelper.httpJsonPost(dxpDataPlan.getItemIp(), JSONObject.toJSONString(reqVo), null),
|
|
|
+ RespUpdateVO.class);
|
|
|
+ syShippingOrderItemService.updateSrmPushState(respUpdateVOList);
|
|
|
}
|
|
|
}
|
|
|
|