yzc 1 жил өмнө
parent
commit
dc599fb19c

+ 5 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/vo/ContractProductVo.java

@@ -259,4 +259,9 @@ public class ContractProductVo extends ContractProduct {
      */
     private BigDecimal outboundQuantity;
 
+    /**
+     * 王工数量
+     */
+    private BigDecimal finishQuantity;
+
 }

+ 9 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/vo/ContractVo.java

@@ -232,5 +232,14 @@ public class ContractVo extends Contract {
      */
     private BigDecimal shipmentAmount;
 
+    /**
+     * 出货数量
+     */
+    private BigDecimal deliverQuantity;
+    /**
+     * 出货数量
+     */
+    private BigDecimal notDeliverQuantity;
+
 }
 

+ 1 - 2
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -458,8 +458,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(ids, 1);
 
         //获取合同产品明细
-        List<ContractProduct> productList = contractProductService.list(q -> q.in(ContractProduct::getContractId, ids));
-        List<ContractProductVo> contractProductVos = BeanUtil.copyToList(productList, ContractProductVo.class);
+        List<ContractProductVo> contractProductVos = contractProductService.getList(IWrapper.<ContractProduct>getWrapper().in(ContractProduct::getContractId, ids));
         //赋值物料信息
         productInfoService.attributeAssign(contractProductVos, ContractProduct::getProductId, (item, productInfo) -> {
             item.setProductCode(productInfo.getCustomCode());

+ 14 - 2
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -31,7 +31,9 @@
                                              JOIN production_order_detail pod ON pod.contract_detail_id = cp.id
                                     WHERE cp.contract_id = t1.id)
                                , 0)                       AS settledAmount,
-                           po.delivery_period             as prodDeliveryPeriod
+                           po.delivery_period             as prodDeliveryPeriod,
+                           t4.deliverQuantity,
+                           t4.notDeliverQuantity
                     FROM contract t1
                              left join customer c on t1.buy_corporation_id = c.id
                              left join sys_user us on c.user_id = us.user_id
@@ -41,7 +43,17 @@
                                                IFNULL(sum(swd.receipt_quantity), 0) AS receipt_quantity
                                         FROM production_order_detail pod
                                                  JOIN stock_wait_details swd ON swd.prod_task_id = pod.id
-                                        GROUP BY pod.contract_id) t3 ON t3.contract_id = t1.id) t1
+                                        GROUP BY pod.contract_id) t3 ON t3.contract_id = t1.id
+                             LEFT JOIN (SELECT t1.contract_id,
+                                               t1.quantity,
+                                               t1.deliverQuantity,
+                                               (t1.quantity - t1.deliverQuantity) notDeliverQuantity
+                                        FROM (SELECT cp.contract_id,
+                                                     IFNULL(sum(cp.quantity), 0)  AS quantity,
+                                                     IFNULL(sum(cor.quantity), 0) AS deliverQuantity
+                                              FROM contract_product cp
+                                                       LEFT JOIN contract_outbound_records cor ON cp.contract_id = cor.contract_id
+                                              GROUP BY cp.contract_id) t1) t4 ON t4.contract_id = t1.id) t1
               GROUP BY t1.id) t1
             ${ew.customSqlSegment}
     </select>

+ 2 - 0
hx-sale/src/main/resources/mapper/contract/ContractProductMapper.xml

@@ -233,8 +233,10 @@
                (SELECT IFNULL(sum(swd.receipt_quantity), 0)
                 FROM stock_wait_details swd
                 WHERE swd.contract_detail_id = cp.id) AS outboundQuantity,
+               pod.finish_quantity,
                cp.*
         FROM contract_product cp
+                 LEFT JOIN production_order_detail pod ON pod.contract_detail_id = cp.id
                  LEFT JOIN product_info pi ON cp.product_id = pi.id
             ${ew.customSqlSegment}
     </select>