ソースを参照

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

zhoux 1 年間 前
コミット
50a5d01704

+ 3 - 3
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -193,7 +193,7 @@
                 AND tpii.into_type = #{intoType}
             </if>
             <if test="fromId != null and fromId != ''">
-                AND tpii.from_id = #{fromId}
+                AND tpii.from_id = #{fromId}::uuid
             </if>
             <if test="fromItemId != null and fromItemId != ''">
                 AND tpii.from_item_id = #{fromItemId}
@@ -217,7 +217,7 @@
                 AND tpii.cp_id = #{cpId}
             </if>
             <if test="sPurId != null">
-                AND tpii.s_pur_id = #{sPurId}
+                AND tpii.s_pur_id = #{sPurId,typeHandler=UuidTypeHandler}
             </if>
         </where>
     </sql>
@@ -1067,7 +1067,7 @@
         SELECT count(1)
         FROM dkic_b.t_psi_inbound_item
         where flg_valid = #{flgValid}
-          AND s_pur_id = #{sPurId}
+          AND s_pur_id = #{sPurId,typeHandler=UuidTypeHandler}
           AND into_type = #{intoType}
     </select>
 

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

@@ -108,6 +108,7 @@ public interface OutboundItemMapper extends BaseMapper<OutboundItem>{
      * @date   : 2024/4/18 13:47
      */
     int  updateOutCost(OutboundItemQuery outboundItemQuery);
+    int  updateOutOrderCost(OutboundItemQuery outboundItemQuery);
 
     /**
      * @desc   : 修改最后一条出库成本(入库成本核对)

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

@@ -836,6 +836,20 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
     </update>
 
 
+    <update id="updateOutOrderCost" parameterType="com.dk.mdm.model.pojo.ivt.OutboundItem">
+        update dkic_b.t_psi_outbound_item
+        <set>
+            <if test=" costPrice != null">
+                cost_price = #{costPrice,jdbcType=NUMERIC},
+            </if>
+            <if test=" costAmt != null">
+                cost_amt = #{costAmt,jdbcType=NUMERIC},
+            </if>
+        </set>
+        where from_item_id = #{fromItemId,typeHandler=UuidTypeHandler}
+    </update>
+
+
     <!-- 根据商品顺序查询表t_psi_outbound_item的一行数据 -->
     <select id="selectItemIndex" resultMap="BaseResultMapResponse">
         SELECT

+ 5 - 0
src/main/java/com/dk/mdm/mapper/mac/RecPayMapper.xml

@@ -310,6 +310,10 @@
         <if test="staffIds != null and staffIds.size() > 0">
             AND t.staff_id  =any(#{staffIdList, typeHandler=UuidListTypeHandler})
         </if>
+        <if test="makeStaffIds != null and makeStaffIds.size() > 0">
+            AND t.make_staff  =any(#{makeStaffIds, typeHandler=UuidListTypeHandler})
+        </if>
+
         <if test="createtimeStart != null and createtimeEnd != null">
             AND t.op_create_time &gt;= #{createtimeStart}::timestamp with time zone
             AND t.op_create_time &lt; #{createtimeEnd}::timestamp with time zone + interval '1 day'
@@ -823,6 +827,7 @@
             or tmsp.sup_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
             or tmo.org_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
             or tms.staff_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+            or t.rp_no LIKE concat('%',my_ex.likequery(#{searchText}),'%')
             )
         </if>
         order by t.op_create_time desc

+ 3 - 3
src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml

@@ -313,15 +313,15 @@
         tma.receivable,
         tma.receivable_residue,
         tma.receipt_residue,
-        tmor.sum_amt_receivable AS "startAmount",
-        concat(tms3.staff_name)  AS "followStaffsName"
+        tmor.sum_amt_receivable AS "startAmount"
+--         concat(tms3.staff_name)  AS "followStaffsName"
         FROM dkic_b.t_mst_customer tmc
         LEFT JOIN dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tmc.cus_from
         LEFT JOIN dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
         LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tmc.org_id
         LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tmc.staff_id
         LEFT JOIN dkic_b.t_mst_staff tms2 on tms2.staff_id = tmc.report_staff
-        LEFT JOIN dkic_b.t_mst_staff tms3 on tms3.staff_id = Any(tmc.follow_staffs)
+--         LEFT JOIN dkic_b.t_mst_staff tms3 on tms3.staff_id = Any(tmc.follow_staffs)
         LEFT JOIN sys.t_data_kind tdk on tdk.kind_code = tmc.sale_status
         LEFT JOIN  dkic_b.t_mac_account tma  on tma.object_id =  tmc.cus_id
         LEFT JOIN dkic_b.t_mac_other_receivable tmor on tmor.object_id = tmc.cus_id and tmor.business_type = 0

+ 0 - 2
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -3026,8 +3026,6 @@
             OR tmc.address_full LIKE concat('%',#{searchText},'%'))
         </if>
         GROUP BY a.object_id, tmc.cus_name, tmc.cus_phone, tmc.address_full
-        HAVING SUM(COALESCE(tpo.out_amt, 0) + COALESCE(tpo.return_amt, 0)) - SUM(COALESCE(tmrp.sum_amt_rec, 0) + COALESCE(sum_amt_pay, 0)) > 0
-
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>

+ 2 - 0
src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml

@@ -232,6 +232,8 @@
         ,t.sub_unit_id
         ,ul.unit_name as "unitName"
         ,u2.unit_name as "subUnitName"
+        ,t.cost_price
+        ,t.cost_amt
         FROM dkic_b.t_psi_order_item as t
         LEFT join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
                  LEFT JOIN dkic_b.t_mst_unit AS ul ON tmgs.unit_id = ul.unit_id

+ 3 - 0
src/main/java/com/dk/mdm/model/query/mac/RecPayQuery.java

@@ -258,6 +258,9 @@ public class RecPayQuery extends PageInfo<RecPayQuery> implements Serializable {
     @ApiModelProperty(value = "业务员List")
     private List<String> staffIdList;
 
+    @ApiModelProperty(value = "业务员List")
+    private List<String> makeStaffIds;
+
 
     @ApiModelProperty(value = "制单时间开始")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")

+ 11 - 0
src/main/java/com/dk/mdm/service/ivt/inbound/InboundItemService.java

@@ -148,10 +148,21 @@ public class InboundItemService extends BaseService<InboundItem> {
 				orderItemMapper.updateCost(orderItem);
 			}
 
+			//判断是否是入库的外协品
+			if(inboundItem.getSkuId() == null && inboundItem.getOutId() == null){
+				//修改出库明细表
+				OutboundItemQuery outboundItemQuery = new OutboundItemQuery()
+						.setFromItemId(inboundItem.getFromItemId())
+						.setCostPrice(inboundItem.getCostPrice())
+						.setCostAmt(inboundItem.getCostAmt());
+				outboundItemMapper.updateOutOrderCost(outboundItemQuery);
+			}
+
 			//查询存货批次明细
 			InventoryBatchResponse inventoryBatchResponse =
 					inventoryBatchMapper.selectCostCondition(new InventoryBatchQuery().setFromItemId(inboundItem.getItemId()));
 
+
 			//外协没有批次
 			if(inventoryBatchResponse != null && inventoryBatchResponse.getBatchId() != null){
 				//查询出库成本

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

@@ -1601,7 +1601,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
      */
     @Transactional(rollbackFor = {Exception.class})
     public ResponseResultVO<?> oneKeyPurchaseInboundRepeal(String orderId) {
-        List<InboundItemResponse> InboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setFromId(orderId));
+        List<InboundItemResponse> InboundItemResponses = inboundItemMapper.selectByCond(new InboundItemQuery().setSPurId(orderId));
         if (InboundItemResponses != null && InboundItemResponses.size() > 0) {
             Map<String, List<InboundItemResponse>> inboundItemMap = InboundItemResponses.stream().collect(Collectors.groupingBy(InboundItemResponse::getIntoId));
             for (String str : inboundItemMap.keySet()) {

+ 41 - 0
src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java

@@ -444,6 +444,26 @@ public class InventoryService extends BaseService<Inventory> {
                     //删除库存、库存批次,库存流水,出库成本
                     this.deleteInventory(delOutList);
 
+                    //region 销售出库反写销售订单成本金额,成本单价
+                    if(Constant.InventoryDocCode.SALE_ORDER.getValue().equals(delOutList.get(0).getInventoryDocCode())){
+                        Map<String, List<InOutRecordVO>> InOutRecordVOListMap = delOutList.stream().collect(Collectors.groupingBy(InOutRecordVO::getBiznisItemId));
+                        for (String str : InOutRecordVOListMap.keySet()) {
+                            //赋值订单明细
+                            OrderItem orderItem = new OrderItem();
+                            OrderItem orderItemSql = orderItemMapper.selectById(new OrderItemQuery().setItemId(str));
+                            //当前订单存在
+                            if (orderItemSql!=null && orderItemSql.getOutQty() != null && orderItemSql.getOutQty().compareTo(BigDecimal.ZERO) > 0) {
+                                //查询当前订单下的出库单
+                                List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setFromId(str));
+                                BigDecimal costAmt = outboundItemResponseList.stream().map(OutboundItemResponse::getCostAmt).reduce(BigDecimal.ZERO, BigDecimal::add)
+                                        .setScale(6, BigDecimal.ROUND_HALF_UP);
+                                orderItem.setItemId(str);
+                                orderItem.setCostAmt(costAmt);
+                                orderItem.setCostPrice(costAmt == null || costAmt.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : costAmt.divide(orderItemSql.getOutQty(), 2, BigDecimal.ROUND_HALF_UP));
+                            }
+                        }
+                    }
+                    //endregion
 
                 }
             }
@@ -717,6 +737,27 @@ public class InventoryService extends BaseService<Inventory> {
             }
         }
 
