Browse Source

装箱出货明细

caozj 1 year ago
parent
commit
e0891bcd3e

+ 0 - 1
hx-sale/src/main/java/com/fjhx/sale/entity/pack/po/PackDetailProduct.java

@@ -59,5 +59,4 @@ public class PackDetailProduct extends BasePo {
      * 备注
      */
     private String remark;
-
 }

+ 4 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/pack/vo/PackDetailProductVo.java

@@ -14,4 +14,8 @@ import lombok.Setter;
 @Setter
 public class PackDetailProductVo extends PackDetailProduct {
 
+    /**
+     * 业务ID
+     */
+    private Long businessId;
 }

+ 20 - 14
hx-sale/src/main/java/com/fjhx/sale/service/pack/impl/PackShipmentServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.sale.entity.documents.po.Documents;
 import com.fjhx.sale.entity.pack.dto.PackShipmentDto;
 import com.fjhx.sale.entity.pack.dto.PackShipmentSelectDto;
+import com.fjhx.sale.entity.pack.po.PackDetail;
 import com.fjhx.sale.entity.pack.po.PackDetailGoods;
 import com.fjhx.sale.entity.pack.po.PackShipment;
 import com.fjhx.sale.entity.pack.vo.PackShipmentVo;
@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
@@ -101,25 +103,29 @@ public class PackShipmentServiceImpl extends ServiceImpl<PackShipmentMapper, Pac
         if (ObjectUtil.isEmpty(dto.getPackDetailIds())){
             throw  new ServiceException("参数缺失:包装明细单ID不能为null");
         }
+        List<Map<String,Object>> list = new ArrayList<>();
         String packDetailIds = dto.getPackDetailIds();
         //获取到包装明细单ID列表
         List<String> ids = Arrays.asList(packDetailIds.split(","));
-        //查询自定义货物
-        List<PackDetailGoods> goodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().in(PackDetailGoods::getPackDetailId,ids));
-        if(CollectionUtils.isNotEmpty(goodsList)){
-            List<Map<String,Object>> list = new ArrayList<>();
-            for(PackDetailGoods p : goodsList){
-                Map<String,Object> map = new HashMap<>();
-                map.put("businessId",p.getId());
-                map.put("price",0);
-                map.put("quantity",p.getQuantity());
-                map.put("subDescription",p.getRemark());
-                map.put("type","20");
-                list.add(map);
+        for(String id : ids){
+            List<PackDetailGoods> goodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().eq(PackDetailGoods::getPackDetailId,id));
+            if(CollectionUtils.isNotEmpty(goodsList)){
+                //添加货物
+                for(PackDetailGoods p : goodsList){
+                    Map<String,Object> map = new HashMap<>();
+                    map.put("businessId",p.getId());
+                    map.put("price",0);
+                    map.put("quantity",p.getQuantity());
+                    map.put("subDescription",p.getRemark());
+                    map.put("type","20");
+                    list.add(map);
+                }
+            }else{
+                List<Map<String,Object>> productList = baseMapper.productDetailList(Arrays.asList(id));
+                list.addAll(productList);
             }
-            return list;
         }
-        return baseMapper.productDetailList(ids);
+        return list;
     }
 
 }

+ 8 - 21
hx-sale/src/main/resources/mapper/pack/PackShipmentMapper.xml

@@ -24,27 +24,14 @@
     </select>
     <select id="productDetailList" resultType="java.util.Map">
         SELECT
-        id as businessId,
-        remark,
-        null as subDescription,
-        null as customsCode,
-        quantity,
-        null as price,
-        10 as type
-        FROM
-        pack_detail_goods dg
-        <where>
-            <include refid="productDetail"/>
-        </where>
-        UNION
-        SELECT
-        dg.id AS businessId,
-        json_unquote( pi.standard_json -> '$.englishName' ) remark,
-        dg.product_name AS subDescription,
-        json_unquote ( pi.standard_json -> '$.customsCode' ) AS customsCode,
-        dg.quantity,
-        cp.price AS price,
-        20 AS type
+            pack_detail_id AS packDetailId,
+            dg.id AS businessId,
+            json_unquote( pi.standard_json -> '$.englishName' ) remark,
+            dg.product_name AS subDescription,
+            json_unquote ( pi.standard_json -> '$.customsCode' ) AS customsCode,
+            dg.quantity,
+            cp.price AS price,
+            20 AS type
         FROM
         pack_detail_product dg
         LEFT JOIN bytesailing_item.product_info pi ON dg.product_id = pi.id