jiangn 1 год назад
Родитель
Сommit
07aa1c446e

+ 15 - 8
src/main/java/com/dk/mdm/controller/sale/OrderController.java

@@ -1,21 +1,17 @@
 package com.dk.mdm.controller.sale;
 
-import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseResultVO;
-import com.dk.mdm.mapper.pur.PurchaseItemMapper;
-import com.dk.mdm.model.pojo.sale.Order;
 import com.dk.common.service.BaseService;
+import com.dk.mdm.model.pojo.sale.Order;
 import com.dk.mdm.model.query.sale.OrderQuery;
 import com.dk.mdm.model.response.sale.OrderResponse;
-import com.dk.mdm.model.vo.pur.PurchaseVO;
 import com.dk.mdm.model.vo.sale.OrderVO;
-import com.dk.mdm.service.pur.PurchaseService;
+import com.dk.mdm.service.sale.OrderService;
+import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import io.swagger.annotations.Api;
-import com.dk.mdm.service.sale.OrderService;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
@@ -187,4 +183,15 @@ public class OrderController {
         return orderService.oneKeyInvalid(id);
     }
 
+    /**
+     * @desc   : 以销定采查询-web
+     * @author : 姜宁
+     * @date   : 2024/7/25 11:07
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"purchase_based_on_sales_web"})
+    public ResponseResultVO<PageList<Map<String, Object>>> purchaseBasedOnSales(@RequestBody Map<String, Object> param) {
+        return orderService.purchaseBasedOnSales(param);
+    }
+
 }

+ 16 - 2
src/main/java/com/dk/mdm/mapper/sale/OrderMapper.java

@@ -1,8 +1,7 @@
 package com.dk.mdm.mapper.sale;
 
-import com.dk.mdm.model.pojo.ivt.Outbound;
-import com.dk.mdm.model.pojo.sale.Order;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.pojo.sale.Order;
 import com.dk.mdm.model.query.sale.OrderQuery;
 import com.dk.mdm.model.response.sale.OrderResponse;
 import org.springframework.stereotype.Repository;
@@ -86,5 +85,20 @@ public interface OrderMapper extends BaseMapper<Order>{
      * @date   : 2024-03-09 11:36
      */
     Map<String, Object> getFactReceipt(String id);
+
+   /**
+    * @desc   : 以销定采查询-web
+    * @author : 姜宁
+    * @date   : 2024/7/25 11:05
+    */
+    List<Map<String, Object>>  purchaseBasedOnSales(Map param);
+
+    /**
+     * @desc   : 以销定采查询-web(数量)
+     * @author : 姜宁
+     * @date   : 2024/7/25 11:06
+     */
+    Long purchaseBasedOnSalesCountByCond(Map param);
+
 }
 

+ 147 - 0
src/main/java/com/dk/mdm/mapper/sale/OrderMapper.xml

@@ -1192,4 +1192,151 @@
           and t.acc_item_type = '账款类型-应收'
           and tpo.from_id = #{id}::uuid
     </select>