+        //region 销售出库反写销售订单成本金额,成本单价
+        if(Constant.InventoryDocCode.SALE_ORDER.getValue().equals(inOutRecordVOList.get(0).getInventoryDocCode())) {
+            Map<String, List<InOutRecordVO>> InOutRecordVOListMap = inOutRecordVOList.stream().collect(Collectors.groupingBy(InOutRecordVO::getInvOrderItemId));
+            for (String str : InOutRecordVOListMap.keySet()) {
+                //赋值订单明细
+                OrderItem orderItem = new OrderItem();
+                OrderItem orderItemSql = orderItemMapper.selectById(new OrderItemQuery().setItemId(str));
+                //当前订单存在
+                if (orderItemSql != null && orderItemSql.getOutQty() != null && orderItemSql.getOutQty().compareTo(BigDecimal.ZERO) > 0) {
+                    //查询当前订单下的出库单
+                    List<OutboundItemResponse> outboundItemResponseList = outboundItemMapper.selectByCond(new OutboundItemQuery().setFromId(str));
+                    BigDecimal costAmt = outboundItemResponseList.stream().map(OutboundItemResponse::getCostAmt).reduce(BigDecimal.ZERO, BigDecimal::add)
+                            .setScale(6, BigDecimal.ROUND_HALF_UP);
+                    orderItem.setItemId(str);
+                    orderItem.setCostAmt(costAmt);
+                    orderItem.setCostPrice(costAmt == null || costAmt.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO : costAmt.divide(orderItemSql.getOutQty(), 2, BigDecimal.ROUND_HALF_UP));
+                }
+            }
+        }
+        //endregion
+
         return inOutRecordVOList;
     }
 

