Browse Source

出运明细推送srm发货单增加回写消息和状态

huxy 2 weeks ago
parent
commit
df5426ec51

+ 24 - 23
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/controller/SyShippingDetailsController.java

@@ -15,7 +15,9 @@ import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.write.metadata.WriteSheet;
 import com.alibaba.excel.write.metadata.fill.FillConfig;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 //import org.apache.shiro.SecurityUtils;
@@ -954,7 +956,6 @@ public class SyShippingDetailsController extends JeecgController<SyShippingDetai
 	  Result<SyShippingDetails> result = new Result<>();
 	  int count = 1;
 	  try {
-
 		  if(syShippingDetails.getSubmitListId().size()==0){
 			  result.setMessage("未拿到ID");
 			  result.setSuccess(false);
@@ -970,9 +971,9 @@ public class SyShippingDetailsController extends JeecgController<SyShippingDetai
 		  }
 
 			  if(syShippingDetails.getType().equals("1")) {
+			  	  syShippingDetailsService.getStrings(idsList);
 
 				  Set<String> seenData = new HashSet<>();
-
 				  //查询未提交数据
 				  QueryWrapper<SyShippingDetailsItem> itemQueryWrapper = new QueryWrapper<>();
 				  itemQueryWrapper.in("group_id",idsList).eq("submit_status","0").eq("del_flag","0");
@@ -1297,31 +1298,31 @@ public class SyShippingDetailsController extends JeecgController<SyShippingDetai
 
 			 List<String> arrIds=Arrays.asList(ids);
 			 //查询明细
-			 PurchasePreDeliverVo purchasePreDeliverVo =  syShippingDetailsService.getPurchasePreDeliverVo(arrIds);
-			 List<PurchasePreDeliverDetailVo> purchasePreDeliverDetailVos =  syShippingDetailsService.getPurchasePreDeliverDetailVo(arrIds);
-			 purchasePreDeliverVo.setPurchasePreDeliverDetailList(purchasePreDeliverDetailVos);
-			 list.add(purchasePreDeliverVo);
-
-//			 //转JSON
-			 Gson userGson = new GsonBuilder().create();
-			 result.put("payload", userGson.toJson(JSONObject.toJSON(list)));
-			 log.info("JSON数据:" + result);
-			 pushvo.setResult(result);
-			 //拼接url 
+			 List<PurchasePreDeliverVo> purchasePreDeliverVos=syShippingDetailsService.getPurchasePreDeliverVo(arrIds);
+			 //获取url
 			 String url = resultList.get(0).getItemIp();
-			 //调用doPost
 			 InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
-			 //处理返回信息
+			 List<SyShippingDetails> list1=new ArrayList<>();
+			//处理返回信息
 			 JSONObject informationJson = interfaceConnUtils.doPostToBasicAuth(result, url);
 			 System.out.println("处理返回信息informationJson\t"+informationJson);
-			 //获取返回信息
-			 String message = informationJson.getString("message");
-//			 //获取是否成功
-//			 String code = jsonArray.getString("code");
-//			 //获取返回消息
-//			 String message = jsonArray.getString("message");
-
-			 log.info("返回信息jsonArray\t"+message);
+			 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 ex){
 

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/SyShippingDetails.java

@@ -117,6 +117,14 @@ public class SyShippingDetails {
 	@Excel(name = "推送信息", width = 15)
 	@ApiModelProperty(value = "推送信息")
 	private String pushMessage;
+	/**srm推送状态*/
+	@Excel(name = "srm推送状态", width = 15)
+	@ApiModelProperty(value = "srm推送状态")
+	private String pushSrmState;
+	/**srm推送信息*/
+	@Excel(name = "srm推送信息", width = 15)
+	@ApiModelProperty(value = "srm推送信息")
+	private String pushSrmMessage;
 
 	//子表集合
 	@TableField(exist = false)

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/PurchasePreDeliverDetailSizeVo.java

@@ -1,5 +1,8 @@
 package org.jeecg.modules.documents.shippingDetails.entity.VO;
 
+import lombok.Data;
+
+@Data
 public class PurchasePreDeliverDetailSizeVo {
     /**id*/
     private String id;
@@ -7,6 +10,8 @@ public class PurchasePreDeliverDetailSizeVo {
     private String deliverDetailId;
     /**出运明细子表id*/
     private String syShippingDetailsId;
+    /**出运明细子表分组id*/
+    private String syShippingDetailGroupId;
     /**尺码*/
     private String size;
     /**发货数量*/

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/entity/VO/PurchasePreDeliverDetailVo.java

@@ -11,6 +11,8 @@ public class PurchasePreDeliverDetailVo {
     private String id;
     /**出运明细子表id*/
     private String syShippingDetailsId;
+    /**出运明细主表id*/
+    private String syShippingId;
     /**出运明细分组id*/
     private String syShippingDetailGroupId;
     /**预发货主表id*/

+ 5 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/SyShippingDetailsMapper.java

@@ -74,9 +74,11 @@ public interface SyShippingDetailsMapper extends BaseMapper<SyShippingDetails> {
     //查询报关要素子表
     public List<SyDeclarationElementsItem> querysyDeclarationElementsItemList(@Param("id") String id);
 
-    public PurchasePreDeliverVo getPurchasePreDeliverVo(@Param("id") List<String> id);
+    public List<PurchasePreDeliverVo> getPurchasePreDeliverVo(@Param("id") List<String> id);
 
-    public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(@Param("id") List<String> shippingDetailsId);
+    public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(@Param("id") List<String> syShippingId);
 
-    List<PurchasePreDeliverDetailSizeVo> getPurchasePreDeliverDetailSizeVo(String shippingDetailsId);
+    public List<PurchasePreDeliverDetailSizeVo> getPurchasePreDeliverDetailSizeVo(@Param("id") List<String> shippingDetailId);
+
+    public List<SyShippingDetails> getStrings(@Param("id")List<String> idsList);
 }

+ 45 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/mapper/xml/SyShippingDetailsMapper.xml

@@ -350,10 +350,11 @@ ${ew.customSqlSegment}
         from sy_shipping_details a
         left join sy_shipping_details_item b
         on a.id=b.shipping_details_id
-        where b.id in
+        where a.id in
         <foreach collection="id" item="item"  open="(" separator="," close=")">
             #{item}
         </foreach>
+        group by a.id
     </select>
 
     <select id="getPurchasePreDeliverDetailVo" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverDetailVo">
@@ -363,7 +364,7 @@ ${ew.customSqlSegment}
         b.item_number 'styleNo',b.inventory_code 'invCode',b.colour 'color',
         b.inventory_name 'invName',b.specification_and_model 'invSpec',
         sum(b.shipment_quantity) 'quantity',b.coding_rules 'codingRules',
-        b.submit_status 'submitStatus',b.weight 'weight',
+        a.id 'syShippingId',b.submit_status 'submitStatus',b.weight 'weight',
         b.guangpei_gate_width 'guangpeiGateWidth',b.small_Po 'smallPo',
         b.distribution_Point 'distributionPoint',b.pack_id 'packId',
         b.material_composition 'composition',b.box_number 'boxNumber',
@@ -371,7 +372,7 @@ ${ew.customSqlSegment}
         from sy_shipping_details a
         left join sy_shipping_details_item b
         on a.id=b.shipping_details_id
-        where b.id in
+        where a.id  in
         <foreach collection="id" item="item"  open="(" separator="," close=")">
             #{item}
         </foreach>
@@ -379,15 +380,50 @@ ${ew.customSqlSegment}
         order by size+0
     </select>
 
-    <select id="getPurchasePreDeliverDetailSizeVo" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverDetailVo">
-        select b.size 'size',c.num,
-               b.id 'syShippingDetailsId',
-               b.ompo_Id_Item 'purchaseId',
-               b.shipment_quantity 'quantity'
+    <select id="getPurchasePreDeliverDetailSizeVo" resultType="org.jeecg.modules.documents.shippingDetails.entity.VO.PurchasePreDeliverDetailSizeVo">
+        select b.size 'size',c.num,b.id 'syShippingDetailsId',
+               b.ompo_Id_Item 'purchaseId',b.shipment_quantity 'quantity',
+               b.group_Id 'syShippingDetailGroupId'
         from sy_shipping_details a
         left join sy_shipping_details_item b on a.id=b.shipping_details_id
 		LEFT JOIN sizetable c ON b.`size`=c.`size`
-        where b.group_Id = #{value}
+        where a.id  in
+        <foreach collection="id" item="item"  open="(" separator="," close=")">
+            #{item}
+        </foreach>
         order by c.num
     </select>
+
+    <select id="getStrings" resultType="org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails">
+        select distinct a.id,push_srm_state
+        from sy_shipping_details a
+        left join sy_shipping_details_item b on a.id=b.shipping_details_id
+        where b.group_id in
+        <foreach collection="id" item="item"  open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
+    <update id="batchSubmission">
+
+        update sy_shipping_details_item
+        <if test='type == "1"'>
+            set submit_status = 1
+            where group_id in
+            <foreach collection="submitListId" item="item"  open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        <if test='type == "2"'>
+            set submit_status = 0
+            where group_id in
+            <foreach collection="submitListId" item="item"  open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+
+
+    </update>
 </mapper>

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/ISyShippingDetailsService.java

@@ -8,6 +8,7 @@ import org.jeecg.modules.documents.shippingDetails.entity.VO.*;
 
 import java.text.ParseException;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 发运明细主表
@@ -63,5 +64,7 @@ public interface ISyShippingDetailsService extends IService<SyShippingDetails> {
 
     public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(List<String> id);
 
-    public PurchasePreDeliverVo getPurchasePreDeliverVo(List<String> id);
+    public List<PurchasePreDeliverVo> getPurchasePreDeliverVo(List<String> id);
+
+    public void getStrings(List<String> idsList);
 }

+ 60 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/shippingDetails/service/impl/SyShippingDetailsServiceImpl.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.documents.shippingDetails.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.common.exception.JeecgBootException;
@@ -361,13 +362,66 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
 
     /**
      * 发运明细推送(查询主表)
-     * @param id
+     * @param ids
      * @return
      */
     @Override
-    public PurchasePreDeliverVo getPurchasePreDeliverVo(List<String> id) {
+    public List<PurchasePreDeliverVo> getPurchasePreDeliverVo(List<String> ids) {
+        List<PurchasePreDeliverVo> purchasePreDeliverVos=syShippingDetailsMapper.getPurchasePreDeliverVo(ids);
+        List<PurchasePreDeliverDetailVo> deliverDetailVos=syShippingDetailsMapper.getPurchasePreDeliverDetailVo(ids);
+        List<PurchasePreDeliverDetailSizeVo> deliverDetailSizeVos=syShippingDetailsMapper.getPurchasePreDeliverDetailSizeVo(ids);
+        Map<String,List<PurchasePreDeliverDetailVo>> deliverDetailVoMaps=new HashMap<>();//预约发货单子表map集合
+        Map<String,List<PurchasePreDeliverDetailSizeVo>> deliverDetailSizeVoMaps=new HashMap<>();//预约发货单子表尺码map集合
+        deliverDetailVos.forEach(p->{
+            if (deliverDetailVoMaps.containsKey(p.getSyShippingId())){
+                deliverDetailVoMaps.get(p.getSyShippingId()).add(p);
+            }else{
+                List<PurchasePreDeliverDetailVo> deliverDetailVos1=new ArrayList<>();
+                deliverDetailVos1.add(p);
+                deliverDetailVoMaps.put(p.getSyShippingId(),deliverDetailVos1);
+            }
+        });
+        deliverDetailSizeVos.forEach(p->{
+            if (deliverDetailSizeVoMaps.containsKey(p.getSyShippingDetailGroupId())){
+                deliverDetailSizeVoMaps.get(p.getSyShippingDetailGroupId()).add(p);
+            }else{
+                List<PurchasePreDeliverDetailSizeVo> deliverDetailVos1=new ArrayList<>();
+                deliverDetailVos1.add(p);
+                deliverDetailSizeVoMaps.put(p.getSyShippingDetailGroupId(),deliverDetailVos1);
+            }
+        });
+        deliverDetailVos.forEach(p->{
+            p.setPurchasePreDeliverDetailSizeList(deliverDetailSizeVoMaps.get(p.getSyShippingDetailGroupId()));
+        });
+        purchasePreDeliverVos.forEach(p->{
+            p.setPurchasePreDeliverDetailList(deliverDetailVoMaps.get(p.getSyShippingId()));
+        });
+        return purchasePreDeliverVos;
+    }
 
-        return syShippingDetailsMapper.getPurchasePreDeliverVo(id);
+    @Override
+    public void getStrings(List<String> idsList) {
+        List<SyShippingDetails> syShippingDetails=syShippingDetailsMapper.getStrings(idsList);
+        Map<String,List<String>> stringListMap=new HashMap<>();
+        syShippingDetails.forEach(p->{
+            if (stringListMap.containsKey(p.getPushSrmState())){
+                stringListMap.get(p.getPushSrmState()).add(p.getId());
+            }else{
+                List<String> ids=new ArrayList<>();
+                ids.add(p.getId());
+                stringListMap.put(p.getPushSrmState(),ids);
+            }
+        });
+        for (String string : stringListMap.keySet()){
+            if (string==null||string.equals("0")||string.equals("2")){
+                List<String> ids=stringListMap.get(string);
+                UpdateWrapper updateWrapper=new UpdateWrapper();
+                updateWrapper.set("push_srm_state","0");
+                updateWrapper.set("push_srm_message","");
+                updateWrapper.in("id",ids);
+                syShippingDetailsMapper.update(null,updateWrapper);
+            }
+        }
     }
 
     /**
@@ -389,7 +443,9 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
     public List<PurchasePreDeliverDetailVo> getPurchasePreDeliverDetailVo(List<String> shippingDetailsId) {
         List<PurchasePreDeliverDetailVo> deliverDetailVos=syShippingDetailsMapper.getPurchasePreDeliverDetailVo(shippingDetailsId);
         deliverDetailVos.forEach(p->{
-            List<PurchasePreDeliverDetailSizeVo> deliverDetailSizeVos=syShippingDetailsMapper.getPurchasePreDeliverDetailSizeVo(p.getSyShippingDetailGroupId());
+            ArrayList arrayList=new ArrayList();
+            arrayList.add(p.getSyShippingDetailGroupId());
+            List<PurchasePreDeliverDetailSizeVo> deliverDetailSizeVos=syShippingDetailsMapper.getPurchasePreDeliverDetailSizeVo(arrayList);
             p.setPurchasePreDeliverDetailSizeList(deliverDetailSizeVos);
         });
         return deliverDetailVos;

+ 88 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/quartz/job/PushShippingDetailsJob.java

@@ -0,0 +1,88 @@
+package org.jeecg.modules.quartz.job;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+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.service.ISyShippingDetailsService;
+import org.jeecg.modules.openApi.entity.DxpDataPlan;
+import org.jeecg.modules.openApi.service.IDxpDataPlanService;
+import org.jeecg.modules.system.util.InterfaceConnUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PushShippingDetailsJob implements Job {
+
+    @Autowired
+    private ISyShippingDetailsService syShippingDetailsService;
+
+    @Autowired
+    private IDxpDataPlanService iDxpDataPlanService;
+
+    @Override
+    public void execute(JobExecutionContext context) throws JobExecutionException {
+        //查询IP及账套信息、时间戳
+        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::getDelFlag, "0");//删除状态=0
+        detailsLambdaQueryWrapper.last("limit 10");//一次最多同步10条数据
+        List<SyShippingDetails> list=syShippingDetailsService.list(detailsLambdaQueryWrapper);
+        List<String> strings=new ArrayList<>();
+        list.forEach(p->{
+            strings.add(p.getId());
+        });
+        List<PurchasePreDeliverVo> purchasePreDeliverVos=syShippingDetailsService.getPurchasePreDeliverVo(strings);
+        JSONObject result = new JSONObject();
+        //转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();
+        }
+    }
+}