+
+    <!-- 以销定采查询销售订单查询表t_psi_order,(条件查询+分页)列表 -->
+    <select id="purchaseBasedOnSales" resultType="Map">
+        SELECT
+        T.order_type AS "orderType",
+        sys.f_get_name_i18n ( tdk1.kind_name_i18n, #{ i18n } ) AS "orderTypeName",
+        T.org_id AS "orgId",
+        tmo.org_name AS "orgName",
+        T.staff_id AS "staffId",
+        tms.staff_name AS "staffName",
+        T.cus_id AS "cusId",
+        tmc.cus_code AS "cusCode",
+        T.cus_name AS "cusName",
+        T.cus_phone AS "cusPhone",
+        T.address_area AS "addressArea",
+        T.address_name AS "addressName",
+        T.address_no AS "addressNo",
+        T.address_full AS "addressFull",
+        T.sales_channel AS "salesChannel",
+        tmsc.channel_name AS "channelName",
+        T.delivery_date AS "deliveryDate",
+        T.sale_discount AS "saleDiscount",
+        T.order_status AS "orderStatus",
+        sys.f_get_name_i18n ( tdk2.kind_name_i18n, #{ i18n } ) AS "orderStatusName",
+        T.out_status AS "outStatus",
+        sys.f_get_name_i18n ( tdk3.kind_name_i18n, #{ i18n } ) AS "outStatusName",
+        T.make_time AS "makingTime",
+        T.cp_id AS "cpId",
+        toi.item_id AS "itemId",
+        T.order_id AS "orderId",
+        T.order_no AS "orderNo",
+        toi.item_index AS "itemIndex",
+        toi.sku_id AS "skuId",
+        toi.item_qty AS "itemQty",
+        toi.price_std AS "priceStd",
+        toi.amt_std AS "amtStd",
+        toi.price_sale AS "priceSale",
+        toi.item_amt AS "itemAmt",
+        toi.price_discount AS "priceDiscount",
+        toi.non_std_code AS "nonStdCode",
+        toi.item_qty - toi.purchase_qty AS "transferableQuantity",
+        toi.remarks AS "remarks",
+        toi.cp_id AS "cpId",
+        tmgs.sku_code AS "skuCode",
+        tmgs.sku_model AS "skuModel",
+        tmgs.sku_name AS "skuName",
+        tmgb.brand_name AS "brandName",
+        tmgb.short_name AS "shortName",
+        tmgs.price_purchase AS "pricePurchase",
+        tmgs.price_standard AS "priceStandard",
+        toi.unit_id AS "unitId",
+        toi.sub_unit_id AS "subUnitId",
+        toi.pack_box AS "packBox",
+        toi.box AS "box",
+        toi.piece AS "piece",
+        tmgus.unit_name         as "subUnitName",
+        tmgu.unit_name         as "unitName",
+        tmgs.flg_sub_unit as "flgSubUnit"
+        FROM
+        dkic_b.t_psi_order
+        AS T
+        LEFT JOIN dkic_b.t_mst_sale_channel tmsc ON T.sales_channel = tmsc.channel_id
+        LEFT JOIN dkic_b.t_mst_org tmo ON T.org_id = tmo.org_id
+        LEFT JOIN dkic_b.t_mst_staff tms ON T.staff_id = tms.staff_id
+        LEFT JOIN dkic_b.t_mst_customer tmc ON T.cus_id = tmc.cus_id
+        LEFT JOIN sys.t_data_kind AS tdk1 ON T.order_type = tdk1.kind_code
+        LEFT JOIN sys.t_data_kind AS tdk2 ON T.order_status = tdk2.kind_code
+        LEFT JOIN sys.t_data_kind AS tdk3 ON T.out_status = tdk3.kind_code
+        LEFT JOIN dkic_b.t_psi_order_item toi ON toi.order_id = T.order_id
+        LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = toi.sku_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
+        left join dkic_b.t_mst_unit as tmgu on toi.unit_id = tmgu.unit_id
+        left join dkic_b.t_mst_unit as tmgus on toi.sub_unit_id = tmgus.unit_id
+        WHERE toi.sku_id is not null
+        and T.flg_valid
+        and toi.flg_valid
+        and toi.purchase_qty &lt; toi.item_qty
+        <if test="cpId != null">
+            AND t.cp_id = #{cpId}
+        </if>
+        <if test="cusPhone != null and cusPhone != ''">
+            AND t.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
+        </if>
+        <if test="cusName != null and cusName != ''">
+            AND t.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
+        </if>
+        <if test="makeTimeStart != null and makeTimeEnd != null">
+            AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+            AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+        </if>
+        <if test="skuName != null and skuName != ''">
+            AND toi.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
+        </if>
+        <if test="skuModel != null and skuModel != ''">
+            AND toi.sku_model LIKE concat('%',my_ex.likequery(#{skuModel}),'%')
+        </if>
+        order by t.op_create_time desc
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
+
+    <!-- 查询表t_psi_order,(条件查询)个数 -->
+    <select id="purchaseBasedOnSalesCountByCond" resultType="Long">
+        SELECT
+        count(1)
+        FROM
+        dkic_b.t_psi_order
+        AS T
+        LEFT JOIN dkic_b.t_mst_sale_channel tmsc ON T.sales_channel = tmsc.channel_id
+        LEFT JOIN dkic_b.t_mst_org tmo ON T.org_id = tmo.org_id
+        LEFT JOIN dkic_b.t_mst_staff tms ON T.staff_id = tms.staff_id
+        LEFT JOIN dkic_b.t_mst_customer tmc ON T.cus_id = tmc.cus_id
+        LEFT JOIN sys.t_data_kind AS tdk1 ON T.order_type = tdk1.kind_code
+        LEFT JOIN sys.t_data_kind AS tdk2 ON T.order_status = tdk2.kind_code
+        LEFT JOIN sys.t_data_kind AS tdk3 ON T.out_status = tdk3.kind_code
+        LEFT JOIN dkic_b.t_psi_order_item toi ON toi.order_id = T.order_id
+        LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = toi.sku_id
+        LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
+        left join dkic_b.t_mst_unit as tmgu on toi.unit_id = tmgu.unit_id
+        left join dkic_b.t_mst_unit as tmgus on toi.sub_unit_id = tmgus.unit_id
+        WHERE toi.sku_id is not null
+        and T.flg_valid
+        and toi.flg_valid
+        and toi.purchase_qty &lt; toi.item_qty
+        <if test="cpId != null">
+            AND t.cp_id = #{cpId}
+        </if>
+        <if test="cusPhone != null and cusPhone != ''">
+            AND t.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
+        </if>
+        <if test="cusName != null and cusName != ''">
+            AND t.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
+        </if>
+        <if test="makeTimeStart != null and makeTimeEnd != null">
+            AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+            AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+        </if>
+        <if test="skuName != null and skuName != ''">
+            AND toi.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
+        </if>
+        <if test="skuModel != null and skuModel != ''">
+            AND toi.sku_model LIKE concat('%',my_ex.likequery(#{skuModel}),'%')
+        </if>
+    </select>
+
+
 </mapper>

+ 11 - 16
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java

@@ -7,7 +7,6 @@ import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.common.model.pojo.PageList;
-import com.dk.common.model.vo.AnnexVO;
 import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
@@ -23,25 +22,18 @@ import com.dk.mdm.mapper.pur.PurchaseItemMapper;
 import com.dk.mdm.mapper.pur.PurchaseMapper;
 import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.InboundItem;
-import com.dk.mdm.model.pojo.ivt.Outbound;
-import com.dk.mdm.model.pojo.ivt.OutboundItem;
 import com.dk.mdm.model.pojo.pur.Purchase;
 import com.dk.mdm.model.pojo.pur.PurchaseItem;
-import com.dk.mdm.model.pojo.sale.Order;
-import com.dk.mdm.model.pojo.sale.OrderItem;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
 import com.dk.mdm.model.query.ivt.InboundQuery;
 import com.dk.mdm.model.query.ivt.InventoryQuery;
-import com.dk.mdm.model.query.ivt.OutboundItemQuery;
-import com.dk.mdm.model.response.ivt.*;
+import com.dk.mdm.model.response.ivt.InboundItemResponse;
+import com.dk.mdm.model.response.ivt.InboundResponse;
+import com.dk.mdm.model.response.ivt.InventoryResponse;
 import com.dk.mdm.model.response.pur.PurchaseItemResponse;
 import com.dk.mdm.model.response.pur.PurchaseResponse;
-import com.dk.mdm.model.response.sale.OrderItemResponse;
-import com.dk.mdm.model.response.sale.OrderResponse;
 import com.dk.mdm.model.vo.ivt.InboundItemVO;
 import com.dk.mdm.model.vo.ivt.InboundVO;
-import com.dk.mdm.model.vo.ivt.OutboundItemVO;
-import com.dk.mdm.model.vo.ivt.OutboundVO;
 import com.dk.mdm.service.common.CommonService;
 import com.dk.mdm.service.ivt.inventory.InventoryService;
 import com.dk.mdm.service.mac.AccountService;
@@ -192,12 +184,15 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         Map<String, Object> map = new HashMap<>();
         map.put("cpId", inboundVO.getCpId());
         map.put("code", Constant.SystemConstant.IVT_001.getValue());
-        //自动办理标识
-        String flgHandleSetting = commonMapper.getSettingValue(map);
+        //自动办理标识 返回的值为true和false,
+//        String flgHandleSetting = commonMapper.getSettingValue(map);
         //自动办理标识为1 自动办理入库
-        if (Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)) {
-            inboundVO.setFlgAutoHandle(Constant.FlgAutoHandle.TRUE.getValue());
-        }
+//        if (Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)) {
+//            inboundVO.setFlgAutoHandle(Constant.FlgAutoHandle.TRUE.getValue());
+//        }
+        //自动办理标识参数,返回的值为true和false
+        Boolean flgAutoHandle = Boolean.parseBoolean(commonMapper.getSettingValue(map));
+        inboundVO.setFlgAutoHandle(flgAutoHandle);
         //endregion
 
         //region  总单

+ 8 - 5
src/main/java/com/dk/mdm/service/pur/PurchaseService.java

@@ -27,20 +27,15 @@ import com.dk.mdm.model.pojo.pur.Purchase;
 import com.dk.mdm.model.pojo.pur.PurchaseItem;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
 import com.dk.mdm.model.query.ivt.InboundQuery;
-import com.dk.mdm.model.query.ivt.OutboundItemQuery;
-import com.dk.mdm.model.query.ivt.OutboundQuery;
 import com.dk.mdm.model.query.pur.PurchaseItemQuery;
 import com.dk.mdm.model.query.pur.PurchaseQuery;
 import com.dk.mdm.model.response.ivt.InboundItemResponse;
 import com.dk.mdm.model.response.ivt.InboundResponse;
-import com.dk.mdm.model.response.ivt.OutboundItemResponse;
-import com.dk.mdm.model.response.ivt.OutboundResponse;
 import com.dk.mdm.model.response.mst.GoodsSkuResponse;
 import com.dk.mdm.model.response.pur.PurchaseItemResponse;
 import com.dk.mdm.model.response.pur.PurchaseResponse;
 import com.dk.mdm.model.vo.ivt.InboundItemVO;
 import com.dk.mdm.model.vo.ivt.InboundVO;
-import com.dk.mdm.model.vo.ivt.OutboundVO;
 import com.dk.mdm.model.vo.pur.PurchaseItemVO;
 import com.dk.mdm.model.vo.pur.PurchaseVO;
 import com.dk.mdm.service.common.CommonService;
@@ -178,6 +173,8 @@ public class PurchaseService extends BaseService<Purchase> {
         purchasevo.setPurType(Constant.DocumentType.PUR_CHASE.getName());
         // 订单状态
         purchasevo.setPurStatus(Constant.OrderStatus.STATUS_DEAL.getName());
+        // 入库状态
+        purchasevo.setIntoStatus(Constant.IntoStatus.DAIRUKU.getName());
         // 获取单号
         Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.PURCHASE.getName(), false);
         purchasevo.setPurId(codeMap.get("outId").toString());
@@ -202,6 +199,8 @@ public class PurchaseService extends BaseService<Purchase> {
             purchaseItem.setIntoAmt(BigDecimal.ZERO);
             purchaseItem.setIntoingQty(BigDecimal.ZERO);
             purchaseItem.setIntoingAmt(BigDecimal.ZERO);
+            // 入库状态
+            purchaseItem.setIntoStatus(Constant.IntoStatus.DAIRUKU.getName());
             //endregion
             purchaseItemMapper.insert(purchaseItem);
             purchaseItemVO.setItemId(purchaseItem.getItemId());
@@ -238,6 +237,8 @@ public class PurchaseService extends BaseService<Purchase> {
                 inboundItemVO.setCostAmt(purchaseItemVO.getItemAmt());
                 //出库数量
                 inboundItemVO.setOutQty(BigDecimal.ZERO);
+                //仓库ID
+                inboundItemVO.setWhId(purchasevo.getWhId());
                 //endregion
 
                 //region 根据sku查询商品信息
@@ -285,6 +286,8 @@ public class PurchaseService extends BaseService<Purchase> {
             inboundVO.setFromId(purchasevo.getPurId());
             //来源单号
             inboundVO.setFromNo(purchasevo.getPurNo());
+            //仓库ID
+            inboundVO.setWhId(purchasevo.getWhId());
             //endregion
             //新建采购入库单
             inboundPurchaseService.purchaseInboundInsert(inboundVO);

+ 10 - 1
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -1202,5 +1202,14 @@ public class OrderService extends BaseService<Order> {
         return ResponseResultUtil.success();
     }
 
-
+    /**
+     * @desc   : 以销定采web
+     * @author : 姜宁
+     * @date   : 2024/7/25 11:07
+     */
+    @Pagination
+    public ResponseResultVO<PageList<Map<String, Object>>> purchaseBasedOnSales(Map<String, Object> param) {
+        return super.mergeListWithCount(param, orderMapper.purchaseBasedOnSales(param),
+                orderMapper.purchaseBasedOnSalesCountByCond(param));
+    }
 }