+ 7 - 0
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -186,6 +186,12 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     //查询库存是否存在
                     InventoryResponse inventoryResponse = this.checkInventoryExist(outboundItemVO);
                     if (inventoryResponse != null) {
+                        //库存量小于本次出库数量
+                        if(inventoryResponse.getInvQty().compareTo(outboundItemVO.getOutingQty())<0){
+                            throw new BaseBusinessException(ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getCode(),
+                                    ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
+                        }
+                        //region  todo  2024年7月10日14:36:47  严格按照库存数量足够额为准
                         BigDecimal invQty = inventoryResponse.getInvQty().subtract(outboundItemVO.getOutingQty());
                         // (库存量  大于等于  本次出库数量不用做任何处理)
                         //库存量 小于  本次出库数量
@@ -194,6 +200,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                             //不够库存数量----新建出库中数量
                             outboundItemVO.setNotEnoughInventoryQty(invQty.abs());
                         }
+                        //endregion
                     } else {
                         //todo 2024年7月2日09:23:38 修改成无库存不允许出库
 //                        //不够库存数量----新建出库中数量

+ 4 - 3
src/main/java/com/dk/mdm/service/pur/PurchaseService.java

@@ -554,10 +554,11 @@ public class PurchaseService extends BaseService<Purchase> {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
         }
 
+        //todo  2024年7月10日11:45:12 这里在联调意见作废的时候能进分支,不知道为什么有这个校验
         // 如果入库中数量或已入库数量不是0,不能作废
-        if (purForUpdate.getIntoQty().compareTo(BigDecimal.ZERO) != 0 || purForUpdate.getIntoingQty().compareTo(BigDecimal.ZERO) != 0) {
-            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());
-        }
+//        if (purForUpdate.getIntoQty().compareTo(BigDecimal.ZERO) != 0 || purForUpdate.getIntoingQty().compareTo(BigDecimal.ZERO) != 0) {
+//            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_AFTER_OPERATE.getMessage());
+//        }
         // 作废
         Purchase purUpdate = new Purchase();
         purUpdate.setFlgValid(false).setPurId(id);

