fubin 2 лет назад
Родитель
Сommit
85b06a3e11

+ 7 - 0
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.java

@@ -33,5 +33,12 @@ public interface OutboundItemMapper extends BaseMapper<OutboundItem>{
      * @date   : 2024-03-09 11:36
      */
     List<OutboundItem> selectByZIdForUpdate(String id);
+
+    /**
+     * @desc   : 根据条件进行查询(出库编辑用)
+     * @author : 付斌
+     * @date   : 2024-03-12 9:36
+     */
+    List<OutboundItemResponse> selectByCondForOutEdit(String id);
 }
 

+ 35 - 0
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.xml

@@ -290,4 +290,39 @@
             )
         </foreach>
     </insert>
+
+    <!-- 根据条件进行查询(出库用) -->
+    <select id="selectByCondForOutEdit" resultMap="BaseResultMapResponse">
+        SELECT t.item_id,
+               t.out_id,
+               t.from_item_id,
+               t.from_id,
+               t.item_index,
+               t.sku_id,
+               tmgs.sku_code                                  as "skuCode",
+               tmgs.sku_model                                 as "skuModel",
+               tmgs.sku_name                                  as "skuName",
+               tpoi.item_qty                                  as "orderQty",
+               tpoi.item_qty - tpoi.outing_qty + t.outing_qty as "canOutingQty",
+               t.outing_qty,
+               t.price_out,
+               t.outing_amt,
+               t.out_qty,
+               t.out_amt,
+               t.non_std_code,
+               t.remarks,
+               t.inv_id,
+               tpi.wh_id                                      as "whId",
+               tpi.inv_qty                                    as "invQty",
+               tpi.usable_qty                                 as "usableQty",
+               tmw.wh_name                                    as "whName"
+        FROM t_psi_outbound_item as t
+                 left join dkic_b.t_psi_order_item as tpoi on tpoi.item_id = t.from_item_id
+                 left join dkic_b.t_mst_goods_sku tmgs on tpoi.sku_id = tmgs.sku_id
+                 left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = t.inv_id
+                 left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
+        where t.flg_valid
+          and t.out_id = #{id}::uuid
+        order by t.item_index
+    </select>
 </mapper>

+ 57 - 5
src/main/java/com/dk/mdm/mapper/ivt/OutboundMapper.xml

@@ -248,11 +248,63 @@
     </select>
 
     <!-- 根据主键查询表t_psi_outbound的一行数据 -->
-    <select id="selectById" resultMap="BaseResultMap">
-        SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_psi_outbound
-        WHERE out_id = #{outId}::uuid
+    <select id="selectById" resultMap="BaseResultMapResponse">
+        SELECT t.out_id,
+               t.out_no,
+               t.out_type,
+               t.from_id,
+               t.from_no,
+               t.from_no                                         as "orderNo",
+               t.org_id,
+               tmo.org_name                                      as "orgName",
+               t.staff_id,
+               tms.staff_name                                    as "staffName",
+               t.cus_id,
+               tmc.cus_code                                      as "cusCode",
+               tmc.cus_name                                      as "cusName",
+               tmc.cus_phone                                     as "cusPhone",
+               tmc.cus_from                                      as "cusFrom",
+               tmc.contact_phone                                 as "contactPhone",
+               tmc.address_full                                  as "addressFull",
+               tmdd.data_value                                   as "cusFromName",
+               tpo.address_area,
+               tpo.address_name,
+               tpo.address_no,
+               tpo.address_gcj02,
+               tpo.address_full,
+               tpo.contact_name,
+               tpo.contact_phone,
+               tpo.sales_channel,
+               tmsc.channel_name                                 as "channelName",
+               t.sup_id,
+               t.out_status,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "outStatusName",
+               t.outing_qty,
+               t.outing_amt,
+               t.out_qty,
+               t.out_amt,
+               t.return_qty,
+               t.return_amt,
+               t.out_date,
+               t.remarks,
+               t.annex_paths,
+               t.make_staff,
+               makestaff.staff_name                              as "makeStaffName",
+               t.make_time,
+               t.receivable_id,
+               t.payable_id,
+               t.cp_id,
+               t.flg_valid
+        FROM t_psi_outbound as t
+                 left join dkic_b.t_psi_order as tpo on tpo.order_id = t.from_id
+                 left join dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tpo.sales_channel
+                 left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+                 left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+                 left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
+                 left join dkic_b.t_mst_dictionary_data tmdd on tmdd.data_id = tmc.cus_from
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.out_status
+        WHERE t.out_id = #{id}::uuid
     </select>
 
     <!-- 根据主键锁定表t_psi_outbound的一行数据 -->

+ 21 - 0
src/main/java/com/dk/mdm/model/response/ivt/OutboundItemResponse.java

@@ -296,6 +296,27 @@ public class OutboundItemResponse extends PageInfo<OutboundItemResponse> impleme
 
     @ApiModelProperty(value = "出库状态")
     private String outStatusName;