+ 12 - 2
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -57,6 +57,7 @@ import com.dk.mdm.model.response.sale.OrderItemResponse;
 import com.dk.mdm.model.response.sale.OrderResponse;
 import com.dk.mdm.model.vo.ivt.OutboundVO;
 import com.dk.mdm.model.vo.mac.RecPayItemVO;
+import com.dk.mdm.model.vo.mst.CustomerVO;
 import com.dk.mdm.model.vo.mst.SupplierVo;
 import com.dk.mdm.model.vo.sale.OrderItemVO;
 import com.dk.mdm.model.vo.sale.OrderVO;
@@ -65,6 +66,7 @@ import com.dk.mdm.service.ivt.outbound.OutboundSaleOrderService;
 import com.dk.mdm.service.mac.AccountService;
 import com.dk.mdm.service.mac.RecPayItemService;
 import com.dk.mdm.service.mac.ReceiptService;
+import com.dk.mdm.service.mst.CustomerService;
 import com.dk.mdm.service.mst.MoneyAccountService;
 import com.dk.mdm.service.mst.SupplierService;
 import org.springframework.stereotype.Service;
@@ -169,6 +171,9 @@ public class OrderService extends BaseService<Order> {
     @Autowired
     private AuthUtils authUtils;
 
+    @Autowired
+    private CustomerService customerService;
+
     /**
      * @desc : 条件查询
      * @author : 付斌
@@ -553,6 +558,13 @@ public class OrderService extends BaseService<Order> {
             gradeCode = listCompany.get(0).get("gradeCode").toString();
         }
 
+        //更新总单客户信息
+        customerService.update(new CustomerVO().setCusId(orderVO.getCusId()).setCusCode(orderVO.getCusCode())
+                .setCusName(orderVO.getCusName()).setCusPhone(orderVO.getCusPhone()).setAddressArea(orderVO.getAddressArea())
+                .setAddressFull(orderVO.getAddressFull()).setAddressName(orderVO.getAddressName())
+                .setAddressNo(orderVO.getAddressNo()).setAddressGcj02(orderVO.getAddressGcj02())
+                .setContactName(orderVO.getContactName()).setContactPhone(orderVO.getContactPhone()).setChannelId(orderVO.getSalesChannel()));
+
         // 明细实体(避免并发,需要再查一遍)
         OrderItem orderItemForUpdate;
         // 转化实体
@@ -905,11 +917,9 @@ public class OrderService extends BaseService<Order> {
                         outboundVO.setSumAmount(orderVO.getSumAmount());
                         outboundVO.setOutId(outboundResponsejson.getOutId());
                         outboundVO.setLimitEdit(true);
-
                         outboundSaleOrderService.saleOutboundUpdate(outboundVO);
                     }
 
-
                 }
             }
         }