+
+    @ApiModelProperty(value = "订单数量")
+    private BigDecimal orderQty;
+
+    @ApiModelProperty(value = "可出库数量")
+    private BigDecimal canOutingQty;
+
+    @ApiModelProperty(value = "仓库ID")
+    private String whId;
+
+    @ApiModelProperty(value = "库存数量")
+    private BigDecimal invQty;
+
+    @ApiModelProperty(value = "可用量")
+    private BigDecimal usableQty;
+
+    @ApiModelProperty(value = "出库明细ID")
+    private String outItemId;
+
+    @ApiModelProperty(value = "订单明细ID")
+    private String orderItemId;
     /*
      * 相关属性
      * @TableField(exist = false)

+ 19 - 8
src/main/java/com/dk/mdm/model/response/ivt/OutboundResponse.java

@@ -347,21 +347,32 @@ public class OutboundResponse extends PageInfo<OutboundResponse> implements Seri
     @ApiModelProperty(value = "客户来源名称")
     private String cusFromName;
 
+    @ApiModelProperty(value = "销售渠道")
+    private String channelName;
+
     @ApiModelProperty(value = "制单员")
     private String makeStaffName;
 
     @ApiModelProperty(value = "出库状态")
     private String outStatusName;
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "行政区划 (a1:省 a2:市 a3:区)")
+    private JSONObject addressArea;
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
-     */
+    @ApiModelProperty(value = "小区或POI")
+    private String addressName;
+
+    @ApiModelProperty(value = "门牌号")
+    private String addressNo;
+
+    @ApiModelProperty(value = "地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)")
+    private JSONObject addressGcj02;
+
+    @ApiModelProperty(value = "联系人")
+    private String contactName;
+
+    @ApiModelProperty(value = "销售渠道")
+    private String salesChannel;
 
 
     private static final long serialVersionUID = 1L;

+ 17 - 6
src/main/java/com/dk/mdm/service/ivt/OutboundService.java

@@ -191,7 +191,7 @@ public class OutboundService extends BaseService<Outbound> {
         OutboundItem outboundItemForUpdate;
 
         // 编辑出库明细
-        List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList().stream().filter(it -> it.getItemId() != null).collect(Collectors.toList());
+        List<OutboundItemVO> editOutboundItemVOList = outboundVO.getItemList();
         for (OutboundItemVO outboundItemVO : editOutboundItemVOList) {
             // 出库中数量不能小于出库数量
             if (outboundItemVO.getOutingQty().compareTo(outboundItemVO.getOutQty()) == -1) {
@@ -241,9 +241,13 @@ public class OutboundService extends BaseService<Outbound> {
      * @date : 2024-03-08 16:38
      */
     public ResponseResultVO<?> invalid(String id) {
-        Outbound outbound = outboundMapper.selectByIdForUpdate(id);
+        Outbound outboundForUpdate  = outboundMapper.selectByIdForUpdate(id);
+        // 并发校验
+        if(!outboundForUpdate.getFlgValid()){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+        }
         // 如果退货数量不是0,不能作废
-        if (outbound.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
+        if (outboundForUpdate.getReturnQty().compareTo(BigDecimal.ZERO) != 0) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());
         }
 
@@ -257,11 +261,14 @@ public class OutboundService extends BaseService<Outbound> {
             orderItemUpdate.setOutingQty(orderItemForUpdate.getOutingQty().subtract(outboundItemForUpdate.getOutingQty()))
                     .setOutingAmt(orderItemForUpdate.getOutingAmt().subtract(outboundItemForUpdate.getOutingAmt()))
                     .setItemId(orderItemForUpdate.getItemId());
+            if(orderItemUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0){
+                orderItemUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
+            }
             orderItemService.updateByUuid(orderItemUpdate);
         }
 
         // 计算订单明细的出库中数量,金额合计
-        List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outbound.getFromId());
+        List<OrderItem> orderItemList = orderItemMapper.selectByZIdForUpdate(outboundForUpdate.getFromId());
         OrderItem orderItem = orderItemList.stream().reduce((x, y) -> {
             OrderItem item = new OrderItem();
             item.setOutingQty(x.getOutingQty().add(y.getOutingQty()));
@@ -270,7 +277,11 @@ public class OutboundService extends BaseService<Outbound> {
         }).get();
         // 更新订单上的出库中数量,金额
         Order orderUpdate = new Order();
-        orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outbound.getFromId());
+        orderUpdate.setOutingQty(orderItem.getOutingQty()).setOutingAmt(orderItem.getOutingAmt()).setOrderId(outboundForUpdate.getFromId());
+        if(orderUpdate.getOutingQty().compareTo(BigDecimal.ZERO) == 0){
+            orderUpdate.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
+        }
+
         orderService.updateByUuid(orderUpdate);
 
         // 作废
@@ -292,7 +303,7 @@ public class OutboundService extends BaseService<Outbound> {
         outboundInfo.put("outbound", outboundResponse);
 
         // 商品明细
-        List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCond(new OutboundItemQuery().setOutId(id));
+        List<OutboundItemResponse> outboundItemResponse = outboundItemMapper.selectByCondForOutEdit(id);
         outboundInfo.put("outboundItem", outboundItemResponse);
         return ResponseResultUtil.success(outboundInfo);
     }

+ 5 - 0
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -204,6 +204,11 @@ public class OrderService extends BaseService<Order> {
      */
     public ResponseResultVO<?> invalid(String id) {
         Order orderForUpdate = orderMapper.selectByIdForUpdate(id);
+        // 并发校验
+        if(!orderForUpdate.getFlgValid()){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+        }
+
         // 如果出库中数量不是0,不能作废
         if (orderForUpdate.getOutingQty().compareTo(BigDecimal.ZERO) != 0) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());

+ 5 - 0
src/main/java/com/dk/mdm/service/sale/OutReturnService.java

@@ -220,6 +220,11 @@ public class OutReturnService extends BaseService<OutReturn> {
      */
     public ResponseResultVO<?> invalid(String id) {
         OutReturn outReturnForUpdate = outReturnMapper.selectByIdForUpdate(id);
+        // 并发校验
+        if(!outReturnForUpdate.getFlgValid()){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+        }
+
         // 如果入库数量不是0,不能作废
         if (outReturnForUpdate.getIntoQty().compareTo(BigDecimal.ZERO) != 0) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());